[gdm] properly set ressources on BSD systems



commit 61712dbc23421e4a5a53a2647692b96935effcb7
Author: Antoine Jacoutot <ajacoutot gnome org>
Date:   Tue Nov 27 17:53:41 2012 +0100

    properly set ressources on BSD systems
    
    On BSD systems, don't use setuid() but setusercontext() with LOGIN_SETALL
    instead to setup the complete user environment and limits as configured
    by login.conf(5).

 daemon/gdm-session-worker.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
index 228460c..57e49a4 100644
--- a/daemon/gdm-session-worker.c
+++ b/daemon/gdm-session-worker.c
@@ -34,6 +34,10 @@
 
 #include <security/pam_appl.h>
 
+#ifdef HAVE_LOGINCAP
+#include <login_cap.h>
+#endif
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
@@ -1792,10 +1796,18 @@ gdm_session_worker_start_session (GdmSessionWorker  *worker,
                         fd = _open_program_session_log (worker->priv->log_file);
                 }
 
+#ifdef HAVE_LOGINCAP
+                if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) {
+                        g_debug ("GdmSessionWorker: setusercontext() failed for user %s: %s",
+                                 passwd_entry->pw_name, g_strerror (errno));
+                        _exit (1);
+                }	
+#else
                 if (setuid (worker->priv->uid) < 0) {
                         g_debug ("GdmSessionWorker: could not reset uid: %s", g_strerror (errno));
                         _exit (1);
                 }
+#endif
 
                 if (setsid () < 0) {
                         g_debug ("GdmSessionWorker: could not set pid '%u' as leader of new session and process group: %s",



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