4

I want to remove that unlock button from the top so a normal users allowed to add a printer from gnome control center. I have added the user to the lp group and it works from the cups web administration page. How can enable any user to access that setting ?

enter image description here

2 Answers2

3

Late reply but I ran into this requirement today and this post is high in the Google results.

In short, you need to apply a local policykit ... policy, that allows the users you want. The file should be created in /var/lib/polkit-1/localauthority/50-local.d/ named something like 50-printer-open-access.pkla (note, this is the location for policies in debian/ubuntu systems - others I don't know)

Note: please see comments below regarding potential file syntax changes on modern distros, I can confirm the examples below are working on ubuntu 18.04

Example 1, allows literally anyone:

[Printer administration]
Identity=*
Action=org.opensuse.cupspkhelper.mechanism.*
ResultAny=no
ResultInactive=no
ResultActive=yes

Example 2, allows any users in the lpadmin group:

[Printer administration]
Identity=unix-group:lpadmin
Action=org.opensuse.cupspkhelper.mechanism.*
ResultAny=no
ResultInactive=no
ResultActive=yes

A reference I found handy:

cleary
  • 224
  • @don_crissti thanks for the heads up - it appears that ubuntu 18.04 may be using both policykit and polkit then? The ubuntu policykit overrides are still using the ini -style syntax – cleary May 16 '18 at 23:30
  • @don_crissti Thanks again for the heads up - – cleary May 20 '18 at 23:52
2

The first answer didn't work for me on Fedora and so I found this document.

Adding this to /etc/polkit-1/rules.d/90-printer-admin.rules worked immediately, didn't even have to close and reopen the control panel.

polkit.addRule(function(action, subject) {
    if (/^org\.opensuse\.cupspkhelper\.mechanism\./.test(action.id) &&
        subject.isInGroup("lp")) {
            return polkit.Result.YES;
    }
});

In Fedora the admin group is lp, not lpadmin, so adjust as needed.

gregswift
  • 121