Skip to content

Commit

Permalink
[postinst] Make dd-agent user and group own /opt/datadog-agent (#97)
Browse files Browse the repository at this point in the history
Users of the Agent can then give no permissions at all to other users
on the `/opt/datadog-agent` directory (which is the home directory of
`dd-agent`), and the Agent can still work fine and not break the users'
changes on upgrade.

Also, on debian, set the home directory of `dd-agent` to
`/opt/datadog-agent` directly on the `adduser` call, for the sake of
brevity.
  • Loading branch information
olivielpeau authored Oct 27, 2016
1 parent 20a2649 commit 31d7044
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions package-scripts/datadog-agent/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ if [ "$DISTRIBUTION" != "Darwin" ]; then
set -e
if [ ! $USER_EXISTS -eq 0 ]; then
echo "Creating dd-agent user"
adduser --system dd-agent --disabled-login --shell /bin/sh --no-create-home --group --quiet
usermod -d /opt/datadog-agent dd-agent
adduser --system dd-agent --disabled-login --shell /bin/sh --home ${INSTALL_DIR} --no-create-home --group --quiet
elif id -nG dd-agent | grep --invert-match --word-regexp --quiet 'dd-agent'; then
# User exists but is not part of the dd-agent group
echo "Adding dd-agent user to dd-agent group"
Expand All @@ -71,8 +70,7 @@ if [ "$DISTRIBUTION" != "Darwin" ]; then
chown -R dd-agent:root ${CONFIG_DIR}
chown -R dd-agent:root ${LOG_DIR}
chown root:root /etc/init.d/datadog-agent
chown -R root:root /opt/datadog-agent
chown -R dd-agent:root ${RUN_DIR}
chown -R dd-agent:dd-agent ${INSTALL_DIR}

if command -v chkconfig >/dev/null 2>&1; then
chkconfig --add datadog-agent
Expand Down

0 comments on commit 31d7044

Please sign in to comment.