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.

1
  • sestatus returns disabled, so SELINUX is turned off. Commented Sep 23, 2014 at 12:18

1 Answer 1

2

Comment out this line from /etc/sudoers

Defaults requiretty

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.