web-dev-qa-db-ja.com

管理者パスワードを必要としないシャットダウンを行うにはどうすればよいですか?

複数の人が私のコンピューターにログインしている場合、Ubuntuはコンピューターをシャットダウンするときにスーパーユーザー認証を要求します。パスワードを要求されずにすべてのユーザーがコンピューターをシャットダウンできるようにするにはどうすればよいですか?

49
Isaiah

回避策は不要です。ポリシーを変更するだけで、複数のユーザーがログインしているときにシャットダウンおよび再起動するための管理者として認証せずにシャットダウンできるようになります。

お気に入りのテキストエディターを使用して、ファイル/usr/share/polkit-1/actions/org.freedesktop.consolekit.policyを編集します。ルート権限が必要になります。

他のユーザーがログインしたときのシャットダウンに関するセクションを変更します

  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.consolekit.system.stop-multiple-users">
    <description>Stop the system when multiple users are logged in</description>
    <message>System policy prevents stopping the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

他のユーザーがログインしたときの再起動に関するセクション

  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.consolekit.system.restart-multiple-users">
    <description>Restart the system when multiple users are logged in</description>
    <message>System policy prevents restarting the system when other users are logged in</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

また、複数のユーザーがログインしているときに、PCをシャットダウンして再起動できます。それを行うかどうかは別の質問です。

27

Richard Hollowayの答え は、実際にはPolickKitの承認が許可される方法ではありません。 /usr/share/polkit-1/actionsの下にインストールされたファイルは、変更するためのものではありません。代わりに、/etc/polkit-1/localauthority/50-local.d/の下で権限を変更する必要があります。

この質問に対しては、次のようにします。

/etc/polkit-1/localauthority/50-local.d/allow_all_users_to_shutdown.pklaという名前のファイルを作成し、sudoeditを使用して次のように編集します。

[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop-multiple-users
ResultInactive=no
ResultActive=yes

次に、同じディレクトリに別の.pklaファイルを作成します。 .pklaなど、allow_all_users_to_restart.pklaで終わる任意の名前を使用し、次の内容を入力します。

[Allow all users to restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.restart-multiple-users
ResultInactive=no
ResultActive=yes

参照:

33
Flimm

より良い方法があります。 dbus-sendがインストールされている場合、dbus root権限にエスカレートする必要なしを使用してシャットダウンできます。

ドキュメントのあるページは思い出せませんが、あるArchlinuxユーザーがこれを理解しました。

シャットダウン:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown

再起動:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Reboot

サスペンド:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1

休止状態:

dbus-send --system --print-reply --dest=org.freedesktop.Hal \
          /org/freedesktop/Hal/devices/computer \
          org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate

よろしく。

16
ibuclaw

HALは現在、廃止されており、最新のUbuntuリリースにはインストールされていないようです。

ConsoleKit および Power dbusサービスを使用して電源状態を管理する必要があります

シャットダウン:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

再起動:

dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

サスペンド:

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

休止状態:

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

Arch Linux フォーラム に感謝します。

これは今のところPreciseとQuantalで動作しますが、FreedesktopのフォーカスがConsoleKitからsystemdに移行しているように見えるので、どれくらいの期間かはわかりません。 Canonicalが気にするかどうかわからない...

12
Epeli

これは14.04で機能します。以前の更新されたバリエーション、IMO、正しい Flimmによる回答

Sudo mkdir -p /etc/polkit-1/localauthority/50-local.d
sudoedit /etc/polkit-1/localauthority/50-local.d/allow_all_users_to_shutdown_reboot_suspend.pkla 

これを内側に貼り付けます:

[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off-multiple-sessions
ResultActive=yes

[Allow all users to reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot-multiple-sessions
ResultActive=yes

[Allow all users to suspend]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-multiple-sessions
ResultActive=yes

[Allow all users to ignore inhibit of shutdown]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off-ignore-inhibit
ResultActive=yes

[Allow all users to ignore inhibit of reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot-ignore-inhibit
ResultActive=yes

[Allow all users to ignore inhibit of suspend]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-ignore-inhibit
ResultActive=yes
4
Konstigt

他のユーザーがターミナルウィンドウを開いてrebootコマンドをrootとして発行しない限り、再起動時にスーパーユーザーパスワードのプロンプトを回避する方法はありません。

Sudo reboot

それでも、ユーザーアカウントのパスワードプロンプトをバイパスするように構成されていない場合は、Sudoもパスワードの入力を求めます。

心配しないでください、これらは良いものです。再起動することはまれであり、単純な管理者パスワードプロンプトにより、誤って自分を追いかけることがなくなります!

1
jathanism

このタスクの実行を許可するグループ/ユーザーに割り当てられたsudoersファイルに停止および/または再起動を追加します。このようにして、シャットダウンできるユーザーを制御できますが、マシンへの完全なルートアクセス権を付与する必要はありません。

http://linux.byexamples.com/archives/315/how-to-shutdown-and-reboot-without-Sudo-password/

0
tommed

これは、コマンドラインから実行する場合にのみ問題になると思います。

その場合、ここに link があり、これが問題の解決に役立ちます。

0
myusuf3