- 论坛徽章:
- 1
|
本帖最后由 SeriousCool 于 2010-04-07 12:27 编辑
又出了点问题。。
下面的C代码,设置了sudo,www用户在命令行下执行后可以生效。
PHP以fastcgi模式运行,身份也是www,放在PHP程序里通过浏览器访问,执行后无效。。。
<?
shell_exec('/usr/bin/sudo /home/www/httpdocs/bin/ngx');
?>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(){
FILE *read_fp;
char buffer[BUFSIZ + 1];
int chars_read;
memset(buffer, '\0', sizeof(buffer));
read_fp = popen("/usr/local/nginx/sbin/nginx -s reload", "r");
if (read_fp != NULL){
chars_read = fread(buffer, sizeof(char), BUFSIZ, read_fp);
pclose(read_fp);
exit(EXIT_SUCCESS);
}
exit(EXIT_SUCCESS);
} |
|