diff --git a/etc/rc.d/rtadvd b/etc/rc.d/rtadvd index 5fe67720fda3..3e7b744ff33c 100755 --- a/etc/rc.d/rtadvd +++ b/etc/rc.d/rtadvd @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: rtadvd,v 1.8 2013/07/09 09:34:58 roy Exp $ +# $NetBSD: rtadvd,v 1.9 2016/11/18 23:10:05 kre Exp $ # # PROVIDE: rtadvd @@ -21,28 +21,47 @@ rtadvd_prereload() { local chdir="$(getent passwd _rtadvd | cut -d: -f6)" local conf=/etc/rtadvd.conf myflags o confdir + local cflag=false - [ -z "$chdir" -o "$chdir" = / ] && return 0 + [ -z "${chdir}" ] || [ "/${chdir}" = // ] && return 0 - if [ -n "$flags" ]; then - myflags=$flags + if [ -n "${flags}" ]; then + myflags=${flags} else eval myflags=\$${name}_flags fi set -- ${myflags} while getopts c:dDfM:Rs o; do - case "$1" in - -c) conf="$OPTARG";; + # ignore other args, they are processed by rtadvd itself + case "${o}" in + c) conf="${OPTARG}" + case "${conf}" in + /*) ;; + *) echo "${name}: config file (${conf}) must be" \ + "full pathname" + return 1 + ;; + esac + cflag=true;; esac - shift done - confdir=$(dirname "$conf") - - echo "$name: copying $conf to $chdir$conf" - cp "$conf" "$chdir$conf" - # Provide a link to the chrooted dump file - ln -snf "$chdir/var/run/$name.dump" /var/run + ${cflag} || test -f "${conf}" && { + confdir=$(dirname "${conf}") + echo "${name}: copying ${conf} to ${chdir}${conf}" + mkdir -p "${chdir}${confdir}" + cp "${conf}" "${chdir}${conf}" || return 1 + } + + # Make sure /var/run exists in the chroot + mkdir -p "${chdir}/var/run" + + # Provide links to the chrooted dump & pid files + ln -snf "${chdir}/var/run/${name}.dump" /var/run + + # Note: actual chroot is done by rtadvd itself + + return 0 } rtadvd_prestart()