1 # $OpenBSD: cfgparse.sh,v 1.7 2018/05/11 03:51:06 dtucker Exp $
2 # Placed in the Public Domain.
4 tid="sshd config parse"
6 # This is a reasonable proxy for IPv6 support.
7 if ! config_defined HAVE_STRUCT_IN6_ADDR ; then
11 # We need to use the keys generated for the regression test because sshd -T
12 # will fail if we're not running with SUDO (no permissions for real keys) or
13 # if we are running tests on a system that has never had sshd installed
14 # because the keys won't exist.
16 grep "HostKey " $OBJ/sshd_config > $OBJ/sshd_config_minimal
17 SSHD_KEYS="`cat $OBJ/sshd_config_minimal`"
19 verbose "reparse minimal config"
20 ($SUDO ${SSHD} -T -f $OBJ/sshd_config_minimal >$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 minimal config"
24 verbose "reparse regress config"
25 ($SUDO ${SSHD} -T -f $OBJ/sshd_config >$OBJ/sshd_config.1 &&
26 $SUDO ${SSHD} -T -f $OBJ/sshd_config.1 >$OBJ/sshd_config.2 &&
27 diff $OBJ/sshd_config.1 $OBJ/sshd_config.2) || fail "reparse regress config"
29 verbose "listenaddress order"
31 cat > $OBJ/sshd_config.0 <<EOD
32 listenaddress 1.2.3.4:1234
33 listenaddress 1.2.3.4:5678
35 [ X${SKIP_IPV6} = Xyes ] || cat >> $OBJ/sshd_config.0 <<EOD
36 listenaddress [::1]:1234
37 listenaddress [::1]:5678
40 # test input sets. should all result in the output above.
41 # test 1: addressfamily and port first
42 cat > $OBJ/sshd_config.1 <<EOD
49 [ X${SKIP_IPV6} = Xyes ] || cat >> $OBJ/sshd_config.1 <<EOD
53 ($SUDO ${SSHD} -T -f $OBJ/sshd_config.1 | \
54 grep 'listenaddress ' >$OBJ/sshd_config.2 &&
55 diff $OBJ/sshd_config.0 $OBJ/sshd_config.2) || \
56 fail "listenaddress order 1"
57 # test 2: listenaddress first
58 cat > $OBJ/sshd_config.1 <<EOD
65 [ X${SKIP_IPV6} = Xyes ] || cat >> $OBJ/sshd_config.1 <<EOD
69 ($SUDO ${SSHD} -T -f $OBJ/sshd_config.1 | \
70 grep 'listenaddress ' >$OBJ/sshd_config.2 &&
71 diff $OBJ/sshd_config.0 $OBJ/sshd_config.2) || \
72 fail "listenaddress order 2"
75 rm -f $OBJ/sshd_config.[012]