polkit ルールは Raspbian Stretch を認識しません。

polkit ルールは Raspbian Stretch を認識しません。

私は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で動作します!

おすすめ記事