PHP Doku:: Functions restricted/disabled by safe mode - features.safe-mode.functions.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFeaturesSafe ModeFunctions restricted/disabled by safe mode

Ein Service von Reinhard Neidl - Webprogrammierung.

Safe Mode

<<Security and Safe Mode

PHP auf der Kommandozeile>>

Functions restricted/disabled by safe mode

This is a still probably incomplete and possibly incorrect listing of the functions limited by safe mode.
Safe mode limited functions
Function Limitations
dbmopen() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
dbase_open() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
filepro() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
filepro_rowcount() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
filepro_retrieve() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
ifx_* sql_safe_mode restrictions, (!= safe mode)
ingres_* sql_safe_mode restrictions, (!= safe mode)
mysql_* sql_safe_mode restrictions, (!= safe mode)
pg_lo_import() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
posix_mkfifo() Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
putenv() Obeys the safe_mode_protected_env_vars and safe_mode_allowed_env_vars ini-directives. See also the documentation on putenv()
move_uploaded_file() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
chdir() Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
dl() Diese Funktion steht im Safe Mode nicht zur Verfügung.
backtick operator Diese Funktion steht im Safe Mode nicht zur Verfügung.
shell_exec() (functional equivalent of backticks) Diese Funktion steht im Safe Mode nicht zur Verfügung.
exec() You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.
system() You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.
passthru() You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.
popen() You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.
fopen() Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
mkdir() Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
rmdir() Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
rename() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
unlink() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
copy() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (on source and target)
chgrp() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
chown() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst.
chmod() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. In addition, you cannot set the SUID, SGID and sticky bits
touch() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst.
symlink() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (note: only the target is checked)
link() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (note: only the target is checked)
apache_request_headers() In safe mode, headers beginning with authorization (case-insensitive) will not be returned.
header() In safe mode, the uid of the script is added to the realm part of the WWW-Authenticate header if you set this header (used for HTTP Authentication).
PHP_AUTH variables In safe mode, the variables PHP_AUTH_USER, PHP_AUTH_PW, and AUTH_TYPE are not available in $_SERVER. Regardless, you can still use REMOTE_USER for the USER. (note: only affected since PHP 4.3.0)
highlight_file(), show_source() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (note: only affected since PHP 4.2.1)
parse_ini_file() Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (note: only affected since PHP 4.2.1)
set_time_limit() Has no effect when PHP is running in Safe Mode.
max_execution_time Has no effect when PHP is running in Safe Mode.
mail() In safe mode, the fifth parameter is disabled. (note: only affected since PHP 4.2.3)
session_start() The owner of a script must be the same as owner of a session.save_path directory if the default files session.save_handler is used.
All filesystem and stream functions. Überprüft ob die Dateien/Verzeichnisse, die mit dem Skript bearbeitet werden sollen, die gleiche UID (Eigentümer) haben wie das Skript selbst. Überprüft, ob das Verzeichnis, in dem das Skript ausgeführt werden soll, die gleiche UID (Eigentümer) hat wie das Skript selbst. (see the safe_mode_include_dir php.ini option.


5 BenutzerBeiträge:
- Beiträge aktualisieren...
Stephen Dewey
13.07.2009 21:39
curl_setopt() will not allow you to activate CURLOPT_FOLLOWLOCATION when in safe mode.
tschmieder at bitworks dot de
22.09.2007 15:04
refers to the previuos posting of

bananarama
15-May-2006 10:11

"all file-handling and -management functions are restricted, just in case someones wondering why they're not listed here.
a script can run these functions on files without errors, if the files were created (are owned) by the same UID, the script was created (is owned) by."

.... or if the directory, in which the file is located, has the same UID as the script, which tries to use a file in that directory...
bananarama
15.05.2006 10:11
all file-handling and -management functions are restricted, just in case someones wondering why they're not listed here.
a script can run these functions on files without errors, if the files were created (are owned) by the same UID, the script was created (is owned) by.

example:
you upload a script, it is owned by UID 720. you upload a picture, it is owned by UID 720. the script creates a thumbnail of the picture. the thumb is owned by UID 30 (the server/apache). this makes it impossible (?) to run a gallery script, which checks for newly uploaded pictures in order to create and display thumbs of them if you want to check, if a thumbnail already exists. the script would be owned by UID 720, the thumb by UID 30.
you could upload a script which creates a file (e.g. from a text file) with .php ending. this script would be owned by UID 30 and could access the thumbs, but it couldnt read the upload pictures.

<?
  $data
= fread(fopen("test.txt", "r"), filesize("test.txt"));
  
 
$file = "test.php";  
  if (!
$file_handle = fopen($file,"a")) { echo "Cannot open file"; } 
  if (!
fwrite($file_handle, $data)) { echo "Cannot write to file"; }   
 
fclose($file_handle);
 
 
chmod("test.php", 0777);
?>
zauker
21.03.2006 23:57
The SAFE_MODE handling of glob() needs a checkup for security reasons.

In short - always with SAFE_MODE on:

1) glob() can still fetch all filenames in a directory not owned by the
same UID as the user, if just the first file in the directory (or more
specific, the glob-pattern) happens to be owned by the same user as the
PHP-script.

2a) No warning is raised if glob is used on another owner's directory
and there is no match.

2b) In those cases where SAFE_MODE correctly prohibits glob() from
fetching a list of files, the warning still discloses the first
filename.

Solution: glob() in SAFE_MODE should be restricted in the same way as
opendir() is

see the link http://bugs.php.net/bug.php?id=28932
Jan
23.10.2005 11:46
It seems that glob and file_exists functions are also restricted in safe-mode.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)