Possible problem with the ${name}_chdir variable behaviour in /etc/c.subr
Tim Preston
graywolfe at mac.com
Sun Mar 20 18:51:40 UTC 2016
I was having a problem making the audio/teamspeak3-server port start fro the rc.d scripts on a -current box that I’ve just built. I eventually traced this down to it not starting in the correct directory.
Looking at the rc.d script I could see that it was attempting to chdir to the correct directory by setting the teamspeak_chdir variable. So it looked like this feature was misbehaving in some way.
To test this I put together an rc.d script for pwd that used ${name}_chdir based on how the teamspeak rc.d script was setup. Running this on a 10.3 box showed that it was changing to the specified directory as expected, but on -current it was not.
I’ve taken a quick look at rc.subr on both boxes but I can’t immediately see what’s breaking this, and I can’t see anything in the setup or behaviour of the -current box that would point to it being something that I’ve broken somehow there.
I was wondering if anyone else could reproduce this?
Simple rc.d script for pwd
-----
#!/bin/sh
# PROVIDE: pwd
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
name="pwd"
rcvar=pwd_enable
db_dir=/var/db/teamspeak
command=/bin/pwd
pwd_chdir=$db_dir
required_dirs="$db_dir"
load_rc_config $name
: ${pwd_enable="NO"}
run_rc_command "$1"
-----
Running on 10.3 shows the expected result
-----
root at amy:~# uname -a
FreeBSD amy.flibble.org 10.3-BETA3 FreeBSD 10.3-BETA3 #3 r296346: Thu Mar 3 15:09:55 GMT 2016 root at amy:/usr/obj/usr/src/sys/GENERIC amd64
root at amy:~# grep FreeBSD /etc/rc.subr
# $FreeBSD: stable/10/etc/rc.subr 292450 2015-12-18 19:58:34Z rilles $
root at amy:~# ls -ld /var/db/teamspeak
drwxr-xr-x 3 teamspeak teamspeak 512 Mar 20 00:23 /var/db/teamspeak
root at amy:~# sum /usr/local/etc/rc.d/pwd
33073 1 /usr/local/etc/rc.d/pwd
root at amy:~# service pwd onestart
Starting pwd.
/var/db/teamspeak
-----
On -current we see that were still in /
-----
root at emily:~# uname -a
FreeBSD emily.flibble.org 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r297022: Fri Mar 18 15:18:44 UTC 2016 root at emily.flibble.org:/usr/obj/usr/src/sys/GENERIC amd64
root at emily:~# grep FreeBSD /etc/rc.subr
# $FreeBSD: head/etc/rc.subr 295949 2016-02-24 01:32:12Z araujo $
root at amy:~# ls -ld /var/db/teamspeak
drwxr-xr-x 3 teamspeak teamspeak 512 Mar 20 00:23 /var/db/teamspeak
root at emily:~# sum /usr/local/etc/rc.d/pwd
33073 1 /usr/local/etc/rc.d/pwd
root at emily:~# service pwd onestart
Starting pwd.
/
-----
--
Tim Preston
graywolfe at mac.com
More information about the freebsd-current
mailing list