From ec95862790e5c9f1fe5739ae6df558bdfc676730 Mon Sep 17 00:00:00 2001 From: Dirk Wetter Date: Tue, 7 Apr 2026 10:27:46 +0200 Subject: [PATCH] Make sure date -r hits a dir readable When checking early for date flavors, there might be an edge case when a directory with a referred file (for the date command) isn't readable which might cause testssl.sh to not detect the date flavor correctly. This fixes that by cd'ing to / in a subshell which should be cd'able and readable under every platform. --- testssl.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testssl.sh b/testssl.sh index f453bb5..937d3ba 100755 --- a/testssl.sh +++ b/testssl.sh @@ -478,14 +478,17 @@ HAS_FREEBSDDATE=false HAS_OPENBSDDATE=false if date -d @735275209 >/dev/null 2>&1; then + # FreeBSD's / MacOS' date doesn't reach this if date -r @735275209 >/dev/null 2>&1; then # Ubuntu >= 25.10 HAS_GNUDATE=true - elif LC_ALL=C date -r 735275209 2>&1 | grep -q "No such file"; then + # need to make sure we end up in a directory with read permission (see #3009) + elif (cd /; LC_ALL=C date -r 735275209 2>&1 | grep -q "No such file"); then # e.g. Debian 24.04, Debian 11-13 HAS_GNUDATE=true + # OpenBSD treats this as a reference (as FreeBSD would do it) elif date -r 735275209 >/dev/null 2>&1; then - # It can't do any conversion from a plain date output. + # OpenBSD date can't do any conversion from a plain date output HAS_OPENBSDDATE=true fi fi