| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 
 | <?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.18 Maintainer: slawek Status: ready -->
<!-- $Revision: 1.10 $ -->
 <chapter id="features.safe-mode">
  <title>Tryb bezpieczny</title>
  <para>
   Tryb bezpieczny (safe mode) jest prb rozwizania problemw
   bezpieczestwa na  wspdzielnym serwerze. Co prawda rozwizywanie ich na
   poziomie PHP nie jest najlepszym rozwizaniem, ale jeli nie ma moliwoci
   zrobienia tego na poziomie serwera www lub systemu operacyjnego, na wielu
   serwerach, zwaszcza u usugodawcw internetowych, uywa si trybu
   bezpiecznego.
  </para>
  <para>
   Dyrektywy konfiguracyjne odpowiadajce za tryb bezpieczny:
   <programlisting role="ini">
<![CDATA[
safe_mode = Off
open_basedir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
]]>
   </programlisting>
  </para>
  <para>
   Gdy opcja <link linkend="ini.safe-mode">safe_mode</link> jest wczona,
   PHP sprawdza czy wacicielem pliku na ktrym na ktrym funkcja chce
   operowa i wacicielem uruchamianego skryptu jest ten sam uytkownik.
   Na przykad:
   <programlisting role="ls">
<![CDATA[
-rw-rw-r--    1 rasmus   rasmus       33 Jul  1 19:20 script.php
-rw-r--r--    1 root     root       1116 May 26 18:01 /etc/passwd
]]>
   </programlisting>
   Uruchomienie script.php
   <programlisting role="php">
<![CDATA[
<?php
 readfile('/etc/passwd');
?>
]]>
   </programlisting>
   z uruchomionym trybem bezpiecznym spowoduje wywietlenie bdu:
   <screen>
<![CDATA[
Warning: SAFE MODE Restriction in effect. The script whose uid is 500 is not 
allowed to access /etc/passwd owned by uid 0 in /docroot/script.php on line 2
]]>
   </screen>
  </para>
  <para>
   Jeli zamiast wcza opcj <link linkend="ini.safe-mode">safe_mode</link>
   ustawisz katalog <link linkend="ini.open-basedir">open_basedir</link>,
   wtedy wszystkie operacje plikowe bed ograniczone do tego katalogu. Na
   przykad (dla httpd.conf Apache'a):
   <programlisting role="ini">
<![CDATA[
<Directory /docroot>
php_admin_value open_basedir /docroot
</Directory>
]]>
   </programlisting>
   Uruchomienie tego samego skryptu script.php z ustawionym katalogiem
   <link linkend="ini.open-basedir">open_basedir</link> spowoduje wywietlenie:
   <screen>
<![CDATA[
Warning: open_basedir restriction in effect. File is in wrong directory in
/docroot/script.php on line 2
]]>
   </screen>
  </para>
  <para>
   Moesz take wyczy pojedyncze funkcje. Jeli do pliku php.ini dodasz:
   <programlisting role="ini">
<![CDATA[
disable_functions readfile,system
]]>
   </programlisting>
   po uruchomieniu skryptu otrzymasz:
   <screen>
<![CDATA[
Warning: readfile() has been disabled for security reasons in
/docroot/script.php on line 2
]]>
   </screen>
  </para>
  <sect1 id="features.safe-mode.functions">
   <title>Funkcje ograniczone/wyczone w trybie bezpiecznym</title>
   <para>
    Jest to najprawdopodobniej wci niekompletna lista funkcji ograniczonych
    przez <link linkend="features.safe-mode">tryb bezpieczny</link>.
    <!-- TODO: add ¬e.sm.*; to the functions mentioned here.
    That entity should link to this section -->
    <table>
     <title>Funkcje ograniczone w trybie bezpiecznym</title>
     <tgroup cols="2">
      <thead>
       <row>
        <entry>Funkcja</entry>
        <entry>Ograniczenia</entry>
       </row>
      </thead>
      <tbody>
       <row>
        <entry><function>dbmopen</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>dbase_open</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>filepro</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>filepro_rowcount</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>filepro_retrieve</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>ifx_*</function></entry>
        <entry>Podlega ograniczeniom narzuconym przez sql_safe_mode,
        (!= tryb bezpieczny)</entry>
        <!-- TODO: more info on sql-safe-mode -->
       </row>
       <row>
        <entry><function>ingres_*</function></entry>
        <entry>Podlega ograniczeniom narzuconym przez sql_safe_mode,
        (!= tryb bezpieczny)</entry>
        <!-- TODO: more info on sql-safe-mode -->
       </row>
       <row>
        <entry><function>mysql_*</function></entry>
        <entry>Podlega ograniczeniom narzuconym przez sql_safe_mode,
        (!= tryb bezpieczny)</entry>
        <!-- TODO: more info on sql-safe-mode -->
       </row>
       <row>
        <entry><function>pg_loimport</function></entry>
        <entry>&sm.uidcheck;</entry>
        <!-- source TODO: there is no PHP-warning for that safe-mode-restriction -->
       </row>
       <row>
        <entry><function>posix_mkfifo</function></entry>
        <entry>&sm.uidcheck.dir;</entry>
       </row>
       <row>
        <entry><function>putenv</function></entry>
        <entry>Podlega dyrektywom safe_mode_protected_env_vars i
        safe_mode_allowed_env_vars w php.ini. Zobacz rwnie dokumantacj
        do <function>putenv</function></entry>
        <!-- TODO: document those directives in chapters/config.xml -->
       </row>
       <row>
        <entry><function>move_uploaded_file</function></entry>
        <entry>&sm.uidcheck; <!-- TODO: check this --></entry>
       </row>
       <!-- TODO: from here on, add warning to the function itself -->
       <row>
        <entry><function>chdir</function></entry>
        <entry>&sm.uidcheck.dir;</entry>
       </row>
       <row>
        <entry><function>dl</function></entry>
        <entry>&sm.disabled;</entry>
       </row>
       <row>
        <entry><link linkend="language.operators.execution">lewy apostrof</link></entry>
        <entry>&sm.disabled;</entry>
       </row>
       <row>
        <entry><function>shell_exec</function> (funkcja rwnowana z
        lewym apostrofem)</entry>
        <entry>&sm.disabled;</entry>
       </row>
       <row>
        <entry><function>exec</function></entry>
        <entry>Moesz uruchamia programy jedynie z katalogu zdefiniowanego
        dyrektyw
        <link linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Ze wzgldw praktycznych obecnie nie ma moliwoci stosowania
        <literal>..</literal> w ciece do programu.</entry>
       </row>
       <row>
        <entry><function>system</function></entry>
        <entry>Mona uruchamia programy jedynie z katalogu zdefiniowanego
        dyrektyw
        <link linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Ze wzgldw praktycznych obecnie nie ma moliwoci stosowania
        <literal>..</literal> w ciece do programu.</entry>
       </row>
       <row>
        <entry><function>passthru</function></entry>
        <entry>Mona uruchamia programy jedynie z katalogu zdefiniowanego
        dyrektyw
        <link linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Ze wzgldw praktycznych obecnie nie ma moliwoci stosowania
        <literal>..</literal> w ciece do programu.</entry>
       </row>
       <row>
        <entry><function>popen</function></entry>
        <entry>Mona uruchamia programy jedynie z katalogu zdefiniowanego
        dyrektyw
        <link linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Ze wzgldw praktycznych obecnie nie ma moliwoci stosowania
        <literal>..</literal> w ciece do programu.</entry>
        <!-- TODO: not sure. popen uses a completely different implementation
        Don't know why, don't know whether it's behaving the same -->
       </row>
       <row>
        <entry><function>mkdir</function></entry>
        <entry>&sm.uidcheck.dir;</entry>
       </row>
       <row>
        <entry><function>rmdir</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>rename</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir;<!-- on the old name only, it seems. Is rename preventing moving files? --></entry>
       </row>
       <row>
        <entry><function>unlink</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir;</entry>
       </row>
       <row>
        <entry><function>copy</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir; (dla 
        <parameter>rda</parameter> i
        <parameter>przeznaczenia</parameter>) </entry>
       </row>
       <row>
        <entry><function>chgrp</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>chown</function></entry>
        <entry>&sm.uidcheck;</entry>
       </row>
       <row>
        <entry><function>chmod</function></entry>
        <entry>&sm.uidcheck; Dodatkowo, nie mona ustawi bitw SUID, SGID
        i sticky bit.</entry>
       </row>
       <row>
        <entry><function>touch</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir;</entry>
       </row>
       <row>
        <entry><function>symlink</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir; (sprawdzany jest jedynie element
        do ktrego tworzony jest link)</entry>
       </row>
       <row>
        <entry><function>link</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir; (sprawdzany jest jedynie element
        do ktrego tworzony jest link)</entry>
       </row>
       <row>
        <entry><function>getallheaders</function></entry>
        <entry>
         W tybie bezpiecznym, nagowki zaczynajce si od 'authorization'
         (wielko liter bez znaczenia) nie bd zwracane. Uwaga: w
         implementacji dla serwera AOL ta funkcjonalno jest uszkodzona
        </entry>
       </row>
       <row>
        <entry>Kada funkcja korzystajca z
         <filename>php4/main/fopen_wrappers.c</filename>
        </entry>
        <entry>??</entry>
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
  </sect1>
 </chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
 |