2011-10-06 22 views
0

我有兩個Web服務器,都在Lighttpd + php(通過fastCGI)。Httpd +/bin/false == system()?

[[email protected] ~]$ lighttpd -v 
lighttpd/1.4.29 (ssl) - a light and fast webserver 
Build-Date: Aug 7 2011 10:52:01 
[[email protected] ~]$ php -v 
PHP 5.3.8 with Suhosin-Patch (cli) (built: Sep 30 2011 05:34:36) 
Copyright (c) 1997-2011 The PHP Group 
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies 
[[email protected] ~]$ php-cgi -v 
PHP 5.3.8 with Suhosin-Patch (cgi-fcgi) (built: Sep 30 2011 05:35:14) 
Copyright (c) 1997-2011 The PHP Group 
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies 

Lighttpd的和php-cgi同時根據用戶的 'http' 與/bin中運行/假(假的)外殼:通過PHP的系統

[[email protected] ~]$ cat /etc/passwd | grep http 
http:x:33:33:http:/srv/http:/bin/false 
[[email protected] ~]$ ps aux | grep "lighttpd\_php-cgi" 
http  1291 0.0 1.1 5152 2816 tty1  S Oct06 0:00 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf 
http  1292 0.0 1.5 14476 3904 ?  Ss Oct06 0:00 /usr/bin/php-cgi 

但我仍然可以執行shell命令( )功能(例如)!

在我的php.ini中沒有disable_functions。 如果我執行系統( 「WHOAMI」)系統( 「ID」)通過PHP,我得到如下:

http 
uid=33(http) gid=33(http) groups=33(http) 

(就像它必須是)。

我能以/bin/false作爲shell執行用戶命令的原因是什麼?

回答

3

documentation作爲明確地說,PHP的system只是爲系統C.從系統的manpage結合:

系統()調用/bin/sh -c command執行命令指定的命令......

/bin/false僅僅是登錄shell(配合使用login,TELNET,SSH等)。

3

/bin/false這裏沒有什麼可做的。您不能通過更改用戶的shell來控制對系統命令的訪問,因爲它們不是通過shell執行的。閱讀更多here

+0

哦,不知道。謝謝,我會記得! – xaero