git: fc186c24b1e7 - main - rc.d/dumpon: minor hardening/tightening up
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 16 Jul 2026 16:25:09 UTC
The branch main has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=fc186c24b1e72fa3eba91c166f7a554a5cea5828
commit fc186c24b1e72fa3eba91c166f7a554a5cea5828
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-07-16 16:24:54 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-07-16 16:25:03 +0000
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
---
libexec/rc/rc.d/dumpon | 13 ++++++++-----
1 file 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"