
私はRaspbian Stretchを実行しており、グループユーザーのメンバー全員にUSBペンドライブのマウントとアンマウントの権限を与えたいと考えています。
そこで私は以下をインストールしました: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
この方法で、raspbian Stretch または jessie で動作するようになりました。
答え2
以下の設定でudisksに権限を適用できました。
/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/