標準ユーザーによるプリンタの追加と削除を許可

標準ユーザーによるプリンタの追加と削除を許可

root以外のユーザーがパスワードを入力せずにCentOS 7のデスクトップGUIを介してプリンタを追加できるようにします。カスタム Polkit ルールを設定し、CUPS 構成を変更してみましたが、成功しませんでした。

rootユーザーでも、GUIを介したプリンタの追加を完全に防ぎます。プリンタを追加する唯一の方法は、端末を介してsudoコマンドを使用することです。

私が試したことは次のとおりです。

  • lp グループのユーザーに対する "org.freedesktop.color-manager.create-device" および "org.freedesktop.systemd1.manage-units" 操作のカスタム Polkit ルール。
  • SystemGroup定義にlpを追加して/etc/cups/cups-files.confを変更します。

Polkitルール(/etc/polkit-1/rules.d/51-custom-printer.rules)


polkit.addRule(function(action, subject) {
  if (action.id == "org.freedesktop.color-manager.create-device" &&
    subject.isInGroup("lp")) {
    return polkit.Result.YES;
  }
});

polkit.addRule(function(action, subject) {
  if (action.id == "org.freedesktop.systemd1.manage-units" &&
    action.lookup("unit") == "cups.service" &&
    subject.isInGroup("lp")) {
    return polkit.Result.YES;
  }
});

CUPS構成( /etc/cups/cups-files.conf)

# Administrator user group, used to match @SYSTEM in cupsd.conf policy rules...
SystemGroup sys root lp

ベストアンサー1

おすすめ記事