[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[desktop] enabling gnome-session reboot and halt options on logout

Currently, logging out of gnome in debian only presents the user with
saving the current session.  However, there is code in gnome-session to
give users the option to logout, reboot and shutdown.  The code says
that enabling this functionality is redhat specific however.

I have user's that have complained about this missing functionality when
we switched from redhat to debian.  As such, I have compiled the
functionality into gnome-session, so they can be presented with that

What I did was a crude hack, but I thought that it might at least
trigger a dialog and perhaps an elegant solution to this.

1. create 'reboot_script' and 'halt_script'.  I dropped sudo commands in
these scripts

2. compile gnome-session with '--reboot-command=reboot_script

3. mkdir /var/run/console

4. create files for who is allowed to reboot.  I just add all the
usernames and let sudo handle the authentication.

foreach username
	touch /var/run/console/username

There are several problems with the above that I will now address.

The reboot and halt wrapper scripts where I put 'sudo /sbin/reboot' and
'sudo /sbin/poweroff'.  Wrapper scripts have to be used with the current
code because gnome-session doesn't do the right thing if there are
arguments to the reboot and halt commands.  Using sudo is probably too
site specific.

IMO, all the console stuff is a bad hack. The gnome-session code checks
for /var/run/console/<current username> to see if the current user is
allowed to reboot or halt.  If the file does not exist, then
gnome-session does not provide the halt and reboot options.  Otherwise,
it does.  Redhat apparently has code that automatically adds users to
/var/run/console when they login locally-- so they make the assumption
that if the user logged in locally, they can shut the machine down.  Not
the best assumption IMO.

Any number of solutions exist for Debian Desktop here.  One is
performing a very light modification to gnome-session to always show
reboot and halt, and then drop gksu (which knows about sudo too)
commands into our wrapper scripts to handle the authentication.  If the
user doesn't have the password, or isn't allowed to shutdown or reboot
via sudo, then it doesn't work, otherwise it does.

Alternately, a 'gnome_shutdown_allow' wrapper script can be created to
add and remove users from /var/run/console.  The advantage here is that 
gnome-session does not have to be patched at all (but of course does
need to be compiled differently).  debconf and dpkg-reconfigure could be
used to help manage this as well (ala etherconf).

I think it is possible to come up with a good solution for this.  It is
a small feature, but one that has made my users much more happy.


Email:        jstrand1@rochester.rr.com
GPG/PGP ID:   26384A3A
Fingerprint:  D9FF DF4A 2D46 A353 A289  E8F5 AA75 DCBE 2638 4A3A

Reply to: