Bug 271361 - hostid_save runs too early (before mountcritlocal)
Summary: hostid_save runs too early (before mountcritlocal)
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.2-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-05-11 12:18 UTC by Meyser+bugs.freebsd.org
Modified: 2023-07-29 03:15 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Meyser+bugs.freebsd.org 2023-05-11 12:18:31 UTC
#> ls -la /etc/machine-id
lrwxr-xr-x  1 root  wheel  20 Feb 19 19:00 /etc/machine-id -> ../var/db/machine-id

rcorder /etc/rc.d/* (exerpt):

[.....]
/etc/rc.d/zvol
/etc/rc.d/root
/etc/rc.d/hostid_save
/etc/rc.d/mdconfig
/etc/rc.d/serial
/etc/rc.d/sppp
/etc/rc.d/growfs_fstab
/etc/rc.d/mountcritlocal
/etc/rc.d/zfsbe
/etc/rc.d/var_run
/etc/rc.d/tmp
/etc/rc.d/zfs
[.....]

after making /etc/machine-id a symlink to /var/db/machine-id
hostid_save can not write to /etc/machine-id as /var is not yet mounted.

I think in hostid_save

# REQUIRE: hostid root

should be replaced by

# REQUIRE: hostid mountcritlocal
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 2023-05-11 13:00:01 UTC
This is interesting, machine-id was added in base 62a149bf621947fb7475c64b1ff04fe19fe16b29, and it was indeed in /var/db/machine-id (with a reasoning of read-only root), and there was a symlink to /etc/machine-id.  Now base ecad3f5c4d922f93ceba455f8bff1c54e1ed4174 reworked it (removing the added machine_id rc script and using hostid_save instead) and made it /etc/machine-id by default.

Adding the authors of both changes to CC to make sure current behavior (regular file in /etc) is what it should be, then you'll need to delete the symlink and let the script to re-create /etc/machine-id.
Comment 2 Tijl Coosemans freebsd_committer freebsd_triage 2023-05-11 13:24:15 UTC
(In reply to Yuri Pankov from comment #1)
Yes, /etc/machine-id is supposed to be a regular file now, like /etc/hostid.
Comment 3 Meyser+bugs.freebsd.org 2023-05-11 14:22:19 UTC
Ah ok. Then *I* just remove the symlink to fix this.

neither "etcupdate" nor "mergemaster -s" catch this during update.

I think it would be wise to extent "hostid_save" funtionality 
to remove the machine_id_file '( the symlink ) before creating it.

Or put something in UPDATING.

At the moment after update ist broken.

P.S. How ist that supposed to work with diskless clients with 
/ ro nfs mounted and /var /tmp on tmpfs.