dumpdev: respect kenv for stable branches

We have somewhat twisted logic to determine actions for dumpdev
considering three sources of information:

* kenv "dumpdev" tunnable supposed to point to specific device;
* /etc/defaults/rc.conf "dumpdev" variable;
* /etc/rc.conf that may be unset or set to "NO", "AUTO" or device name.

For CURRENT without any setting in kenv or /etc/rc.conf
the default is "AUTO". For STABLE branches the default is "NO".

Current implementation breaks for STABLE branches if kenv points
to specific device but /etc/rc.conf does not set "dumpdev" at all.

Let us fix it commenting out "dumpdev" in /etc/defaults/rc.conf
for STABLE branches and making the code to consult kenv
if "dumpdev" is not set elsewhere.

MFC-after:	1 month
This commit is contained in:
Eugene Grosbein 2023-07-02 14:54:57 +07:00
parent 005aa1743b
commit ccc806a049
3 changed files with 11 additions and 6 deletions

View File

@ -643,7 +643,9 @@ lpd_flags="" # Flags to lpd (if enabled).
nscd_enable="NO" # Run the nsswitch caching daemon.
chkprintcap_enable="NO" # Run chkprintcap(8) before running lpd.
chkprintcap_flags="-d" # Create missing directories by default.
dumpdev="AUTO" # Device to crashdump to (device name, AUTO, or NO).
dumpdev="AUTO" # Device to crashdump to (device name, AUTO, or NO);
# this should be commented out here
# for stable branches to respect kenv.
dumpon_flags="" # Options to pass to dumpon(8), followed by dumpdev.
dumpdir="/var/crash" # Directory where crash dumps are to be stored
savecore_enable="YES" # Extract core from dump devices if any

View File

@ -52,15 +52,18 @@ dumpon_start()
# early so a crash early in the boot process can be caught.
#
case ${dumpdev} in
[Nn][Oo] | '')
[Nn][Oo])
;;
[Aa][Uu][Tt][Oo])
[Aa][Uu][Tt][Oo] | '')
root_hold_wait
dev=$(/bin/kenv -q dumpdev)
if [ -n "${dev}" ] ; then
dumpon_try "${dev}"
return $?
fi
if [ -z ${dumpdev} ] ; then
return
fi
while read dev mp type more ; do
[ "${type}" = "swap" ] || continue
case ${dev} in
@ -85,7 +88,7 @@ dumpon_start()
dumpon_stop()
{
case ${dumpdev} in
[Nn][Oo] | '')
[Nn][Oo])
;;
*)
rm -f /dev/dumpdev

View File

@ -20,11 +20,11 @@ savecore_prestart()
{
# Quit if we have no dump device
case ${dumpdev} in
[Nn][Oo] | '')
[Nn][Oo])
debug 'No dump device. Quitting.'
return 1
;;
[Aa][Uu][Tt][Oo])
[Aa][Uu][Tt][Oo] | '')
if [ ! -L /dev/dumpdev ]; then
return 1
fi