brata-hsdc / brata

Automatically exported from code.google.com/p/brata
2 stars 0 forks source link

Station application needs sudo for shutdown #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Shutdown requires the entire application run as sudo. It would be nice if this 
wasn't needed.

Original issue reported on code.google.com by @jawaad-ahmad on 2 Nov 2014 at 4:58

GoogleCodeExporter commented 9 years ago

Original comment by @jawaad-ahmad on 2 Nov 2014 at 5:00

GoogleCodeExporter commented 9 years ago
You can add the user you want to be able to run shutdown by adding a line to 
the /etc/sudoers file like this (for user "pi"):

pi ALL=(ALL) NOPASSWD: /sbin/shutdown

This should allow the user pi to run "sudo shutdown" without entering a 
password.  I believe this syntax is correct, but I have not tested it.

Original comment by @ellerychan on 11 Nov 2014 at 3:58

GoogleCodeExporter commented 9 years ago
This won't work as-is. The connection.py file currently has the following code 
to shut down:

    sys_bus = dbus.SystemBus()
    ck_srv = sys_bus.get_object('org.freedesktop.ConsoleKit',
                                '/org/freedesktop/ConsoleKit/Manager')
    ck_iface = dbus.Interface(ck_srv,
                              'org.freedesktop.ConsoleKit.Manager')
    stop_method = ck_iface.get_dbus_method("Stop")
    stop_method()

I can't remember right now why I did this instead of running /sbin/shutdown. 
I'll see if I can recall over the next few days; otherwise, I can modify the 
code to run /sbin/shutdown and modify /etc/sudoers as described.

Original comment by @jawaad-ahmad on 6 Dec 2014 at 3:46

GoogleCodeExporter commented 9 years ago

Original comment by @jawaad-ahmad on 18 Feb 2015 at 11:35