[quote]How can I configure dbus to allow ssh-user to suspend server

Original link: http://askubuntu.com/questions/21586/how-can-i-configure-dbus-to-allow-ssh-user-to-suspend-server

There are two basic ways this can be done and a workaround:

Either you need to modify /usr/share/polkit-1/actions/org.freedesktop.upower.policy, set the XDG_SESSION_COOKIE environment variable to the appropriate value or use pm-suspend:

Modifying /usr/share/polkit-1/actions/org.freedesktop.upower.policy

Apply this patch:

--- /usr/share/polkit-1/actions/org.freedesktop.upower.policy.orig  2011-11-16 19:06:59.274055248 +0100
+++ /usr/share/polkit-1/actions/org.freedesktop.upower.policy   2011-11-16 19:11:15.178864922 +0100
@@ -21,6 +21,7 @@
     <defaults>
       <allow_inactive>no</allow_inactive>
       <allow_active>yes</allow_active>
+      <allow_any>yes</allow_any>
     </defaults>
   </action>

(To the <action id="org.freedesktop.upower.suspend"> tag/section), and it’ll work too…

or

XDG_SESSION_COOKIE

When you’re using the desktop, you’ll see that $XDG_SESSION_COOKIE has one value, but in an ssh session, it has another. Store XDG_SESSION_COOKIE e.g. in a .dotfile or something when the desktop starts and source it in your script that needs to do it over ssh.

pm-suspend

Or you could just give up on doing it with dbus and UPower and just issue pm-suspend as root and get it over with! :-)

此条目发表在 Linux使用 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>