Sample Header Ad - 728x90

How to allow `www-data` to call `supervisorctl status`?

0 votes
2 answers
2577 views
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: , [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
Asked by Flame (111 rep)
Jul 16, 2020, 07:05 PM
Last activity: Jul 21, 2021, 09:44 PM