gdm r6790 - in trunk: . daemon



Author: halfline
Date: Thu Mar 19 20:32:39 2009
New Revision: 6790
URL: http://svn.gnome.org/viewvc/gdm?rev=6790&view=rev

Log:
2009-03-19  Ray Strode  <rstrode redhat com>

	* daemon/gdm-display-access-file.c
	(_create_xauth_file_for_user),
	(_clean_up_stale_auth_subdirs):
	Remove empty auth subdirs which can
	creep in from system crashes.


Modified:
   trunk/ChangeLog
   trunk/daemon/gdm-display-access-file.c

Modified: trunk/daemon/gdm-display-access-file.c
==============================================================================
--- trunk/daemon/gdm-display-access-file.c	(original)
+++ trunk/daemon/gdm-display-access-file.c	Thu Mar 19 20:32:39 2009
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <errno.h>
+#include <limits.h>
 #include <pwd.h>
 #include <string.h>
 #include <sys/types.h>
@@ -220,6 +221,31 @@
         return TRUE;
 }
 
+static void
+clean_up_stale_auth_subdirs (void)
+{
+        GDir *dir;
+        const char *filename;
+
+        dir = g_dir_open (GDM_XAUTH_DIR, 0, NULL);
+
+        if (dir == NULL) {
+                return;
+        }
+
+        while ((filename = g_dir_read_name (dir)) != NULL) {
+                char *path;
+
+                path = g_build_filename (GDM_XAUTH_DIR, filename, NULL);
+
+                /* Will only succeed if the directory is empty
+                 */
+                g_rmdir (path);
+                g_free (path);
+        }
+        g_dir_close (dir);
+}
+
 static FILE *
 _create_xauth_file_for_user (const char  *username,
                              char       **filename,
@@ -262,6 +288,9 @@
         } else {
                 /* if it does exist make sure it has correct mode 01775 */
                 g_chmod (GDM_XAUTH_DIR, S_ISVTX | S_IRWXU |S_IRWXG | S_IROTH | S_IXOTH);
+
+                /* and clean up any stale auth subdirs */
+                clean_up_stale_auth_subdirs ();
         }
 
         if (!_get_uid_and_gid_for_user (username, &uid, &gid)) {



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