Browse Source

Add a small comment at the top to explain what this file does.

Use $() constructs as it's safer than ``.
Both req. by deraadt@
Use pkill instead of pgrep in rc_check so that we don't need to fiddle
with redirections in reload.
prodded by schwarze@
ok robert@
OPENBSD_5_0
ajacoutot 13 years ago
parent
commit
ece0bd2a32
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/etc/rc.d/rc.subr

+ 8
- 6
src/etc/rc.d/rc.subr View File

@ -1,4 +1,6 @@
# $OpenBSD: rc.subr,v 1.24 2011/03/09 19:37:16 ajacoutot Exp $
# $OpenBSD: rc.subr,v 1.25 2011/03/10 10:21:39 ajacoutot Exp $
# Default functions and variables used by rc.d(8) scripts.
rc_err() { rc_err() {
echo $1 echo $1
@ -10,7 +12,7 @@ rc_start() {
} }
rc_check() { rc_check() {
pgrep -f "^${pexp}"
pkill -0 -f "^${pexp}"
} }
rc_reload() { rc_reload() {
@ -22,7 +24,7 @@ rc_stop() {
} }
rc_cmd() { rc_cmd() {
[ `id -u` -eq 0 -o X"$1" = "Xcheck" ] || \
[ $(id -u) -eq 0 -o X"$1" = "Xcheck" ] || \
rc_err "$0: need root privileges" rc_err "$0: need root privileges"
eval _enotsup=\${rc_${1}} eval _enotsup=\${rc_${1}}
@ -51,7 +53,7 @@ rc_cmd() {
type rc_post >/dev/null && rc_post || return 0 type rc_post >/dev/null && rc_post || return 0
;; ;;
reload) reload)
(rc_check && rc_reload) >/dev/null
rc_check && rc_reload >/dev/null
;; ;;
restart) restart)
/etc/rc.d/${_name} stop && /etc/rc.d/${_name} start /etc/rc.d/${_name} stop && /etc/rc.d/${_name} start
@ -65,7 +67,7 @@ rc_cmd() {
[ -n "${daemon}" ] || rc_err "$0: daemon is not set" [ -n "${daemon}" ] || rc_err "$0: daemon is not set"
_name=`basename $0`
_name=$(basename $0)
eval _rcflags=\${${_name}_flags} eval _rcflags=\${${_name}_flags}
eval _rcuser=\${${_name}_user} eval _rcuser=\${${_name}_user}
@ -78,6 +80,6 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && \
[ -n "${_rcflags}" ] && daemon_flags=${_rcflags} [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
[ -n "${_rcuser}" ] && daemon_user=${_rcuser} [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
daemon_flags=`echo ${daemon_flags} | tr -s "[:space:]"`
daemon_flags=$(echo ${daemon_flags} | tr -s "[:space:]")
pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c" rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"

Loading…
Cancel
Save