Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7-0]: src/etc/rc.d Pull up following revision(s) (requested by kr...
details: https://anonhg.NetBSD.org/src/rev/33d560839bad
branches: netbsd-7-0
changeset: 801241:33d560839bad
user: snj <snj%NetBSD.org@localhost>
date: Mon Nov 21 07:22:51 2016 +0000
description:
Pull up following revision(s) (requested by kre in ticket #1274):
etc/rc.d/rtadvd: revision 1.9
The config file is not required to exist (unless specified via -c).
(reported by rhialto%falu.nl@localhost) Don't fail to start if it doesn't.
Make sure the directory for the config file exists inside the chroot before
attempting to copy into it ("confdir" was calculated, but never used...)
While here, fix getopts usage (obviously only ever previously tested when
the -c arg was the first option...) and don't use test(1)'s -o operator
(especially not when one of the other args is an unknown string).
If -c is given (and we will chroot), require filename to be full path.
Misc minor style cleanups.
diffstat:
etc/rc.d/rtadvd | 45 ++++++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 13 deletions(-)
diffs (71 lines):
diff -r c0500f81a091 -r 33d560839bad etc/rc.d/rtadvd
--- a/etc/rc.d/rtadvd Wed Nov 16 18:31:23 2016 +0000
+++ b/etc/rc.d/rtadvd Mon Nov 21 07:22:51 2016 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: rtadvd,v 1.8 2013/07/09 09:34:58 roy Exp $
+# $NetBSD: rtadvd,v 1.8.8.1 2016/11/21 07:22:51 snj Exp $
#
# PROVIDE: rtadvd
@@ -21,28 +21,47 @@
{
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"
+
+ ${cflag} || test -f "${conf}" && {
+ confdir=$(dirname "${conf}")
+ echo "${name}: copying ${conf} to ${chdir}${conf}"
+ mkdir -p "${chdir}${confdir}"
+ cp "${conf}" "${chdir}${conf}" || return 1
+ }
- # Provide a link to the chrooted dump file
- ln -snf "$chdir/var/run/$name.dump" /var/run
+ # 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()
Home |
Main Index |
Thread Index |
Old Index