2

I am running CentOS 6, as httpd is executed as user 'apache'. For security reasons, I want to use sudo to be executed via exec as user 'aq':

<?php exec("/usr/bin/sudo -u aq somescript.sh",$output,$return_val);?>

With visudo I have added the following line:

apache ALL = (aq) NOPASSWD: ALL

Furthermore I temporary gave apache as login shell (/bin/bash), to be able to test

/usr/bin/sudo -u aq somescript.sh

directly which worked.

php exec fails as $return_val delivers a '1' if sudo is invoked.

Stefan
  • 137
  • 13

1 Answers1

2

Comment out this line from /etc/sudoers

Defaults requiretty

I'v tested your case in few ways ant this one gives me success.

Karolis Tička
  • 244
  • 1
  • 4
  • 13