PHP lstat le chemin complet plusieurs fois avant de lire le fichier recherché. Et cela se produit lorsque dans la configuration apache httpd est spécifié PHP_ADMIN_VALUE paramètre open_basedir ou si safe_mode est ON .
Si j'ai un site web simple avec seulement la page phpinfo.php et à l'intérieur nous avons seulement "".
Considérons que nous avons la dernière version de httpd (2.2.15) et de PHP (5.2.13 ou 5.3.2).
Si nous spécifions safe_mode=on ou PHP_ADMIN_VALUE open_basedir dans Configuration de l'hôte virtuel :
<Directory "/usr/local/myspace/webspace/httpdocs">
PHP\_ADMIN\_VALUE open\_basedir "/usr/local/myspace/webspace"
</Directory>
<VirtualHost \*:80>
ServerName damorealt.xoom.it
DocumentRoot "/usr/local/myspace/webspace/httpdocs"
CustomLog /var/log/httpd/damorealt/access\_log combined
ErrorLog /var/log/httpd/damorealt/error\_log
</VirtualHost >
Page d'appel http://damorealt.xoom.it/phpinfo.php nous pouvons reproduire le comportement suivant :
Premier contrôle
25933 lstat("/usr", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
Deuxième contrôle
25933 lstat("/usr", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
Troisième contrôle (incomplet)
25933 lstat("/usr", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
Cinquième contrôle.
25933 lstat("/usr", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
25933 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
Lisez le dossier !
25933 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O\_RDONLY) = 16
25933 fstat(16, {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
25933 read(16, "\\n", 8192) = 16
25933 read(16, "", 8192) = 0
25933 read(16, "", 8192) = 0
25933 close(16) = 0
Si PHP_ADMIN_VALUE open_basedir "/usr/local/myspace/webspace" est supprimé : :
Premier contrôle
26235 time(NULL) = 1278696735
26235 lstat("/usr", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
26235 lstat("/usr/local", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
26235 lstat("/usr/local/myspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
26235 lstat("/usr/local/myspace/webspace", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
26235 lstat("/usr/local/myspace/webspace/httpdocs", {st\_mode=S\_IFDIR|0755, st\_size=4096, ...}) = 0
26235 lstat("/usr/local/myspace/webspace/httpdocs/phpinfo.php", {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
Lisez le fichier.
26235 open("/usr/local/myspace/webspace/httpdocs/phpinfo.php", O\_RDONLY) = 16
26235 fstat(16, {st\_mode=S\_IFREG|0644, st\_size=16, ...}) = 0
26235 read(16, "\\n", 8192) = 16
26235 read(16, "", 8192) = 0
26235 read(16, "", 8192) = 0
26235 close(16) = 0
26235 uname({sys="Linux", node="svilpar4", ...}) = 0
26235 time(NULL) = 1278696735
26235 writev(15, \[{"HTTP/1.1 200 OK\\r\\nDate: Fri, 09 J"..., 173},\[...\]
26235 chdir("/") = 0
Quelqu'un peut-il m'expliquer pourquoi PHP a un tel comportement ?