Skip to content

Commit a7de265

Browse files
committed
Prevent Address in use error
Use dynamic listening port (assigned from system), detect it from process by calling lsof.
1 parent d579f02 commit a7de265

24 files changed

+121
-90
lines changed

.github/workflows/install-dependencies

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -ex
22

3-
COMMON="meson curl git make file bzip2 jose tang cryptsetup keyutils jq socat ${CC}"
3+
COMMON="meson curl git make file bzip2 jose tang cryptsetup keyutils jq socat lsof ${CC}"
44

55
case "${DISTRO}" in
66
debian:*|ubuntu:*)
@@ -33,7 +33,7 @@ debian:*|ubuntu:*)
3333
printf 'max_parallel_downloads=10\nfastestmirror=1\n' >> /etc/dnf/dnf.conf
3434
dnf -y clean all
3535
dnf -y --setopt=deltarpm=0 update
36-
dnf -y install dnf-utils jq socat cryptsetup keyutils cracklib-dicts
36+
dnf -y install dnf-utils jq socat cryptsetup keyutils cracklib-dicts lsof
3737
dnf -y builddep clevis
3838
;;
3939

src/luks/tests/assume-yes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ trap 'on_exit' ERR
3333

3434
TMP="$(mktemp -d)"
3535

36-
port=$(tang_new_random_port)
37-
tang_run "${TMP}" "${port}"
36+
tang_run "${TMP}"
37+
port=$(tang_get_port "${TMP}")
3838

3939
url="http://localhost:${port}"
4040
cfg=$(printf '{"url":"%s"}' "$url")

src/luks/tests/assume-yes-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ trap 'on_exit' ERR
3333

3434
TMP="$(mktemp -d)"
3535

36-
port=$(tang_new_random_port)
37-
tang_run "${TMP}" "${port}"
36+
tang_run "${TMP}"
37+
port=$(tang_get_port "${TMP}")
3838

3939
url="http://localhost:${port}"
4040
cfg=$(printf '{"url":"%s"}' "$url")

src/luks/tests/bind-binary-keyfile-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ trap 'on_exit' EXIT
3333

3434
TMP="$(mktemp -d)"
3535

36-
port=$(tang_new_random_port)
37-
tang_run "${TMP}" "${port}"
36+
tang_run "${TMP}"
37+
port=$(tang_get_port "${TMP}")
3838

3939
url="http://localhost:${port}"
4040
ADV="${TMP}/adv.jws"

src/luks/tests/bind-luks1-avoid-luksmeta-corruption

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ DEV="${TMP}/luks1-device"
3737
new_device "luks1" "${DEV}"
3838

3939
# TANG server specifics
40-
port=$(tang_new_random_port)
41-
tang_run "${TMP}" "${port}"
40+
tang_run "${TMP}"
41+
port=$(tang_get_port "${TMP}")
42+
4243
url="http://localhost:${port}"
4344

4445
# Initial binding to ensure luksmeta gets corrupted

src/luks/tests/edit-tang-luks1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ trap 'on_exit' ERR
3636

3737
TMP="$(mktemp -d)"
3838

39-
port=$(tang_new_random_port)
40-
tang_run "${TMP}" "${port}"
39+
tang_run "${TMP}"
40+
port=$(tang_get_port "${TMP}")
4141

4242
url="http://localhost:${port}"
4343

@@ -64,9 +64,9 @@ fi
6464

6565
# Now let's have another tang instance running and change the config to use
6666
# the new one.
67-
port2=$(tang_new_random_port)
6867
TMP2="$(mktemp -d)"
69-
tang_run "${TMP2}" "${port2}"
68+
tang_run "${TMP2}"
69+
port2=$(tang_get_port "${TMP2}")
7070
new_url="http://localhost:${port2}"
7171
new_cfg=$(printf '{"url":"%s"}' "${new_url}")
7272

src/luks/tests/edit-tang-luks2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ trap 'on_exit' ERR
3636

3737
TMP="$(mktemp -d)"
3838

39-
port=$(tang_new_random_port)
40-
tang_run "${TMP}" "${port}"
39+
tang_run "${TMP}"
40+
port=$(tang_get_port "${TMP}")
4141

4242
url="http://localhost:${port}"
4343

@@ -64,9 +64,9 @@ fi
6464

6565
# Now let's have another tang instance running and change the config to use
6666
# the new one.
67-
port2=$(tang_new_random_port)
6867
TMP2="$(mktemp -d)"
69-
tang_run "${TMP2}" "${port2}"
68+
tang_run "${TMP2}"
69+
port2=$(tang_get_port "${TMP2}")
7070
new_url="http://localhost:${port2}"
7171
new_cfg=$(printf '{"url":"%s"}' "${new_url}")
7272

src/luks/tests/pass-tang-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/pass-tang-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/regen-inplace-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/regen-inplace-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/regen-not-inplace-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
export TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/regen-not-inplace-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
export TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/report-sss-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/report-sss-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/report-tang-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/report-tang-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trap 'on_exit' EXIT
3232

3333
TMP=$(mktemp -d)
3434

35-
port=$(tang_new_random_port)
36-
tang_run "${TMP}" "${port}"
35+
tang_run "${TMP}"
36+
port=$(tang_get_port "${TMP}")
3737

3838
url="http://localhost:${port}"
3939
adv="${TMP}/adv"

src/luks/tests/unlock-arbitrary-parameter

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ trap 'on_exit' ERR
3030

3131
TMP="$(mktemp -d)"
3232

33-
port=$(tang_new_random_port)
34-
tang_run "${TMP}" "${port}"
33+
tang_run "${TMP}"
34+
port=$(tang_get_port "${TMP}")
3535

3636
url="http://localhost:${port}"
3737
adv="${TMP}/adv"

src/luks/tests/unlock-tang-luks1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ trap 'on_exit' ERR
3333

3434
TMP="$(mktemp -d)"
3535

36-
port=$(tang_new_random_port)
37-
tang_run "${TMP}" "${port}"
36+
tang_run "${TMP}"
37+
port=$(tang_get_port "${TMP}")
3838

3939
url="http://localhost:${port}"
4040
adv="${TMP}/adv"

src/luks/tests/unlock-tang-luks2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ trap 'on_exit' ERR
3333

3434
TMP="$(mktemp -d)"
3535

36-
port=$(tang_new_random_port)
37-
tang_run "${TMP}" "${port}"
36+
tang_run "${TMP}"
37+
port=$(tang_get_port "${TMP}")
3838

3939
url="http://localhost:${port}"
4040
adv="${TMP}/adv"

src/pins/tang/tests/default-thp-alg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ trap 'on_exit' EXIT
3434

3535
TMP="$(mktemp -d)"
3636

37-
port=$(tang_new_random_port)
38-
tang_run "${TMP}" "${port}"
37+
tang_run "${TMP}"
38+
port=$(tang_get_port "${TMP}")
3939

4040
url="http://localhost:${port}"
4141
data="just a sample text"

src/pins/tang/tests/pin-tang

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ trap 'on_exit' EXIT
3131

3232
TMP="$(mktemp -d)"
3333

34-
port=$(tang_new_random_port)
35-
36-
tang_run "${TMP}" "${port}" sig exc
34+
tang_run "${TMP}" sig exc
35+
port=$(tang_get_port "${TMP}")
3736

3837
thp="$(jose jwk thp -i "$TMP/db/sig.jwk")"
3938
adv="${TMP}/adv.jws"

0 commit comments

Comments
 (0)