1

I'm trying to debug a new PolicyKit rule that looks like this:

polkit.addRule(function(action, subject) {
    polkit.log("action=" + action);
    polkit.log("subject=" + subject);
    if (action.id == "org.freedesktop.udisks2.filesystem-unmount-others"){
        return polkit.Result.YES;
    }
});

But I can't find the output of the polkit.log() calls anywhere in /var/log/. I even tried adding a line to /etc/rsyslog.d/50-default.conf

*.*         /var/log/all

which produces lots of output, but not for polkit.log(). Where can I find the log messages for these calls?

1

From the policykit documentation:

The log() method writes the given message to the system logger prefixed with the JavaScript filename and line number. Log entries are emitted using the LOG_AUTHPRIV flag meaning that the log entries usually ends up in the file /var/log/secure. The log() method is usually only used when debugging rules. The Action and Subject types has suitable toString() methods defined for easy logging, for example,

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.policykit.exec") {
        polkit.log("action=" + action);
        polkit.log("subject=" + subject);
    }
});

will produce the following when the user runs pkexec -u bateman bash -i from a shell:

May 24 14:28:50 thinkpad polkitd[32217]: /etc/polkit-1/rules.d/10-test.rules:3: action=[Action id='org.freedesktop.policykit.exec' command_line='/usr/bin/bash -i' program='/usr/bin/bash' user='bateman' user.gecos='Patrick Bateman' user.display='Patrick Bateman (bateman)']
May 24 14:28:50 thinkpad polkitd[32217]: /etc/polkit-1/rules.d/10-test.rules:4: subject=[Subject pid=1352 user='davidz' groups=davidz,wheel, seat='seat0' session='1' local=true active=true]

This type of log events is usually found in /var/log/auth.log in Debian and its derivatives including Ubuntu.

Source: /var/log/secure not present in 14.04 ,is there any alternative?

  • I've tried that example, and can't get it to work. Also tested on a fresh Ubuntu VM. As far as I can tell, my .rules file is never being executed. Futhermore, the last entry I have in /var/log/auth.log is over two years old, which seems rather strange... – Keidax Oct 13 '14 at 14:24
  • 1
    @Keidax, it's another problem. But logs should be /var/log/auth.log. May I suggest to open a new question for your rules file never executed? – Sylvain Pineau Oct 13 '14 at 14:26
  • Alright, posted here. – Keidax Oct 13 '14 at 15:24
  • This will not work. As of now (Ubuntu 19.04) and for the foreseeable future (19.10 betas), Ubuntu uses polkit 0.105. The javascript/ECMAscript rules were enabled on version 0.106. askubuntu.com/a/704062/10542 – Cliff Jun 28 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.