diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-10-07 22:48:52 +0000 |
---|---|---|
committer | Tarmac <> | 2013-10-07 22:48:52 +0000 |
commit | b08b7abcdf0716aa1b2da9d50e09545b3feb33a6 (patch) | |
tree | 0205d7f3b79b3f7f8c3e97a6d53946b5727f08ad | |
parent | c9fd5894171ba5ae000035108a8c622eb8ecc7a2 (diff) | |
parent | c883b98eeb0d4f7d64a810d793bf642063f09795 (diff) | |
download | lightdm-git-b08b7abcdf0716aa1b2da9d50e09545b3feb33a6.tar.gz |
Add regression test for corrupt X authority files.
Approved by PS Jenkins bot, Robert Ancell.
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/scripts/corrupt-xauthority.conf | 36 | ||||
-rw-r--r-- | tests/src/test-runner.c | 13 | ||||
-rwxr-xr-x | tests/test-corrupt-xauthority | 2 |
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 7c5a4cdf..03c0a54f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -56,6 +56,7 @@ TESTS = \ test-session-stderr-multi-write \ test-session-stderr-backup \ test-xauthority \ + test-corrupt-xauthority \ test-system-xauthority \ test-user-renamed \ test-user-renamed-invalid \ @@ -311,6 +312,7 @@ EXTRA_DIST = \ scripts/change-authentication.conf \ scripts/cancel-authentication.conf \ scripts/console-kit.conf \ + scripts/corrupt-xauthority.conf \ scripts/crash-authenticate.conf \ scripts/cred-error.conf \ scripts/cred-expired.conf \ diff --git a/tests/scripts/corrupt-xauthority.conf b/tests/scripts/corrupt-xauthority.conf new file mode 100644 index 00000000..318b872a --- /dev/null +++ b/tests/scripts/corrupt-xauthority.conf @@ -0,0 +1,36 @@ +# +# Check can login if existing corrupt authority present +# + +[SeatDefaults] +autologin-user=corrupt-xauth +user-session=default + +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER-0 START VT=7 + +# Daemon connects when X server is ready +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# Session starts +#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 DESKTOP_SESSION=default USER=corrupt-xauth +#?XSERVER-0 ACCEPT-CONNECT +#?SESSION-X-0 CONNECT-XSERVER + +# Check where the X authority is +#?*SESSION-X-0 READ-ENV NAME=XAUTHORITY +#?SESSION-X-0 READ-ENV NAME=XAUTHORITY VALUE=.*/home/corrupt-xauth/.Xauthority + +# Check has correct permissions +#?*SESSION-X-0 CHECK-X-AUTHORITY +#?SESSION-X-0 CHECK-X-AUTHORITY MODE=rw------- + +# Cleanup +#?*STOP-DAEMON +#?SESSION-X-0 TERMINATE SIGNAL=15 +#?XSERVER-0 TERMINATE SIGNAL=15 +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index e893bb86..14b1c186 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -2069,6 +2069,8 @@ main (int argc, char **argv) {"log-pam", "password", TRUE, "Log PAM", NULL, NULL, NULL, NULL, 1030}, /* This account shows multiple prompts on login */ {"multi-prompt", "password", TRUE, "Multi Prompt", NULL, NULL, NULL, NULL, 1031}, + /* This account has an existing corrupt X authority */ + {"corrupt-xauth", "password", TRUE, "Corrupt Xauthority", NULL, NULL, NULL, NULL, 1032}, {NULL, NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0} }; passwd_data = g_string_new (""); @@ -2123,6 +2125,17 @@ main (int argc, char **argv) g_key_file_free (dmrc_file); + /* Write corrupt X authority file */ + if (strcmp (users[i].user_name, "corrupt-xauth") == 0) + { + gchar data[1] = { 0xFF }; + + path = g_build_filename (home_dir, users[i].user_name, ".Xauthority", NULL); + g_file_set_contents (path, data, 1, NULL); + chmod (path, S_IRUSR | S_IWUSR); + g_free (path); + } + /* Add passwd file entry */ g_string_append_printf (passwd_data, "%s:%s:%d:%d:%s:%s/home/%s:/bin/sh\n", users[i].user_name, users[i].password, users[i].uid, users[i].uid, users[i].real_name, temp_dir, users[i].user_name); diff --git a/tests/test-corrupt-xauthority b/tests/test-corrupt-xauthority new file mode 100755 index 00000000..217e7d4e --- /dev/null +++ b/tests/test-corrupt-xauthority @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner corrupt-xauthority test-gobject-greeter |