Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 May 2023 20:23:31 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 271287] etcupdate silently installs empty files / unhandled error in install_new()
Message-ID:  <bug-271287-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271287

            Bug ID: 271287
           Summary: etcupdate silently installs empty files / unhandled
                    error in install_new()
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: 000.fbsd@quip.cz

I described it in mailinglist with more verbose details
https://lists.freebsd.org/archives/freebsd-stable/2023-April/001271.html
https://lists.freebsd.org/archives/freebsd-stable/2023-May/001289.html

In some corner cases etcupdate installs 80+ empty files in to /etc/ which m=
akes
the system unbootable. All files that should be just automatically updated =
were
installed empty. Vital files like /etc/login.conf, scripts in /etc/rc.d/ an=
d so
on.

etcupdate contains function install_new() which uses "cp -Rp" to copy files=
 to
/etc/ but it does not check if copy failed or not and silently continue. Th=
is
leads to unbootable system in some corner cases. The function clearly does =
not
do what it should according to comment above the function. It always return=
s 0.

# Install the "new" version of a file.  Returns true if it succeeds
# and false otherwise.
#
# $1 - pathname of the file to install (relative to DESTDIR)
install_new()
{

    if ! install_dirs $NEWTREE "$DESTDIR" $1; then
        return 1
    fi
    log "cp -Rp ${NEWTREE}$1 ${DESTDIR}$1"
    if [ -z "$dryrun" ]; then
        cp -Rp ${NEWTREE}$1 ${DESTDIR}$1 >&3 2>&1
    fi
    post_install_file $1
    return 0
}=20


In my case the problem of failing cp -Rp was caused by running etcupdate on
upgraded system from 12.3 to 13.2 without reboot so every call of cp -Rp fa=
iled
with "Function not implemented", but it is not user visible error. etcupdate
shows nothing wrong. Those messages are logged in to /var/db/etcupdate/log =
but
if you run "etcupdate" and because it shows success then "etcupdate resolve"
and "etcupdate status" then the log file does not contain anything useful
because it is overwritten by each new run of etcupdate.
I propose appending to log file instead of overwriting it. Or use some kind=
 of
rotation of at least 5 history files. It was really hard to find what / whe=
re
is going wrong after the system cannot boot.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-271287-227>