diff options
-rw-r--r-- | regress/cfgparse.sh | 60 |
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 | |||
4 | tid="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 | |||
11 | grep "HostKey " $OBJ/sshd_config > $OBJ/sshd_config_minimal | ||
12 | SSHD_KEYS="`cat $OBJ/sshd_config_minimal`" | ||
13 | |||
14 | verbose "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 | |||
19 | verbose "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 | |||
24 | verbose "listenaddress order" | ||
25 | # expected output | ||
26 | cat > $OBJ/sshd_config.0 <<EOD | ||
27 | listenaddress 1.2.3.4:1234 | ||
28 | listenaddress 1.2.3.4:5678 | ||
29 | listenaddress [::1]:1234 | ||
30 | listenaddress [::1]:5678 | ||
31 | EOD | ||
32 | # test input sets. should all result in the output above. | ||
33 | # test 1: addressfamily and port first | ||
34 | cat > $OBJ/sshd_config.1 <<EOD | ||
35 | ${SSHD_KEYS} | ||
36 | addressfamily any | ||
37 | port 1234 | ||
38 | port 5678 | ||
39 | listenaddress 1.2.3.4 | ||
40 | listenaddress ::1 | ||
41 | EOD | ||
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 | ||
47 | cat > $OBJ/sshd_config.1 <<EOD | ||
48 | listenaddress 1.2.3.4 | ||
49 | listenaddress ::1 | ||
50 | port 1234 | ||
51 | port 5678 | ||
52 | addressfamily any | ||
53 | EOD | ||
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 | ||
60 | rm -f $OBJ/sshd_config.[012] | ||