From e8c6b9414340b517f91efe5a2a170eaaf9ab9509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Sat, 12 Dec 2015 16:08:46 +0100 Subject: [PATCH 1/4] check docker.service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- tests/3_docker_daemon_configuration_files.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/3_docker_daemon_configuration_files.sh b/tests/3_docker_daemon_configuration_files.sh index dc2fdbc..04367c5 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="$(get_systemd_service_file docker-registry.service)" +file="$(get_systemd_service_file docker.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="$(get_systemd_service_file docker-registry.service)" +file="$(get_systemd_service_file docker.service)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ]; then pass "$check_3_2" From 606f70f83f75ed995098cf2d16cde6fc0eae1b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Sat, 12 Dec 2015 16:16:50 +0100 Subject: [PATCH 2/4] flexible paths for docker.socket as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- tests/3_docker_daemon_configuration_files.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/3_docker_daemon_configuration_files.sh b/tests/3_docker_daemon_configuration_files.sh index 04367c5..8865ceb 100644 --- a/tests/3_docker_daemon_configuration_files.sh +++ b/tests/3_docker_daemon_configuration_files.sh @@ -65,7 +65,7 @@ fi # 3.5 check_3_5="3.5 - Verify that docker.socket file ownership is set to root:root" -file="/usr/lib/systemd/system/docker.socket" +file="$(get_systemd_service_file docker.socket)" if [ -f "$file" ]; then if [ "$(stat -c %u%g $file)" -eq 00 ]; then pass "$check_3_5" @@ -80,7 +80,7 @@ fi # 3.6 check_3_6="3.6 - Verify that docker.socket file permissions are set to 644" -file="/usr/lib/systemd/system/docker.socket" +file="$(get_systemd_service_file docker.socket)" if [ -f "$file" ]; then if [ "$(stat -c %a $file)" -eq 644 ]; then pass "$check_3_6" From e19f997b3f9054263ad3339ba4d30243248da66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Sat, 12 Dec 2015 16:57:40 +0100 Subject: [PATCH 3/4] if systemctl show fails, use /usr/lib/systemd/system/ path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- helper_lib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helper_lib.sh b/helper_lib.sh index 69ba6ee..ed966ab 100644 --- a/helper_lib.sh +++ b/helper_lib.sh @@ -88,5 +88,11 @@ get_docker_effective_command_line_args() { get_systemd_service_file(){ SERVICE="$1" - systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' + + systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2 + if [ $? -eq 0 ]; then + systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' + else + echo "/usr/lib/systemd/system/$SERVICE" + fi } From 4e414f51ef4ad64dee3c7747d0e78ab53c1f80b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Mon, 14 Dec 2015 20:27:10 +0100 Subject: [PATCH 4/4] check /etc/systemd/system/ before systemctl, /usr/lib/systemd/ fallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- helper_lib.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/helper_lib.sh b/helper_lib.sh index ed966ab..74c8849 100644 --- a/helper_lib.sh +++ b/helper_lib.sh @@ -89,10 +89,11 @@ get_docker_effective_command_line_args() { get_systemd_service_file(){ SERVICE="$1" - systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2 - if [ $? -eq 0 ]; then - systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' + if [ -f "/etc/systemd/system/$SERVICE" ]; then + echo "/etc/systemd/system/$SERVICE" + elif systemctl show -p FragmentPath "$SERVICE" 2> /dev/null 1>&2; then + systemctl show -p FragmentPath "$SERVICE" | sed 's/.*=//' else - echo "/usr/lib/systemd/system/$SERVICE" + echo "/usr/lib/systemd/system/$SERVICE" fi }