Define a Policykit action for Upstart

Posted by gentakojima on Ask Ubuntu See other posts from Ask Ubuntu or by gentakojima
Published on 2012-03-22T10:14:10Z Indexed on 2012/03/22 11:39 UTC
Read the original article Hit count: 245

Filed under:
|
|

I'm trying to get some user to start, stop and reload services by using the udev Upstart interface. I'm using Ubuntu 10.04.

I created the file /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>

And also the corresponding authority file /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

But when I try to stop a service, I get Access Denied :(

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"))

© Ask Ubuntu or respective owner

Related posts about 10.04

  • An increase to 3 Gig of RAM slows down Ubuntu 10.04 LTS

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have Ubuntu 10.04 running from an external hard drive (installed on an enclosure) connected via USB port. Like a month or so ago, I increased RAM on my pc from 2 Gigs to 3 Gigs. This resulted on extremely long boot times and slow application loads. While I was understanding the nature of my problem… >>> More

  • Default /etc/apt/sources.list?

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I need default source list for ubuntu 10.04. Can anybody help me? Here is Mine:--- Ubuntu supported packages deb http://archive.ubuntu.com/ubuntu/ lucid main restricted multiverse universe deb http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse deb http://archive… >>> More

  • SSH main process ended

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have a running ubuntu server 10.04.1. When I tried to login to the server via ssh, I could not. Instead, I got connection refused error. I tried to ping the machine and I got reply! So, the clear reason is that SSH daemon is stopped. After reboot, I was able to login to my server via ssh. After… >>> More

  • PPA causing 404 error?

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I need default source list for ubuntu 10.04. Can anybody help me? Here is Mine:--- Ubuntu supported packages deb http://archive.ubuntu.com/ubuntu/ lucid main restricted multiverse universe deb http://archive.ubuntu.com/ubuntu/ lucid-backports main restricted universe multiverse deb http://archive… >>> More

  • Postgresql fails to start on Ubuntu 10.04.4 LTS

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I installed postgresql 9.2 from add-apt-repository ppa:pitti/postgresql using apt-get install postgresql-9.2 At the end of the install and every time I try to launch postgresql by using the following command /etc/init.d/postgresql start or service postgresql start I get this error: Error:… >>> More

Related posts about dbus

  • Not able to compile dbus-ping-pong

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have downloaded files from http://cgit.collabora.com/git/user/alban/dbus-ping-pong.git/tree/ I am trying to compile it using the command gcc pkg-config --libs --cflags dbus-1 dbus-glib-1-2 glib-2.0 -o dbus-ping-pong dbus-ping-pong.c However, I get errors: /tmp/ccmJkxXb.o: In function g_once_init_enter: dbus-ping-pong… >>> More

  • How to find other end of unix socket connection?

    as seen on Server Fault - Search for 'Server Fault'
    I have a process (dbus-daemon) which has many open connection over UNIX sockets. One of these connections is fd #36: =$ ps uw -p 23284 USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND depesz 23284 0.0 0.0 24680 1772 ? Ss 15:25 0:00 /bin/dbus-daemon --fork… >>> More

  • symlink for dbus headers

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    Source code for something that won't compile has the line #include but in real life that header file is in /usr/include/dbus-1.0/ Similarsituation exists for the dbus-c++ package. Why doesn't Ubuntu provide a symlink /usr/include/dbus pointing to the dbus-1.0 directory? Is this an bug in the… >>> More

  • Resetting Update Manager

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    How can I fix Update Manager in 12.04, which hangs when I try to install any update, while sudo apt-get upgrade works fine? I suspect it has something to do with my python installation. This is the error message: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/defer/__init__… >>> More

  • How to get Webkit Browser DBus Bridge working?

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I've been struggling to get the Browser Dbus Binding working for Webkit/GTK (http://gitorious.org/webkitgtk/stable) port. I have been able to successfully compile the Webkit/GTK port as well as the DBus binding library on my Ubuntu Lucid Beta. I also installed the DBus binding library at the standard… >>> More