Merge lp:~robert-ancell/lightdm/utmp-line into lp:lightdm

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 1920
Merged at revision: 1919
Proposed branch: lp:~robert-ancell/lightdm/utmp-line
Merge into: lp:lightdm
Diff against target: 203 lines (+123/-8)
5 files modified
src/session-child.c (+12/-6)
tests/Makefile.am (+2/-0)
tests/scripts/utmp.conf (+59/-0)
tests/src/libsystem.c (+48/-2)
tests/test-utmp (+2/-0)
To merge this branch: bzr merge lp:~robert-ancell/lightdm/utmp-line
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
LightDM Development Team Pending
Review via email: mp+210123@code.launchpad.net

Commit message

Set utmp ut_line to the display name (i.e. :0). This matches what programs expect (e.g. 'w'). Add tests to check we are setting it correctly.

To post a comment you must log in.
lp:~robert-ancell/lightdm/utmp-line updated
1920. By Robert Ancell

Remove unnecessary WAIT from utmp test

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/session-child.c'
2--- src/session-child.c 2014-02-25 22:12:22 +0000
3+++ src/session-child.c 2014-03-10 04:28:57 +0000
4@@ -601,10 +601,13 @@
5 memset (&ut, 0, sizeof (ut));
6 ut.ut_type = USER_PROCESS;
7 ut.ut_pid = child_pid;
8- if (tty)
9+ if (xdisplay)
10+ {
11+ strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line));
12+ strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
13+ }
14+ else if (tty)
15 strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
16- if (xdisplay)
17- strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
18 strncpy (ut.ut_user, username, sizeof (ut.ut_user));
19 if (xdisplay)
20 strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host));
21@@ -632,10 +635,13 @@
22 memset (&ut, 0, sizeof (ut));
23 ut.ut_type = DEAD_PROCESS;
24 ut.ut_pid = child_pid;
25- if (tty)
26+ if (xdisplay)
27+ {
28+ strncpy (ut.ut_line, xdisplay, sizeof (ut.ut_line));
29+ strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
30+ }
31+ else if (tty)
32 strncpy (ut.ut_line, tty + strlen ("/dev/"), sizeof (ut.ut_line));
33- if (xdisplay)
34- strncpy (ut.ut_id, xdisplay, sizeof (ut.ut_id));
35 strncpy (ut.ut_user, username, sizeof (ut.ut_user));
36 if (xdisplay)
37 strncpy (ut.ut_host, xdisplay, sizeof (ut.ut_host));
38
39=== modified file 'tests/Makefile.am'
40--- tests/Makefile.am 2014-03-07 03:37:10 +0000
41+++ tests/Makefile.am 2014-03-10 04:28:57 +0000
42@@ -144,6 +144,7 @@
43 test-vnc-open-file-descriptors \
44 test-xdmcp-client \
45 test-xdmcp-server-login \
46+ test-utmp \
47 test-no-accounts-service \
48 test-console-kit \
49 test-no-console-kit \
50@@ -475,6 +476,7 @@
51 scripts/user-renamed.conf \
52 scripts/user-renamed-invalid.conf \
53 scripts/user-session.conf \
54+ scripts/utmp.conf \
55 scripts/vnc-command.conf \
56 scripts/vnc-dimensions.conf \
57 scripts/vnc-login.conf \
58
59=== added file 'tests/scripts/utmp.conf'
60--- tests/scripts/utmp.conf 1970-01-01 00:00:00 +0000
61+++ tests/scripts/utmp.conf 2014-03-10 04:28:57 +0000
62@@ -0,0 +1,59 @@
63+#
64+# Check UTMP records written on login
65+#
66+
67+[test-utmp-config]
68+check-events=true
69+
70+[SeatDefaults]
71+autologin-user=have-password1
72+user-session=default
73+
74+#?*START-DAEMON
75+#?RUNNER DAEMON-START
76+
77+# X server starts
78+#?XSERVER-0 START VT=7 SEAT=seat0
79+
80+# Daemon connects when X server is ready
81+#?*XSERVER-0 INDICATE-READY
82+#?XSERVER-0 INDICATE-READY
83+#?XSERVER-0 ACCEPT-CONNECT
84+
85+# UTMP record written
86+#?UTMP TYPE=USER_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0
87+
88+# Autologin session starts
89+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 DESKTOP_SESSION=default USER=have-password1
90+#?XSERVER-0 ACCEPT-CONNECT
91+#?SESSION-X-0 CONNECT-XSERVER
92+
93+# Logout session
94+#?*SESSION-X-0 LOGOUT
95+
96+# UTMP record written
97+#?UTMP TYPE=DEAD_PROCESS LINE=:0 ID=:0 USER=have-password1 HOST=:0
98+
99+# X server stops
100+#?XSERVER-0 TERMINATE SIGNAL=15
101+
102+# X server starts
103+#?XSERVER-0 START VT=7 SEAT=seat0
104+
105+# Daemon connects when X server is ready
106+#?*XSERVER-0 INDICATE-READY
107+#?XSERVER-0 INDICATE-READY
108+#?XSERVER-0 ACCEPT-CONNECT
109+
110+# Greeter starts
111+#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
112+#?XSERVER-0 ACCEPT-CONNECT
113+#?GREETER-X-0 CONNECT-XSERVER
114+#?GREETER-X-0 CONNECT-TO-DAEMON
115+#?GREETER-X-0 CONNECTED-TO-DAEMON
116+
117+# Cleanup
118+#?*STOP-DAEMON
119+#?GREETER-X-0 TERMINATE SIGNAL=15
120+#?XSERVER-0 TERMINATE SIGNAL=15
121+#?RUNNER DAEMON-EXIT STATUS=0
122
123=== modified file 'tests/src/libsystem.c'
124--- tests/src/libsystem.c 2014-02-26 03:49:42 +0000
125+++ tests/src/libsystem.c 2014-03-10 04:28:57 +0000
126@@ -37,6 +37,19 @@
127 static int active_vt = 7;
128
129 static gboolean status_connected = FALSE;
130+static GKeyFile *config;
131+
132+static void connect_status (void)
133+{
134+ if (status_connected)
135+ return;
136+ status_connected = TRUE;
137+
138+ status_connect (NULL, NULL);
139+
140+ config = g_key_file_new ();
141+ g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL);
142+}
143
144 struct pam_handle
145 {
146@@ -501,8 +514,7 @@
147 if (vt != active_vt)
148 {
149 active_vt = vt;
150- if (!status_connected)
151- status_connected = status_connect (NULL, NULL);
152+ connect_status ();
153 status_notify ("VT ACTIVATE VT=%d", active_vt);
154 }
155 break;
156@@ -1434,6 +1446,40 @@
157 struct utmpx *
158 pututxline (const struct utmpx *ut)
159 {
160+ GString *status;
161+
162+ status = g_string_new ("UTMP");
163+ switch (ut->ut_type)
164+ {
165+ case INIT_PROCESS:
166+ g_string_append_printf (status, " TYPE=INIT_PROCESS");
167+ break;
168+ case LOGIN_PROCESS:
169+ g_string_append_printf (status, " TYPE=LOGIN_PROCESS");
170+ break;
171+ case USER_PROCESS:
172+ g_string_append_printf (status, " TYPE=USER_PROCESS");
173+ break;
174+ case DEAD_PROCESS:
175+ g_string_append_printf (status, " TYPE=DEAD_PROCESS");
176+ break;
177+ default:
178+ g_string_append_printf (status, " TYPE=%d", ut->ut_type);
179+ }
180+ if (ut->ut_line)
181+ g_string_append_printf (status, " LINE=%s", ut->ut_line);
182+ if (ut->ut_id)
183+ g_string_append_printf (status, " ID=%s", ut->ut_id);
184+ if (ut->ut_user)
185+ g_string_append_printf (status, " USER=%s", ut->ut_user);
186+ if (ut->ut_host)
187+ g_string_append_printf (status, " HOST=%s", ut->ut_host);
188+
189+ connect_status ();
190+ if (g_key_file_get_boolean (config, "test-utmp-config", "check-events", NULL))
191+ status_notify ("%s", status->str);
192+ g_string_free (status, TRUE);
193+
194 return (struct utmpx *)ut;
195 }
196
197
198=== added file 'tests/test-utmp'
199--- tests/test-utmp 1970-01-01 00:00:00 +0000
200+++ tests/test-utmp 2014-03-10 04:28:57 +0000
201@@ -0,0 +1,2 @@
202+#!/bin/sh
203+./src/dbus-env ./src/test-runner utmp test-gobject-greeter

Subscribers

People subscribed via source and target branches