How do I prevent Polkit authentication dialogues from popping up when I start a ThinLinc session?

On some distributions, users may be presented with Polkit authentication dialogues when starting a ThinLinc session. While harmless, these can be annoying, and confusing for users who don’t know what they mean.

One common example is color-manager, which may display a dialogue such as this:

We can tell Polkit not to display these dialogues and skip authentication altogether for remote users, by creating a rules file. One example of a rules file for suppressing color-manager authentication dialogues might look like this:

polkit.addRule(function(action, subject) {
   if (action.id.startsWith('org.freedesktop.color-manager.')) {
      if (!subject.local) {
        return polkit.Result.NO;
      }
    }
});

This can be placed in a file at /etc/polkit-1/rules.d/02-allow-colord.rules, which should be readable by the polkitd user.

NOTE: Polkit versions <0.106 use a different syntax for rules, in .pkla files. However, most distributions still using such versions are either unsupported or do not work with ThinLinc. It is recommended to use the .rules file syntax, but you should ensure that this is supported by your version of Polkit first.

Other dialogues and desktop user actions can be controlled in the same way. If you have any Polkit rules that you use to improve end user experience in ThinLinc, please feel free to post them below.

See also https://bugzilla.cendio.com/show_bug.cgi?id=5584.

3 Likes

I had to change this line to:
return polkit.Result.YES;

Otherwise, this did exactly what I wanted. :slight_smile:

Time to figure out what the other pop-ups are tagged with for the action id and make my life easier.

Thanks!

1 Like

I had similar issues with the Polkit authentication pop-up messages at initial connection. I am running Rocky Linux 9.6 with ThinLink server 4.19 installed and I ended up making three rules to squash the Polkit pop-up messages.

[root@******** rules.d]# ll
total 20
-rw-r–r–. 1 root cad 189 9 okt 15:44 02-allow-colord.rules
-rw-r–r–. 1 root cad 188 14 okt 18:16 03-allow-suspend.rules
-rw-r–r–. 1 root cad 204 14 okt 18:17 04-allow-network.rules
-rw-r–r–. 1 root root 974 16 mei 2022 49-polkit-pkla-compat.rules
-rw-r–r–. 1 root root 326 27 mrt 2018 50-default.rules
[root@******** rules.d]# cat 02-allow-colord.rules
polkit.addRule(function(action, subject) {
if (action.id.startsWith(‘org.freedesktop.color-manager.’)) {
if (!subject.local) {
return polkit.Result.YES;
}
}
});

[root@******** rules.d]# cat 03-allow-suspend.rules
polkit.addRule(function(action, subject) {
if (action.id.startsWith(‘org.freedesktop.login1.suspend’)) {
if (!subject.local) {
return polkit.Result.NO;
}
}
});

[root@******** rules.d]# cat 04-allow-network.rules
polkit.addRule(function(action, subject) {
if (action.id.startsWith(‘org.freedesktop.NetworkManager.network-control’)) {
if (!subject.local) {
return polkit.Result.NO;
}
}
});

[root@******** rules.d]#

1 Like