svn commit: r354537 - in head/net/samplicator: . files
Mark Felder
feld at FreeBSD.org
Mon May 19 13:04:09 UTC 2014
Author: feld
Date: Mon May 19 13:04:08 2014
New Revision: 354537
URL: http://svnweb.freebsd.org/changeset/ports/354537
QAT: https://qat.redports.org/buildarchive/r354537/
Log:
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
Modified:
head/net/samplicator/Makefile
head/net/samplicator/files/samplicator.in
Modified: head/net/samplicator/Makefile
==============================================================================
--- head/net/samplicator/Makefile Mon May 19 12:55:10 2014 (r354536)
+++ head/net/samplicator/Makefile Mon May 19 13:04:08 2014 (r354537)
@@ -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
Modified: head/net/samplicator/files/samplicator.in
==============================================================================
--- head/net/samplicator/files/samplicator.in Mon May 19 12:55:10 2014 (r354536)
+++ head/net/samplicator/files/samplicator.in Mon May 19 13:04:08 2014 (r354537)
@@ -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"
More information about the svn-ports-head
mailing list