Skip to content

Commit d7fef7e

Browse files
committed
Correctly reap unused authentication sessions
1 parent f6c926d commit d7fef7e

File tree

6 files changed

+92
-0
lines changed

6 files changed

+92
-0
lines changed

src/session.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ session_watch_cb (GPid pid, gint status, gpointer data)
234234
}
235235

236236
g_signal_emit (G_OBJECT (session), signals[STOPPED], 0);
237+
238+
/* Drop our reference on the child process, it has terminated */
239+
g_object_unref (session);
237240
}
238241

239242
static gboolean
@@ -362,6 +365,11 @@ session_start (Session *session, const gchar *service, const gchar *username, gb
362365
_exit (EXIT_FAILURE);
363366
}
364367

368+
/* Hold a reference on this object until the child process terminates so we
369+
* can handle the watch callback even if it is no longer used. Otherwise a
370+
* zombie process will remain */
371+
g_object_ref (session);
372+
365373
/* Listen for session termination */
366374
session->priv->authentication_started = TRUE;
367375
session->priv->child_watch = g_child_watch_add (session->priv->pid, session_watch_cb, session);

tests/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ TESTS = \
1515
test-autologin-session-crash \
1616
test-autologin-password \
1717
test-autologin-new-authtok \
18+
test-change-authentication \
19+
test-restart-authentication \
1820
test-pam \
1921
test-login-pam \
2022
test-denied \
@@ -169,6 +171,7 @@ EXTRA_DIST = \
169171
scripts/autologin-session-crash.conf \
170172
scripts/autologin-session-error.conf \
171173
scripts/autologin-xserver-crash.conf \
174+
scripts/change-authentication.conf \
172175
scripts/console-kit.conf \
173176
scripts/crash-authenticate.conf \
174177
scripts/cred-error.conf \
@@ -222,6 +225,7 @@ EXTRA_DIST = \
222225
scripts/plymouth-active-vt.conf \
223226
scripts/plymouth-inactive-vt.conf \
224227
scripts/plymouth-no-seat.conf \
228+
scripts/restart-authentication.conf \
225229
scripts/script-hooks.conf \
226230
scripts/script-hook-fail-display-setup.conf \
227231
scripts/script-hook-fail-greeter-setup.conf \
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Check can change authentication
3+
#
4+
5+
[LightDM]
6+
minimum-display-number=50
7+
8+
#?RUNNER DAEMON-START
9+
10+
# X server starts
11+
#?XSERVER :50 START
12+
#?XSERVER :50 INDICATE-READY
13+
14+
# LightDM connects to X server
15+
#?XSERVER :50 ACCEPT-CONNECT
16+
17+
# Greeter starts
18+
#?GREETER :50 START
19+
#?XSERVER :50 ACCEPT-CONNECT
20+
#?GREETER :50 CONNECT-XSERVER
21+
#?GREETER :50 CONNECT-TO-DAEMON
22+
#?GREETER :50 CONNECTED-TO-DAEMON
23+
24+
# Start authentication
25+
#?*GREETER :50 AUTHENTICATE USERNAME=have-password1
26+
#?GREETER :50 SHOW-PROMPT TEXT="Password:"
27+
28+
# Change user authentication
29+
#?*GREETER :50 AUTHENTICATE USERNAME=have-password2
30+
#?GREETER :50 SHOW-PROMPT TEXT="Password:"
31+
32+
# Cleanup
33+
#?*STOP-DAEMON
34+
# Don't know what order they will terminate
35+
#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
36+
#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
37+
#?RUNNER DAEMON-EXIT STATUS=0
38+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Check can restart authentication
3+
#
4+
5+
[LightDM]
6+
minimum-display-number=50
7+
8+
#?RUNNER DAEMON-START
9+
10+
# X server starts
11+
#?XSERVER :50 START
12+
#?XSERVER :50 INDICATE-READY
13+
14+
# LightDM connects to X server
15+
#?XSERVER :50 ACCEPT-CONNECT
16+
17+
# Greeter starts
18+
#?GREETER :50 START
19+
#?XSERVER :50 ACCEPT-CONNECT
20+
#?GREETER :50 CONNECT-XSERVER
21+
#?GREETER :50 CONNECT-TO-DAEMON
22+
#?GREETER :50 CONNECTED-TO-DAEMON
23+
24+
# Start authentication
25+
#?*GREETER :50 AUTHENTICATE USERNAME=have-password1
26+
#?GREETER :50 SHOW-PROMPT TEXT="Password:"
27+
28+
# Restart authentication
29+
#?*GREETER :50 AUTHENTICATE USERNAME=have-password1
30+
#?GREETER :50 SHOW-PROMPT TEXT="Password:"
31+
32+
# Cleanup
33+
#?*STOP-DAEMON
34+
# Don't know what order they will terminate
35+
#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
36+
#?(GREETER :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15)
37+
#?RUNNER DAEMON-EXIT STATUS=0
38+

tests/test-change-authentication

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner change-authentication test-gobject-greeter

tests/test-restart-authentication

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
./src/dbus-env ./src/test-runner restart-authentication test-gobject-greeter

0 commit comments

Comments
 (0)