Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

entrypoint.sh 844B

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