summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2009-03-19 20:32:39 +0000
committerRay Strode <halfline@src.gnome.org>2009-03-19 20:32:39 +0000
commit65ab52f6714827e146ffdaeb7d8fbeceab328a05 (patch)
tree74cc5c44250fd3cd17a8289242cc24f8e71a8d6c
parent77575e02591692261c8f5b7097542143287e77de (diff)
downloadgdm-65ab52f6714827e146ffdaeb7d8fbeceab328a05.tar.gz
Remove empty auth subdirs which can creep in from system crashes.
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. svn path=/trunk/; revision=6790
-rw-r--r--ChangeLog8
-rw-r--r--daemon/gdm-display-access-file.c29
2 files changed, 37 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b1504ba8..f48e72a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
2009-03-16 Ray Strode <rstrode@redhat.com>
Give greeter and slave access to display
diff --git a/daemon/gdm-display-access-file.c b/daemon/gdm-display-access-file.c
index 05865e78..82b2b763 100644
--- a/daemon/gdm-display-access-file.c
+++ b/daemon/gdm-display-access-file.c
@@ -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 @@ _get_uid_and_gid_for_user (const char *username,
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 @@ _create_xauth_file_for_user (const char *username,
} 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)) {