[ANSWERED] Problem with TRANSMISSION_HOME

Ask for help and report issues not specific to either the Mac OS X or GTK+ versions of Transmission
Locked
nickh
Posts: 6
Joined: Sat Apr 30, 2011 9:21 am

[ANSWERED] Problem with TRANSMISSION_HOME

Post by nickh »

Hi,
I've been using transmission on ClearOS (a CentOS derivative) for a while now (v1.92?) which I installed a while back using a standard user "transmission" with a home folder of /home/transmission. There is now an rpm for ClearOS using v2.22. The rpm uses a home of /var/lib/transmission and has an init script to use this home - here is a cut down version:

Code: Select all

#!/bin/bash
# source function library
. /etc/rc.d/init.d/functions

# Defaults
TRANSMISSION_HOME="/var/lib/transmission"
DAEMON_ARGS="-b -t -a \"*.*.*.*\" -e /var/log/transmission/transmission.log"

# Configuration overrides
[ -e /etc/sysconfig/transmission-daemon ] && source /etc/sysconfig/transmission-daemon

# Daemon
NAME="transmission-daemon"

# Environment
DAEMON="/usr/bin/transmission-daemon"
DAEMON_USER="transmission"
DAEMON_PROCESS="transmission-daemon"
DAEMON_PIDFILE="/var/run/$NAME.pid"
DAEMON_LOCKFILE="/var/lock/subsys/$NAME"

[ -x "$DAEMON" ] || exit 0

PIDFILE="/var/run/$DAEMON_PROCESS.pid"
RETVAL=0
prog="transmission-daemon"

# See how we were called.
case "$1" in
  start)
	echo -n $"Starting $prog: "

	if [ -n "$TRANSMISSION_HOME" ]; then
		export TRANSMISSION_HOME
	fi

	daemon --check $DAEMON --user "$DAEMON_USER" --pidfile $PIDFILE $DAEMON $DAEMON_ARGS	RETVAL=$?

	if [ $RETVAL = 0 ]; then
		touch $DAEMON_LOCKFILE
		/sbin/pidof -o %PPID -x $NAME > $DAEMON_PIDFILE
	fi

	echo
	;;

[snip]

exit $RETVAL
When this starts transmission-daemon the settings.json and other folders are created under /home/transmission and not /var/lib/transmission. It is like transmission is ignoring the setting of TRANSMISSION_HOME and using the home folder instead. Is this correct?

I know I can override it with the -g switch but I don't see that I should have to.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

nickh wrote:transmission is ignoring the setting of TRANSMISSION_HOME and using the home folder instead. Is this correct?
No. Did you check /etc/sysconfig/transmission-daemon? it could be changing TRANSMISSION_HOME.

Otherwise only a modified Transmission would not follow (comments from the code):

Code: Select all

 Transmission's default configuration file directory.
 *
 * The default configuration directory is determined this way:
 * -# If the TRANSMISSION_HOME environment variable is set, its value is used.
 * -# On Darwin, "${HOME}/Library/Application Support/${appname}" is used.
 * -# On Windows, "${CSIDL_APPDATA}/${appname}" is used.
 * -# If XDG_CONFIG_HOME is set, "${XDG_CONFIG_HOME}/${appname}" is used.
 * -# ${HOME}/.config/${appname}" is used as a last resort.
nickh
Posts: 6
Joined: Sat Apr 30, 2011 9:21 am

Re: Problem with TRANSMISSION_HOME

Post by nickh »

I had checked /etc/sysconfig/transmission-daemon and it is effectively empty:

Code: Select all

# Username/password example
# DAEMON_ARGS="-b -t -a \"*.*.*.*\" -e /var/log/transmission/transmission.log"

# No username/password, but limited to 192.168.1.*
# DAEMON_ARGS="-b -T -a \"192.168.1.*\" -e /var/log/transmission/transmission.log"
Is the usage in the init script OK? It seems OK to me but I am relatively new to linux.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

nickh wrote:Is the usage in the init script OK?
Looks fine to me too.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

You could test renaming your current settings.json and after starting the daemon see where the new one is created.

If it is still not using TRANSMISSION_HOME then it could be a bug. I've never used TRANSMISSION_HOME so I haven't noticed (my start script uses -g).
nickh
Posts: 6
Joined: Sat Apr 30, 2011 9:21 am

Re: Problem with TRANSMISSION_HOME

Post by nickh »

What you suggest is what I did while trying to track down the issue - stop transmission-daemon, delete settings.json, start transmission-daemon with the init script. A new settings.json was created in /home/transmission/.config/transmission-daemon rather than /var/lib/transmission/.config/transmission-daemon as I expected.

If it is a bug, does it have to be formally reported or is this thread good enough?
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

I would report it in Trac. You do have to register and login before creating a new report (the link doesn't appear before).
nickh
Posts: 6
Joined: Sat Apr 30, 2011 9:21 am

Re: Problem with TRANSMISSION_HOME

Post by nickh »

Ticket is now submitted awaiting moderation.
Jordan
Transmission Developer
Posts: 2312
Joined: Sat May 26, 2007 3:39 pm
Location: Titania's Room

Re: Problem with TRANSMISSION_HOME

Post by Jordan »

It doesn't appear to be a Transmission bug:
$ ./transmission-daemon -f 2>&1 | grep "Using settings"
[20:40:40.705] Using settings from "/home/jordan/.config/transmission-daemon" (daemon.c:489)
^C
$ export TRANSMISSION_HOME=/tmp/transmission-test
$ ./transmission-daemon -f 2>&1 | grep "Using settings"
[20:40:51.724] Using settings from "/tmp/transmission-test" (daemon.c:489)
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

The same information can be obtained from a running daemon by:

Code: Select all

transmission-remote -si | grep Configuration
but that doesn't solve the problem.

What is the difference of daemon on the script, and the usual start-stop-daemon which is what I use?

Does daemon pass the environment? even when changing users? (I'm not even sure this is true for start-stop-daemon) That is the main difference between Jordan's test and using the script shown.
nickh
Posts: 6
Joined: Sat Apr 30, 2011 9:21 am

Re: Problem with TRANSMISSION_HOME

Post by nickh »

Thanks for the responses. This is the daemon script (part of /etc/init.d/functions)

Code: Select all

# A function to start a program.
daemon() {
	# Test syntax.
	local gotbase= force= nicelevel corelimit
	local pid base= user= nice= bg= pid_file=
	nicelevel=0
	while [ "$1" != "${1##[-+]}" ]; do
	  case $1 in
	    '')    echo $"$0: Usage: daemon [+/-nicelevel] {program}"
	           return 1;;
	    --check)
		   base=$2
		   gotbase="yes"
		   shift 2
		   ;;
	    --check=?*)
	    	   base=${1#--check=}
		   gotbase="yes"
		   shift
		   ;;
	    --user)
		   user=$2
		   shift 2
		   ;;
	    --user=?*)
	           user=${1#--user=}
		   shift
		   ;;
	    --pidfile)
		   pid_file=$2
		   shift 2
		   ;;
	    --pidfile=?*)
		   pid_file=${1#--pidfile=}
		   shift
		   ;;
	    --force)
	    	   force="force"
		   shift
		   ;;
	    [-+][0-9]*)
	    	   nice="nice -n $1"
	           shift
		   ;;
	    *)     echo $"$0: Usage: daemon [+/-nicelevel] {program}"
	           return 1;;
	  esac
	done

        # Save basename.
        [ -z "$gotbase" ] && base=${1##*/}

        # See if it's already running. Look *only* at the pid file.
	__pids_var_run "$base" "$pid_file"

	[ -n "$pid" -a -z "$force" ] && return

	# make sure it doesn't core dump anywhere unless requested
	corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
	
	# if they set NICELEVEL in /etc/sysconfig/foo, honor it
	[ -n "${NICELEVEL:-}" ] && nice="nice -n $NICELEVEL"
	
	# Echo daemon
        [ "${BOOTUP:-}" = "verbose" -a -z "${LSB:-}" ] && echo -n " $base"

	# And start it up.
	if [ -z "$user" ]; then
	   $nice /bin/bash -c "$corelimit >/dev/null 2>&1 ; $*"
	else
	   $nice runuser -s /bin/bash - $user -c "$corelimit >/dev/null 2>&1 ; $*"
	fi
	[ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
}
I don't know if this helps. What it is exactly doing is beyond my knowledge.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: Problem with TRANSMISSION_HOME

Post by rb07 »

It runs something else... runuser, which has:
-m, --preserve-environment
.......do not reset environment variables
-p
.......same as -m
which is not used in the daemon function, so it doesn't propagate TRANSMISSION_HOME.
Locked