From d146c56bfd69ee04a24cc5ef0f9ae0f6349a707e Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 7 Apr 2026 16:02:48 +0200 Subject: [PATCH] Make sure date -r hits a readable dir (3.2) 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 not to detect the date flavor correctly. This fixes that (#3009) 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 2bc59fa..3272da6 100755 --- a/testssl.sh +++ b/testssl.sh @@ -471,14 +471,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