From d42fedc37009f56ecc384c063077c7077d71ff64 Mon Sep 17 00:00:00 2001 From: Ilya Dus Date: Fri, 10 Apr 2020 16:26:25 +0300 Subject: [PATCH] fix(sh): check default ubuntu locations of docker.service and docker.socket files Signed-off-by: Ilya Dus --- helper_lib.sh | 4 +++- tests/1_host_configuration.sh | 4 ++-- tests/3_docker_daemon_configuration_files.sh | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/helper_lib.sh b/helper_lib.sh index 9a84f8f..bb89aee 100644 --- a/helper_lib.sh +++ b/helper_lib.sh @@ -103,11 +103,13 @@ get_docker_configuration_file_args() { grep "$OPTION" "$CONFIG_FILE" | sed 's/.*://g' | tr -d '" ', } -get_systemd_service_file() { +get_service_file() { SERVICE="$1" if [ -f "/etc/systemd/system/$SERVICE" ]; then echo "/etc/systemd/system/$SERVICE" + elif [ -f "/lib/systemd/system/$SERVICE" ]; then + echo "/lib/systemd/system/$SERVICE" elif systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2; then systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' else diff --git a/tests/1_host_configuration.sh b/tests/1_host_configuration.sh index 045b968..fb8260b 100644 --- a/tests/1_host_configuration.sh +++ b/tests/1_host_configuration.sh @@ -214,7 +214,7 @@ check_1_2_6() { starttestjson "$id_1_2_6" "$desc_1_2_6" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.service)" + file="$(get_service_file docker.service)" if [ -f "$file" ]; then if command -v auditctl >/dev/null 2>&1; then if auditctl -l | grep "$file" >/dev/null 2>&1; then @@ -251,7 +251,7 @@ check_1_2_7() { starttestjson "$id_1_2_7" "$desc_1_2_7" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.socket)" + file="$(get_service_file docker.socket)" if [ -e "$file" ]; then if command -v auditctl >/dev/null 2>&1; then if auditctl -l | grep "$file" >/dev/null 2>&1; then diff --git a/tests/3_docker_daemon_configuration_files.sh b/tests/3_docker_daemon_configuration_files.sh index ed9d418..9a91f93 100644 --- a/tests/3_docker_daemon_configuration_files.sh +++ b/tests/3_docker_daemon_configuration_files.sh @@ -17,7 +17,7 @@ check_3_1() { starttestjson "$id_3_1" "$desc_3_1" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.service)" + file="$(get_service_file docker.service)" if [ -f "$file" ]; then if [ "$(stat -c %u%g $file)" -eq 00 ]; then pass "$check_3_1" @@ -45,7 +45,7 @@ check_3_2() { starttestjson "$id_3_2" "$desc_3_2" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.service)" + file="$(get_service_file docker.service)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 600 ]; then pass "$check_3_2" @@ -73,7 +73,7 @@ check_3_3() { starttestjson "$id_3_3" "$desc_3_3" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.socket)" + file="$(get_service_file docker.socket)" if [ -f "$file" ]; then if [ "$(stat -c %u%g $file)" -eq 00 ]; then pass "$check_3_3" @@ -101,7 +101,7 @@ check_3_4() { starttestjson "$id_3_4" "$desc_3_4" totalChecks=$((totalChecks + 1)) - file="$(get_systemd_service_file docker.socket)" + file="$(get_service_file docker.socket)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ] || [ "$(stat -c %a $file)" -eq 600 ]; then pass "$check_3_4"