You are not logged in.

#1 2018-09-23 22:24:41

mkkot
Member
From: Poland
Registered: 2009-12-20
Posts: 288

[Solved] Sudoers rule ignored in favor of polkit

I need a VPN connection activation and deactivation privilege for an unprivileged user. So I read about sudoers file on a wiki and with visudo did this:

kinia ALL=(ALL) NOPASSWD:/usr/bin/systemctl stop openvpn-client@SP52-client.service

So, user kinia should be able to run this systemctl stop command without being asked for a password.

sudo -lU kinia
User kinia may run the following commands on linux:
    (ALL) NOPASSWD: /usr/bin/systemctl stop openvpn-client@SP52-client.service

However, this rule is ignored in favor of:

/usr/share/polkit-1/actions/org.freedesktop.systemd1.policy

<action id="org.freedesktop.systemd1.manage-units">
                <description gettext-domain="systemd">Manage system services or other units</description>
                <message gettext-domain="systemd">Authentication is required to manage system services or other units.</message>
                <defaults>
                        <allow_any>auth_admin</allow_any>
                        <allow_inactive>auth_admin</allow_inactive>
                        <allow_active>auth_admin_keep</allow_active>
                </defaults>
        </action>

So, the system instead of executing my action, displays a window asking for a password of user in (I guess) adm group.

Before I reconfigure the system to use polkit for this task instead of sudoers file, please tell me why this happens? Is this "works as designed" or I'm doing something wrong here?

Last edited by mkkot (2018-09-23 22:39:43)

Offline

#2 2018-09-23 22:29:56

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [Solved] Sudoers rule ignored in favor of polkit

Are you running the systemctl... commmand using sudo?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2018-09-23 22:36:11

mkkot
Member
From: Poland
Registered: 2009-12-20
Posts: 288

Re: [Solved] Sudoers rule ignored in favor of polkit

Yeah, no. I just noticed this silly mistake and wanted to remove this topic, but you already answered.

Anyway, I can see it still asks for a password, this time sudo asks for it:

sudo stop openvpn-client@SP52-client.service
[sudo] password for kinia:

Offline

#4 2018-09-23 22:37:47

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [Solved] Sudoers rule ignored in favor of polkit

Surely you should be running...

sudo systemctl stop openvpn-client@SP52-client.service

No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2018-09-23 22:39:17

mkkot
Member
From: Poland
Registered: 2009-12-20
Posts: 288

Re: [Solved] Sudoers rule ignored in favor of polkit

Surely I should not be sitting till late night here as my mind seems to be off. Thanks a lot, it works all fine now!

Offline

#6 2018-09-26 01:47:31

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [Solved] Sudoers rule ignored in favor of polkit

Yeah, polkit and sudo are two completely unrelated ways of acquiring root permissions for a process... it just happens that by convention, the same users have permission for both, and sometimes, programs like systemctl can be used with either one. smile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB