Browse Source

Introduce an _rc_check_name() function to check the input script name so that

we don't end up with cryptic error messages.
Regex help from rpe@
Issue reported by Anthony Coulter in rcctl(8), but better fix the root cause.
Also clarify the mage page that rc.d script name must follow ksh(1) variable
naming.
ok robert@ sthen@
OPENBSD_6_1
ajacoutot 8 years ago
parent
commit
9d07915d24
1 changed files with 8 additions and 2 deletions
  1. +8
    -2
      src/etc/rc.d/rc.subr

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

@ -1,4 +1,4 @@
# $OpenBSD: rc.subr,v 1.115 2016/08/31 08:47:11 ajacoutot Exp $
# $OpenBSD: rc.subr,v 1.116 2016/09/07 13:12:42 ajacoutot Exp $
#
# Copyright (c) 2010, 2011, 2014-2016 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@ -60,6 +60,10 @@ _rc_rm_runfile() {
rm -f ${_RC_RUNFILE}
}
_rc_check_name() {
[[ $1 == +([_[:alpha:]])+(|[_[:alnum:]]) ]]
}
_rc_do() {
if [ -n "${_RC_DEBUG}" ]; then
echo "doing $@" && "$@"
@ -238,6 +242,9 @@ rc_cmd() {
esac
}
_name=$(basename $0)
_rc_check_name "${_name}" || _rc_err "invalid rc.d script name: ${_name}"
[ -n "${daemon}" ] || _rc_err "$0: daemon is not set"
unset _RC_DEBUG _RC_FORCE
@ -250,7 +257,6 @@ while getopts "df" c; do
done
shift $((OPTIND-1))
_name=$(basename $0)
_RC_RUNDIR=/var/run/rc.d
_RC_RUNFILE=${_RC_RUNDIR}/${_name}


Loading…
Cancel
Save