Skip to content

Commit 7bbed76

Browse files
committed
Fix ssh_compat_SUITE
1 parent 2af7bcc commit 7bbed76

33 files changed

+949
-229
lines changed

lib/ssh/test/ssh_compat_SUITE.erl

Lines changed: 186 additions & 101 deletions
Large diffs are not rendered by default.

lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-base-image

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# %CopyrightBegin%
33
#
44
# SPDX-License-Identifier: Apache-2.0
@@ -17,19 +17,22 @@
1717
# limitations under the License.
1818
#
1919
# %CopyrightEnd%
20+
#
21+
# ./create-base-image
2022

21-
UBUNTU_VER=${1:-16.04}
23+
UBUNTU_VER=${1:-18.04}
2224

2325
USER=sshtester
2426
PWD=foobar
2527

2628
docker build \
27-
-t ssh_compat_suite-ubuntu \
29+
-t ssh_compat_suite_img-ubuntu:$UBUNTU_VER \
2830
--build-arg https_proxy=$HTTPS_PROXY \
2931
--build-arg http_proxy=$HTTP_PROXY \
3032
- <<EOF
3133
3234
FROM ubuntu:$UBUNTU_VER
35+
ARG DEBIAN_FRONTEND=noninteractive
3336
WORKDIR /buildroot
3437
3538
# Prepare for installing OpenSSH
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
# %CopyrightBegin%
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
# %CopyrightEnd%
20+
21+
# ./create-dropbear-image dropbear 2025.88 [in-file]
22+
23+
case $1 in
24+
dropbear)
25+
FAMssh=dropbear
26+
VERssh=$2
27+
LINK=https://matt.ucc.asn.au/dropbear/releases/dropbear-${VERssh}.tar.bz2
28+
TMP=tmp.tar.bz2
29+
;;
30+
*)
31+
echo "Unsupported: $1"
32+
exit 1
33+
esac
34+
35+
BASE_VER=$3
36+
INPUT_FILE=$4
37+
38+
VER=${FAMssh}${VERssh}-${BASE_VER}
39+
40+
BASE_IMG=ssh_compat_suite_img-ubuntu:$BASE_VER
41+
42+
if [[ $(docker images -q $BASE_IMG 2> /dev/null) == "" ]] ; then
43+
echo "Building $BASE_IMG..."
44+
if ! ./create-base-image $BASE_VER; then
45+
echo "Create base failed." >&2
46+
exit 1
47+
fi
48+
fi
49+
50+
# This way of fetching the tar-file separate from the docker commands makes
51+
# http-proxy handling way easier. The wget command handles the $https_proxy
52+
# variable while the docker command must have /etc/docker/something changed
53+
# and the docker server restarted. That is not possible without root access.
54+
55+
# Make a Dockerfile. This method simplifies env variable handling considerably:
56+
cat - > TempDockerFile <<EOF
57+
58+
FROM $BASE_IMG
59+
ARG DEBIAN_FRONTEND=noninteractive
60+
61+
LABEL ${FAMssh}-version=${VER}
62+
63+
WORKDIR /buildroot
64+
65+
COPY ${TMP} .
66+
RUN tar xf ${TMP}
67+
68+
# Build and install
69+
70+
WORKDIR ${FAMssh}-${VERssh}
71+
72+
RUN apt-get update
73+
RUN apt-get -y install openssh-sftp-server
74+
75+
# Probably VERY dropbear dependent...:
76+
RUN ./configure --without-pie \
77+
--prefix=/buildroot/ssh \
78+
--enable-pam \
79+
LDFLAGS=-Wl,-R/buildroot/ssl/lib
80+
RUN make
81+
RUN make install
82+
RUN mkdir -p /etc/dropbear
83+
RUN mkdir -p /usr/libexec
84+
RUN ln -s /usr/lib/sftp-server /usr/libexec/sftp-server
85+
86+
RUN echo Built ${VER}
87+
88+
# Start the daemon, but keep it in foreground to avoid killing the container
89+
CMD ["/buildroot/ssh/sbin/dropbear", "-R", "-F", "-E", "-p", "1234"]
90+
91+
EOF
92+
93+
# Fetch the tar file. This could be done in an "ADD ..." in the Dockerfile,
94+
# but then we hit the proxy problem...
95+
96+
if [[ "x$INPUT_FILE" = "x" ]]
97+
then
98+
wget -O $TMP $LINK
99+
100+
elif [[ "x$INPUT_FILE" != "x$TMP" ]]
101+
then
102+
echo "Use $INPUT_FILE for input"
103+
cp $INPUT_FILE $TMP
104+
fi
105+
106+
# Build the image:
107+
docker build -t ssh_compat_suite_img-ssh:$VER -f ./TempDockerFile .
108+
CODE=$?
109+
110+
# Cleaning
111+
rm -fr ./TempDockerFile $TMP
112+
113+
exit $CODE

lib/ssh/test/ssh_compat_SUITE_data/build_scripts/create-ssh-image

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# %CopyrightBegin%
33
#
44
# SPDX-License-Identifier: Apache-2.0
@@ -18,27 +18,36 @@
1818
#
1919
# %CopyrightEnd%
2020

21-
# ./create-image openssh 7.3p1 openssl 1.0.2m [in-file]
21+
# ./create-ssh-image openssh 7.3p1 openssl 1.0.2m [in-file]
2222

2323
case $1 in
2424
openssh)
25-
FAMssh=openssh
26-
VERssh=$2
27-
PFX=https://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-
28-
SFX=.tar.gz
29-
TMP=tmp.tar.gz
30-
;;
25+
FAMssh=openssh
26+
VERssh=$2
27+
LINK=https://ftp.eu.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${VERssh}.tar.gz
28+
TMP=tmp.tar.gz
29+
;;
3130
*)
32-
echo "Unsupported: $1"
33-
exit
31+
echo "Unsupported: $1"
32+
exit 2
3433
esac
3534

3635
FAMssl=$3
3736
VERssl=$4
37+
BASE_VER=$5
3838

39-
INPUT_FILE=$5
39+
INPUT_FILE=$6
4040

41-
VER=${FAMssh}${VERssh}-${FAMssl}${VERssl}
41+
VER=${FAMssh}${VERssh}-${FAMssl}${VERssl}-${BASE_VER}
42+
43+
case $FAMssl$VERssl in
44+
openssl3*)
45+
LIB_DIR="lib64"
46+
;;
47+
*)
48+
LIB_DIR="lib"
49+
;;
50+
esac
4251

4352
# This way of fetching the tar-file separate from the docker commands makes
4453
# http-proxy handling way easier. The wget command handles the $https_proxy
@@ -48,7 +57,8 @@ VER=${FAMssh}${VERssh}-${FAMssl}${VERssl}
4857
# Make a Dockerfile. This method simplifies env variable handling considerably:
4958
cat - > TempDockerFile <<EOF
5059
51-
FROM ssh_compat_suite-${FAMssl}:${VERssl}
60+
FROM ssh_compat_suite_img-${FAMssl}:${VERssl}-${BASE_VER}
61+
ARG DEBIAN_FRONTEND=noninteractive
5262
5363
LABEL openssh-version=${VER}
5464
@@ -66,34 +76,36 @@ cat - > TempDockerFile <<EOF
6676
--prefix=/buildroot/ssh \
6777
--with-ssl-dir=/buildroot/ssl \
6878
--with-pam \
69-
LDFLAGS=-Wl,-R/buildroot/ssl/lib
79+
LDFLAGS=-Wl,-R/buildroot/ssl/${LIB_DIR}
7080
RUN make
7181
RUN make install
7282
RUN echo UsePAM yes >> /buildroot/ssh/etc/sshd_config
7383
7484
RUN echo Built ${VER}
7585
7686
# Start the daemon, but keep it in foreground to avoid killing the container
77-
CMD /buildroot/ssh/sbin/sshd -D -p 1234
87+
CMD ["/buildroot/ssh/sbin/sshd", "-D", "-e", "-p", "1234"]
7888
7989
EOF
8090

8191
# Fetch the tar file. This could be done in an "ADD ..." in the Dockerfile,
8292
# but then we hit the proxy problem...
8393

84-
if [ "x$INPUT_FILE" = "x" ]
94+
if [[ "x$INPUT_FILE" == "x" ]]
8595
then
86-
wget -O $TMP $PFX$VERssh$SFX
96+
wget -O $TMP $LINK
8797

88-
elif [ "x$INPUT_FILE" != "x$TMP" ]
98+
elif [[ "x$INPUT_FILE" != "x$TMP" ]]
8999
then
90100
echo "Use $INPUT_FILE for input"
91101
cp $INPUT_FILE $TMP
92102
fi
93103

94104
# Build the image:
95-
docker build -t ssh_compat_suite-ssh:$VER -f ./TempDockerFile .
105+
docker build -t ssh_compat_suite_img-ssh:$VER -f ./TempDockerFile .
106+
CODE=$?
96107

97108
# Cleaning
98109
rm -fr ./TempDockerFile $TMP
99110

111+
exit $CODE
Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# %CopyrightBegin%
33
#
44
# SPDX-License-Identifier: Apache-2.0
@@ -19,41 +19,62 @@
1919
# %CopyrightEnd%
2020

2121

22-
# ./create-image openssl 1.0.2m [in-file]
23-
24-
case "$1" in
25-
"openssl")
26-
FAM=openssl
27-
VER=$2
28-
PFX=https://www.openssl.org/source/openssl-
29-
SFX=.tar.gz
30-
TMP=tmp.tar.gz
31-
;;
32-
"libressl")
33-
FAM=libressl
34-
VER=$2
35-
PFX=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-
36-
SFX=.tar.gz
37-
TMP=tmp.tar.gz
38-
;;
22+
# ./create-ssl-image openssl 1.0.2m [in-file]
23+
24+
case $1$2 in
25+
openssl[0-1]*)
26+
FAM=openssl
27+
VER=$2
28+
DASH_VER=$(echo -n $VER | sed 's/\./_/g')
29+
LINK=https://github.com/openssl/openssl/releases/download/OpenSSL_${DASH_VER}/openssl-${VER}.tar.gz
30+
TMP=tmp.tar.gz
31+
;;
32+
openssl3*)
33+
FAM=openssl
34+
VER=$2
35+
LINK=https://github.com/openssl/openssl/releases/download/openssl-${VER}/openssl-${VER}.tar.gz
36+
TMP=tmp.tar.gz
37+
;;
38+
libressl[2-3].[0-7]*)
39+
FAM=libressl
40+
VER=$2
41+
LINK=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${VER}.tar.gz
42+
TMP=tmp.tar.gz
43+
;;
44+
libressl[3-4]*)
45+
FAM=libressl
46+
VER=$2
47+
LINK=https://github.com/libressl/portable/releases/download/v${VER}/libressl-${VER}.tar.gz
48+
TMP=tmp.tar.gz
49+
;;
3950
*)
40-
echo No lib type
41-
exit
42-
;;
51+
echo No lib type
52+
exit 1
53+
;;
4354
esac
4455

45-
INPUT_FILE=$3
56+
BASE_VER=$3
57+
INPUT_FILE=$4
4658

47-
case $1$2 in
59+
BASE_IMG=ssh_compat_suite_img-ubuntu:$BASE_VER
60+
61+
if [[ $(docker images -q $BASE_IMG 2> /dev/null) == "" ]] ; then
62+
echo "Building $BASE_IMG..."
63+
if ! ./create-base-image $BASE_VER; then
64+
echo "Create base failed." >&2
65+
exit 1
66+
fi
67+
fi
68+
69+
case $FAM$VER in
4870
openssl0.9.8[a-l])
4971
CONFIG_FLAGS=no-asm
50-
;;
72+
;;
5173
*)
52-
CONFIG_FLAGS=
53-
;;
74+
CONFIG_FLAGS=
75+
;;
5476
esac
5577

56-
5778
# This way of fetching the tar-file separate from the docker commands makes
5879
# http-proxy handling way easier. The wget command handles the $https_proxy
5980
# variable while the docker command must have /etc/docker/something changed
@@ -62,7 +83,8 @@ esac
6283
# Make a Dockerfile. This method simplifies env variable handling considerably:
6384
cat - > TempDockerFile <<EOF
6485
65-
FROM ssh_compat_suite-ubuntu:latest
86+
FROM $BASE_IMG
87+
ARG DEBIAN_FRONTEND=noninteractive
6688
6789
LABEL version=$FAM-$VER
6890
@@ -84,18 +106,21 @@ EOF
84106
# Fetch the tar file. This could be done in an "ADD ..." in the Dockerfile,
85107
# but then we hit the proxy problem...
86108

87-
if [ "x$INPUT_FILE" = "x" ]
109+
if [[ "x$INPUT_FILE" == "x" ]]
88110
then
89-
wget -O $TMP $PFX$VER$SFX
111+
wget -O $TMP $LINK
90112

91-
elif [ "x$INPUT_FILE" != "x$TMP" ]
113+
elif [[ "x$INPUT_FILE" != "x$TMP" ]]
92114
then
93-
echo "Use $INPUT_FILE for input"
115+
echo "Use $INPUT_FILE for input"
94116
cp $INPUT_FILE $TMP
95117
fi
96118

97119
# Build the image:
98-
docker build -t ssh_compat_suite-$FAM:$VER -f ./TempDockerFile .
120+
docker build -t ssh_compat_suite_img-$FAM:$VER-$BASE_VER -f ./TempDockerFile .
121+
CODE=$?
99122

100123
# Cleaning
101124
rm -fr ./TempDockerFile $TMP
125+
126+
exit $CODE

0 commit comments

Comments
 (0)