diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2012-08-02 14:17:41 +0200 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2012-08-02 14:17:41 +0200 |
commit | d7fef7e48e4b39637a59551953198c00ab4137f6 (patch) | |
tree | 920cc9c706dbcbf64a5b0a7a00ed8489cb955135 | |
parent | f6c926dd1ea0fe9f98430870768f7d24f342e0d6 (diff) | |
download | lightdm-d7fef7e48e4b39637a59551953198c00ab4137f6.tar.gz |
Correctly reap unused authentication sessions
-rw-r--r-- | src/session.c | 8 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/scripts/change-authentication.conf | 38 | ||||
-rw-r--r-- | tests/scripts/restart-authentication.conf | 38 | ||||
-rwxr-xr-x | tests/test-change-authentication | 2 | ||||
-rwxr-xr-x | tests/test-restart-authentication | 2 |
6 files changed, 92 insertions, 0 deletions
diff --git a/src/session.c b/src/session.c index 473ef92a..3bf34d6f 100644 --- a/src/session.c +++ b/src/session.c @@ -234,6 +234,9 @@ session_watch_cb (GPid pid, gint status, gpointer data) } g_signal_emit (G_OBJECT (session), signals[STOPPED], 0); + + /* Drop our reference on the child process, it has terminated */ + g_object_unref (session); } static gboolean @@ -362,6 +365,11 @@ session_start (Session *session, const gchar *service, const gchar *username, gb _exit (EXIT_FAILURE); } + /* Hold a reference on this object until the child process terminates so we + * can handle the watch callback even if it is no longer used. Otherwise a + * zombie process will remain */ + g_object_ref (session); + /* Listen for session termination */ session->priv->authentication_started = TRUE; session->priv->child_watch = g_child_watch_add (session->priv->pid, session_watch_cb, session); diff --git a/tests/Makefile.am b/tests/Makefile.am index d036b0b1..93b47f33 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,6 +15,8 @@ TESTS = \ test-autologin-session-crash \ test-autologin-password \ test-autologin-new-authtok \ + test-change-authentication \ + test-restart-authentication \ test-pam \ test-login-pam \ test-denied \ @@ -169,6 +171,7 @@ EXTRA_DIST = \ scripts/autologin-session-crash.conf \ scripts/autologin-session-error.conf \ scripts/autologin-xserver-crash.conf \ + scripts/change-authentication.conf \ scripts/console-kit.conf \ scripts/crash-authenticate.conf \ scripts/cred-error.conf \ @@ -222,6 +225,7 @@ EXTRA_DIST = \ scripts/plymouth-active-vt.conf \ scripts/plymouth-inactive-vt.conf \ scripts/plymouth-no-seat.conf \ + scripts/restart-authentication.conf \ scripts/script-hooks.conf \ scripts/script-hook-fail-display-setup.conf \ scripts/script-hook-fail-greeter-setup.conf \ diff --git a/tests/scripts/change-authentication.conf b/tests/scripts/change-authentication.conf new file mode 100644 index 00000000..d3860a19 --- /dev/null +++ b/tests/scripts/change-authentication.conf @@ -0,0 +1,38 @@ +# +# Check can change authentication +# + +[LightDM] +minimum-display-number=50 + +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER :50 START +#?XSERVER :50 INDICATE-READY + +# LightDM connects to X server +#?XSERVER :50 ACCEPT-CONNECT + +# Greeter starts +#?GREETER :50 START +#?XSERVER :50 ACCEPT-CONNECT +#?GREETER :50 CONNECT-XSERVER +#?GREETER :50 CONNECT-TO-DAEMON +#?GREETER :50 CONNECTED-TO-DAEMON + +# Start authentication +#?*GREETER :50 AUTHENTICATE USERNAME=have-password1 +#?GREETER :50 SHOW-PROMPT TEXT="Password:" + +# Change user authentication +#?*GREETER :50 AUTHENTICATE USERNAME=have-password2 +#?GREETER :50 SHOW-PROMPT TEXT="Password:" + +# Cleanup +#?*STOP-DAEMON +# Don't know what order they will terminate +#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15) +#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15) +#?RUNNER DAEMON-EXIT STATUS=0 + diff --git a/tests/scripts/restart-authentication.conf b/tests/scripts/restart-authentication.conf new file mode 100644 index 00000000..f45edc89 --- /dev/null +++ b/tests/scripts/restart-authentication.conf @@ -0,0 +1,38 @@ +# +# Check can restart authentication +# + +[LightDM] +minimum-display-number=50 + +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER :50 START +#?XSERVER :50 INDICATE-READY + +# LightDM connects to X server +#?XSERVER :50 ACCEPT-CONNECT + +# Greeter starts +#?GREETER :50 START +#?XSERVER :50 ACCEPT-CONNECT +#?GREETER :50 CONNECT-XSERVER +#?GREETER :50 CONNECT-TO-DAEMON +#?GREETER :50 CONNECTED-TO-DAEMON + +# Start authentication +#?*GREETER :50 AUTHENTICATE USERNAME=have-password1 +#?GREETER :50 SHOW-PROMPT TEXT="Password:" + +# Restart authentication +#?*GREETER :50 AUTHENTICATE USERNAME=have-password1 +#?GREETER :50 SHOW-PROMPT TEXT="Password:" + +# Cleanup +#?*STOP-DAEMON +# Don't know what order they will terminate +#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15) +#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15) +#?RUNNER DAEMON-EXIT STATUS=0 + diff --git a/tests/test-change-authentication b/tests/test-change-authentication new file mode 100755 index 00000000..3d5ec60b --- /dev/null +++ b/tests/test-change-authentication @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner change-authentication test-gobject-greeter diff --git a/tests/test-restart-authentication b/tests/test-restart-authentication new file mode 100755 index 00000000..b9cb62e4 --- /dev/null +++ b/tests/test-restart-authentication @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner restart-authentication test-gobject-greeter |