Re: [PHP] I can't execute pf commands
On 7/28/2011 9:09 AM, Bulent Malik wrote: > Hi > > I use php5.3 on freebsd > > I also use pf ( packet filter) on it. > > I need to execute pfctl in php script. But I couldn't execute . I don't get > any errors about that. > > Shell commands is allowed in php.ini My > > My script is below, > > > shell_exec('pfctl -s nat'); > > exec('pfctl -s nat'); > > > If I execute another command like this ; it works > > shell_exec('ls -l /var/tmp') ; > > What can the problem be ? Run the following command from your cli which pfctl If the results show, like mine does, that pfctl is in /sbin/pfctl then you will not be able to run that command. Your www doesn't have the /sbin/ folders in its path. Try this instead. shell_exec('which pfctl') ; If you get results, you should be able to execute it. But, on the flip side, it re-writes /etc/pf.conf and on my box, its permissions are "-rw---". So, you can assume that nobody besides root will be able to write to this file. Now, if you go the route Shawn talked about, it will work. Just be sure to limit the sudoers to only allow the pfctl command and not all allow all commands on your system. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I can't execute pf commands
another point: I think you tried it in shell as a root but in browser it can't execute it as a root again I agree with Shawn it is from permission try the command that I told you I mean edit the command and then run it in browser
Re: [PHP] I can't execute pf commands
Bulint clear private data or cookies maybe your browser stores something and can't act for this clear them and then try and tell us the result 2011/7/28 Bulent Malik > ** > > > > >> did you try it in shell? or just You tried it in PHP? > > Yeah, I tried it on shell and it works on it. Also if I execute it as > command line, it works ; > > php test.php > > But when I try it on www ( internet explorer, firefox, chrome ..) it > doesn't work. > > >
Re: [PHP] I can't execute pf commands
Arthur would you please explain it in more details?
Re: [PHP] I can't execute pf commands
On 07/28/2011 01:22 PM, Arthur Moczulski wrote: > Answer to your problem is in your pop Apache module configuration. I would > suggest to look how different your cli php.ini file is in comparison to your > Apache php module php.ini file No > Also I would not follow the suggestion of adding Apache user to sudoers. > It's quite high risk move in security-wise Good luck getting it to work another way. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: RE: [PHP] I can't execute pf commands
Answer to your problem is in your pop Apache module configuration. I would suggest to look how different your cli php.ini file is in comparison to your Apache php module php.ini file Also I would not follow the suggestion of adding Apache user to sudoers. It's quite high risk move in security-wise Arthur Moczulski On 28 Jul 2011 19:16, "Bulent Malik" wrote: > > > > > >> did you try it in shell? or just You tried it in PHP? > > Yeah, I tried it on shell and it works on it. Also if I execute it as > command line, it works ; > > php test.php > > But when I try it on www ( internet explorer, firefox, chrome ..) it > doesn't work. > >
RE: [PHP] I can't execute pf commands
Bulent Malik wrote: > > > > > >> did you try it in shell? or just You tried it in PHP? > >Yeah, I tried it on shell and it works on it. Also if I execute it as >command line, it works ; > >php test.php > >But when I try it on www ( internet explorer, firefox, chrome ..) it >doesn't work. > > Sounds like it might need you to specify the full paths to the commands/apps you're using in the shell call. Your user might have the right path environment variable specified, but its unlikely the Apache user will have. This user is usually called something like apache or www2. Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I can't execute pf commands
>> did you try it in shell? or just You tried it in PHP? Yeah, I tried it on shell and it works on it. Also if I execute it as command line, it works ; php test.php But when I try it on www ( internet explorer, firefox, chrome ..) it doesn't work.
Re: [PHP] I can't execute pf commands
did you try it in shell? or just You tried it in PHP?