~darkxst/ubuntu/saucy/gdm/lp1212408

« back to all changes in this revision

Viewing changes to daemon/gdm-session-worker.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-04-08 16:35:19 UTC
  • mto: This revision was merged to the branch mainline in revision 241.
  • Revision ID: james.westby@ubuntu.com-20110408163519-3b8ivhbvx4ypi3fm
Tags: upstream-2.32.1
ImportĀ upstreamĀ versionĀ 2.32.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <grp.h>
33
33
#include <pwd.h>
34
34
 
35
 
#ifdef  HAVE_LOGINDEVPERM
36
 
#include <libdevinfo.h>
37
 
#endif  /* HAVE_LOGINDEVPERM */
38
 
 
39
35
#include <security/pam_appl.h>
40
36
 
41
37
#include <glib.h>
1035
1031
                                   error->message);
1036
1032
                        g_error_free (error);
1037
1033
                 } else {
1038
 
                         int res;
1039
 
 
1040
 
                         res = chown (cachefilename,
1041
 
                                      worker->priv->uid,
1042
 
                                      worker->priv->gid);
1043
 
                         if (res == -1) {
1044
 
                                 g_warning ("GdmSessionWorker: Error setting owner of cache file: %s",
1045
 
                                            g_strerror (errno));
1046
 
                         }
1047
 
 
1048
 
                        g_chmod (cachefilename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
1049
1034
                        g_debug ("Copy successful");
1050
1035
                }
1051
1036
 
1183
1168
                return;
1184
1169
 
1185
1170
        if (worker->priv->state >= GDM_SESSION_WORKER_STATE_SESSION_OPENED) {
1186
 
                gdm_session_worker_cache_userfiles (worker);
 
1171
                pid_t pid;
 
1172
 
 
1173
                pid = fork ();
 
1174
 
 
1175
                if (pid == 0) {
 
1176
                        if (setuid (worker->priv->uid) < 0) {
 
1177
                                g_debug ("GdmSessionWorker: could not reset uid: %s", g_strerror (errno));
 
1178
                                _exit (1);
 
1179
                        }
 
1180
 
 
1181
                        gdm_session_worker_cache_userfiles (worker);
 
1182
                        _exit (0);
 
1183
                }
 
1184
 
 
1185
                if (pid > 0) {
 
1186
                        gdm_wait_on_pid (pid);
 
1187
                }
1187
1188
                pam_close_session (worker->priv->pam_handle, 0);
1188
1189
                gdm_session_auditor_report_logout (worker->priv->auditor);
1189
 
 
1190
 
#ifdef  HAVE_LOGINDEVPERM
1191
 
                /*
1192
 
                 * Only do logindevperm processing if /dev/console or
1193
 
                 * a device associated with a VT
1194
 
                 */
1195
 
                if (worker->priv->display_device != NULL &&
1196
 
                   (strncmp (worker->priv->display_device, "/dev/vt/", strlen ("/dev/vt/")) == 0 ||
1197
 
                    strcmp  (worker->priv->display_device, "/dev/console") == 0)) {
1198
 
                        g_debug ("Logindevperm logout for user %s, device %s",
1199
 
                                 worker->priv->username,
1200
 
                                 worker->priv->display_device);
1201
 
                        (void) di_devperm_logout (worker->priv->display_device);
1202
 
                }
1203
 
#endif  /* HAVE_LOGINDEVPERM */
1204
 
 
1205
1190
        } else {
1206
1191
                const void *p;
1207
1192
 
1989
1974
        register_ck_session (worker);
1990
1975
 
1991
1976
        gdm_get_pwent_for_name (worker->priv->username, &passwd_entry);
1992
 
 
1993
 
#ifdef  HAVE_LOGINDEVPERM
1994
 
        /*
1995
 
         * Only do logindevperm processing if /dev/console or
1996
 
         * a device associated with a VT
1997
 
         */
1998
 
        if (worker->priv->display_device != NULL &&
1999
 
           (strncmp (worker->priv->display_device, "/dev/vt/", strlen ("/dev/vt/")) == 0 ||
2000
 
            strcmp  (worker->priv->display_device, "/dev/console") == 0)) {
2001
 
                g_debug ("Logindevperm login for user %s, device %s",
2002
 
                         worker->priv->username,
2003
 
                         worker->priv->display_device);
2004
 
                (void) di_devperm_login (worker->priv->display_device,
2005
 
                                         passwd_entry->pw_uid,
2006
 
                                         passwd_entry->pw_gid,
2007
 
                                         NULL);
2008
 
        }
2009
 
#endif  /* HAVE_LOGINDEVPERM */
2010
 
 
2011
1977
        g_debug ("GdmSessionWorker: opening user session with program '%s'",
2012
1978
                 worker->priv->arguments[0]);
2013
1979