From 64d110f19d0c5df76a86721d8d18e49f9108d840 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Mon, 15 Nov 2021 07:25:08 -0500 Subject: [PATCH] Check file permissions on ./testssl.sh This commit adds a check that ./testssl.sh has both read and execute permission. If ./testssl.sh is lacking execute permission, it will pass the tests in 00_testssl_help.t and 01_testssl_banner.t that run the program as `bash ./testssl.sh`, but will fail the subsequent tests that run the program as `./testssl.sh`, but the reason for the failure will not be clear. --- t/00_testssl_help.t | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/00_testssl_help.t b/t/00_testssl_help.t index b3d39c2..bedcb8c 100755 --- a/t/00_testssl_help.t +++ b/t/00_testssl_help.t @@ -4,6 +4,7 @@ use strict; use Test::More; +use File::stat; my $tests = 0; my $fileout=""; @@ -20,6 +21,15 @@ my $error_regexp4='command not found'; my $error_regexp5='(syntax error|unexpected token)'; printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no error ..."; +my $info = stat($prg); +my $retMode = $info->mode; + +is($retMode & 0400, 0400, "Checking \"./testssl.sh\" for read permission"); +$tests++; + +is($retMode & 0100, 0100, "Checking \"./testssl.sh\" for execute permission"); +$tests++; + $fileout = `timeout 10 bash $prg 2>&1`; my $retval=$?;