aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2026-07-16 16:24:54 +0000
committerEnji Cooper <ngie@FreeBSD.org>2026-07-16 16:25:03 +0000
commitfc186c24b1e72fa3eba91c166f7a554a5cea5828 (patch)
tree464bb3c0dbd5ffcd1c85ea3557328b58b6b79e18
parenta2f50c4b32d1c126cf2309dab61d27d6329908f8 (diff)
rc.d/dumpon: minor hardening/tightening up
- Scope local variables properly to each function. - Quote variables that should be treated as single words. - Replace `${cmd}; if [ $? -eq 0 ]` with `if ${cmd}` for simplicity. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D57899
-rwxr-xr-xlibexec/rc/rc.d/dumpon13
1 files changed, 8 insertions, 5 deletions
diff --git a/libexec/rc/rc.d/dumpon b/libexec/rc/rc.d/dumpon
index 0dfcdb266b20..784187e54bb3 100755
--- a/libexec/rc/rc.d/dumpon
+++ b/libexec/rc/rc.d/dumpon
@@ -22,8 +22,7 @@ dumpon_try()
warn "The dumppubkey variable is deprecated. Use dumpon_flags."
flags="${flags} -k ${dumppubkey}"
fi
- /sbin/dumpon ${flags} "${1}"
- if [ $? -eq 0 ]; then
+ if /sbin/dumpon ${flags} "${1}"; then
# Make a symlink in devfs for savecore
ln -fs "${1}" /dev/dumpdev
return 0
@@ -34,11 +33,13 @@ dumpon_try()
dumpon_warn_unencrypted()
{
+ local flag
+
if [ -n "${dumppubkey}" ]; then
return
fi
for flag in ${dumpon_flags}; do
- if [ $flag = -k ]; then
+ if [ "$flag" = -k ]; then
return
fi
done
@@ -47,6 +48,8 @@ dumpon_warn_unencrypted()
dumpon_start()
{
+ local dev mp type more
+
# Enable dumpdev so that savecore can see it. Enable it
# early so a crash early in the boot process can be caught.
#
@@ -60,7 +63,7 @@ dumpon_start()
dumpon_try "${dev}"
return $?
fi
- if [ -z ${dumpdev} ] ; then
+ if [ -z "${dumpdev}" ] ; then
return
fi
while read dev mp type more ; do
@@ -96,7 +99,7 @@ dumpon_stop()
esac
}
-load_rc_config $name
+load_rc_config "$name"
# doesn't make sense to run in a svcj: config setting
dumpon_svcj="NO"