diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2015-09-16 14:15:07 -0400 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2015-09-16 14:15:07 -0400 |
commit | b6b38b948fbda74f6d1ad7d5595800f9cc8a2fc6 (patch) | |
tree | 7b4b9470981c60c37d6467e5db1ea96585758100 /tests | |
parent | 32af51843a8f45d39f4c120777ac2446b93adacd (diff) | |
download | lightdm-b6b38b948fbda74f6d1ad7d5595800f9cc8a2fc6.tar.gz |
Add regression test for libaudit support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/scripts/audit-autologin.conf | 63 | ||||
-rw-r--r-- | tests/src/libsystem.c | 50 | ||||
-rwxr-xr-x | tests/test-audit-autologin | 2 |
4 files changed, 117 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index df6229cf..29189373 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -174,6 +174,7 @@ TESTS = \ test-utmp-login \ test-utmp-autologin \ test-utmp-wrong-password \ + test-audit-autologin \ test-no-accounts-service \ test-console-kit \ test-no-console-kit \ @@ -366,6 +367,7 @@ EXTRA_DIST = \ scripts/additional-config-priority.conf \ scripts/additional-system-config.conf \ scripts/additional-system-config-priority.conf \ + scripts/audit-autologin.conf \ scripts/autologin.conf \ scripts/autologin-guest.conf \ scripts/autologin-guest-fail-setup-script.conf \ diff --git a/tests/scripts/audit-autologin.conf b/tests/scripts/audit-autologin.conf new file mode 100644 index 00000000..bf3994e4 --- /dev/null +++ b/tests/scripts/audit-autologin.conf @@ -0,0 +1,63 @@ +# +# Check libaudit record written on autologin +# + +[test-audit-config] +check-events=true + +[Seat:*] +autologin-user=have-password1 +user-session=default + +#?*START-DAEMON +#?RUNNER DAEMON-START + +# X server starts +#?XSERVER-0 START VT=7 SEAT=seat0 + +# Daemon connects when X server is ready +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# libaudit record written +#?AUDIT OPEN +#?AUDIT LOG-ACCT TYPE=USER_LOGIN PGNAME= OP=login NAME=have-password1 ID=1000 HOST= ADDR= TTY=/dev/tty7 RESULT=1 + +# Autologin session starts +#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 +#?LOGIN1 ACTIVATE-SESSION SESSION=c0 +#?XSERVER-0 ACCEPT-CONNECT +#?SESSION-X-0 CONNECT-XSERVER + +# Logout session +#?*SESSION-X-0 LOGOUT + +# libaudit record written +#?AUDIT OPEN +#?AUDIT LOG-ACCT TYPE=USER_LOGOUT PGNAME= OP=logout NAME=have-password1 ID=1000 HOST= ADDR= TTY=/dev/tty7 RESULT=1 + +# X server stops +#?XSERVER-0 TERMINATE SIGNAL=15 + +# X server starts +#?XSERVER-0 START VT=7 SEAT=seat0 + +# Daemon connects when X server is ready +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# Greeter starts +#?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter +#?LOGIN1 ACTIVATE-SESSION SESSION=c1 +#?XSERVER-0 ACCEPT-CONNECT +#?GREETER-X-0 CONNECT-XSERVER +#?GREETER-X-0 CONNECT-TO-DAEMON +#?GREETER-X-0 CONNECTED-TO-DAEMON + +# Cleanup +#?*STOP-DAEMON +#?GREETER-X-0 TERMINATE SIGNAL=15 +#?XSERVER-0 TERMINATE SIGNAL=15 +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/libsystem.c b/tests/src/libsystem.c index 1d6fffd3..a947f7c7 100644 --- a/tests/src/libsystem.c +++ b/tests/src/libsystem.c @@ -1,6 +1,8 @@ #define _GNU_SOURCE #define __USE_GNU +#include <config.h> + #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -26,6 +28,10 @@ #include <xcb/xcb.h> #include <gio/gunixsocketaddress.h> +#if HAVE_LIBAUDIT +#include <libaudit.h> +#endif + #include "status.h" #define LOGIN_PROMPT "login:" @@ -1937,3 +1943,47 @@ xcb_disconnect (xcb_connection_t *c) free (c); } +#if HAVE_LIBAUDIT +int +audit_open (void) +{ + connect_status (); + if (g_key_file_get_boolean (config, "test-audit-config", "check-events", NULL)) + status_notify ("AUDIT OPEN"); + + return 1; +} + +int +audit_log_acct_message (int audit_fd, int type, const char *pgname, + const char *op, const char *name, unsigned int id, + const char *host, const char *addr, const char *tty, int result) +{ + gchar *type_string; + + connect_status (); + if (!g_key_file_get_boolean (config, "test-audit-config", "check-events", NULL)) + return 1; + + switch (type) + { + case AUDIT_USER_LOGIN: + type_string = g_strdup ("USER_LOGIN"); + break; + case AUDIT_USER_LOGOUT: + type_string = g_strdup ("USER_LOGOUT"); + break; + default: + type_string = g_strdup_printf ("%d", type); + break; + } + + status_notify ("AUDIT LOG-ACCT TYPE=%s PGNAME=%s OP=%s NAME=%s ID=%u HOST=%s ADDR=%s TTY=%s RESULT=%d", + type_string, pgname ? pgname : "", op ? op : "", name ? name : "", id, host ? host : "", addr ? addr : "", tty ? tty : "", result); + + g_free (type_string); + + return 1; +} + +#endif diff --git a/tests/test-audit-autologin b/tests/test-audit-autologin new file mode 100755 index 00000000..1762b250 --- /dev/null +++ b/tests/test-audit-autologin @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner audit-autologin test-gobject-greeter |