summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2015-09-16 14:19:03 -0400
committerRobert Ancell <robert.ancell@canonical.com>2015-09-16 14:19:03 -0400
commit8126134a5af5ad624a649399d484b2af0a872158 (patch)
treebf636376f1d5f32eb5b35510678aa263b6f74e70
parenta919a000a0f242970237ea653918970e6c1a1d74 (diff)
downloadlightdm-git-8126134a5af5ad624a649399d484b2af0a872158.tar.gz
Add regression test for libaudit support
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/scripts/audit-autologin.conf63
-rw-r--r--tests/src/libsystem.c50
-rwxr-xr-xtests/test-audit-autologin2
4 files changed, 117 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8769c23f..84bae837 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -162,6 +162,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 \
@@ -349,6 +350,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 b6f87d63..52758272 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>
@@ -24,6 +26,10 @@
#include <xcb/xcb.h>
#include <gio/gunixsocketaddress.h>
+#if HAVE_LIBAUDIT
+#include <libaudit.h>
+#endif
+
#include "status.h"
#define LOGIN_PROMPT "login:"
@@ -1747,3 +1753,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