You are not logged in.

#1 2016-11-26 02:40:07

STREBLO
Member
Registered: 2015-02-15
Posts: 135

pkexec doesn't work properly

I've been struggling trying to make pkexec work and I feel like I've tried everything. I've tried putting my rules in different areas, I've read the man pages numerous times, and I can't figure out what the hell I'm doing wrong.

My commands are being detected, and polkit is recognizing them, but it isn't allowing my actions to go by without authentication.

I'm trying to have the command accepted without authentication, specifically 'zpool status'. It is being recognizing and I am getting up polkit pop up asking for authentication. The problem is I have written my rule so that it does not need authentication. I want the rule to be accepted and work without a password for my user in group wheel.

Here is my action:

/usr/share/polkit-1/actions/org.john.zpool.policy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<policyconfig>

  <vendor>John Ramsden</vendor>
  <vendor_url>https://ramsdenj.com/</vendor_url>

  <action id="org.john.zpool.status">
    <description>Run zpool status</description>
    <message>Authentication is required to run zpool status as (user=$(user), user.gecos=$(user.gecos), user.display=$(user.display)$
    <defaults>
      <allow_any>yes</allow_any>
      <allow_inactive>yes</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/zpool</annotate>
    <annotate key="org.freedesktop.policykit.exec.argv1">status</annotate>
  </action>

</policyconfig>

and here is my rule:

/usr/share/polkit-1/rules.d/10-zpool.rules
polkit.addRule(function(action, subject) {
    if ((action.id == "org.john.zpool.status") &&
        subject.isInGroup("wheel"))
    {
        return polkit.Result.YES;
    }
});

how do I get my command to be accepted without me having to type a password in?

Offline

Board footer

Powered by FluxBB