CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/docker/entrypoint.sh
Views: 1903
1
#!/bin/bash
2
3
MSF_USER=msf
4
MSF_GROUP=msf
5
TMP=${MSF_UID:=1000}
6
TMP=${MSF_GID:=1000}
7
8
# if the user starts the container as root or another system user,
9
# don't use a low privileged user as we mount the home directory
10
if [ "$MSF_UID" -eq "0" ]; then
11
"$@"
12
else
13
# if the users group already exists, create a random GID, otherwise
14
# reuse it
15
if ! getent group $MSF_GID > /dev/null; then
16
addgroup -g $MSF_GID $MSF_GROUP
17
else
18
addgroup $MSF_GROUP
19
fi
20
21
# check if user id already exists
22
if ! getent passwd $MSF_UID > /dev/null; then
23
adduser -u $MSF_UID -D $MSF_USER -g $MSF_USER -G $MSF_GROUP $MSF_USER
24
# add user to metasploit group so it can read the source
25
addgroup $MSF_USER $METASPLOIT_GROUP
26
su-exec $MSF_USER "$@"
27
# fall back to root exec if the user id already exists
28
else
29
"$@"
30
fi
31
fi
32
33