20788N/A--- gdm-2.30.2/data/Makefile.am-orig 2010-05-14 13:30:20.924722341 -0500
20788N/A+++ gdm-2.30.2/data/Makefile.am 2010-05-14 13:33:45.306375555 -0500
20788N/A@@ -135,8 +135,10 @@ uninstall-hook:
20788N/A -rf \
20788N/A $(DESTDIR)$(workingdir)/.gconf.mandatory \
20788N/A $(DESTDIR)$(workingdir)/.config/dconf \
20788N/A- $(DESTDIR)$(screenshotdir) \
20788N/A- $(DESTDIR)$(xauthdir)
20788N/A+ $(DESTDIR)$(screenshotdir)
20788N/A+ if test "x$(xauthdir)" -ne "x/tmp"; then \
20788N/A+ rm -rf $(DESTDIR)$(xauthdir) \
20788N/A+ fi
20788N/A
20788N/A -rmdir \
20788N/A $(DESTDIR)$(sysconfdir)/dconf/db \
20788N/A@@ -217,9 +219,11 @@ install-data-hook: gdm.conf-custom Xsess
20788N/A fi
20788N/A
20788N/A if test '!' -d $(DESTDIR)$(xauthdir); then \
20788N/A- $(mkinstalldirs) $(DESTDIR)$(xauthdir); \
20788N/A- chmod 0711 $(DESTDIR)$(xauthdir); \
20788N/A- chown root:gdm $(DESTDIR)$(xauthdir) || : ; \
20788N/A+ if test "x$(xauthdir)" -ne "x/tmp"; then \
20788N/A+ $(mkinstalldirs) $(DESTDIR)$(xauthdir); \
20788N/A+ chmod 0711 $(DESTDIR)$(xauthdir); \
20788N/A+ chown root:gdm $(DESTDIR)$(xauthdir) || : ; \
20788N/A+ fi \
20788N/A fi
20788N/A
20788N/A if test '!' -d $(DESTDIR)$(screenshotdir); then \
20788N/A--- gdm-2.30.2/daemon/gdm-display-access-file.h-orig 2010-05-14 17:19:02.519085968 -0500
20788N/A+++ gdm-2.30.2/daemon/gdm-display-access-file.h 2010-05-14 17:19:34.297760711 -0500
20788N/A@@ -83,6 +83,7 @@ gboolean gdm_display_access
20788N/A
20788N/A void gdm_display_access_file_close (GdmDisplayAccessFile *file);
20788N/A char *gdm_display_access_file_get_path (GdmDisplayAccessFile *file);
20788N/A+void gdm_display_access_file_cleanup_xauth (void);
20788N/A
20788N/A G_END_DECLS
20788N/A #endif /* __GDM_DISPLAY_ACCESS_FILE_H__ */
20788N/A--- gdm-2.30.5/daemon/gdm-display-access-file.c.1 2010-09-09 08:45:53.471667052 +0800
20788N/A+++ gdm-2.30.5/daemon/gdm-display-access-file.c 2010-09-09 08:48:59.866248040 +0800
20788N/A@@ -41,6 +41,8 @@
20788N/A #include "gdm-display-access-file.h"
20788N/A #include "gdm-common.h"
20788N/A
20788N/A+static const char *xauth_dir_name = NULL;
20788N/A+
20788N/A struct _GdmDisplayAccessFilePrivate
20788N/A {
20788N/A char *username;
20788N/A@@ -221,13 +223,24 @@ _get_uid_and_gid_for_user (const char *u
20788N/A return TRUE;
20788N/A }
20788N/A
20788N/A+void
20788N/A+gdm_display_access_file_cleanup_xauth (void)
20788N/A+{
20788N/A+ /* Clean up any xauth_dir_name when shutting down */
20788N/A+ if (strcmp (GDM_XAUTH_DIR, "/tmp") == 0 && xauth_dir_name != NULL) {
20788N/A+ g_remove (xauth_dir_name);
20788N/A+ g_debug ("GdmDisplayAccessFile: Unlinking xauth directory %s", xauth_dir_name);
20788N/A+ xauth_dir_name = NULL;
20788N/A+ }
20788N/A+}
20788N/A+
20788N/A static void
20788N/A-clean_up_stale_auth_subdirs (void)
20788N/A+clean_up_stale_auth_subdirs (const char * xauth_dir_name)
20788N/A {
20788N/A GDir *dir;
20788N/A const char *filename;
20788N/A
20788N/A- dir = g_dir_open (GDM_XAUTH_DIR, 0, NULL);
20788N/A+ dir = g_dir_open (xauth_dir_name, 0, NULL);
20788N/A
20788N/A if (dir == NULL) {
20788N/A return;
20788N/A@@ -236,7 +249,7 @@ clean_up_stale_auth_subdirs (void)
20788N/A while ((filename = g_dir_read_name (dir)) != NULL) {
20788N/A char *path;
20788N/A
20788N/A- path = g_build_filename (GDM_XAUTH_DIR, filename, NULL);
20788N/A+ path = g_build_filename (xauth_dir_name, filename, NULL);
20788N/A
20788N/A /* Will only succeed if the directory is empty
20788N/A */
20788N/A@@ -251,11 +264,14 @@ _create_xauth_file_for_user (const char
20788N/A char **filename,
20788N/A GError **error)
20788N/A {
20788N/A+ struct stat statbuf;
20788N/A+ gboolean dir_exists;
20788N/A char *template;
20788N/A const char *dir_name;
20788N/A char *auth_filename;
20788N/A int fd;
20788N/A FILE *fp;
20788N/A+ int xauth_dir_fp;
20788N/A uid_t uid;
20788N/A gid_t gid;
20788N/A
20788N/A@@ -268,10 +284,36 @@ _create_xauth_file_for_user (const char
20788N/A fp = NULL;
20788N/A fd = -1;
20788N/A
20788N/A+ dir_exists = TRUE;
20788N/A+
20788N/A+ if (xauth_dir_name == NULL) {
20788N/A+ if (strcmp (GDM_XAUTH_DIR, "/tmp") == 0) {
20788N/A+ dir_exists = FALSE;
20788N/A+ template = g_strdup_printf ("/tmp/gdm-auth-cookies-XXXXXX");
20788N/A+ xauth_dir_name = gdm_make_temp_dir (template);
20788N/A+
20788N/A+ g_debug ("GdmDisplayAccessFile: Creating xauth directory %s", xauth_dir_name);
20788N/A+ g_chmod (xauth_dir_name, 0711);
20788N/A+ _get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid);
20788N/A+ if (chown (xauth_dir_name, 0, gid) != 0) {
20788N/A+ g_warning ("Unable to change owner of '%s'",
20788N/A+ xauth_dir_name);
20788N/A+ }
20788N/A+ } else {
20788N/A+ xauth_dir_name = GDM_XAUTH_DIR;
20788N/A+ }
20788N/A+ }
20788N/A+
20788N/A+ /*
20788N/A+ * Note: if GDM_XAUTH_DIR is "/tmp", we never fall into the next if-case, since
20788N/A+ * gdm_make_temp_dir calls mkdtemp() which creates the directory.
20788N/A+ */
20788N/A+
20788N/A /* Create directory if not exist, then set permission 0711 and ownership root:gdm */
20788N/A- if (g_file_test (GDM_XAUTH_DIR, G_FILE_TEST_IS_DIR) == FALSE) {
20788N/A- g_remove (GDM_XAUTH_DIR);
20788N/A- if (g_mkdir (GDM_XAUTH_DIR, 0711) != 0) {
20788N/A+ if (g_file_test (xauth_dir_name, G_FILE_TEST_IS_DIR) == FALSE) {
20788N/A+ dir_exists = FALSE;
20788N/A+ g_remove (xauth_dir_name);
20788N/A+ if (g_mkdir (xauth_dir_name, 0711) != 0) {
20788N/A g_set_error (error,
20788N/A G_FILE_ERROR,
20788N/A g_file_error_from_errno (errno),
20788N/A@@ -279,18 +321,70 @@ _create_xauth_file_for_user (const char
20788N/A goto out;
20788N/A }
20788N/A
20788N/A- g_chmod (GDM_XAUTH_DIR, 0711);
20788N/A+ g_chmod (xauth_dir_name, 0711);
20788N/A _get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid);
20788N/A- if (chown (GDM_XAUTH_DIR, 0, gid) != 0) {
20788N/A+ if (chown (xauth_dir_name, 0, gid) != 0) {
20788N/A g_warning ("Unable to change owner of '%s'",
20788N/A- GDM_XAUTH_DIR);
20788N/A+ xauth_dir_name);
20788N/A+ }
20788N/A+ }
20788N/A+
20788N/A+ /* Do sanity testing on the Xauth directory */
20788N/A+ if ((xauth_dir_fp = open (xauth_dir_name, O_RDONLY | O_NOFOLLOW)) == -1) {
20788N/A+ /* If it is a symlink, open fails with O_NOFOLLOW. */
20788N/A+ g_set_error (error,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
20788N/A+ _("GDM authorization directory %s cannot be opened."),
20788N/A+ xauth_dir_name);
20788N/A+ goto out;
20788N/A+ }
20788N/A+
20788N/A+ if (fstat (xauth_dir_fp, &statbuf) == 0) {
20788N/A+ if (! S_ISDIR (statbuf.st_mode)) {
20788N/A+ g_set_error (error,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
20788N/A+ _("GDM authorization directory %s is not a directory."),
20788N/A+ xauth_dir_name);
20788N/A+ goto out;
20788N/A+ }
20788N/A+
20788N/A+ if (statbuf.st_uid != 0) {
20788N/A+ g_set_error (error,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
20788N/A+ _("GDM authorization directory %s: uid is not root"),
20788N/A+ xauth_dir_name);
20788N/A+ goto out;
20788N/A+ }
20788N/A+
20788N/A+ _get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid);
20788N/A+ if (statbuf.st_gid != gid) {
20788N/A+ g_set_error (error,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
20788N/A+ _("GDM authorization directory %s: gid is not the GDM user"),
20788N/A+ xauth_dir_name);
20788N/A+ goto out;
20788N/A }
20788N/A } else {
20788N/A- /* if it does exist make sure it has correct mode 0711 */
20788N/A- g_chmod (GDM_XAUTH_DIR, 0711);
20788N/A+ g_set_error (error,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR,
20788N/A+ GDM_DISPLAY_ACCESS_FILE_ERROR_FINDING_AUTH_ENTRY,
20788N/A+ _("Cannot fstat() the GDM authorization directory"),
20788N/A+ xauth_dir_name);
20788N/A+ goto out;
20788N/A+ }
20788N/A+
20788N/A+ if (dir_exists == TRUE) {
20788N/A+ /* If we did not create the directory, do some cleanup */
20788N/A+
20788N/A+ /* Make sure it has correct mode 0711 */
20788N/A+ g_chmod (xauth_dir_name, 0711);
20788N/A
20788N/A /* and clean up any stale auth subdirs */
20788N/A- clean_up_stale_auth_subdirs ();
20788N/A+ clean_up_stale_auth_subdirs (xauth_dir_name);
20788N/A }
20788N/A
20788N/A if (!_get_uid_and_gid_for_user (username, &uid, &gid)) {
20788N/A@@ -303,9 +397,8 @@ _create_xauth_file_for_user (const char
20788N/A
20788N/A }
20788N/A
20788N/A- template = g_strdup_printf (GDM_XAUTH_DIR
20788N/A- "/auth-for-%s-XXXXXX",
20788N/A- username);
20788N/A+ template = g_strdup_printf ("%s/auth-for-%s-XXXXXX",
20788N/A+ xauth_dir_name, username);
20788N/A
20788N/A g_debug ("GdmDisplayAccessFile: creating xauth directory %s", template);
20788N/A /* Initially create with mode 01700 then later chmod after we create database */
20788N/A@@ -394,6 +487,8 @@ out:
20788N/A if (fd != -1) {
20788N/A close (fd);
20788N/A }
20788N/A+ if (xauth_dir_fp > 0)
20788N/A+ close (xauth_dir_fp);
20788N/A
20788N/A return fp;
20788N/A }
20788N/A--- gdm-2.30.2/daemon/main.c-orig 2010-05-14 17:20:13.467572360 -0500
20788N/A+++ gdm-2.30.2/daemon/main.c 2010-05-14 17:21:22.588427699 -0500
20788N/A@@ -51,6 +51,7 @@
20788N/A #include "gdm-settings.h"
20788N/A #include "gdm-settings-direct.h"
20788N/A #include "gdm-settings-keys.h"
20788N/A+#include "gdm-display-access-file.h"
20788N/A
20788N/A #define GDM_DBUS_NAME "org.gnome.DisplayManager"
20788N/A
20788N/A@@ -686,6 +687,8 @@ main (int argc,
20788N/A gdm_settings_direct_shutdown ();
20788N/A gdm_log_shutdown ();
20788N/A
20788N/A+ gdm_display_access_file_cleanup_xauth ();
20788N/A+
20788N/A g_main_loop_unref (main_loop);
20788N/A
20788N/A ret = 0;