Files
metasploit-gs/docker/entrypoint.sh
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
830 B
Bash
Raw Normal View History

2018-02-17 20:12:35 +01:00
#!/bin/bash
MSF_USER=msf
MSF_GROUP=msf
TMP=${MSF_UID:=1000}
TMP=${MSF_GID:=1000}
2018-10-21 22:30:01 +02:00
# if the user starts the container as root or another system user,
# don't use a low privileged user as we mount the home directory
if [ "$MSF_UID" -eq "0" ]; then
"$@"
else
# if the users group already exists, create a random GID, otherwise
# reuse it
2023-10-18 15:38:21 +02:00
if ! getent group $MSF_GID > /dev/null; then
2018-10-21 22:30:01 +02:00
addgroup -g $MSF_GID $MSF_GROUP
else
addgroup $MSF_GROUP
fi
2018-02-17 20:12:35 +01:00
2018-10-21 22:30:01 +02:00
# check if user id already exists
2023-10-18 15:38:21 +02:00
if ! getent passwd $MSF_UID > /dev/null; then
2018-10-21 22:30:01 +02:00
adduser -u $MSF_UID -D $MSF_USER -g $MSF_USER -G $MSF_GROUP $MSF_USER
# add user to metasploit group so it can read the source
addgroup $MSF_USER $METASPLOIT_GROUP
su-exec $MSF_USER "$@"
# fall back to root exec if the user id already exists
else
"$@"
fi
2018-02-17 20:12:35 +01:00
fi