Welcome to refracta

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

How to log out, reboot, shutdown?

Stuff that has not yet gone into the official build.

How to log out, reboot, shutdown?

Postby fsmithred » Tue Oct 21, 2014 2:08 pm

Running jessie with openbox, no display manager, no systemd, no consolekit or policykit. Primary user has sudo privs with no password for halt and reboot. Command aliases and user's name are in sudoers. (see below)

The following (sanitized) code in v.9.1.1 of the installer (from 9.1.0+dzz3) removes the user privs line in the installation's sudoers.
Code: Select all
# squeeze (or other distro) might have used(***/***)etc/sudoers
if grep -qs $oldusername /target(***/***)etc/sudoers ; then
sed -i "/$oldusername/d" /target(***/***)etc/sudoers

I'm mainly looking for other ways to log out, shutdown, reboot, and probably should include hibernate and suspend. Secondary issue is what to do with sudo in this case. I need to look through the code closely again before writing a solution. A quick fix is possible by adding another item to the config file or the expert menu.

Current logout script used on the desktop:
Code: Select all
#!/usr/bin/env bash
# quit-dialogue.4
# For openbox, xscreensaver. Need sudo allowed for halt and reboot.

yad  --question --title="Exit Choices" \
        --width=350 --height=60  \
   --button="Lock Screen":0 --button="Logout":1 \
   --button="Reboot":2 --button="Shutdown":3 --button=gtk-close:4

   case $answer in
      0) xscreensaver-command -lock ;;
      1) openbox --exit ;;
      2) sudo /sbin/reboot ;;
      3) sudo /sbin/halt ;;
      4) exit 0 ;;

exit 0

Code: Select all
# Cmnd alias specification

Cmnd_Alias HALT = /sbin/shutdown, /sbin/halt
Cmnd_Alias REBOOT = /sbin/reboot
Cmnd_Alias MEM = /usr/local/bin/ps_mem.py

# User privilege specification
root   ALL=(ALL:ALL) ALL
User avatar
Posts: 2081
Joined: Wed Mar 09, 2011 9:13 pm

Re: How to log out, reboot, shutdown?

Postby dzz » Tue Oct 21, 2014 2:52 pm

Code: Select all
user ALL= NOPASSWD: /usr/sbin/pm-suspend, /usr/sbin/pm-hibernate, /sbin/halt, /sbin/reboot

Change "user" to suit (or can be "%group", e.g. %sudo) and put that in a file, e.g "user_shutdown", in sudoers.d (better than messing with main sudoers) and chmod 0440
Works here from terminal or custom launcher. A yad dialog could probably be designed.

If you get problems with X display for root, this works here:

Code: Select all
xhost SI:localuser:root && sudo command && xhost -SI:localuser:root
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: How to log out, reboot, shutdown?

Postby dzz » Wed Oct 22, 2014 7:16 pm

Another way using setuid, no messing with sudo:
Copy /sbin/halt to somewhere else (maybe not ~).

Code: Select all
chown root:root /copy/of/halt
chmod 6711 /copy/of/halt

Do the same with reboot. Works here. Not tried it with pm-suspend yet.
Posts: 647
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Return to Experimental

Who is online

Users browsing this forum: No registered users and 0 guests