abbypan 发表于 2005-8-3 20:38:25

关于php中使用super

装的是debian

根据
http://www.programfan.com/article/showarticle.asp?id=1310
做的

前面都可以通过,在命令行底下用super可以成功添加用户,但
在php底下,照着编程就错了

<?php
$username="bbbb";
system(escapeshellcmd("/usr/bin/super auser$username"));
?>

是不是apache、php要求什么特别的配置
谁能帮忙看看,谢谢

涩兔子 发表于 2005-8-3 21:36:01

请参阅PHP手册safe mode中有关safe_mode_exec_dir的设置

abbypan 发表于 2005-8-3 22:16:13

谢谢斑竹,不过还有问题
safe_mode = On
safe_mode_exec_dir=/usr/local/bin

在/usr/bin里有super、iptables的可执行文件
在super.tab里加   iptables /usr/bin/iptables nobody,try
然后
<?php
system("super iptables-A INPUT -i eth0 -p tcp -s 192.168.0.21 -j ACCEPT");
?>

在命令行下用iptables -L 查看,发现根本不起作用啊?这又是为何

涩兔子 发表于 2005-8-3 23:45:44

兔兔使用的FC3,whereis iptables在/sbin/iptables

所以我尝试safe_mode_exec_dir = /sbin


<?php

system("/sbin/ifconfig");

?>

可以显示eth0 Link encap:Ethernet HWaddr 00:0A:EB:FF:86:33 inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20a:ebff:feff:8633/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:42177 errors:0 dropped:0 overruns:0 frame:0 TX packets:2802 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7131746 (6.8 MiB) TX bytes:273340 (266.9 KiB) Interrupt:11 Base address:0xc800 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:3779 errors:0 dropped:0 overruns:0 frame:0 TX packets:3779 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3989682 (3.8 MiB) TX bytes:3989682 (3.8 MiB)

我把你的super iptables -A INPUT -i eth0 -p tcp -s 192.168.0.21 -j ACCEPT在终端里输入,并没有输出结果

PHP的system使用来显示终端结果的,请核对你的命令正确 :idea:

abbypan 发表于 2005-8-4 13:52:37

谢谢斑竹,但是我仍用
safe_mode_exec_dir = /usr/local/bin
现在我在终端、浏览器端均可实现象上面iptables的设置,

但是之前
system("ls -a");
有结果输出

装了super之后,全部变成必须用
system("superls -a");
才行──而且必须先在super.tab中设置过后才能用

有没有办法解决这个问题呢?──就是达到
       ls,date之类的命令不必使用super就可象之前一样直接输出?

涩兔子 发表于 2005-8-4 16:23:42

还是应该仔细阅读PHP手册Chapter 22. Safe Mode

然后man一下相应终端下的命令行的详细参数

似乎可以从这个过程中体验更多的东东哦 :mrgreen:
页: [1]
查看完整版本: 关于php中使用super