~darkxst/ubuntu/saucy/gdm/lp1212408

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu_daemon_autologin_tracking.patch

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2012-10-07 07:40:28 UTC
  • Revision ID: package-import@ubuntu.com-20121007074028-f2c3v19u9oqxqf9r
Tags: 3.6.0-0ubuntu4
* debian/patches
  - add 3 upstream patches to fix logout when autologin enabled.
    (LP: #1061993)
    - ubuntu_ensure_dirs.patch
    - ubuntu_slave-only-set-up-autologin.patch
    - ubuntu_daemon_autologin_tracking.patch
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 34c15fe8f3d000a7579b720a99bc945be3aad10e Mon Sep 17 00:00:00 2001
 
2
From: Ray Strode <rstrode@redhat.com>
 
3
Date: Thu, 4 Oct 2012 18:13:56 -0400
 
4
Subject: [PATCH] daemon: user marker file for tracking autologin instead of
 
5
 static variable.
 
6
 
 
7
We currently decide whether or not to skip autologin by a first_login
 
8
state variable in the static display object.
 
9
 
 
10
These days we can have multiple static display objects, so storing the
 
11
state variable doesn't make much sense.  We could make the variable
 
12
static, but instead this commit switches to using a marker file in
 
13
/var/run/gdm.
 
14
 
 
15
https://bugzilla.gnome.org/show_bug.cgi?id=682467
 
16
 
 
17
--- gdm-3.6.0.orig/configure.ac
 
18
+++ gdm-3.6.0/configure.ac
 
19
@@ -1338,6 +1338,26 @@ AC_SUBST(GDM_PID_FILE)
 
20
 AC_DEFINE_UNQUOTED(GDM_PID_FILE, "$GDM_PID_FILE", [pid file])
 
21
 
 
22
 dnl ---------------------------------------------------------------------------
 
23
+dnl - ran once marker
 
24
+dnl ---------------------------------------------------------------------------
 
25
+
 
26
+AC_ARG_WITH(ran-once-marker-directory,
 
27
+            AS_HELP_STRING([--with-ran-once-marker-directory=<dir>],
 
28
+                           [ran once marker directory]))
 
29
+
 
30
+if ! test -z "$with_ran_once_marker_directory"; then
 
31
+   GDM_RAN_ONCE_MARKER_DIR=$with_ran_once_marker_directory
 
32
+else
 
33
+   GDM_RAN_ONCE_MARKER_DIR=${localstatedir}/run/gdm
 
34
+fi
 
35
+AC_SUBST(GDM_RAN_ONCE_MARKER_DIR)
 
36
+AC_DEFINE_UNQUOTED(GDM_RAN_ONCE_MARKER_DIR, "$GDM_RAN_ONCE_MARKER_DIR", [ran once marker dir])
 
37
+
 
38
+GDM_RAN_ONCE_MARKER_FILE="$GDM_RAN_ONCE_MARKER_DIR/ran-once-marker"
 
39
+AC_SUBST(GDM_RAN_ONCE_MARKER_FILE)
 
40
+AC_DEFINE_UNQUOTED(GDM_RAN_ONCE_MARKER_FILE, "$GDM_RAN_ONCE_MARKER_FILE", [ran once marker file])
 
41
+
 
42
+dnl ---------------------------------------------------------------------------
 
43
 dnl - GREETER WORKING DIRECTORY
 
44
 dnl ---------------------------------------------------------------------------
 
45
 
 
46
--- gdm-3.6.0.orig/daemon/gdm-simple-slave.c
 
47
+++ gdm-3.6.0/daemon/gdm-simple-slave.c
 
48
@@ -503,6 +503,10 @@ start_autologin_conversation_if_necessar
 
49
 {
 
50
         gboolean enabled;
 
51
 
 
52
+        if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
 
53
+                return;
 
54
+        }
 
55
+
 
56
         gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, NULL);
 
57
 
 
58
         if (!enabled) {
 
59
@@ -716,6 +720,23 @@ on_session_cancelled (GdmSession      *s
 
60
 }
 
61
 
 
62
 static void
 
63
+touch_marker_file (GdmSimpleSlave *slave)
 
64
+{
 
65
+        int fd;
 
66
+
 
67
+        fd = g_creat (GDM_RAN_ONCE_MARKER_FILE, 0644);
 
68
+
 
69
+        if (fd < 0 && errno != EEXIST) {
 
70
+                g_warning ("could not create %s to mark run, this may cause auto login "
 
71
+                           "to repeat: %m", GDM_RAN_ONCE_MARKER_FILE);
 
72
+                return;
 
73
+        }
 
74
+
 
75
+        fsync (fd);
 
76
+        close (fd);
 
77
+}
 
78
+
 
79
+static void
 
80
 create_new_session (GdmSimpleSlave  *slave)
 
81
 {
 
82
         gboolean       display_is_local;
 
83
@@ -816,6 +837,8 @@ create_new_session (GdmSimpleSlave  *sla
 
84
                           slave);
 
85
 
 
86
         start_autologin_conversation_if_necessary (slave);
 
87
+
 
88
+        touch_marker_file (slave);
 
89
 }
 
90
 
 
91
 static void
 
92
@@ -1222,6 +1245,10 @@ wants_autologin (GdmSimpleSlave *slave)
 
93
         int delay = 0;
 
94
         /* FIXME: handle wait-for-go */
 
95
 
 
96
+        if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
 
97
+                return FALSE;
 
98
+        }
 
99
+
 
100
         gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, &delay);
 
101
         return enabled && delay == 0;
 
102
 }
 
103
--- gdm-3.6.0.orig/daemon/main.c
 
104
+++ gdm-3.6.0/daemon/main.c
 
105
@@ -145,6 +145,12 @@ write_pid (void)
 
106
         atexit (delete_pid);
 
107
 }
 
108
 
 
109
+static void
 
110
+delete_first_run_marker (void)
 
111
+{
 
112
+        g_unlink (GDM_RAN_ONCE_MARKER_FILE);
 
113
+}
 
114
+
 
115
 static gboolean
 
116
 ensure_dir_with_perms (const char *path,
 
117
                        uid_t       uid,
 
118
@@ -178,6 +184,12 @@ gdm_daemon_ensure_dirs (uid_t uid,
 
119
 {
 
120
         GError *error = NULL;
 
121
 
 
122
+        /* Set up /var/run/gdm */
 
123
+        if (!ensure_dir_with_perms (GDM_RAN_ONCE_MARKER_DIR, 0, gid, (S_IRWXU | S_IRWXG), &error)) {
 
124
+                gdm_fail (_("Failed to create ran once marker dir %s: %s"),
 
125
+                          GDM_RAN_ONCE_MARKER_DIR, error->message);
 
126
+        }
 
127
+
 
128
         /* Set up /var/gdm */
 
129
         if (!ensure_dir_with_perms (AUTHDIR, uid, gid, (S_IRWXU | S_IRWXG | S_ISVTX), &error)) {
 
130
                 gdm_fail (_("Failed to create AuthDir %s: %s"),
 
131
@@ -421,6 +433,9 @@ main (int    argc,
 
132
         delete_pid ();
 
133
         write_pid ();
 
134
 
 
135
+        /* clean up any stale ran once marker file that may be lingering */
 
136
+        delete_first_run_marker ();
 
137
+
 
138
         g_chdir (AUTHDIR);
 
139
 
 
140
         main_loop = g_main_loop_new (NULL, FALSE);
 
141
--- gdm-3.6.0.orig/daemon/gdm-static-display.c
 
142
+++ gdm-3.6.0/daemon/gdm-static-display.c
 
143
@@ -46,7 +46,6 @@
 
144
 struct GdmStaticDisplayPrivate
 
145
 {
 
146
         GdmDBusStaticDisplay *skeleton;
 
147
-        gboolean first_login;
 
148
 };
 
149
 
 
150
 static void     gdm_static_display_class_init   (GdmStaticDisplayClass *klass);
 
151
@@ -117,30 +116,11 @@ gdm_static_display_unmanage (GdmDisplay
 
152
 {
 
153
         g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
 
154
 
 
155
-        GDM_STATIC_DISPLAY (display)->priv->first_login = FALSE;
 
156
-
 
157
         GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
 
158
 
 
159
         return TRUE;
 
160
 }
 
161
 
 
162
-static void
 
163
-gdm_static_display_get_timed_login_details (GdmDisplay *display,
 
164
-                                            gboolean   *enabledp,
 
165
-                                            char      **usernamep,
 
166
-                                            int        *delayp)
 
167
-{
 
168
-        GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->get_timed_login_details (display, enabledp, usernamep, delayp);
 
169
-
 
170
-        if (!GDM_STATIC_DISPLAY (display)->priv->first_login) {
 
171
-                /* if this is autologin but not timed login, then disable
 
172
-                 * autologin after the first one */
 
173
-                if (*enabledp && *delayp == 0) {
 
174
-                        *enabledp = FALSE;
 
175
-                }
 
176
-        }
 
177
-}
 
178
-
 
179
 static GObject *
 
180
 gdm_static_display_constructor (GType                  type,
 
181
                                    guint                  n_construct_properties,
 
182
@@ -185,7 +165,6 @@ gdm_static_display_class_init (GdmStatic
 
183
         display_class->manage = gdm_static_display_manage;
 
184
         display_class->finish = gdm_static_display_finish;
 
185
         display_class->unmanage = gdm_static_display_unmanage;
 
186
-        display_class->get_timed_login_details = gdm_static_display_get_timed_login_details;
 
187
 
 
188
         g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
 
189
 }
 
190
@@ -195,8 +174,6 @@ gdm_static_display_init (GdmStaticDispla
 
191
 {
 
192
 
 
193
         static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
 
194
-
 
195
-        static_display->priv->first_login = TRUE;
 
196
 }
 
197
 
 
198
 GdmDisplay *