From 3c70d77047a981d0e009cf44dcfd6a37ba9a6131 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Tue, 28 Feb 2012 17:12:54 +1100 Subject: Check autologin fails if prompted for a password --- tests/Makefile.am | 6 ++++-- tests/scripts/autologin-password.conf | 34 ++++++++++++++++++++++++++++++++++ tests/src/libsystem.c | 2 +- tests/src/test-runner.c | 32 +++++++++++++++++--------------- tests/test-autologin-password | 2 ++ 5 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 tests/scripts/autologin-password.conf create mode 100755 tests/test-autologin-password (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 665f8ae7..4ee4a882 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,6 +12,7 @@ TESTS = \ test-autologin-invalid-session \ test-autologin-xserver-crash \ test-autologin-session-crash \ + test-autologin-password \ test-autologin-denied \ test-autologin-expired \ test-autologin-logout \ @@ -122,15 +123,16 @@ EXTRA_DIST = \ data/xsessions/alternative.desktop \ data/xsessions/default.desktop \ scripts/autologin.conf \ + scripts/autologin-denied.conf \ + scripts/autologin-expired.conf \ scripts/autologin-guest.conf \ scripts/autologin-guest-fail-setup-script.conf \ scripts/autologin-guest-logout.conf \ scripts/autologin-invalid-session.conf \ scripts/autologin-invalid-user.conf \ scripts/autologin-logout.conf \ - scripts/autologin-denied.conf \ - scripts/autologin-expired.conf \ scripts/autologin-new-authtok.conf \ + scripts/autologin-password.conf \ scripts/autologin-previous-session.conf \ scripts/autologin-session-crash.conf \ scripts/autologin-xserver-crash.conf \ diff --git a/tests/scripts/autologin-password.conf b/tests/scripts/autologin-password.conf new file mode 100644 index 00000000..cef39441 --- /dev/null +++ b/tests/scripts/autologin-password.conf @@ -0,0 +1,34 @@ +# +# Check automatic login stops if an account prompts for a password +# + +[LightDM] +minimum-display-number=50 + +[SeatDefaults] +autologin-user=always-password + +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER :50 START +#?XSERVER :50 INDICATE-READY + +# LightDM connects to X server +#?XSERVER :50 ACCEPT-CONNECT + +# (Session fails) + +# Greeter starts +#?GREETER :50 START +#?XSERVER :50 ACCEPT-CONNECT +#?GREETER :50 CONNECT-XSERVER +#?GREETER :50 CONNECT-TO-DAEMON +#?GREETER :50 CONNECTED-TO-DAEMON + +# 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/src/libsystem.c b/tests/src/libsystem.c index 2629f317..a02ad000 100644 --- a/tests/src/libsystem.c +++ b/tests/src/libsystem.c @@ -307,7 +307,7 @@ pam_authenticate (pam_handle_t *pamh, int flags) entry = getpwnam (pamh->user); /* Prompt for password if required */ - if (entry && (strcmp (pamh->service_name, "lightdm-autologin") == 0 || strcmp (entry->pw_passwd, "") == 0)) + if (entry && strcmp (pamh->user, "always-password") != 0 && (strcmp (pamh->service_name, "lightdm-autologin") == 0 || strcmp (entry->pw_passwd, "") == 0)) password_matches = TRUE; else { diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 945a79ff..e13581d2 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -1312,32 +1312,34 @@ main (int argc, char **argv) {"have-password2", "password", TRUE, "Password User 2", NULL, NULL, NULL, NULL, 1001}, {"have-password3", "password", TRUE, "Password User 3", NULL, NULL, NULL, NULL, 1002}, {"have-password4", "password", TRUE, "Password User 4", NULL, NULL, NULL, NULL, 1003}, + /* This account always prompts for a password, even if using the lightdm-autologin service */ + {"always-password", "password", TRUE, "Password User 4", NULL, NULL, NULL, NULL, 1004}, /* These accounts have no password */ - {"no-password1", "", TRUE, "No Password User 1", NULL, NULL, NULL, NULL, 1004}, - {"no-password2", "", TRUE, "No Password User 2", NULL, NULL, NULL, NULL, 1005}, - {"no-password3", "", TRUE, "No Password User 3", NULL, NULL, NULL, NULL, 1006}, - {"no-password4", "", TRUE, "No Password User 4", NULL, NULL, NULL, NULL, 1007}, + {"no-password1", "", TRUE, "No Password User 1", NULL, NULL, NULL, NULL, 1005}, + {"no-password2", "", TRUE, "No Password User 2", NULL, NULL, NULL, NULL, 1006}, + {"no-password3", "", TRUE, "No Password User 3", NULL, NULL, NULL, NULL, 1007}, + {"no-password4", "", TRUE, "No Password User 4", NULL, NULL, NULL, NULL, 1008}, /* This account has a keyboard layout */ - {"have-layout", "", TRUE, "Layout User", NULL, "us", NULL, NULL, 1008}, + {"have-layout", "", TRUE, "Layout User", NULL, "us", NULL, NULL, 1009}, /* This account has a set of keyboard layouts */ - {"have-layouts", "", TRUE, "Layouts User", NULL, "ru", "fr\toss;ru;", NULL, 1009}, + {"have-layouts", "", TRUE, "Layouts User", NULL, "ru", "fr\toss;ru;", NULL, 1010}, /* This account has a language set */ - {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1010}, + {"have-language", "", TRUE, "Language User", NULL, NULL, NULL, "en_AU.utf8", 1011}, /* This account has a preconfigured session */ - {"have-session", "", TRUE, "Session User", "alternative", NULL, NULL, NULL, 1011}, + {"have-session", "", TRUE, "Session User", "alternative", NULL, NULL, NULL, 1012}, /* This account has the home directory mounted on login */ - {"mount-home-dir", "", FALSE, "Mounted Home Dir User", NULL, NULL, NULL, NULL, 1012}, + {"mount-home-dir", "", FALSE, "Mounted Home Dir User", NULL, NULL, NULL, NULL, 1013}, /* This account is denied access */ - {"denied", "", TRUE, "Denied User", NULL, NULL, NULL, NULL, 1013}, + {"denied", "", TRUE, "Denied User", NULL, NULL, NULL, NULL, 1014}, /* This account has expired */ - {"expired", "", TRUE, "Expired User", NULL, NULL, NULL, NULL, 1014}, + {"expired", "", TRUE, "Expired User", NULL, NULL, NULL, NULL, 1015}, /* This account needs a password change */ - {"new-authtok", "", TRUE, "New Token User", NULL, NULL, NULL, NULL, 1015}, + {"new-authtok", "", TRUE, "New Token User", NULL, NULL, NULL, NULL, 1016}, /* change-user1 is switched to change-user2 when authentication succeeds */ - {"change-user1", "", TRUE, "Change User 1", NULL, NULL, NULL, NULL, 1016}, - {"change-user2", "", TRUE, "Change User 2", NULL, NULL, NULL, NULL, 1017}, + {"change-user1", "", TRUE, "Change User 1", NULL, NULL, NULL, NULL, 1017}, + {"change-user2", "", TRUE, "Change User 2", NULL, NULL, NULL, NULL, 1018}, /* change-user-invalid switches to invalid-user when authentication succeeds */ - {"change-user-invalid", "", TRUE, "Invalid Change User",NULL, NULL, NULL, NULL, 1018}, + {"change-user-invalid", "", TRUE, "Invalid Change User",NULL, NULL, NULL, NULL, 1019}, {NULL, NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0} }; passwd_data = g_string_new (""); diff --git a/tests/test-autologin-password b/tests/test-autologin-password new file mode 100755 index 00000000..1ec3260f --- /dev/null +++ b/tests/test-autologin-password @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner autologin-password test-gobject-greeter -- cgit v1.2.1