Skip to content

Commit

Permalink
Add mask and group ownership to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehdi-Bendriss committed Feb 5, 2024
1 parent 6f1dc9d commit b4324fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 4 additions & 3 deletions snap/hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sed -i "s:/var/lib/mongodb:$SNAP_COMMON/var/lib/mongodb:g" $MONGO_CONFIG_FILE
sed -i "s:/var/run:/tmp:g" $MONGO_CONFIG_FILE

# Change ownership of snap directories to allow snap_daemon to read/write
chown -R 584788:root ${SNAP_DATA}/*
chown -R 584788:root ${SNAP_COMMON}/*

chown -R 584788:root "${SNAP_DATA}"/*
chown -R 584788:root "${SNAP_COMMON}"/*
chgrp root "${SNAP_COMMON}/var/log/"*
chmod g+s "${SNAP_COMMON}/var/log/"*
13 changes: 11 additions & 2 deletions snap/local/start-mongod.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

# For security measures, daemons should not be run as sudo. Execute mongod as the non-sudo user: snap-daemon.
exec $SNAP/usr/bin/setpriv --clear-groups --reuid snap_daemon \
--regid snap_daemon -- $SNAP/usr/bin/mongod --config ${SNAP_DATA}/etc/mongod/mongod.conf ${MONGOD_ARGS} "$@"
exec \
"${SNAP}/usr/bin/setpriv" \
--clear-groups \
--reuid snap_daemon \
--regid snap_daemon \
-- \
"${SNAP}/usr/bin/mongod" \
--config "${SNAP_DATA}/etc/mongod/mongod.conf" \
--setParameter processUmask=037 \
"${MONGOD_ARGS}" \
"$@"

0 comments on commit b4324fe

Please sign in to comment.