为 Upstart 定义一个 Policykit 操作

为 Upstart 定义一个 Policykit 操作

我正在尝试让一些用户使用 udev Upstart 界面启动、停止和重新加载服务。我使用的是 Ubuntu 10.04。

我创建了文件 /usr/share/polkit-1/actions/com.ubuntu.Upstart0_6.Job.policy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>UXITIC</vendor>
  <vendor_url>http://citius.usc.es/</vendor_url>
  <icon_name>gdm</icon_name>

  <action id="com.ubuntu.Upstart0_6.Job.Stop">
    <_description>Stops a service</_description>
    <_message>Privileges are required to stop a service.</_message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>
</policyconfig>

还有相应的权限文件 /etc/polkit-1/localauthority/50-local.d/10-allow-users-to-start-and-stop-services.pkla

[Stop services]
Identity=unix-user:jorge
Action=com.ubuntu.Upstart_0.6.Job.Stop
ResultAny=no
ResultInactive=no
ResultActive=auth_self

但是当我尝试停止服务时,我收到“访问被拒绝”信息 :(

jorge$ dbus-send --print-reply --system --dest=com.ubuntu.Upstart /com/ubuntu/Upstart/jobs/ssh com.ubuntu.Upstart0_6.Job.Stop array:string:'' boolean:true
Error org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 1 matched rules; type="method_call", sender=":1.452" (uid=1021 pid=28234 comm="dbus-send) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))

相关内容