After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 114432 - [PATCH] gnome-session logout enhancement
[PATCH] gnome-session logout enhancement
Status: RESOLVED FIXED
Product: gnome-session
Classification: Core
Component: gnome-session
2.2.x
Other All
: Normal normal
: ---
Assigned To: Session Maintainers
Session Maintainers
: 111305 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-06-05 00:29 UTC by James Strandboge
Modified: 2005-08-15 01:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
allows pam_console checks to be disabled so logout options display (1.23 KB, patch)
2003-06-05 16:34 UTC, James Strandboge
none Details | Review
The patch advertised in 17182 didn't work for me on Slackware-9.1 - modified it to suit my setup (1.48 KB, patch)
2003-10-15 13:18 UTC, Andrei Yurkevich
needs-work Details | Review

Description James Strandboge 2003-06-05 00:29:09 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);
Comment 1 Mark McLoughlin 2003-06-05 12:10:29 UTC
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.
Comment 2 Owen Taylor 2003-06-05 12:25:51 UTC
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.
Comment 3 Mark McLoughlin 2003-06-05 12:41:41 UTC
Hmm, glad I cc-ed you then  ...

Do you have any suggestions on how to not make this Red Hat specific ?
Comment 4 James Strandboge 2003-06-05 14:23:31 UTC
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.
Comment 5 James Strandboge 2003-06-05 16:32:37 UTC
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.
Comment 6 James Strandboge 2003-06-05 16:34:03 UTC
Created attachment 17182 [details] [review]
allows pam_console checks to be disabled so logout options display
Comment 7 Murray Cumming 2003-07-09 08:20:47 UTC
*** Bug 111305 has been marked as a duplicate of this bug. ***
Comment 8 Murray Cumming 2003-07-09 08:21:06 UTC
*** Bug 111305 has been marked as a duplicate of this bug. ***
Comment 9 Andrei Yurkevich 2003-10-15 13:18:34 UTC
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
Comment 10 alexander.winston 2004-01-03 15:40:41 UTC
Upgrading the priority level to High due to the patches attached.
Comment 11 Mark McLoughlin 2004-02-04 08:19:20 UTC
We really need a configure flag for this patch to be anyway useful.
Comment 12 Carlos Garnacho 2005-03-16 14:58:39 UTC
Mark, now that gnome-session uses GDM to reboot/halt, this bug can be closed, right?
Comment 13 James Strandboge 2005-03-18 14:17:26 UTC
Yes
Comment 14 Sebastien Bacher 2005-07-23 14:21:06 UTC
closing the bug since gdm is used for that now