File: safe-mode.xml

package info (click to toggle)
phpdoc 20020310-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 35,272 kB
  • ctags: 354
  • sloc: xml: 799,767; php: 1,395; cpp: 500; makefile: 200; sh: 140; awk: 51
file content (323 lines) | stat: -rwxr-xr-x 11,305 bytes parent folder | download
1
2
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
312
313
314
315
316
317
318
319
320
321
322
323
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- EN-Revision: 1.20 Maintainer: stefan_saasen Status: ready -->
 <chapter id="features.safe-mode">
  <title>Safe Mode</title>
   <para>
    Safe Mode ist der Versuch, Sicherheitsprobleme bei gemeinsam 
    genutzten Servern zu lsen.
    Bezogen auf die Systemarchitektur, ist es der falsche Ansatz, 
    diese Probleme innerhalb der PHP Schicht lsen zu wollen. 
    Da es auf Ebene des Webservers bzw. des Betriebssystems keine
    praktischen Alternativen gibt, wird Safe Mode nunmehr von vielen
    Leuten, vor allem von Providern, eingesetzt.
   </para>
   <para>
    Es existieren folgende Direktiven um Safe Mode zu konfigurieren:
    <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>
    Wenn <link linkend="ini.safe-mode">safe_mode</link> aktiviert ist, 
    berprft PHP, ob der Eigentmer des laufenden Skriptes dem Eigentmer 
    der Datei entspricht, an der mit Hilfe der Dateifunktionen gearbeitet 
    werden soll.
    Beispiel:
    <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>
    Bei der Ausfhrung dieses Skriptes
    <programlisting role="php">
<![CDATA[     
<?php
 readfile('/etc/passwd'); 
?> 
]]>
    </programlisting>
     erscheint bei aktiviertem Safe Mode folgende Warnung:
     <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>
    Wenn anstelle von <link linkend="ini.safe-mode">safe_mode</link> ein 
    <link linkend="ini.open-basedir">open_basedir</link> 
    Verzeichnis angegeben wurde, knnen Dateioperationen 
    nur noch unterhalb dieses Verzeichnisses vorgenommen werden.
    Beispiel (Apache httpd.conf):
    <programlisting role="ini">
<![CDATA[     
<Directory /docroot>
php_admin_value open_basedir /docroot 
</Directory>
]]> 
    </programlisting>
    Wenn das Skript script.php mit der 
    <link linkend="ini.open-basedir">open_basedir</link>
    Einstellung ausgefhrt wird, erscheint folgende Warnung:
    <screen>  
<![CDATA[  
Warning: open_basedir restriction in effect. File is in wrong directory in 
/docroot/script.php on line 2 
]]>
    </screen>
   </para>
   <para>
    Darberhinaus knnen einzelne Funktionen deaktiviert werden.
    Wrde man folgenden Eintrag in der php.ini vornehmen:
    <programlisting role="ini">
<![CDATA[    
disable_functions readfile,system  
]]>
    </programlisting>
    Wrde diese Warnung erscheinen:
    <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>Funktionen, die durch Safe Mode deaktiviert oder eingeschrnkt werden</title>
    <para>
     Dies ist eine Auflistung der Funktionen, die durch 
     <link linkend="features.safe-mode">Safe Mode</link> eingeschrnkt
     werden. Diese Liste ist mglicherweise unvollstndig und fehlerhaft!
     <!-- TODO: add &note.sm.*; to the functions mentioned here.
     That entity should link to this section -->
     <table>
      <title>Durch Safe Mode eingeschrnkte Funktionen</title>
      <tgroup cols="2">
       <thead>
        <row>
         <entry>Funktion</entry>
         <entry>Einschrnkungen</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>sql_safe_mode restrictions, (!= Safe Mode)</entry>
         <!-- TODO: more info on sql-safe-mode -->
        </row>
        <row>
         <entry><function>ingres_*</function></entry>
         <entry>sql_safe_mode restrictions, (!= Safe Mode)</entry>
         <!-- TODO: more info on sql-safe-mode -->
        </row>
        <row>
         <entry><function>mysql_*</function></entry>
         <entry>sql_safe_mode restrictions, (!= Safe Mode)</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>
          Fhrt die safe_mode_protected_env_vars und 
          safe_mode_allowed_env_vars ini-directiven aus.
          Siehe auch Dokumentation zu <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">
          backtick operator</link>
         </entry>
         <entry>&sm.disabled;</entry>
        </row>
        <row>
         <entry><function>shell_exec</function> (funktional gleichwertig zu den 
          Backtick-Operatoren)</entry>
         <entry>&sm.disabled;</entry>
        </row>
        <row>
         <entry><function>exec</function></entry>
         <entry>Ausfhrbare Dateien knnen nur innerhalb des durch <link 
          linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link> angegebenen
          Verzeichnisses ausgefhrt werden.
          Aus praktischen Grnden ist es momentan nicht erlaubt, <literal>..</literal>
          im Pfad zu den ausfhrbaren Datein anzugeben.
         </entry>
        </row>
        <row>
         <entry><function>system</function></entry>
         <entry>Ausfhrbare Dateien knnen nur innerhalb des durch <link 
          linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link> angegebenen
          Verzeichnisses ausgefhrt werden.
          Aus praktischen Grnden ist es momentan nicht erlaubt, <literal>..</literal>
          im Pfad zu den ausfhrbaren Datein anzugeben.
         </entry>
        </row>
        <row>
         <entry><function>passthru</function></entry>
         <entry>Ausfhrbare Dateien knnen nur innerhalb des durch <link 
          linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link> angegebenen
          Verzeichnisses ausgefhrt werden.
          Aus praktischen Grnden ist es momentan nicht erlaubt, <literal>..</literal>
          im Pfad zu den ausfhrbaren Datein anzugeben.
         </entry>
        </row>
        <row>
         <entry><function>popen</function></entry>
         <entry>Ausfhrbare Dateien knnen nur innerhalb des durch <link 
          linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link> angegebenen
          Verzeichnisses ausgefhrt werden.
          Aus praktischen Grnden ist es momentan nicht erlaubt, <literal>..</literal>
          im Pfad zu den ausfhrbaren Datein anzugeben.
         </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; (on 
         <parameter>source</parameter> and 
         <parameter>target</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; In addition, you cannot  
         set the SUID, SGID and sticky bits</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; (note: only the target is 
         checked)</entry>
        </row>
        <row>
         <entry><function>link</function></entry>
         <entry>&sm.uidcheck; &sm.uidcheck.dir; (note: only the target is 
         checked)</entry>
        </row>
        <row>
         <entry><function>getallheaders</function></entry>
         <entry>
          Header die mit 'authorization' (unabhngig von Gro- oder Kleinschreibung)
          beginnen, werden bei Verwendung von Safe Mode nicht zurckgegeben. 
          Achtung: Dies ist fehlerhaft bei der AOL-Server Implementation 
          der Funktion <function>getallheaders</function>!
         </entry>
        </row>
        <row>
         <entry>Jede Funktion, die 
          <filename>php4/main/fopen_wrappers.c</filename>
          benutzt...
         </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
-->