0

I have a PHP script that calls exec('supervisorctl status 2>&1', $output);, which runs as www-data user (through Apache).

However this user does not have access to this command. I would like to allow permissions for www-data only for this exact supervisorctl status command. It outputs the running supervisor processes very nicely and I'd like to show that in my webinterface.

# Running `supervisorctl status` under any user except root:
$ supervisorctl status
error: <class 'socket.error'>, [Errno 13] Permission denied: file: /usr/lib/python2.7/socket.py line: 228

I've tried adding this part to the /etc/sudoers file (using visudo) but it results in the same error (I possibly need more permissions since the error refers to python?) :

# /etc/sudoers
Cmnd_Alias SUPERVISOR_STATUS = /usr/bin/supervisorctl status

www-data ALL=(ALL) NOPASSWD: SUPERVISOR_STATUS
0

I got it to work. Apparently, when defining stuff in /etc/sudoers, this means that you are going to call commands with sudo.

So in order to execute it in php, I'd run:

exec('sudo supervisorctl status 2>&1', $output);

This should then work under www-data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.