diff options
author | Mark Felder <feld@FreeBSD.org> | 2014-05-19 13:04:08 +0000 |
---|---|---|
committer | Mark Felder <feld@FreeBSD.org> | 2014-05-19 13:04:08 +0000 |
commit | 49748d6df2be2b323076f3156d2595755b72025f (patch) | |
tree | 8c3f9f4134edc3010b8b8befe41ab19bd3d7a03d /net/samplicator | |
parent | 9b8fa99c533909eeb84d724ad7f034cfb8732b34 (diff) |
Notes
Diffstat (limited to 'net/samplicator')
-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" |