Merge lp:~khadgaray/lightdm/1.2-auologin-uid into lp:lightdm/1.2

Proposed by Ritesh Khadgaray
Status: Needs review
Proposed branch: lp:~khadgaray/lightdm/1.2-auologin-uid
Merge into: lp:lightdm/1.2
Diff against target: 248 lines (+125/-7)
10 files modified
data/lightdm.conf (+1/-1)
src/accounts.c (+18/-0)
src/accounts.h (+2/-0)
src/seat.c (+34/-6)
tests/Makefile.am (+6/-0)
tests/scripts/autologin-uid-invalid.conf (+31/-0)
tests/scripts/autologin-uid.conf (+27/-0)
tests/src/test-runner.c (+2/-0)
tests/test-autologin-uid (+2/-0)
tests/test-autologin-uid-invalid (+2/-0)
To merge this branch: bzr merge lp:~khadgaray/lightdm/1.2-auologin-uid
Reviewer Review Type Date Requested Status
LightDM Development Team Pending
Review via email: mp+198795@code.launchpad.net

Commit message

Add autologin support based off uid.

Description of the change

To post a comment you must log in.
1535. By Ritesh Khadgaray

fix typo

Revision history for this message
Robert Ancell (robert-ancell) wrote :

I am currently opposed to this feature, see bug for more details.

Unmerged revisions

1535. By Ritesh Khadgaray

fix typo

1534. By Ritesh Khadgaray

lightdm cannot autologin based on UID . backport of mterry's branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/lightdm.conf'
--- data/lightdm.conf 2013-06-17 22:43:08 +0000
+++ data/lightdm.conf 2013-12-12 17:39:31 +0000
@@ -51,7 +51,7 @@
51# session-setup-script = Script to run when starting a user session (runs as root)51# session-setup-script = Script to run when starting a user session (runs as root)
52# session-cleanup-script = Script to run when quitting a user session (runs as root)52# session-cleanup-script = Script to run when quitting a user session (runs as root)
53# autologin-guest = True to log in as guest by default53# autologin-guest = True to log in as guest by default
54# autologin-user = User to log in with by default (overrides autologin-guest)54# autologin-user = User to log in with by default (overrides autologin-guest); can also specify uid with uid:XXX
55# autologin-user-timeout = Number of seconds to wait before loading default user55# autologin-user-timeout = Number of seconds to wait before loading default user
56# autologin-session = Session to load for automatic login (overrides user-session)56# autologin-session = Session to load for automatic login (overrides user-session)
57# exit-on-failure = True if the daemon should exit if this seat fails57# exit-on-failure = True if the daemon should exit if this seat fails
5858
=== modified file 'src/accounts.c'
--- src/accounts.c 2013-06-17 23:10:20 +0000
+++ src/accounts.c 2013-12-12 17:39:31 +0000
@@ -291,6 +291,24 @@
291}291}
292292
293const gchar *293const gchar *
294accounts_get_name_by_uid (uid_t uid)
295{
296 const gchar *name = NULL;
297
298 errno = 0;
299 struct passwd *user_info;
300
301 user_info = getpwuid (uid);
302 if (user_info)
303 name = user_info->pw_name;
304
305 if (!name && errno != 0)
306 g_warning ("Unable to get information on user %d: %s", uid, strerror (errno));
307
308 return name;
309}
310
311const gchar *
294user_get_name (User *user)312user_get_name (User *user)
295{313{
296 g_return_val_if_fail (user != NULL, NULL);314 g_return_val_if_fail (user != NULL, NULL);
297315
=== modified file 'src/accounts.h'
--- src/accounts.h 2011-11-29 04:42:03 +0000
+++ src/accounts.h 2013-12-12 17:39:31 +0000
@@ -40,6 +40,8 @@
4040
41User *accounts_get_current_user (void);41User *accounts_get_current_user (void);
4242
43const gchar *accounts_get_name_by_uid (uid_t uid);
44
43GType user_get_type (void);45GType user_get_type (void);
4446
45const gchar *user_get_name (User *user);47const gchar *user_get_name (User *user);
4648
=== modified file 'src/seat.c'
--- src/seat.c 2013-06-17 22:35:03 +0000
+++ src/seat.c 2013-12-12 17:39:31 +0000
@@ -9,6 +9,7 @@
9 * license.9 * license.
10 */10 */
1111
12#include <pwd.h>
12#include <stdlib.h>13#include <stdlib.h>
13#include <string.h>14#include <string.h>
14#include <sys/wait.h>15#include <sys/wait.h>
@@ -583,22 +584,49 @@
583{584{
584}585}
585586
587static gchar *
588resolve_username (Seat *seat, const gchar *username)
589{
590 const gchar *const uidpfx = "uid:";
591 const gchar *resolved = NULL;
592
593 if (username == NULL || g_strcmp0 (username, "") == 0)
594 return NULL;
595
596 if (g_str_has_prefix (username, uidpfx))
597 {
598 const gchar *uidstr = username + strlen (uidpfx);
599 char *endptr = NULL;
600 int uid = strtol (uidstr, &endptr, 10);
601 if (endptr && endptr[0] == 0)
602 resolved = accounts_get_name_by_uid (uid);
603 else
604 g_debug (seat, "UID %s is not a number", uidstr);
605 }
606 else
607 resolved = username;
608
609 return g_strdup (resolved);
610}
611
586static gboolean612static gboolean
587seat_real_start (Seat *seat)613seat_real_start (Seat *seat)
588{614{
589 const gchar *autologin_username;615 gchar *autologin_username;
590 int autologin_timeout;616 int autologin_timeout;
591617
592 g_debug ("Starting seat");618 g_debug ("Starting seat");
593619
594 /* Start showing a greeter */620 /* Start showing a greeter */
595 autologin_username = seat_get_string_property (seat, "autologin-user");621 autologin_username = resolve_username (seat, seat_get_string_property (seat, "autologin-user"));
596 if (g_strcmp0 (autologin_username, "") == 0)
597 autologin_username = NULL;
598 autologin_timeout = seat_get_integer_property (seat, "autologin-user-timeout");622 autologin_timeout = seat_get_integer_property (seat, "autologin-user-timeout");
599623
600 if (autologin_username)624 if (autologin_username)
601 return switch_to_user_or_start_greeter (seat, autologin_username, TRUE, FALSE, NULL, FALSE, TRUE, autologin_timeout);625 {
626 int ret = switch_to_user_or_start_greeter (seat, autologin_username, TRUE, FALSE, NULL, FALSE, TRUE, autologin_timeout);
627 g_free (autologin_username);
628 return ret;
629 }
602 else if (seat_get_boolean_property (seat, "autologin-guest"))630 else if (seat_get_boolean_property (seat, "autologin-guest"))
603 return switch_to_user_or_start_greeter (seat, NULL, TRUE, TRUE, NULL, FALSE, TRUE, autologin_timeout);631 return switch_to_user_or_start_greeter (seat, NULL, TRUE, TRUE, NULL, FALSE, TRUE, autologin_timeout);
604 else632 else
605633
=== modified file 'tests/Makefile.am'
--- tests/Makefile.am 2013-11-26 03:18:34 +0000
+++ tests/Makefile.am 2013-12-12 17:39:31 +0000
@@ -24,6 +24,8 @@
24 test-autologin-new-authtok \24 test-autologin-new-authtok \
25 test-autologin-gobject-timeout \25 test-autologin-gobject-timeout \
26 test-autologin-gobject-guest-timeout \26 test-autologin-gobject-guest-timeout \
27 test-autologin-uid \
28 test-autologin-uid-invalid \
27 test-pam \29 test-pam \
28 test-login-pam \30 test-login-pam \
29 test-denied \31 test-denied \
@@ -172,6 +174,8 @@
172 test-login-qt-guest-logout174 test-login-qt-guest-logout
173endif175endif
174176
177TESTS =
178
175EXTRA_DIST = \179EXTRA_DIST = \
176 $(TESTS) \180 $(TESTS) \
177 data/system.conf \181 data/system.conf \
@@ -201,6 +205,8 @@
201 scripts/autologin-session-crash.conf \205 scripts/autologin-session-crash.conf \
202 scripts/autologin-session-error.conf \206 scripts/autologin-session-error.conf \
203 scripts/autologin-timeout.conf \207 scripts/autologin-timeout.conf \
208 scripts/test-autologin-uid.conf \
209 scripts/test-autologin-uid-invalid.conf \
204 scripts/autologin-xserver-crash.conf \210 scripts/autologin-xserver-crash.conf \
205 scripts/console-kit.conf \211 scripts/console-kit.conf \
206 scripts/corrupt-xauthority.conf \212 scripts/corrupt-xauthority.conf \
207213
=== added file 'tests/scripts/autologin-uid-invalid.conf'
--- tests/scripts/autologin-uid-invalid.conf 1970-01-01 00:00:00 +0000
+++ tests/scripts/autologin-uid-invalid.conf 2013-12-12 17:39:31 +0000
@@ -0,0 +1,31 @@
1#
2# Check fails to autologin invalid user by uid
3#
4
5[SeatDefaults]
6autologin-user=uid:9999
7
8#?RUNNER DAEMON-START
9
10# (fails to start session for invalid user)
11
12# X server starts
13#?XSERVER-0 START VT=7
14
15# Daemon connects when X server is ready
16#?*XSERVER-0 INDICATE-READY
17#?XSERVER-0 INDICATE-READY
18#?XSERVER-0 ACCEPT-CONNECT
19
20# Greeter starts
21#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
22#?XSERVER-0 ACCEPT-CONNECT
23#?GREETER-X-0 CONNECT-XSERVER
24#?GREETER-X-0 CONNECT-TO-DAEMON
25#?GREETER-X-0 CONNECTED-TO-DAEMON
26
27# Cleanup
28#?*STOP-DAEMON
29#?GREETER-X-0 TERMINATE SIGNAL=15
30#?XSERVER-0 TERMINATE SIGNAL=15
31#?RUNNER DAEMON-EXIT STATUS=0
032
=== added file 'tests/scripts/autologin-uid.conf'
--- tests/scripts/autologin-uid.conf 1970-01-01 00:00:00 +0000
+++ tests/scripts/autologin-uid.conf 2013-12-12 17:39:31 +0000
@@ -0,0 +1,27 @@
1#
2# Check automatically logs in default user by uid
3#
4
5[SeatDefaults]
6autologin-user=uid:1000
7
8#?RUNNER DAEMON-START
9
10# X server starts
11#?XSERVER-0 START VT=7
12
13# Daemon connects when X server is ready
14#?*XSERVER-0 INDICATE-READY
15#?XSERVER-0 INDICATE-READY
16#?XSERVER-0 ACCEPT-CONNECT
17
18# Session starts
19#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 DESKTOP_SESSION=default USER=have-password1
20#?XSERVER-0 ACCEPT-CONNECT
21#?SESSION-X-0 CONNECT-XSERVER
22
23# Cleanup
24#?*STOP-DAEMON
25#?SESSION-X-0 TERMINATE SIGNAL=15
26#?XSERVER-0 TERMINATE SIGNAL=15
27#?RUNNER DAEMON-EXIT STATUS=0
028
=== modified file 'tests/src/test-runner.c'
--- tests/src/test-runner.c 2013-11-26 03:18:34 +0000
+++ tests/src/test-runner.c 2013-12-12 17:39:31 +0000
@@ -2067,6 +2067,8 @@
2067 {"multi-prompt", "password", TRUE, "Multi Prompt", NULL, NULL, NULL, NULL, 1031},2067 {"multi-prompt", "password", TRUE, "Multi Prompt", NULL, NULL, NULL, NULL, 1031},
2068 /* This account has an existing corrupt X authority */2068 /* This account has an existing corrupt X authority */
2069 {"corrupt-xauth", "password", TRUE, "Corrupt Xauthority", NULL, NULL, NULL, NULL, 1032},2069 {"corrupt-xauth", "password", TRUE, "Corrupt Xauthority", NULL, NULL, NULL, NULL, 1032},
2070 /* 9999 is reserved as not present */
2071 /* {"", "", "", 9999}, */
2070 {NULL, NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0}2072 {NULL, NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0}
2071 };2073 };
2072 passwd_data = g_string_new ("");2074 passwd_data = g_string_new ("");
20732075
=== added file 'tests/test-autologin-uid'
--- tests/test-autologin-uid 1970-01-01 00:00:00 +0000
+++ tests/test-autologin-uid 2013-12-12 17:39:31 +0000
@@ -0,0 +1,2 @@
1#!/bin/sh
2./src/dbus-env ./src/test-runner autologin-uid test-gobject-greeter
03
=== added file 'tests/test-autologin-uid-invalid'
--- tests/test-autologin-uid-invalid 1970-01-01 00:00:00 +0000
+++ tests/test-autologin-uid-invalid 2013-12-12 17:39:31 +0000
@@ -0,0 +1,2 @@
1#!/bin/sh
2./src/dbus-env ./src/test-runner autologin-uid-invalid test-gobject-greeter

Subscribers

People subscribed via source and target branches