summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/cfgparse.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/regress/cfgparse.sh b/regress/cfgparse.sh
new file mode 100644
index 000000000..95bd9a8a4
--- /dev/null
+++ b/regress/cfgparse.sh
@@ -0,0 +1,60 @@
1# $OpenBSD: cfgparse.sh,v 1.4 2015/05/04 01:51:39 dtucker Exp $
2# Placed in the Public Domain.
3
4tid="config parse"
5
6# We need to use the keys generated for the regression test because sshd -T
7# will fail if we're not running with SUDO (no permissions for real keys) or
8# if we are # running tests on a system that has never had sshd installed
9# (keys won't exist).
10
11grep "HostKey " $OBJ/sshd_config > $OBJ/sshd_config_minimal
12SSHD_KEYS="`cat $OBJ/sshd_config_minimal`"
13
14verbose "reparse minimal config"
15($SUDO ${SSHD} -T -f $OBJ/sshd_config_minimal >$OBJ/sshd_config.1 &&
16 $SUDO ${SSHD} -T -f $OBJ/sshd_config.1 >$OBJ/sshd_config.2 &&
17 diff $OBJ/sshd_config.1 $OBJ/sshd_config.2) || fail "reparse minimal config"
18
19verbose "reparse regress config"
20($SUDO ${SSHD} -T -f $OBJ/sshd_config >$OBJ/sshd_config.1 &&
21 $SUDO ${SSHD} -T -f $OBJ/sshd_config.1 >$OBJ/sshd_config.2 &&
22 diff $OBJ/sshd_config.1 $OBJ/sshd_config.2) || fail "reparse regress config"
23
24verbose "listenaddress order"
25# expected output
26cat > $OBJ/sshd_config.0 <<EOD
27listenaddress 1.2.3.4:1234
28listenaddress 1.2.3.4:5678
29listenaddress [::1]:1234
30listenaddress [::1]:5678
31EOD
32# test input sets. should all result in the output above.
33# test 1: addressfamily and port first
34cat > $OBJ/sshd_config.1 <<EOD
35${SSHD_KEYS}
36addressfamily any
37port 1234
38port 5678
39listenaddress 1.2.3.4
40listenaddress ::1
41EOD
42($SUDO ${SSHD} -T -f $OBJ/sshd_config.1 | \
43 grep 'listenaddress ' >$OBJ/sshd_config.2 &&
44 diff $OBJ/sshd_config.0 $OBJ/sshd_config.2) || \
45 fail "listenaddress order 1"
46# test 2: listenaddress first
47cat > $OBJ/sshd_config.1 <<EOD
48listenaddress 1.2.3.4
49listenaddress ::1
50port 1234
51port 5678
52addressfamily any
53EOD
54($SUDO ${SSHD} -T -f $OBJ/sshd_config.1 | \
55 grep 'listenaddress ' >$OBJ/sshd_config.2 &&
56 diff $OBJ/sshd_config.0 $OBJ/sshd_config.2) || \
57 fail "listenaddress order 2"
58
59# cleanup
60rm -f $OBJ/sshd_config.[012]