Subject: gdm: problems with automounted home directories
Package: gdm
Version: 2.13.0.10-2
Severity: normal
Tags: patch

We have seen problems with users restoring there settings when logging
in. The symptoms are as follows:
- user logs in for the first time and gets an error message about
  permission problems in ~/.dmrc
- the second login attempt is fine
- in the logs:
  Apr 27 16:51:43 localhost gdm[6921]: gdm_slave_session_start: /home/user is 
not owned by uid 1000.

We have a setup where user home directories are mounted using an
automounter with ghosting enabled (--ghost option to automount). This
causes unmounted directories to appear like:
    0 dr-xr-xr-x  2 root root 0 May  1 12:34 /home/user
after an access to any file inside this directory the home directory is
mounted on top of it and the directory changes to:
 8.0K drwxr-sr-x  104 user consul 8.0K May  1 12:29 /home/user

This obviously confuses gdm into thinking the user's home directory is
not owned by the user. This problem can be solved by setting
CheckDirOwner to false in gdm.conf.

The problem can also be solved quite easily in gdm by stat()-ing
the .dmrc file before the home directory. The changes to
daemon/filecheck.c: gdm_file_check() are limited to moving some code
around.

The other point is that it would be nice if the error message to the
user would be a little clearer. The problem was not with the permissions
of the ~/.dmrc file (which is what the error said) but with the
directory.

-- 
-- arthur de jong - [EMAIL PROTECTED] - west consulting b.v. --
--- daemon/filecheck.c.orig	2006-05-01 12:41:29.000000000 +0200
+++ daemon/filecheck.c	2006-05-01 14:44:13.000000000 +0200
@@ -54,37 +54,8 @@
 	ve_string_empty (file))
 	    return FALSE;
 
-    /* Stat directory */
-    VE_IGNORE_EINTR (r = g_stat (dir, &statbuf));
-    if (r < 0) {
-	    if ( ! absentdirok)
-		 syslog (LOG_WARNING, _("%s: Directory %s does not exist."),
-			 caller, dir);
-	    return FALSE;
-    }
-
-    /* Check if dir is owned by the user ... 
-       Only, if GDM_KEY_CHECK_DIR_OWNER is true (default)
-       This is a "hack" for directories not owned by 
-       the user.
-       2004-06-22, Andreas Schubert, MATHEMA Software GmbH */
-
-    if G_UNLIKELY (gdm_get_value_bool (GDM_KEY_CHECK_DIR_OWNER) && (statbuf.st_uid != user)) {
-        syslog (LOG_WARNING, _("%s: %s is not owned by uid %d."), caller, dir, user);
-        return FALSE;
-    }
-    
-    /* ... if group has write permission ... */
-    if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
-	syslog (LOG_WARNING, _("%s: %s is writable by group."), caller, dir);
-	return FALSE;
-    }
-
-    /* ... and if others have write permission. */
-    if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
-	syslog (LOG_WARNING, _("%s: %s is writable by other."), caller, dir);
-	return FALSE;
-    }
+    /* We should stat the file before the directory to trigger mounting the directory
+       if it is auto-mounted. */
 
     fullpath = g_build_filename (dir, file, NULL);
 
@@ -141,6 +112,38 @@
 
     g_free (fullpath);
 
+    /* Stat directory */
+    VE_IGNORE_EINTR (r = g_stat (dir, &statbuf));
+    if (r < 0) {
+	    if ( ! absentdirok)
+		 syslog (LOG_WARNING, _("%s: Directory %s does not exist."),
+			 caller, dir);
+	    return FALSE;
+    }
+
+    /* Check if dir is owned by the user ... 
+       Only, if GDM_KEY_CHECK_DIR_OWNER is true (default)
+       This is a "hack" for directories not owned by 
+       the user.
+       2004-06-22, Andreas Schubert, MATHEMA Software GmbH */
+
+    if G_UNLIKELY (gdm_get_value_bool (GDM_KEY_CHECK_DIR_OWNER) && (statbuf.st_uid != user)) {
+        syslog (LOG_WARNING, _("%s: %s is not owned by uid %d."), caller, dir, user);
+        return FALSE;
+    }
+    
+    /* ... if group has write permission ... */
+    if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) {
+	syslog (LOG_WARNING, _("%s: %s is writable by group."), caller, dir);
+	return FALSE;
+    }
+
+    /* ... and if others have write permission. */
+    if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) {
+	syslog (LOG_WARNING, _("%s: %s is writable by other."), caller, dir);
+	return FALSE;
+    }
+
     /* Yeap, this file is ok */
     return TRUE;
 }

Reply via email to