summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2011-03-10 10:21:40 +0000
committerAntoine Jacoutot <ajacoutot@cvs.openbsd.org>2011-03-10 10:21:40 +0000
commita69da822a010a6b85820c79eea80b7922e726956 (patch)
tree2620aac0a89abecc307850a6aad4b3f05ff6ecd4
parente02c8230906fee7ddf4cfe1c7038f393555377db (diff)
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@
-rw-r--r--etc/rc.d/rc.subr14
1 files changed, 8 insertions, 6 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index 0cc7dfa5807..02058ba34fc 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -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() {
echo $1
@@ -10,7 +12,7 @@ rc_start() {
}
rc_check() {
- pgrep -f "^${pexp}"
+ pkill -0 -f "^${pexp}"
}
rc_reload() {
@@ -22,7 +24,7 @@ rc_stop() {
}
rc_cmd() {
- [ `id -u` -eq 0 -o X"$1" = "Xcheck" ] || \
+ [ $(id -u) -eq 0 -o X"$1" = "Xcheck" ] || \
rc_err "$0: need root privileges"
eval _enotsup=\${rc_${1}}
@@ -51,7 +53,7 @@ rc_cmd() {
type rc_post >/dev/null && rc_post || return 0
;;
reload)
- (rc_check && rc_reload) >/dev/null
+ rc_check && rc_reload >/dev/null
;;
restart)
/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"
-_name=`basename $0`
+_name=$(basename $0)
eval _rcflags=\${${_name}_flags}
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 "${_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}}"
rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"