change virtualenv logic. umask -> 0022

This commit is contained in:
Michel Oosterhof 2017-12-27 09:29:37 +04:00
parent ab83da8978
commit 98d0c49456
1 changed files with 16 additions and 14 deletions

View File

@ -2,8 +2,9 @@
#Change the below to yes if you are using authbind to listen to port 22 #Change the below to yes if you are using authbind to listen to port 22
AUTHBIND_ENABLED=no AUTHBIND_ENABLED=no
#Change the below to change default "cowrie-env" virtual environment # To override the default virtual enviroment, either set COWRIE_VIRTUAL_ENV or
COWRIE_VIRTUAL_ENV=cowrie-env # activate it before starting Cowrie
#COWRIE_VIRTUAL_ENV=my-env
#Change the below to -n to disable daemonizing (for instance when using supervisor) #Change the below to -n to disable daemonizing (for instance when using supervisor)
DAEMONIZE="" DAEMONIZE=""
@ -12,6 +13,9 @@ DAEMONIZE=""
## don't modify below here ## ## don't modify below here ##
################################################################################ ################################################################################
# The default Python virtual environment is "cowrie-env". If you set the variable
# COWRIE_VIRTUAL_ENV you can override this
DEFAULT_VIRTUAL_ENV=cowrie-env
find_cowrie_directory() { find_cowrie_directory() {
# Determine Cowrie directory # Determine Cowrie directory
@ -27,18 +31,12 @@ find_cowrie_directory() {
activate_venv() { activate_venv() {
# Activate Python virtual environment # Activate Python virtual environment
VENV="$1" VENV="$1"
if [ ! -d "$VENV" ]
then
echo "The specified virtualenv \"$VENV\" was not found!"
exit 1
fi
if [ ! -f "$VENV/bin/activate" ] if [ ! -f "$VENV/bin/activate" ]
then then
echo "The specified virtualenv \"$VENV\" was not found!" return 1
exit 2
fi fi
echo "Activating virtualenv \"$VENV\""
. $VENV/bin/activate . $VENV/bin/activate
return 0
} }
cowrie_status() { cowrie_status() {
@ -60,7 +58,7 @@ cowrie_status() {
cowrie_start() { cowrie_start() {
# Start Cowrie # Start Cowrie
COWRIEARGS="$*" COWRIEARGS="$*"
TWISTEDARGS="${DAEMONIZE} ${XARGS} --umask 0007 --pidfile ${PIDFILE}" TWISTEDARGS="${DAEMONIZE} ${XARGS} --umask 0022 --pidfile ${PIDFILE}"
# For Docker log to stdout, for non-Docker log to file # For Docker log to stdout, for non-Docker log to file
if [ "$DOCKER" = "yes" ]; then if [ "$DOCKER" = "yes" ]; then
@ -70,9 +68,13 @@ cowrie_start() {
fi fi
if [ ! -z "$VIRTUAL_ENV" ]; then if [ ! -z "$VIRTUAL_ENV" ]; then
echo "Found existing Python virtual environment \"$VIRTUAL_ENV\"" echo 2>&1 "Using activated Python virtual environment \"$VIRTUAL_ENV\""
elif [ ! -z "$COWRIE_VIRTUAL_ENV" ]; then elif activate_venv "$COWRIE_VIRTUAL_ENV"; then
activate_venv "$COWRIE_VIRTUAL_ENV" echo 2>&1 "Using custom Python virtual environment \"$VIRTUAL_ENV\""
elif activate_venv "$DEFAULT_VIRTUAL_ENV"; then
echo 2>&1 "Using default Python virtual environment \"$VIRTUAL_ENV\""
else
echo 2>&1 "Not using Python virtual environment"
fi fi
echo "Starting cowrie: [twistd ${TWISTEDARGS} cowrie ${COWRIEARGS}]..." echo "Starting cowrie: [twistd ${TWISTEDARGS} cowrie ${COWRIEARGS}]..."