vimadeva Posted May 1, 2007 Share Posted May 1, 2007 Hi all! I'm new in linux and php. My problem is that i want to create a file (dhcpd.conf) and then copy it to /etc/conf.d. The problem is that i can't use exec(cp /var/www/html/dhcpd.conf /etc/dhcp.conf) or exec(sudo -u root cp /var/www/html/dhcpd.conf /etc/dhcp.conf). I already added this line to /etc/ sudoers: ALL ALL=(ALL) NOPASSWD ALL hoping that that would help, but the problem continues. If I run exec("whoami") in a php file, it shows apache, but exec("sudo -u root whoami") dies. I would appreciate some help, i need this for today . Sorry for the bad english. Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/ Share on other sites More sharing options...
dzysyak Posted May 1, 2007 Share Posted May 1, 2007 I had similar problem. I have resolved it by changing folder access rights. But sudo do not work through exec() even after changes to /etc/ sudoers I will really appreciate if someone can explain why and how this can be resolved? May be some changes to php.ini or apache config required? Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-242651 Share on other sites More sharing options...
vimadeva Posted May 1, 2007 Author Share Posted May 1, 2007 I had similar problem. I have resolved it by changing folder access rights. But sudo do not work through exec() even after changes to /etc/ sudoers I will really appreciate if someone can explain why and how this can be resolved? May be some changes to php.ini or apache config required? I remember that the exec worked in a gentoo installation but I had to make a new installation in a new pc, because iptables wasnt availble in gentoo, so... maybe is a problem of fedora, or maybe, as you say i didnt configured php.ini or httpd.conf as it might be. It will be very helpful to know what we have to modify in those files. Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-242680 Share on other sites More sharing options...
vimadeva Posted May 1, 2007 Author Share Posted May 1, 2007 I read somewhere that the problem might be SELinux, I set it to disabled and permissive, but the problem still persist, any help?? Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-242815 Share on other sites More sharing options...
trq Posted May 1, 2007 Share Posted May 1, 2007 <?php echo exec("sudo whoami"); ?> Returns root on my Gentoo box. PS; Whats all this about iptables not being available in Gentoo? I'm running a custom Gentoo firewall (router) with a network of 6 computers all configured via iptables. Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-242940 Share on other sites More sharing options...
vimadeva Posted May 1, 2007 Author Share Posted May 1, 2007 <?php echo exec("sudo whoami"); ?> Returns root on my Gentoo box. PS; Whats all this about iptables not being available in Gentoo? I'm running a custom Gentoo firewall (router) with a network of 6 computers all configured via iptables. When I execute echo("whoami") it returns apache, when i execute echo("sudo whoamo") nothing is printed :S Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-242966 Share on other sites More sharing options...
trq Posted May 2, 2007 Share Posted May 2, 2007 Sorry... when I tested my commands I actually used php-cli, not the apache module. I believe you need to configure suexec which is (I believe - haven't really looked into it much) a patch for Apache. There doesn't seem to be a USE flag for this in Gentoo, meaning you would need to modify the ebuild and place it in a local overlay, then reemerge Apache. If your using Fedora, look for an Apache rpm with suexec support. Link to comment https://forums.phpfreaks.com/topic/49507-exec-problem/#findComment-243040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.