GNOME Bugzilla – Bug 114432
[PATCH] gnome-session logout enhancement
Last modified: 2005-08-15 01:26:20 UTC
There are sections in logout.c that allow redhat users to see a 'reboot' and 'shutdown' option on the logout dialog, if certain criteria are met. The below patch takes a more generalized approach, that can be used by any distribution. It simply checks if the commands specified by --reboot-command and --halt-command in configure exist, and if so, the reboot and shutdown options show up for the user, otherwise not. What this allows is for a distribution or user to create a reboot_wrapper and halt_wrapper command, specify it to configure, and then have the logout options available. As such, the wrapper commands can handle authenication with gksu, sudo or whatever. These scripts are of course separate from the patch and gnome-session, but the idea is to make gnome-session more usable to more people, rather than just redhat users. Jamie --- gnome-session-2.2.1.orig/gnome-session/logout.c +++ gnome-session-2.2.1/gnome-session/logout.c @@ -302,14 +302,7 @@ FALSE, TRUE, 0); } - /* Red Hat specific code to check if the user has a - * good chance of being able to shutdown the system, - * and if so, give them that option - */ - s = g_strconcat ("/var/lock/console/", g_get_user_name (), NULL); - t = g_strconcat ("/var/run/console/", g_get_user_name (), NULL); - if (((geteuid () == 0) || g_file_exists (t) || g_file_exists(s)) && - access (halt_command[0], X_OK) == 0) + if (access (halt_command[0], X_OK) == 0 && access (reboot_command[0], X_OK) == 0) { GtkWidget *frame; GtkWidget *action_vbox; @@ -332,8 +325,6 @@ r = reboot = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (r), _("_Restart the computer")); gtk_box_pack_start (GTK_BOX (action_vbox), r, FALSE, FALSE, 0); } - g_free (s); - g_free (t); gsm_center_window_on_screen (GTK_WINDOW (box), screen, monitor);
James: the patch looks good to me. Do you have CVS access ? If not, will you attach the patch using "Create a new attachment" rather than appending it. Thanks much. Owen: cc-ing you so that you are aware of the change.
Eeek! Please don't replace the /var/lock/console/ and uid checks. The new code is in no way equivalent for systems with pam-console; in particular the user may be remote-logged into GNOME (via an XDCMP, say) rather than logged in at the console, and so may not have rights to shut down the machine.
Hmm, glad I cc-ed you then ... Do you have any suggestions on how to not make this Red Hat specific ?
I took out the "redhat specific" code since I thought it was odd that there was distribution specific code in there in the first place. I will look at the code and attach a proposed patch that is equivalent for redhat (eg, doesn't take out the uid checks), but allows shutdown options. The reason why I did it this wasy in the first place was I was thinking that distributions could let the wrapper script do this uid checking, etc, rather than just filling up gnome-session with this code. This would allow them to do cool things like prompt for password, etc. That code could be lifted straight out of gnome-session and dropped into the wrapper to provide equivalent functionality. Anways, I get back to you.
Ok. Attached is a patch that should please everyone. The default behavior is to stay as is. However, if DISABLE_PAMCONSOLE is set, then the console checks are not used (but uid is), and the logout options appear. Ideally, DISABLE_PAMCONSOLE should be set via configure, but for illustrative purposes, I just set it in logout.c. Keep in mind, that just because the logout options show up, it doesn't necessarily mean that the action selected will occur. The reboot-command and halt-command specified to configure should do some checking (eg via sudo etc). This patch simply allows for distributors of gnome besides redhat to take advantage of the these logout options if they want to.
Created attachment 17182 [details] [review] allows pam_console checks to be disabled so logout options display
*** Bug 111305 has been marked as a duplicate of this bug. ***
Created attachment 20721 [details] [review] The patch advertised in 17182 didn't work for me on Slackware-9.1 - modified it to suit my setup
Upgrading the priority level to High due to the patches attached.
We really need a configure flag for this patch to be anyway useful.
Mark, now that gnome-session uses GDM to reboot/halt, this bug can be closed, right?
Yes
closing the bug since gdm is used for that now