LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Reboot/shutdown command without sudo (http://www.linuxquestions.org/questions/debian-26/reboot-shutdown-command-without-sudo-867919/)

eveningsky339 03-11-2011 07:46 AM

Reboot/shutdown command without sudo
 
I've added entries to my Openbox menu labeled Reboot and Shutdown. Problem is, reboot and shutdown h only work as root, and I never login as root.

I've tried su-to-root -c reboot, but the menu entries remain unresponsive.

I do not have sudo installed because I feel it is a security issue. However, I found that sudo reboot works with the menu entry, but only if my account is set to use sudo without a password in /etc/sudoers. :doh:

I use tint2 as my panel, but have had no luck with finding a shutdown/reboot button.

hilyard 03-11-2011 07:51 AM

Ctrl-Alt-Del

Eat fish once in awhile (lol)

cynwulf 03-11-2011 07:54 AM

I run openbox and tint2 on my old spare laptop. sudo is the best way to do this - in fact this is the kind of stuff that sudo was actually designed for. Follow this guide: http://www.debianuserforums.org/viewtopic.php?f=9&t=216

rizzy 03-11-2011 08:03 AM

I use Crunchbang linux that has openbox DE preconfigured. Looking through the menu logout config:
Code:

                </item>
                <item label="Exit">
                        <action name="Execute">
                                <execute>
                                        openbox-logout
                                </execute>
                        </action>
                </item>

That takes me to /usr/bin/openbox-logout
This is how that looks like:
Code:

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
import os

class DoTheLogOut:

    # Cancel/exit
    def delete_event(self, widget, event, data=None):
        gtk.main_quit()
        return False

    # Logout
    def logout(self, widget):
        os.system("openbox --exit")

    # Reboot
    def reboot(self, widget):
        os.system("gdm-control --reboot && openbox --exit")

    # Shutdown
    def shutdown(self, widget):
        os.system("gdm-control --shutdown && openbox --exit")

    def __init__(self):
        # Create a new window
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("Exit? Choose an option:")
        self.window.set_resizable(False)
        self.window.set_position(1)
        self.window.connect("delete_event", self.delete_event)
        self.window.set_border_width(20)

        # Create a box to pack widgets into
        self.box1 = gtk.HBox(False, 0)
        self.window.add(self.box1)

        # Create cancel button
        self.button1 = gtk.Button("_Cancel")
        self.button1.set_border_width(10)
        self.button1.connect("clicked", self.delete_event, "Changed me mind :)")
        self.box1.pack_start(self.button1, True, True, 0)
        self.button1.show()

        # Create logout button
        self.button2 = gtk.Button("_Log out")
        self.button2.set_border_width(10)
        self.button2.connect("clicked", self.logout)
        self.box1.pack_start(self.button2, True, True, 0)
        self.button2.show()

        # Create reboot button
        self.button3 = gtk.Button("_Reboot")
        self.button3.set_border_width(10)
        self.button3.connect("clicked", self.reboot)
        self.box1.pack_start(self.button3, True, True, 0)
        self.button3.show()

        # Create shutdown button
        self.button4 = gtk.Button("_Shutdown")
        self.button4.set_border_width(10)
        self.button4.connect("clicked", self.shutdown)
        self.box1.pack_start(self.button4, True, True, 0)
        self.button4.show()

        self.box1.show()
        self.window.show()

def main():
    gtk.main()

if __name__ == "__main__":
    gogogo = DoTheLogOut()
    main()


eveningsky339 03-11-2011 08:34 AM

Quote:

Originally Posted by Caravel (Post 4286912)
I run openbox and tint2 on my old spare laptop. sudo is the best way to do this - in fact this is the kind of stuff that sudo was actually designed for. Follow this guide: http://www.debianuserforums.org/viewtopic.php?f=9&t=216

Exactly what I needed, thank you. :)


All times are GMT -5. The time now is 08:47 AM.