0

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?

serguei
  • 1
  • 2

1 Answers1

0

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

Niraj Nandane
  • 1,318
  • 1
  • 13
  • 24
  • now it's working from SSH under admin, but doesn't work from shell_exec from php. I get same results running " id admin" "uid=1001(admin) gid=1001(admin) groups=1001(admin),190(systemd-journal)" so it's some php shell_exec bug – serguei Sep 15 '22 at 18:56
  • Can you please try this `admin ALL=(ALL) NOPASSWD: ALL` – Niraj Nandane Sep 19 '22 at 04:08
  • Also try adding this in /etc/sudoers. `Defaults:admin !requiretty` – Niraj Nandane Sep 19 '22 at 04:13