19.3. パーティション再設定のロック

polkit により、個別操作のパーミッションを設定できます。ディスク管理サービスのユーティリティーである udisks2 の場合、設定は /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy にあります。このファイルには、システム管理者が上書きできる操作およびデフォルト値のセットが含まれます。

重要

/etc に保存される polkit 設定が /usr/share/ のパッケージで提供される設定内容を上書きします。

手順

  1. /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy と同じ内容のファイルを作成します。

    cp /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy /etc/share/polkit-1/actions/org.freedesktop.udisks2.policy

    /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy ファイルは変更しないようにしてください。変更を加えても、次のパッケージの更新で上書きされます。

  2. 不要な操作を削除し、以下の行を /etc/polkit-1/actions/org.freedesktop.udisks2.policy ファイルに追加します。

    <action id="org.freedesktop.udisks2.modify-device">
      <message>Authentication is required to modify the disks settings</message>
         <defaults>
            <allow_any>no</allow_any>
            <allow_inactive>no</allow_inactive>
            <allow_active>yes</allow_active>
          </defaults>
     </action>

    root ユーザーのみがこの操作を実行できるようにする必要がある場合は、noauth_admin に置き換えます。

  3. 変更を保存します。

ユーザーがディスク設定を変更しようとすると、以下のメッセージが返されます。

Authentication is required to modify the disks settings.