summaryrefslogtreecommitdiffstats
path: root/tests/ts/login
diff options
context:
space:
mode:
authorKarel Zak2011-10-05 12:10:26 +0200
committerKarel Zak2011-10-26 23:17:17 +0200
commitc82d9c977c7fdf28ede2db15601edde1a5819511 (patch)
treef8173e4967e03186f3ae1bdbfe85a273006c46f6 /tests/ts/login
parenttests: cleanup islocal test (diff)
downloadkernel-qcow2-util-linux-c82d9c977c7fdf28ede2db15601edde1a5819511.tar.gz
kernel-qcow2-util-linux-c82d9c977c7fdf28ede2db15601edde1a5819511.tar.xz
kernel-qcow2-util-linux-c82d9c977c7fdf28ede2db15601edde1a5819511.zip
login: add login.defs code and tests
The new logindefs.c file contains /etc/login.defs parser and functions for searching in the list of the login default variables. The patch also contains a new regression test for the code. Based on pam_login-4.0 from Suse. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests/ts/login')
-rwxr-xr-xtests/ts/login/logindefs24
-rw-r--r--tests/ts/login/logindefs.data16
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ts/login/logindefs b/tests/ts/login/logindefs
new file mode 100755
index 000000000..10caed752
--- /dev/null
+++ b/tests/ts/login/logindefs
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="defs"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+# list all items
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" | sed 's:'$TS_SELF'/::g' >> $TS_OUTPUT
+
+# search
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str STRING >> $TS_OUTPUT
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" num NUMBER >> $TS_OUTPUT
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" bool BOOLEAN >> $TS_OUTPUT
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str EMPTY >> $TS_OUTPUT
+
+$TS_HELPER_LOGINDEFS "$TS_SELF/logindefs.data" str UNKNOWN >> $TS_OUTPUT
+
+ts_finalize
diff --git a/tests/ts/login/logindefs.data b/tests/ts/login/logindefs.data
new file mode 100644
index 000000000..b899ff7d0
--- /dev/null
+++ b/tests/ts/login/logindefs.data
@@ -0,0 +1,16 @@
+#
+# this is /etc/login.defs sample
+#
+
+HELLO_WORLD "hello world!"
+STRING this_is_string # another comment
+NUMBER 123456
+BOOLEAN yEs
+
+CRAZY1 = "this is crazy format"
+CRAZY2=fooBar
+CRAZY3 FoooBaaar
+
+EMPTY
+
+END "the is end"