Skip to contentSkip to conversation

polkit: any idea how to enable logging with polkit.log() function

DISCUSSION Yu, Mingli 1 participant 1 message Mar 18, 2024

lore
Share & tools
lore

Yu, Mingli

author
#0 lore raw

Hi,

I'm trying to enable logging with polkit.log() function.

1, Remove --no-debug flag from ExecStart command in polkit.service.

2, Add log rule as below:

$ cat /etc/polkit-1/rules.d/00-log-access.rules
polkit.addRule(function(action, subject) {
        polkit.log(action);
        polkit.log("WWWWWW" + subject);
});

3, restart polkit service

$ systemctl daemon-reload
# systemctl restart polkit

4, issue the access as "pkexec -u testu bash -i"

# groupadd testg
# useradd -g testg testu
# passwd testu
New password:
Retype new password:
passwd: password updated successfully
# pkexec -u testu bash -i
testhost:~$

5, check the log

# journalctl | grep polkitd > /var/log/polkit.log
# cat  /var/log/polkit.log
Mar 11 08:42:09 qemux86-64 polkitd[549]: Started polkitd version 123
Mar 11 08:42:10 qemux86-64 polkitd[549]: Loading rules from directory /etc/polkit-1/rules.d
Mar 11 08:42:10 qemux86-64 polkitd[549]: 08:42:10.530: Loading rules from directory /etc/polkit-1/rules.d
Mar 11 08:42:10 qemux86-64 polkitd[549]: 08:42:10.538: Loading rules from directory /usr/share/polkit-1/rules.d
Mar 11 08:42:10 qemux86-64 polkitd[549]: Loading rules from directory /usr/share/polkit-1/rules.d
Mar 11 08:42:10 qemux86-64 polkitd[549]: Finished loading, compiling and executing 3 rules
Mar 11 08:42:10 qemux86-64 polkitd[549]: 08:42:10.559: Finished loading, compiling and executing 3 rules
Mar 11 08:42:10 qemux86-64 polkitd[549]: Entering main event loop
Mar 11 08:42:10 qemux86-64 polkitd[549]: Connected to the system bus
Mar 11 08:42:10 qemux86-64 polkitd[549]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Mar 11 08:42:10 qemux86-64 polkitd[549]: 08:42:10.596: Acquired the name org.freedesktop.PolicyKit1 on the system bus

But I didn't find any log related to what defined as /etc/polkit-1/rules.d/00-log-access.rules, any idea how to enable logging for polkit.log.

Thanks,