Skip to content

Commit

Permalink
net-p2p/deluge-cli: correct deluge_web rc-script
Browse files Browse the repository at this point in the history
From the PR:
The rc.d script for deluge_web outright disrespects a user's home directory and
instead tries to execute against hardcoded /home/${deluge_web_user} paths. This
is invalid and dangerous behavior. When running as a user, the user's home
directory must be respected. The attached patch fixes this behavior as a break-fix.

PR:		234902
Submitted by:	Phillip R. Jaenke <[email protected]>
  • Loading branch information
mexicarne committed Mar 5, 2019
1 parent 997b403 commit 10a8527
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion net-p2p/deluge-cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PORTNAME= deluge
DISTVERSIONPREFIX= ${PORTNAME}-
DISTVERSION= 1.3.15
PORTREVISION= 7
PORTREVISION= 8
CATEGORIES= net-p2p python
PKGNAMESUFFIX= -cli

Expand Down
16 changes: 10 additions & 6 deletions net-p2p/deluge-cli/files/deluge_web.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ command_interpreter=%%PYTHON_CMD%%
start_precmd=${name}_prestart
stop_postcmd=${name}_poststop


deluge_web_prestart()
{
if [ "$deluge_web_user" = 'asjklasdfjklasdf' ]; then
err 1 "You must set deluge_web_user to a real, unprivileged user"
fi
deluge_web_home=$(pw user show ${deluge_web_user} | cut -d : -f 9)
if [ -z ${deluge_web_home} ]; then
err 1 "deluge_web_user does not have a valid home directory."
fi

if [ ! -d "/var/run/${name}" ]; then
if [ -e "/var/run/${name}" ]; then
Expand All @@ -52,14 +57,13 @@ deluge_web_prestart()
mkdir -p /var/run/${name}
fi

if [ ! -d "/home/${deluge_web_user}/.python-eggs" ]; then
mkdir -p /home/${deluge_web_user}/.python-eggs
fi
if [ ! -d "${deluge_web_home}/.python-eggs" ]; then
mkdir ${deluge_web_home}/.python-eggs
chown -R $deluge_web_user ${deluge_web_home}/.python-eggs

chmod 0755 /var/run/${name}
chown -R $deluge_web_user /var/run/${name}
chown -R $deluge_web_user /home/${deluge_web_user}/.python-eggs
export PYTHON_EGG_CACHE="/home/${deluge_web_user}/.python-eggs"
export PYTHON_EGG_CACHE="${deluge_web_home}/.python-eggs"
}

deluge_web_poststop()
Expand All @@ -72,7 +76,7 @@ load_rc_config $name

: ${deluge_web_enable:="NO"}
: ${deluge_web_user:="asjklasdfjklasdf"}
: ${deluge_web_confdir:="/home/${deluge_web_user}/.config/deluge"}
: ${deluge_web_confdir:="${deluge_web_home}/.config/deluge"}
: ${deluge_web_loglevel:="error"}
: ${deluge_web_logfile:="/var/tmp/${name}.log"}

Expand Down

0 comments on commit 10a8527

Please sign in to comment.