git: b82d5062426d - stable/14 - rc.d/dumpon: minor hardening/tightening up
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 04 Sep 2026 05:58:19 UTC
The branch stable/14 has been updated by ngie:
URL: https://cgit.FreeBSD.org/src/commit/?id=b82d5062426dca5887d656ce729603b9626160f6
commit b82d5062426dca5887d656ce729603b9626160f6
Author: Enji Cooper <ngie@FreeBSD.org>
AuthorDate: 2026-07-16 16:24:54 +0000
Commit: Enji Cooper <ngie@FreeBSD.org>
CommitDate: 2026-09-04 05:57:58 +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
(cherry picked from commit fc186c24b1e72fa3eba91c166f7a554a5cea5828)
---
libexec/rc/rc.d/dumpon | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/libexec/rc/rc.d/dumpon b/libexec/rc/rc.d/dumpon
index a6748711b796..52145548e5af 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,5 +99,6 @@ dumpon_stop()
esac
}
-load_rc_config $name
+load_rc_config "$name"
+
run_rc_command "$1"