summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2012-10-04 18:13:56 -0400
committerRay Strode <rstrode@redhat.com>2012-10-15 15:04:51 -0400
commit11d4b97bfda92a254d2ef55b4795456367a3cfbb (patch)
tree985119024103d0efb8a21293a245cd8a0c74bfde
parent47c73024739a65614c6a0ddcdd1c08239798044a (diff)
downloadgdm-11d4b97bfda92a254d2ef55b4795456367a3cfbb.tar.gz
daemon: user marker file for tracking autologin instead of static variable.
We currently decide whether or not to skip autologin by a first_login state variable in the static display object. These days we can have multiple static display objects, so storing the state variable doesn't make much sense. We could make the variable static, but instead this commit switches to using a marker file in /var/run/gdm. https://bugzilla.gnome.org/show_bug.cgi?id=682467
-rw-r--r--configure.ac20
-rw-r--r--daemon/gdm-simple-slave.c27
-rw-r--r--daemon/gdm-static-display.c23
-rw-r--r--daemon/main.c15
4 files changed, 62 insertions, 23 deletions
diff --git a/configure.ac b/configure.ac
index d3635cf4..caa2bc25 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1333,6 +1333,26 @@ AC_SUBST(GDM_PID_FILE)
AC_DEFINE_UNQUOTED(GDM_PID_FILE, "$GDM_PID_FILE", [pid file])
dnl ---------------------------------------------------------------------------
+dnl - ran once marker
+dnl ---------------------------------------------------------------------------
+
+AC_ARG_WITH(ran-once-marker-directory,
+ AS_HELP_STRING([--with-ran-once-marker-directory=<dir>],
+ [ran once marker directory]))
+
+if ! test -z "$with_ran_once_marker_directory"; then
+ GDM_RAN_ONCE_MARKER_DIR=$with_ran_once_marker_directory
+else
+ GDM_RAN_ONCE_MARKER_DIR=${localstatedir}/run/gdm
+fi
+AC_SUBST(GDM_RAN_ONCE_MARKER_DIR)
+AC_DEFINE_UNQUOTED(GDM_RAN_ONCE_MARKER_DIR, "$GDM_RAN_ONCE_MARKER_DIR", [ran once marker dir])
+
+GDM_RAN_ONCE_MARKER_FILE="$GDM_RAN_ONCE_MARKER_DIR/ran-once-marker"
+AC_SUBST(GDM_RAN_ONCE_MARKER_FILE)
+AC_DEFINE_UNQUOTED(GDM_RAN_ONCE_MARKER_FILE, "$GDM_RAN_ONCE_MARKER_FILE", [ran once marker file])
+
+dnl ---------------------------------------------------------------------------
dnl - GREETER WORKING DIRECTORY
dnl ---------------------------------------------------------------------------
diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c
index 4bbf503c..8838a2a6 100644
--- a/daemon/gdm-simple-slave.c
+++ b/daemon/gdm-simple-slave.c
@@ -521,6 +521,10 @@ start_autologin_conversation_if_necessary (GdmSimpleSlave *slave)
{
gboolean enabled;
+ if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
+ return;
+ }
+
gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, NULL);
if (!enabled) {
@@ -734,6 +738,23 @@ on_session_cancelled (GdmSession *session,
}
static void
+touch_marker_file (GdmSimpleSlave *slave)
+{
+ int fd;
+
+ fd = g_creat (GDM_RAN_ONCE_MARKER_FILE, 0644);
+
+ if (fd < 0 && errno != EEXIST) {
+ g_warning ("could not create %s to mark run, this may cause auto login "
+ "to repeat: %m", GDM_RAN_ONCE_MARKER_FILE);
+ return;
+ }
+
+ fsync (fd);
+ close (fd);
+}
+
+static void
create_new_session (GdmSimpleSlave *slave)
{
gboolean display_is_local;
@@ -834,6 +855,8 @@ create_new_session (GdmSimpleSlave *slave)
slave);
start_autologin_conversation_if_necessary (slave);
+
+ touch_marker_file (slave);
}
static void
@@ -1249,6 +1272,10 @@ wants_autologin (GdmSimpleSlave *slave)
int delay = 0;
/* FIXME: handle wait-for-go */
+ if (g_file_test (GDM_RAN_ONCE_MARKER_FILE, G_FILE_TEST_EXISTS)) {
+ return FALSE;
+ }
+
gdm_slave_get_timed_login_details (GDM_SLAVE (slave), &enabled, NULL, &delay);
return enabled && delay == 0;
}
diff --git a/daemon/gdm-static-display.c b/daemon/gdm-static-display.c
index 1806be94..8e7254da 100644
--- a/daemon/gdm-static-display.c
+++ b/daemon/gdm-static-display.c
@@ -46,7 +46,6 @@
struct GdmStaticDisplayPrivate
{
GdmDBusStaticDisplay *skeleton;
- gboolean first_login;
};
static void gdm_static_display_class_init (GdmStaticDisplayClass *klass);
@@ -117,30 +116,11 @@ gdm_static_display_unmanage (GdmDisplay *display)
{
g_return_val_if_fail (GDM_IS_DISPLAY (display), FALSE);
- GDM_STATIC_DISPLAY (display)->priv->first_login = FALSE;
-
GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->unmanage (display);
return TRUE;
}
-static void
-gdm_static_display_get_timed_login_details (GdmDisplay *display,
- gboolean *enabledp,
- char **usernamep,
- int *delayp)
-{
- GDM_DISPLAY_CLASS (gdm_static_display_parent_class)->get_timed_login_details (display, enabledp, usernamep, delayp);
-
- if (!GDM_STATIC_DISPLAY (display)->priv->first_login) {
- /* if this is autologin but not timed login, then disable
- * autologin after the first one */
- if (*enabledp && *delayp == 0) {
- *enabledp = FALSE;
- }
- }
-}
-
static GObject *
gdm_static_display_constructor (GType type,
guint n_construct_properties,
@@ -185,7 +165,6 @@ gdm_static_display_class_init (GdmStaticDisplayClass *klass)
display_class->manage = gdm_static_display_manage;
display_class->finish = gdm_static_display_finish;
display_class->unmanage = gdm_static_display_unmanage;
- display_class->get_timed_login_details = gdm_static_display_get_timed_login_details;
g_type_class_add_private (klass, sizeof (GdmStaticDisplayPrivate));
}
@@ -195,8 +174,6 @@ gdm_static_display_init (GdmStaticDisplay *static_display)
{
static_display->priv = GDM_STATIC_DISPLAY_GET_PRIVATE (static_display);
-
- static_display->priv->first_login = TRUE;
}
GdmDisplay *
diff --git a/daemon/main.c b/daemon/main.c
index c9b39899..b1c644f3 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -145,6 +145,12 @@ write_pid (void)
atexit (delete_pid);
}
+static void
+delete_first_run_marker (void)
+{
+ g_unlink (GDM_RAN_ONCE_MARKER_FILE);
+}
+
static gboolean
ensure_dir_with_perms (const char *path,
uid_t uid,
@@ -178,6 +184,12 @@ gdm_daemon_ensure_dirs (uid_t uid,
{
GError *error = NULL;
+ /* Set up /var/run/gdm */
+ if (!ensure_dir_with_perms (GDM_RAN_ONCE_MARKER_DIR, 0, gid, (S_IRWXU | S_IRWXG), &error)) {
+ gdm_fail (_("Failed to create ran once marker dir %s: %s"),
+ GDM_RAN_ONCE_MARKER_DIR, error->message);
+ }
+
/* Set up /var/gdm */
if (!ensure_dir_with_perms (AUTHDIR, uid, gid, (S_IRWXU | S_IRWXG | S_ISVTX), &error)) {
gdm_fail (_("Failed to create AuthDir %s: %s"),
@@ -421,6 +433,9 @@ main (int argc,
delete_pid ();
write_pid ();
+ /* clean up any stale ran once marker file that may be lingering */
+ delete_first_run_marker ();
+
g_chdir (AUTHDIR);
main_loop = g_main_loop_new (NULL, FALSE);