diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-10-08 11:11:54 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2013-10-08 11:11:54 +1300 |
commit | 2743d27d2001b7a433553ae903e6fafb30b5d2f9 (patch) | |
tree | 9dd2d4ed76520fe1d2b8d56ff85d901b312c4072 | |
parent | 2dcf6f49378f62f2428314b56d027f56d744c7fb (diff) | |
download | lightdm-git-2743d27d2001b7a433553ae903e6fafb30b5d2f9.tar.gz |
Add regression test for corrupt X authority files
-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 4232afca..cdb49f90 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,6 +46,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 \ @@ -210,6 +211,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..610d9270 --- /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_SESSION_COOKIE=ck-cookie-x:0 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 4c3fb71d..c2664df4 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -2039,6 +2039,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 (""); @@ -2092,6 +2094,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 |