net-ops/global/pre-tasks.d/015set-overlay-permissions
John Van de Meulebrouck Brendgard 75e566ab61
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.
2023-11-17 14:58:51 +01:00

31 lines
649 B
Bash
Executable file

#!/bin/sh
#
# Set overlay file permissions in model directory before apply.d/60overlay
# rsyncs it to /
#
set -e
self=$(basename "$0")
MODEL_OVERLAY="$COSMOS_MODEL/overlay"
if ! test -d "$MODEL_OVERLAY"; then
test -z "$COSMOS_VERBOSE" || echo "$self: overlay is a no-op"
exit 0
fi
args=""
if [ "x$COSMOS_VERBOSE" = "xy" ]; then
args="-v"
fi
if [ -d "$MODEL_OVERLAY/root" ]; then
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