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 (299 lines) | stat: -rw-r--r-- 9,963 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
<?xml version="1.0" encoding="iso-8859-2"?>
<!-- EN-Revision: 1.18 Maintainer: luk Status: ready -->

 <chapter id="features.safe-mode">
  <title>Bezpen reim</title>

  <para>
   Bezpen reim PHP je pokus o een bezpenosti sdlench server.
   Je architekturln nekorektn pokouet se eit tento problm na
   rovni PHP, ale protoe een na rovni webovskho serveru a operanho
   systmu nejsou pli realistick, mnoho lid, zvlat ISP, pouv
   nyn bezpen reim.    
  </para>
  <para>
   Konfiguran direktivy, kter ovldaj bezpen reim: 
   <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>
   Pokud je <link linkend="ini.safe-mode">safe_mode</link> zapnut, PHP
   kontroluje, je-li vlastnk bcho skriptu vlastnkem souboru, s nm
   se m manipulovat. Napklad: 
   <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>
   Sputn skriptu script.php 
   <programlisting role="php">
<![CDATA[
<?php
 readfile('/etc/passwd'); 
?>
]]>
   </programlisting>
   bude mt v bezpenm reimu za vsledek tuto chybu: 
   <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>
   Pokud namsto <link linkend="ini.safe-mode">safe_mode</link> nastavte 
   adres <link linkend="ini.open-basedir">open_basedir</link>, potom
   vechny operace se soubory budou omezeny pod specifikovan adres.
   Napklad (pklad Apache httpd.conf): 
   <programlisting role="ini">
<![CDATA[
<Directory /docroot>
  php_admin_value open_basedir /docroot 
</Directory>
]]>
   </programlisting>
   Kdy spustte tent soubor script.php s timto nastavenm
   <link linkend="ini.open-basedir">open_basedir</link>, dostanete tento
   vsledek:
   <screen>
<![CDATA[
Warning: open_basedir restriction in effect. File is in wrong directory in 
/docroot/script.php on line 2 
]]>
   </screen>
  </para>
  <para>
   Mete tak vypnout jednotliv funkce. Pokud pidme toto do souboru
   php.ini:    
   <programlisting role="ini">
<![CDATA[
disable_functions readfile,system  
]]>
   </programlisting>
   zskme takovto vstup: 
   <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>Funkce omezen/deaktivovan v bezpenm reimu</title>
   <para>
    Toto je pravdpodobn nepln a mon nesprvn pehled funkc
    omezench v 
    <link linkend="features.safe-mode">bezpenm reimu</link>.
    <!-- TODO: add &note.sm.*; to the functions mentioned here.
    That entity should link to this section -->
    <table>
     <title>Funkce omezen v bezpenm reimu</title>
     <tgroup cols="2">
      <thead>
       <row>
        <entry>Funkce</entry>
        <entry>Omezen</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>Obeys the safe_mode_protected_env_vars and 
        safe_mode_allowed_env_vars ini-directives. Viz tak dokumentaci
	<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 opertor</link></entry>
        <entry>&sm.disabled;</entry>
       </row>
       <row>
        <entry><function>shell_exec</function> (funkn ekvivalent backticks)</entry>
        <entry>&sm.disabled;</entry>
       </row>
       <row>
        <entry><function>exec</function></entry>
        <entry>Mete spoutt programy pouze uvnit adrese <link 
        linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Z praktickch dvod nen momentln mon mt v cest k souboru
	s programem komponenty <literal>..</literal>.</entry>
       </row>
       <row>
        <entry><function>system</function></entry>
        <entry>Mete spoutt programy pouze uvnit adrese <link 
        linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Z praktickch dvod nen momentln mon mt v cest k souboru
	s programem komponenty <literal>..</literal>.</entry>
       </row>
       <row>
        <entry><function>passthru</function></entry>
        <entry>Mete spoutt programy pouze uvnit adrese <link 
        linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Z praktickch dvod nen momentln mon mt v cest k souboru
	s programem komponenty <literal>..</literal>.</entry>
       </row>
       <row>
        <entry><function>popen</function></entry>
        <entry>Mete spoutt programy pouze uvnit adrese <link 
        linkend="ini.safe-mode-exec-dir">safe_mode_exec_dir</link>.
        Z praktickch dvod nen momentln mon mt v cest k souboru
	s programem komponenty <literal>..</literal>.</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; (pro 
        <parameter>source</parameter> a 
        <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; Navc nemete nastavovat  
        SUID, SGID a 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; (pozn.: testovn je pouze
	cl)</entry>
       </row>
       <row>
        <entry><function>link</function></entry>
        <entry>&sm.uidcheck; &sm.uidcheck.dir; (pozn.: testovn je pouze
	cl)</entry>
       </row>
       <row>
        <entry><function>getallheaders</function></entry>
        <entry>V bezpenm reimu nebudou hlaviky zanajc 'authorization'
	(bez ohledu na velikost psmen) vraceny. Varovn: toto nefunguje
	s aol-server implementac <function>getallheaders</function>!</entry>
       </row>
       <row>
        <entry>Jakkoli funkce kter pouvaj 
         <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:
-->