polkit 规则无法识别 raspbian 拉伸

polkit 规则无法识别 raspbian 拉伸

我正在运行 raspbian 扩展,我想授予组用户的每个成员安装和卸载 usb-pendrives 的权利

因此我安装了:udisks2

/usr/share/polkit-1/rules.d/50-udisks.rules我创建了一个包含以下内容的*.rules 文件:

polkit.addRule(function(action, subject) {


var YES = polkit.Result.YES;
  var permission = {
    // only required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.filesystem-mount-system-internal": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // only required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount": YES,
    "org.freedesktop.udisks2.filesystem-mount-system": YES,
    "org.freedesktop.udisks2.encrypted-unlock": YES,
    "org.freedesktop.udisks2.eject-media": YES,
    "org.freedesktop.udisks2.power-off-drive": YES,
    // required for udisks2 if using udiskie from another seat (e.g. systemd):
    "org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
    "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
    "org.freedesktop.udisks2.eject-media-other-seat": YES,
    "org.freedesktop.udisks2.power-off-drive-other-seat": YES
  };
  if (subject.isInGroup("users")) {
    return permission[action.id];
  }
});

我重新启动了 polkit 服务:

systemctl restart polkit

发出时:udiskctl mount -b /dev/sda1 仍然要求用户以 root 身份登录。

知道出了什么问题吗?

答案1

看来这是因为 Debian 尚未使用 JavaScript 样式规则文件。您必须将*.pkla这样的文件放入/etc/polkit-1/localauthority/50-local.d/53-udisk.pkla.

名为“user”的单个用户的内容:

/etc/polkit-1/localauthority/50-local.d/53-udisk.pkla:

[Enable Controlling of udisk]
Identity=unix-user:user
Action=org.freedesktop.udisks.filesystem-mount;org.freedesktop.udisks.filesystem-mount-system-internal;org.freedesktop.udisks.luks-unlock;org.freedesktop.udisks.drive-eject;org.freedesktop.udisks.drive-detach;org.freedesktop.udisks2.filesystem-mount;org.freedesktop.udisks2.filesystem-mount-system;org.freedesktop.udisks2.encrypted-unlock;org.freedesktop.udisks2.eject-media;org.freedesktop.udisks2.power-off-drive;org.freedesktop.udisks2.filesystem-mount-other-seat;org.freedesktop.udisks2.encrypted-unlock-other-seat;org.freedesktop.udisks2.eject-media-other-seat;org.freedesktop.udisks2.power-off-drive-other-seat
ResultAny=yes
ResultInactive=yes
ResultActive=yes

这样,它现在就可以在 raspbianstretch 或 jessie 上为我工作了!

答案2

我可以使用以下设置向 udisk 申请权限。

/etc/polkit-1/localauthority/50-local.d/50-udisks.pkla

[udisks]
Identity=unix-group:users
Action=org.freedesktop.udisks*
ResultAny=yes
ResultInactive=no
ResultActive=yes

参考:https://mxlinux.org/wiki/system/mount-internal-partition-without-using-root-password/

相关内容