|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# Tests that using OpenSSH with wolfEngine works. |
| 5 | +# |
| 6 | + |
| 7 | +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" |
| 8 | +WOLFENGINE_ROOT="${SCRIPT_DIR}/.." |
| 9 | + |
| 10 | +if [ -z "${OPENSSL_INSTALL_DIR}" ]; then |
| 11 | + OPENSSL_INSTALL_DIR=${SCRIPT_DIR}/openssl |
| 12 | +fi |
| 13 | +OPENSSH_DIR=${SCRIPT_DIR}/openssh |
| 14 | + |
| 15 | +source ${SCRIPT_DIR}/build-openssl-wolfengine.sh |
| 16 | + |
| 17 | +do_cleanup() { |
| 18 | + printf "Cleaning up.\n" |
| 19 | + |
| 20 | + # Use the environment variable KEEP_OPENSSH to prevent OpenSSH and OpenSSL |
| 21 | + # directories from being deleted at the end of the run. |
| 22 | + if [ -z "${KEEP_OPENSSH}" ]; then |
| 23 | + printf "\tDeleting OpenSSH directory.\n" |
| 24 | + rm -rf ${OPENSSH_DIR} |
| 25 | + |
| 26 | + printf "\tDeleting OpenSSL install directory.\n" |
| 27 | + rm -rf ${OPENSSL_INSTALL_DIR} |
| 28 | + fi |
| 29 | +} |
| 30 | + |
| 31 | +do_failure() { |
| 32 | + # Keep the OpenSSH and OpenSSL directories around to help debug the failure. |
| 33 | + KEEP_OPENSSH=1 |
| 34 | + do_cleanup |
| 35 | + exit 1 |
| 36 | +} |
| 37 | + |
| 38 | +# Register trap on interrupt (2) and terminate (15) |
| 39 | +trap do_failure INT TERM |
| 40 | + |
| 41 | +download_openssh() { |
| 42 | + printf "Downloading OpenSSH..." |
| 43 | + if [ -n "${OPENSSH_NO_DOWNLOAD}" -o -n "${OPENSSH_NO_BUILD}" ]; then |
| 44 | + return |
| 45 | + fi |
| 46 | + |
| 47 | + rm -rf ${OPENSSH_DIR} |
| 48 | + |
| 49 | + cd ${SCRIPT_DIR} |
| 50 | + |
| 51 | + git clone https://github.com/openssh/openssh-portable.git $OPENSSH_DIR >> $LOGFILE 2>&1 |
| 52 | + if [ $? != 0 ]; then |
| 53 | + printf "failed\n" |
| 54 | + do_failure |
| 55 | + fi |
| 56 | + printf "ok.\n" |
| 57 | + |
| 58 | + cd ${WOLFENGINE_ROOT} |
| 59 | +} |
| 60 | + |
| 61 | +build_openssh() { |
| 62 | + if [ -n "${OPENSSH_NO_BUILD}" ]; then |
| 63 | + return |
| 64 | + fi |
| 65 | + |
| 66 | + cd ${OPENSSH_DIR} |
| 67 | + |
| 68 | + printf "Building OpenSSH.\n" |
| 69 | + printf "\tRunning autoreconf..." |
| 70 | + autoreconf >> $LOGFILE 2>&1 |
| 71 | + if [ $? != 0 ]; then |
| 72 | + printf "failed.\n" |
| 73 | + do_failure |
| 74 | + fi |
| 75 | + printf "ok.\n" |
| 76 | + |
| 77 | + printf "\tConfiguring..." |
| 78 | + ./configure --with-ssl-dir=${OPENSSL_INSTALL} --without-openssl-header-check --with-ssl-engine >> $LOGFILE 2>&1 |
| 79 | + if [ $? != 0 ]; then |
| 80 | + printf "failed.\n" |
| 81 | + do_failure |
| 82 | + fi |
| 83 | + printf "ok.\n" |
| 84 | + make clean >> $LOGFILE 2>&1 |
| 85 | + |
| 86 | + printf "\tBuilding..." |
| 87 | + make -j$MAKE_JOBS >> $LOGFILE 2>&1 |
| 88 | + if [ $? != 0 ]; then |
| 89 | + printf "failed.\n" |
| 90 | + do_failure |
| 91 | + fi |
| 92 | + printf "ok.\n" |
| 93 | + |
| 94 | + cd ${WOLFENGINE_ROOT} |
| 95 | +} |
| 96 | + |
| 97 | +test_openssh_separate() { |
| 98 | + cd ${OPENSSH_DIR} |
| 99 | + |
| 100 | + printf "Running OpenSSH tests with wolfEngine\n" |
| 101 | + for T in connect \ |
| 102 | + proxy-connect \ |
| 103 | + agent \ |
| 104 | + connect-privsep \ |
| 105 | + connect-uri \ |
| 106 | + proto-version \ |
| 107 | + proto-mismatch \ |
| 108 | + exit-status \ |
| 109 | + envpass \ |
| 110 | + transfer \ |
| 111 | + banner \ |
| 112 | + rekey \ |
| 113 | + dhgex \ |
| 114 | + stderr-data \ |
| 115 | + stderr-after-eof \ |
| 116 | + broken-pipe \ |
| 117 | + try-ciphers \ |
| 118 | + yes-head \ |
| 119 | + login-timeout \ |
| 120 | + agent-getpeereid \ |
| 121 | + agent-timeout \ |
| 122 | + agent-ptrace \ |
| 123 | + agent-subprocess \ |
| 124 | + keyscan \ |
| 125 | + keygen-change \ |
| 126 | + keygen-convert \ |
| 127 | + keygen-moduli \ |
| 128 | + key-options \ |
| 129 | + scp \ |
| 130 | + scp-uri \ |
| 131 | + sftp \ |
| 132 | + sftp-chroot \ |
| 133 | + sftp-cmds \ |
| 134 | + sftp-badcmds \ |
| 135 | + sftp-batch \ |
| 136 | + sftp-glob \ |
| 137 | + sftp-perm \ |
| 138 | + sftp-uri \ |
| 139 | + reconfigure \ |
| 140 | + dynamic-forward \ |
| 141 | + forwarding \ |
| 142 | + multiplex \ |
| 143 | + reexec \ |
| 144 | + brokenkeys \ |
| 145 | + sshcfgparse \ |
| 146 | + cfgparse \ |
| 147 | + cfgmatch \ |
| 148 | + cfgmatchlisten \ |
| 149 | + percent \ |
| 150 | + addrmatch \ |
| 151 | + localcommand \ |
| 152 | + forcecommand \ |
| 153 | + portnum \ |
| 154 | + keytype \ |
| 155 | + kextype \ |
| 156 | + cert-hostkey \ |
| 157 | + cert-userkey \ |
| 158 | + host-expand \ |
| 159 | + keys-command \ |
| 160 | + forward-control \ |
| 161 | + integrity \ |
| 162 | + krl \ |
| 163 | + multipubkey \ |
| 164 | + limit-keytype \ |
| 165 | + hostkey-agent \ |
| 166 | + keygen-knownhosts \ |
| 167 | + hostkey-rotate \ |
| 168 | + principals-command \ |
| 169 | + cert-file \ |
| 170 | + cfginclude \ |
| 171 | + servcfginclude \ |
| 172 | + allow-deny-users \ |
| 173 | + authinfo \ |
| 174 | + sshsig \ |
| 175 | + keygen-comment \ |
| 176 | + knownhosts-command |
| 177 | + do |
| 178 | + printf "\t$T..." |
| 179 | + make t-exec LTESTS=$T >> $LOGFILE 2>&1 |
| 180 | + if [ $? != 0 ]; then |
| 181 | + printf "failed\n" |
| 182 | + do_failure |
| 183 | + fi |
| 184 | + printf "ok.\n" |
| 185 | + done |
| 186 | + |
| 187 | + cd ${WOLFENGINE_ROOT} |
| 188 | +} |
| 189 | + |
| 190 | +test_openssh_one() { |
| 191 | + cd ${OPENSSH_DIR} |
| 192 | + |
| 193 | + printf "Running OpenSSH tests with wolfEngine\n" |
| 194 | + for T in integrity |
| 195 | + do |
| 196 | + printf "\t$T..." |
| 197 | + make t-exec LTESTS=$T >> $LOGFILE 2>&1 |
| 198 | + if [ $? != 0 ]; then |
| 199 | + printf "failed\n" |
| 200 | + do_failure |
| 201 | + fi |
| 202 | + printf "ok.\n" |
| 203 | + done |
| 204 | + |
| 205 | + cd ${WOLFENGINE_ROOT} |
| 206 | +} |
| 207 | + |
| 208 | +test_openssh() { |
| 209 | + cd ${OPENSSH_DIR} |
| 210 | + |
| 211 | + printf "Running OpenSSH tests with wolfEngine..." |
| 212 | + make tests >> $LOGFILE 2>&1 |
| 213 | + if [ $? != 0 ]; then |
| 214 | + printf "failed\n" |
| 215 | + do_failure |
| 216 | + fi |
| 217 | + printf "ok.\n" |
| 218 | + |
| 219 | + cd ${WOLFENGINE_ROOT} |
| 220 | +} |
| 221 | + |
| 222 | +if [ -z "${LOGFILE}" ]; then |
| 223 | + LOGFILE=${SCRIPT_DIR}/openssh-tests.log |
| 224 | +fi |
| 225 | +rm -f $LOGFILE |
| 226 | + |
| 227 | +export OPENSSL_EXTRA_CFLAGS="-g3 -O0 -fno-omit-frame-pointer -fno-inline-functions" |
| 228 | + |
| 229 | +# Versions of OpenSSL to test |
| 230 | +if [ -n "${OPENSSL_VERSIONS}" ]; then |
| 231 | + VERSIONS=${OPENSSL_VERSIONS} |
| 232 | +else |
| 233 | + VERSIONS="1.0.2 1.1.1" |
| 234 | +fi |
| 235 | + |
| 236 | +export OPENSSL_CONF=$WOLFENGINE_ROOT/engine.conf |
| 237 | +export OPENSSL_ENGINES=$WOLFENGINE_ROOT/.libs |
| 238 | +export LD_LIBRARY_PATH="$WOLFENGINE_ROOT/.libs:$WOLFENGINE_ROOT:$LD_LIBRARY_PATH" |
| 239 | + |
| 240 | +download_openssh |
| 241 | + |
| 242 | +for VERSION in $VERSIONS |
| 243 | +do |
| 244 | + if [ "${VERSION}" = "1.0.2" ]; then |
| 245 | + OPENSSL_VERS_STR="OpenSSL 1.0.2h" |
| 246 | + get_openssl_102h |
| 247 | + configure_openssl_102h |
| 248 | + build_openssl_102h |
| 249 | + install_openssl_102h |
| 250 | + elif [ "${VERSION}" = "1.1.1" ]; then |
| 251 | + OPENSSL_VERS_STR="OpenSSL 1.1.1b" |
| 252 | + get_openssl_111b |
| 253 | + configure_openssl_111b |
| 254 | + build_openssl_111b |
| 255 | + install_openssl_111b |
| 256 | + fi |
| 257 | + OPENSSL_INSTALL=${OPENSSL_INSTALL_DIR} |
| 258 | + setup_openssl_install |
| 259 | + |
| 260 | + WOLFENGINE_EXTRA_OPTS="--enable-openssh" |
| 261 | + build_wolfengine |
| 262 | + |
| 263 | + # We don't want to print debug messages as that will trigger false failures |
| 264 | + # in the OpenSSH tests. |
| 265 | + WE_DEBUG=0 |
| 266 | + WE_OPENSSL_CONF=${SCRIPT_DIR}/wolfengine.conf |
| 267 | + write_conf_file |
| 268 | + |
| 269 | + build_openssh |
| 270 | + test_openssh_separate |
| 271 | +done |
| 272 | + |
| 273 | + |
0 commit comments