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
7
We currently decide whether or not to skip autologin by a first_login
8
state variable in the static display object.
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
15
https://bugzilla.gnome.org/show_bug.cgi?id=682467
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])
22
dnl ---------------------------------------------------------------------------
23
+dnl - ran once marker
24
+dnl ---------------------------------------------------------------------------
26
+AC_ARG_WITH(ran-once-marker-directory,
27
+ AS_HELP_STRING([--with-ran-once-marker-directory=<dir>],
28
+ [ran once marker directory]))
30
+if ! test -z "$with_ran_once_marker_directory"; then
31
+ GDM_RAN_ONCE_MARKER_DIR=$with_ran_once_marker_directory
33
+ GDM_RAN_ONCE_MARKER_DIR=${localstatedir}/run/gdm
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])
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])
42
+dnl ---------------------------------------------------------------------------
43
dnl - GREETER WORKING DIRECTORY
44
dnl ---------------------------------------------------------------------------
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
52
+ if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
56
gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, NULL);
59
@@ -716,6 +720,23 @@ on_session_cancelled (GdmSession *s
63
+touch_marker_file (GdmSimpleSlave *slave)
67
+ fd = g_creat (GDM_RAN_ONCE_MARKER_FILE, 0644);
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);
80
create_new_session (GdmSimpleSlave *slave)
82
gboolean display_is_local;
83
@@ -816,6 +837,8 @@ create_new_session (GdmSimpleSlave *sla
86
start_autologin_conversation_if_necessary (slave);
88
+ touch_marker_file (slave);
92
@@ -1222,6 +1245,10 @@ wants_autologin (GdmSimpleSlave *slave)
94
/* FIXME: handle wait-for-go */
96
+ if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
100
gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, &delay);
101
return enabled && delay == 0;
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)
110
+delete_first_run_marker (void)
112
+ g_unlink (GDM_RAN_ONCE_MARKER_FILE);
116
ensure_dir_with_perms (const char *path,
118
@@ -178,6 +184,12 @@ gdm_daemon_ensure_dirs (uid_t uid,
120
GError *error = NULL;
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);
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,
135
+ /* clean up any stale ran once marker file that may be lingering */
136
+ delete_first_run_marker ();
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
144
struct GdmStaticDisplayPrivate
146
GdmDBusStaticDisplay *skeleton;
147
- gboolean first_login;
150
static void gdm_static_display_class_init (GdmStaticDisplayClass *klass);
151
@@ -117,30 +116,11 @@ gdm_static_display_unmanage (GdmDisplay
153
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
155
- GDM_STATIC_DISPLAY (display)->priv->first_login = FALSE;
157
GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
163
-gdm_static_display_get_timed_login_details (GdmDisplay *display,
164
- gboolean *enabledp,
168
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->get_timed_login_details (display, enabledp, usernamep, delayp);
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) {
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;
188
g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
190
@@ -195,8 +174,6 @@ gdm_static_display_init (GdmStaticDispla
193
static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
195
- static_display->priv->first_login = TRUE;