Page 1 of 1

shell_exec("journalctl"); user permissions

Posted: Tue Sep 13, 2022 12:09 pm
by jonny1960
I'm trying to get log messages of 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."

Code: Select all

shell_exec('whoami') //shows "admin"
Tried to put into /etc/sudoers.d/admin these lines one by one but none of them worked

Code: Select all

%admin ALL=(root) NOPASSWD: /usr/sbin/journalctl
admin ALL=NOPASSWD: /usr/sbin/journalctl
%admin ALL=(ALL) 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?