shell_exec("journalctl"); permissions

Viewed 60

I'm trying to get log messages from journalctl from PHP, but getting an error - "Hint: You are currently not seeing messages from other users and the system. Users in the 'systemd-journal' group can see all messages."

shell_exec('whoami') //shows "admin"

Tried to put into /etc/sudoers.d/admin these lines one by one but none of them worked

%admin ALL=(root) NOPASSWD: /usr/sbin/journalctl
admin ALL=NOPASSWD: /usr/sbin/journalctl
%admin ALL=(ALL) ALL
www-data ALL=NOPASSWD: ALL

shell_exec("sudo -l"); - doesn't indicate that this privilege has been granted

How can I grant privilege to php shell_exec sudo on CENTOS 7 to get this request?

1 Answers

Add admin ALL=(ALL) NOPASSWD: ALL and Defaults:admin !requiretty in /etc/sudoers to get this working.

Related