From: Dusty Mabe Date: Fri, 23 May 2025 13:18:12 +0000 (-0400) Subject: src/core/manager.c: log preset activity on first boot X-Git-Tag: v258-rc1~486 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdd852a199480a84bf21d782f72b48bca059d306;p=thirdparty%2Fsystemd.git src/core/manager.c: log preset activity on first boot This gives us a little more information about what units were enabled or disabled on that first boot and will be useful for OS developers tracking down the source of unit state. An example with this enabled looks like: ``` NET: Registered PF_VSOCK protocol family systemd[1]: Applying preset policy. systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring. systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring. systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'. systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'. systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'. systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'. systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'. systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'. systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'. systemd[1]: Populated /etc with preset unit settings. ``` Considering it only happens on first boot and not on every boot I think the extra information is worth the extra verbosity in the logs just for that boot. --- diff --git a/src/core/manager.c b/src/core/manager.c index 4b0f85273ec..981c2dc1471 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1893,8 +1893,15 @@ static void manager_preset_all(Manager *m) { /* If this is the first boot, and we are in the host system, then preset everything */ UnitFilePresetMode mode = ENABLE_FIRST_BOOT_FULL_PRESET ? UNIT_FILE_PRESET_FULL : UNIT_FILE_PRESET_ENABLE_ONLY; + InstallChange *changes = NULL; + size_t n_changes = 0; - r = unit_file_preset_all(RUNTIME_SCOPE_SYSTEM, 0, NULL, mode, NULL, NULL); + CLEANUP_ARRAY(changes, n_changes, install_changes_free); + + log_info("Applying preset policy."); + r = unit_file_preset_all(RUNTIME_SCOPE_SYSTEM, /* file_flags = */ 0, + /* root_dir = */ NULL, mode, &changes, &n_changes); + install_changes_dump(r, "preset", changes, n_changes, /* quiet = */ false); if (r < 0) log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r, "Failed to populate /etc with preset unit settings, ignoring: %m");