diff options
author | feld <feld@FreeBSD.org> | 2014-05-19 21:04:08 +0800 |
---|---|---|
committer | feld <feld@FreeBSD.org> | 2014-05-19 21:04:08 +0800 |
commit | 3a97f1e5d4fbb97a0935f5fac492c43133d4fdee (patch) | |
tree | 8c3f9f4134edc3010b8b8befe41ab19bd3d7a03d /net | |
parent | a55550521e9f8aa87e6a2e39205cbd4f622491ed (diff) | |
download | freebsd-ports-gnome-3a97f1e5d4fbb97a0935f5fac492c43133d4fdee.tar.gz freebsd-ports-gnome-3a97f1e5d4fbb97a0935f5fac492c43133d4fdee.tar.zst freebsd-ports-gnome-3a97f1e5d4fbb97a0935f5fac492c43133d4fdee.zip |
Overhaul of rc script which was non-functional
Most notable change is the renaming of $samplicator_user to
$samplicator_runas. The reasoning is that the usage of daemon(8) and
$name_user does not mix well; it resulted in the following:
_doit='su -m $name_user -c '\''sh -c "/usr/sbin/daemon -u $name_user ..."
This defeats the purpose of daemon which has to be launched as root.
Sponsored by: SupraNet Communications, Inc
Diffstat (limited to 'net')
-rw-r--r-- | net/samplicator/Makefile | 2 | ||||
-rw-r--r-- | net/samplicator/files/samplicator.in | 49 |
2 files changed, 24 insertions, 27 deletions
diff --git a/net/samplicator/Makefile b/net/samplicator/Makefile index 3fc16137b4e7..7dd46743a61c 100644 --- a/net/samplicator/Makefile +++ b/net/samplicator/Makefile @@ -2,7 +2,7 @@ PORTNAME= samplicator PORTVERSION= 1.3.7.b6 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net MASTER_SITES= ${MASTER_SITE_GOOGLE_CODE} MASTER_SITE_SUBDIR= samplicator diff --git a/net/samplicator/files/samplicator.in b/net/samplicator/files/samplicator.in index 8ef5bb52d66f..de0f6094ca01 100644 --- a/net/samplicator/files/samplicator.in +++ b/net/samplicator/files/samplicator.in @@ -11,13 +11,13 @@ # samplicator_enable="YES" # # optional # samplicator_flags="-S -p 2055 -c %%PREFIX%%/etc/samplicator.conf" -# samplicator_user="nobody" +# samplicator_runas="nobody" # # The default is to run samplicator as nobody, which will prevent you from # using the -S flag (maintain (spoof) source addresses). # If you want to maintain (spoof) source addresses, you will need to run as # root. -# This can be accomplished by adding samplicator_user="root" to /etc/rc.conf +# This can be accomplished by adding samplicator_runas="root" to /etc/rc.conf . /etc/rc.subr @@ -26,45 +26,42 @@ rcvar=samplicator_enable load_rc_config $name # Set defaults -samplicator_enable=${samplicator_enable:-"NO"} -samplicator_flags=${samplicator_flags:-"-p 2055 -c %%PREFIX%%/etc/samplicator.conf"} -samplicator_user=${samplicator_user:-"nobody"} +: ${samplicator_enable:=NO} +: ${samplicator_flags="-p 2055 -c %%PREFIX%%/etc/samplicator.conf"} +: ${samplicator_runas:=nobody} pidfile=/var/run/samplicator.pid -command=%%PREFIX%%/bin/samplicate +procname="%%PREFIX%%/bin/samplicate" +command=/usr/sbin/daemon +command_args=" -cf -p ${pidfile} -u ${samplicator_runas} ${procname} ${samplicator_flags}" required_files=%%PREFIX%%/etc/samplicator.conf start_precmd=samplicator_precmd -start_cmd=samplicator_start -stop_postcmd=samplicator_cleanup +stop_postcmd="[ -f ${pidfile} ] && rm ${pidfile}" samplicator_precmd() { - # since we are using daemon(1) to drop privs, we cannot let samplicator fork - %%ECHO%% "${samplicator_flags}" | %%EGREP%% -q "(^\-f| \-f)" 2>&1 > /dev/null + # bypass rc_flags as we use samplicator_flags directly via daemon(8) + rc_flags="" + + # create empty pidfile with correct permissions + install -o ${samplicator_runas} /dev/null ${pidfile} + + # since we are using daemon(8) to drop privs, we cannot let samplicator fork + echo "${samplicator_flags}" | egrep -q "(^\-f| \-f)" if [ $? -eq 0 ]; then - %%ECHO%% "Please remove parameter -f from samplicator_flags" - %%ECHO%% + echo "Please remove parameter -f from samplicator_flags" + echo return 1 fi # root is required for -S, do a pre-launch sanity check - %%ECHO%% "${samplicator_flags}" | %%EGREP%% -q "(^\-S| \-S)" 2>&1 > /dev/null - if [ $? -eq 0 && ${samplicator_user} -ne "root" ]; then - %%ECHO%% "-S requires that samplicator_user be set to root." - %%ECHO%% + echo "${samplicator_flags}" | egrep -q "(^\-S| \-S)" + if [ $? -eq 0 ] && [ $(id -u ${samplicator_runas}) -ne 0 ]; then + echo "-S requires that samplicator_runas be set to root." + echo return 1 fi } -samplicator_start() { - echo "Starting samplicator." - %%TOUCH%% ${pidfile} && %%CHOWN%% ${samplicator_user} ${pidfile} - /usr/sbin/daemon -cf -p ${pidfile} -u ${samplicator_user} ${command} ${samplicator_flags} -} - -samplicator_cleanup() { - [ -f ${pidfile} ] && %%RM%% ${pidfile} -} - run_rc_command "$1" |