这是一个非常狭窄的问题(与"太宽"的问题相反)此脚本的输出
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$filename = '/tmp/password';
$handle = fopen($filename, 'r');
if ($handle)
{
$username = fgets($handle);
$password = fgets($handle);
echo 'user='.$username.'<br>';
echo 'pass='.$password.'<br>';
}
else
{
echo 'handle= is false<br>';
}
if (file_exists($filename))
{
echo "filename $filename exists<br>";
}
else
{
echo "filename $filename does not exists<br>";
}
$dir = '/tmp';
$files_of_tmp_dir = scandir($dir);
print_r($files_of_tmp_dir);
?>
导致显示以下内容
Warning: fopen(/tmp/password): failed to open stream: No such file or directory in /var/www/html/mydomain/read_credentials.php on line 8
handle= is false
filename /tmp/password does not exists
Array ( [0] => . [1] => .. [2] => httpd_lua_shm.23475 )
问题:为什么只有一个用户文件'httpd_lua_shm.23475',howerver
此命令:
[root@newhostname tmp]# ls -l /tmp | wc -l
返回 23。
和:
ls -l /tmp
不输出这 23 个文件中的文件名"httpd_lua_shm.23475"。
这里有黑客吗,谁能简单地解释这种"过于宽泛"的行为?:)
好吧,只有悲惨的人没有读过这个问题,但他们只能投反对票。
上级:
仔细阅读,问题(!作为输出列出的单个文件不在/tmp 文件夹中,即使在 root 下也是如此。此"httpd_lua_shm.23475"在根目录下的/tmp 文件夹中不存在。您正在谈论权限。堆栈溢出中没有黑客?加油!:)
UPD 2:该问题仅在/tmp 文件夹中说明。其他文件夹从工作方面还可以。去找出为什么会这样,然后发布和回答。
运行 php 脚本的用户在 tmp
目录中的权限与 root 的权限不同。