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

未关闭
#9 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
文档
描述清晰度
需要澄清
活跃度
停滞
技术栈
linux, python

调研方向

首先检查 issue 中提到的 AptKit PolicyKit 操作:org.aptkit.install-or-remove-packages、org.aptkit.install-purchased-packages 和 org.aptkit.upgrade-packages。确定其授权变量是否包含软件包名称,然后记录变量名称,或明确说明不支持软件包级匹配。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Python
星标
15
派生
10
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

linuxmint/aptkit 的其他 Issue

查看 linuxmint/aptkit 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。