Stuff that has not yet gone into the official build.
Post a reply

How to log out, reboot, shutdown?

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:
# squeeze (or other distro) might have used(***/***)etc/sudoers
if grep -qs $oldusername /target(***/***)etc/sudoers ; then
sed -i "/$oldusername/d" /target(***/***)etc/sudoers
fi


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:
#!/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
   
answer="$?"

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

exit 0


Code:
# 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   ALL=NOPASSWD: HALT, REBOOT, MEM, NET

Re: How to log out, reboot, shutdown?

Tue Oct 21, 2014 2:52 pm

Code:
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:
xhost SI:localuser:root && sudo command && xhost -SI:localuser:root

Re: How to log out, reboot, shutdown?

Wed Oct 22, 2014 7:16 pm

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

Code:
su
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.
Post a reply