What are the Polkit variables utilized by the AptKit PolicyKit actions?

Open
#9 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
linux, python

Research direction

Start by examining the AptKit PolicyKit actions named in the issue: org.aptkit.install-or-remove-packages, org.aptkit.install-purchased-packages, and org.aptkit.upgrade-packages. Determine whether their authorization variables contain package names, then document the variable names or clearly state that package-level matching is unavailable.

Written by the indexing model from the issue text.

Description

Modern PolicyKit utilizes JavaScript for authorization rules. The "Action" type supports the "lookup()" method, which is used to lookup the variables passed from the mechanism (in this case AptKit). Regarding package management on our company workstations, we construct rules to prevent users from installing/removing/upgrading certain packages while allowing such actions for other packages. This works very well with the PackageKit, Flatpak, and Synaptic PolicyKit actions - we can use regex to test if the applicable polkit variable contains the name of a package we want to restrict. Thus far we haven't been able to determine what polkit variables the AptKit PolicyKit actions are using.

So, is there someone who can provide the polkit variables used by the actions noted below? That is assuming variables are used and would contain the names of the packages.

org.aptkit.install-or-remove-packages
org.aptkit.install-purchased-packages
org.aptkit.upgrade-packages

For example, here are some trimmed rules that work for PackageKit, Flatpak, and Synaptic:

  • PackageKit polkit action variable "package_ids" contains the package name
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.packagekit.package-downgrade" ||
        action.id == "org.freedesktop.packagekit.package-install" ||
        action.id == "org.freedesktop.packagekit.package-reinstall" ||
    	action.id == "org.freedesktop.packagekit.package-remove") {
        if (RegExp('sssd','i').test(action.lookup("package_ids")) === true ||
            RegExp('unattended','i').test(action.lookup("package_ids")) === true ||
            RegExp('vnc','i').test(action.lookup("package_ids")) === true)
        {
            return polkit.Result.NO;
        }
        else {
            return polkit.Result.YES;
        }
    }
});
  • Flatpak polkit action variable "ref" contains the package name
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.Flatpak.app-install" ||
	action.id == "org.freedesktop.Flatpak.app-uninstall") {
        if (RegExp('torrent','i').test(action.lookup("ref")) === true ||
            RegExp('dconf-editor','i').test(action.lookup("ref")) === true ||
            RegExp('vnc','i').test(action.lookup("ref")) === true)
        {
            return polkit.Result.NO;
        }
        else {
            return polkit.Result.YES;
        }
    }
});
  • Synaptic polkit action variable "command_line" contains the package name
polkit.addRule(function(action, subject) {
    if (action.id == "com.ubuntu.pkexec.synaptic") {
        if (RegExp('linux-image','i').test(action.lookup("command_line")) === true)
        {
	    return polkit.Result.NO;
	}
	else {
	    return polkit.Result.YES;
	}
    }
});

https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html

Dominant language
Python
Stars
15
Forks
10
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from linuxmint/aptkit

All issues in linuxmint/aptkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.