The branch main has been updated by eugen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=ccc806a049383e5611b3752e6f384cf03a208039

commit ccc806a049383e5611b3752e6f384cf03a208039
Author:     Eugene Grosbein <eu...@freebsd.org>
AuthorDate: 2023-07-02 07:54:57 +0000
Commit:     Eugene Grosbein <eu...@freebsd.org>
CommitDate: 2023-07-02 07:54:57 +0000

    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
---
 libexec/rc/rc.conf       | 4 +++-
 libexec/rc/rc.d/dumpon   | 9 ++++++---
 libexec/rc/rc.d/savecore | 4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf
index 06fda945e86e..8884fab7e016 100644
--- a/libexec/rc/rc.conf
+++ b/libexec/rc/rc.conf
@@ -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
diff --git a/libexec/rc/rc.d/dumpon b/libexec/rc/rc.d/dumpon
index 6ca335b73842..ed43c4a24762 100755
--- a/libexec/rc/rc.d/dumpon
+++ b/libexec/rc/rc.d/dumpon
@@ -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
diff --git a/libexec/rc/rc.d/savecore b/libexec/rc/rc.d/savecore
index 5d8204a1e805..e7186699a176 100755
--- a/libexec/rc/rc.d/savecore
+++ b/libexec/rc/rc.d/savecore
@@ -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

Reply via email to