From 75e566ab61fe9d485a70f3066084705c720315b2 Mon Sep 17 00:00:00 2001 From: John Van de Meulebrouck Brendgard Date: Fri, 17 Nov 2023 14:58:51 +0100 Subject: [PATCH] Make sure that /root in overlay is owned by root as well as that /root/.ssh and its content is only owned and readable by root. This is redundant if the previous permissions were properly applied and no other changes have been made by the user or something else, but is added for good measure as a layered defense. --- global/pre-tasks.d/015set-overlay-permissions | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/global/pre-tasks.d/015set-overlay-permissions b/global/pre-tasks.d/015set-overlay-permissions index 37f9844..205180b 100755 --- a/global/pre-tasks.d/015set-overlay-permissions +++ b/global/pre-tasks.d/015set-overlay-permissions @@ -14,10 +14,17 @@ if ! test -d "$MODEL_OVERLAY"; then exit 0 fi +args="" +if [ "x$COSMOS_VERBOSE" = "xy" ]; then + args="-v" +fi + if [ -d "$MODEL_OVERLAY/root" ]; then - args="" - if [ "x$COSMOS_VERBOSE" = "xy" ]; then - args="-v" - fi + chown ${args} root:root "$MODEL_OVERLAY"/root chmod ${args} 0700 "$MODEL_OVERLAY"/root fi + +if [ -d "$MODEL_OVERLAY/root/.ssh" ]; then + chown ${args} -R root:root "$MODEL_OVERLAY"/root/.ssh + chmod ${args} 0700 "$MODEL_OVERLAY"/root/.ssh +fi