#!/bin/bash12MSF_USER=msf3MSF_GROUP=msf4TMP=${MSF_UID:=1000}5TMP=${MSF_GID:=1000}67# if the user starts the container as root or another system user,8# don't use a low privileged user as we mount the home directory9if [ "$MSF_UID" -eq "0" ]; then10"$@"11else12# if the users group already exists, create a random GID, otherwise13# reuse it14if ! getent group $MSF_GID > /dev/null; then15addgroup -g $MSF_GID $MSF_GROUP16else17addgroup $MSF_GROUP18fi1920# check if user id already exists21if ! getent passwd $MSF_UID > /dev/null; then22adduser -u $MSF_UID -D $MSF_USER -g $MSF_USER -G $MSF_GROUP $MSF_USER23# add user to metasploit group so it can read the source24addgroup $MSF_USER $METASPLOIT_GROUP25su-exec $MSF_USER "$@"26# fall back to root exec if the user id already exists27else28"$@"29fi30fi313233