Skip to content

Commit

Permalink
Make sure that COSMOS_BASE is only readable
Browse files Browse the repository at this point in the history
by root since it's possible that the directory
can contain files that after applying the
overlay to / only should be read or writable
by root.
  • Loading branch information
Gijutsu committed Nov 17, 2023
1 parent 75e566a commit 8d4ce2d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions global/post-tasks.d/014set-cosmos-permissions
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
#
# Set Cosmos directory permissions so that
# the files cannot be read by anyone but root,
# since it's possible that the directory
# can contain files that after applying the
# overlay to / only should be read or writable
# by root.

set -e
self=$(basename "$0")

if ! test -d "$COSMOS_BASE"; then
test -z "$COSMOS_VERBOSE" || echo "$self: COSMOS_BASE was not found. Aborting change of permissions."
exit 0
fi

args=""
if [ "x$COSMOS_VERBOSE" = "xy" ]; then
args="-v"
fi

chown ${args} root:root "$COSMOS_BASE"
chmod ${args} 750 "$COSMOS_BASE"
24 changes: 24 additions & 0 deletions global/pre-tasks.d/014set-cosmos-permissions
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
#
# Set Cosmos directory permissions so that
# the files cannot be read by anyone but root,
# since it's possible that the directory
# can contain files that after applying the
# overlay to / only should be read or writable
# by root.

set -e
self=$(basename "$0")

if ! test -d "$COSMOS_BASE"; then
test -z "$COSMOS_VERBOSE" || echo "$self: COSMOS_BASE was not found. Aborting change of permissions."
exit 0
fi

args=""
if [ "x$COSMOS_VERBOSE" = "xy" ]; then
args="-v"
fi

chown ${args} root:root "$COSMOS_BASE"
chmod ${args} 750 "$COSMOS_BASE"

0 comments on commit 8d4ce2d

Please sign in to comment.