Bug 255514

Summary: etcupdate cleared the executable bit from /etc/rc.d/netif when resolving conflicts
Product: Base System Reporter: Ulrich Spörlein <uqs>
Component: confAssignee: John Baldwin <jhb>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste, jhb, pi
Priority: --- Flags: jhb: mfc-stable13?
jhb: mfc-stable12?
Version: 13.0-STABLE   
Hardware: Any   
OS: Any   

Description Ulrich Spörlein freebsd_committer freebsd_triage 2021-04-30 13:08:45 UTC
Hi,

this basically bricked a remote system (luckily I had OOB access).

First, freebsd-update bricked the update to 13 as it copied a half kernel over but the modules failed to load due to version symbol mismatch (what?). Then I did the regular kernel/world build and install, followed by etcupdate.

I have a sleep in /etc/rc.d/netif (phys link takes too long to come up), etcupdate entered the EDITOR to fix up the conflict, then I marked as resolved.
 
Rebooted and:
 
Starting devd.
eval: /etc/rc.d/netif: Permission denied
em1: link state changed to UP
debugnet_any_ifnet_update: Bad dn_init result from em1 (ifp 0xfffff80003c98000), ignoring.
eval: /etc/rc.d/netif: Permission denied
route: writing to routing socket: Network is unreachable
add net default: gateway 185.95.219.48 fib 0: Network is unreachable
Autoloading module: ichsmb.ko
eval: /etc/rc.d/netif: Permission denied
 
 
Dafuq?
 
root@acme:~# ls -l /etc/rc.d/net*
-rw-r--r--  1 root  wheel  5995 Apr 30 14:42 /etc/rc.d/netif
-r-xr-xr-x  1 root  wheel  2774 Jan  6 16:52 /etc/rc.d/netoptions
-r-xr-xr-x  1 root  wheel  3067 Jan  6 16:52 /etc/rc.d/netwait
Comment 1 commit-hook freebsd_committer freebsd_triage 2022-05-25 21:23:22 UTC
A commit in branch main references this bug:

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

commit f8287caae48246e34d6a7af5446df3c36127b7f0
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:20:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-25 21:20:40 +0000

    etcupdate: Preserve permissions when installing a resolved file.

    Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
    cat to overwrite the contents of the existing file rather than cp so
    that metadata of the existing file such as permissions and ownership
    is preserved.

    PR:             255514
    Reported by:    uqs
    MFC after:      1 week

 usr.sbin/etcupdate/etcupdate.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-07-13 18:01:54 UTC
A commit in branch stable/13 references this bug:

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

commit 8660d530f72f4103add7487db56b941e6297a8cc
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:20:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-13 18:00:50 +0000

    etcupdate: Preserve permissions when installing a resolved file.

    Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
    cat to overwrite the contents of the existing file rather than cp so
    that metadata of the existing file such as permissions and ownership
    is preserved.

    PR:             255514
    Reported by:    uqs

    (cherry picked from commit f8287caae48246e34d6a7af5446df3c36127b7f0)

 usr.sbin/etcupdate/etcupdate.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-07-13 18:01:56 UTC
A commit in branch stable/12 references this bug:

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

commit 101639e978868b996dca4309800133eb93605e85
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:20:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-07-13 18:01:08 +0000

    etcupdate: Preserve permissions when installing a resolved file.

    Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
    cat to overwrite the contents of the existing file rather than cp so
    that metadata of the existing file such as permissions and ownership
    is preserved.

    PR:             255514
    Reported by:    uqs

    (cherry picked from commit f8287caae48246e34d6a7af5446df3c36127b7f0)

 usr.sbin/etcupdate/etcupdate.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)