From e5f15e216d2fd82d7fb37a906500923396926a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Fri, 27 Nov 2015 19:25:14 +0100 Subject: [PATCH 1/2] get the systemd service file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- helper_lib.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/helper_lib.sh b/helper_lib.sh index 7704f4d..69ba6ee 100644 --- a/helper_lib.sh +++ b/helper_lib.sh @@ -85,3 +85,8 @@ get_docker_effective_command_line_args() { OPTION="$1" get_docker_cumulative_command_line_args $OPTION | tail -n1 } + +get_systemd_service_file(){ + SERVICE="$1" + systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' +} From 80794e5638a08477a1481b7c67dd2a4882a8ddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Fri, 27 Nov 2015 19:26:03 +0100 Subject: [PATCH 2/2] get .service file location from systemd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- tests/1_host_configuration.sh | 4 ++-- tests/3_docker_daemon_configuration_files.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/1_host_configuration.sh b/tests/1_host_configuration.sh index 37a984b..157c9a8 100644 --- a/tests/1_host_configuration.sh +++ b/tests/1_host_configuration.sh @@ -114,7 +114,7 @@ fi # 1.11 check_1_11="1.11 - Audit Docker files and directories - docker-registry.service" -file="/usr/lib/systemd/system/docker-registry.service" +file="$(get_systemd_service_file docker-registry.service)" if [ -f "$file" ]; then command -v auditctl >/dev/null 2>&1 if [ $? -eq 0 ]; then @@ -134,7 +134,7 @@ fi # 1.12 check_1_12="1.12 - Audit Docker files and directories - docker.service" -file="/usr/lib/systemd/system/docker.service" +file="$(get_systemd_service_file docker.service)" if [ -f "$file" ]; then command -v auditctl >/dev/null 2>&1 if [ $? -eq 0 ]; then diff --git a/tests/3_docker_daemon_configuration_files.sh b/tests/3_docker_daemon_configuration_files.sh index b3ff542..dc2fdbc 100644 --- a/tests/3_docker_daemon_configuration_files.sh +++ b/tests/3_docker_daemon_configuration_files.sh @@ -5,7 +5,7 @@ info "3 - Docker Daemon Configuration Files" # 3.1 check_3_1="3.1 - Verify that docker.service file ownership is set to root:root" -file="/usr/lib/systemd/system/docker.service" +file="$(get_systemd_service_file docker-registry.service)" if [ -f "$file" ]; then if [ "$(stat -c %u%g $file)" -eq 00 ]; then pass "$check_3_1" @@ -20,7 +20,7 @@ fi # 3.2 check_3_2="3.2 - Verify that docker.service file permissions are set to 644" -file="/usr/lib/systemd/system/docker.service" +file="$(get_systemd_service_file docker-registry.service)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ]; then pass "$check_3_2" @@ -35,7 +35,7 @@ fi # 3.3 check_3_3="3.3 - Verify that docker-registry.service file ownership is set to root:root" -file="/usr/lib/systemd/system/docker-registry.service" +file="$(get_systemd_service_file docker-registry.service)" if [ -f "$file" ]; then if [ "$(stat -c %u%g $file)" -eq 00 ]; then pass "$check_3_3" @@ -50,7 +50,7 @@ fi # 3.4 check_3_4="3.4 - Verify that docker-registry.service file permissions are set to 644" -file="/usr/lib/systemd/system/docker-registry.service" +file="$(get_systemd_service_file docker-registry.service)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ]; then pass "$check_3_4"