From c1e0dc9c882dfae7ba4bf49c50fd253ea199e7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 1 Apr 2022 10:15:54 +0200 Subject: [PATCH 1/2] systemctl: stop saying "vendor preset" We have vendor presets, and local admin presets, and runtime presets (under /usr/lib, /usr/local/lib and /etc, /run, respectively). When we display preset state, it can be configured in any of those places, so we shouldn't say anything about the origin. (Another nice advantage is that it improves alignment: [root@f36 ~]# systemctl list-unit-files multipathd.service UNIT FILE STATE VENDOR PRESET multipathd.service enabled enabled ^ this looks we have a "PRESET" column that is empty.) --- man/systemctl.xml | 2 +- src/systemctl/systemctl-list-unit-files.c | 2 +- src/systemctl/systemctl-show.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/man/systemctl.xml b/man/systemctl.xml index 963eb9ec3a..3d03c0374b 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -221,7 +221,7 @@ Sun 2017-02-26 20:57:49 EST 2h 3min left Sun 2017-02-26 11:56:36 EST 6h ago $ systemctl status bluetooth ● bluetooth.service - Bluetooth service - Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled) + Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; preset: enabled) Active: active (running) since Wed 2017-01-04 13:54:04 EST; 1 weeks 0 days ago Docs: man:bluetoothd(8) Main PID: 930 (bluetoothd) diff --git a/src/systemctl/systemctl-list-unit-files.c b/src/systemctl/systemctl-list-unit-files.c index 552e85a06b..fa7a789b28 100644 --- a/src/systemctl/systemctl-list-unit-files.c +++ b/src/systemctl/systemctl-list-unit-files.c @@ -54,7 +54,7 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) { _cleanup_(unit_file_presets_freep) UnitFilePresets presets = {}; int r; - table = table_new("unit file", "state", "vendor preset"); + table = table_new("unit file", "state", "preset"); if (!table) return log_oom(); diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index 1c0b002734..c514109b17 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -318,7 +318,7 @@ static void print_status_info( bool *ellipsized) { const char *active_on, *active_off, *on, *off, *ss, *fs; - const char *enable_on, *enable_off, *enable_vendor_on, *enable_vendor_off; + const char *enable_on, *enable_off, *preset_on, *preset_off; _cleanup_free_ char *formatted_path = NULL; usec_t timestamp; const char *path; @@ -331,7 +331,7 @@ static void print_status_info( format_active_state(i->active_state, &active_on, &active_off); format_enable_state(i->unit_file_state, &enable_on, &enable_off); - format_enable_state(i->unit_file_preset, &enable_vendor_on, &enable_vendor_off); + format_enable_state(i->unit_file_preset, &preset_on, &preset_off); const SpecialGlyph glyph = unit_active_state_to_glyph(unit_active_state_from_string(i->active_state)); @@ -366,8 +366,8 @@ static void print_status_info( on, strna(i->load_state), off, path, enable_on, i->unit_file_state, enable_off, - show_preset ? "; vendor preset: " : "", - enable_vendor_on, show_preset ? i->unit_file_preset : "", enable_vendor_off); + show_preset ? "; preset: " : "", + preset_on, show_preset ? i->unit_file_preset : "", preset_off); } else if (path) printf(" Loaded: %s%s%s (%s)\n", From 93651582aef1ee626dc6f8d032195acd73bc9372 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 23 Mar 2020 12:25:19 -0400 Subject: [PATCH 2/2] manager: optionally, do a full preset on first boot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A compile time option is added to select behaviour: by default UNIT_FILE_PRESET_ENABLE_ONLY is still used, but the intent is to change to UNIT_FILE_PRESET_FULL at some point in the future. Distros that want to opt-in can use the config option to change the behaviour. (The option is just a boolean: it would be possible to make it multi-valued, and allow full, enable-only, disable-only, none. But so far nobody has asked for this, and it's better not to complicate things needlessly.) With the configuration option flipped, instead of only doing enablements, perform a full preset on first boot. The reason is that although `/etc/machine-id` might be missing, there may be other files provisioned in `/etc` (in fact, this use case is mentioned in `log_execution_mode`). Some of those possible files include enablement symlinks even if presets dictate it should be disabled. Such a seemingly contradictory situation occurs in {RHEL,Fedora} CoreOS, where we ship `/etc` as if `preset-all` were called. However, we want to allow users to disable default-enabled services via Ignition, which does this by creating preset dropins before switchroot. (For why we do `preset-all` at compose time, see: https://github.com/coreos/fedora-coreos-config/pull/77). For example, the composed FCOS image has a `enable zincati.service` preset and an enablement for that in `/etc`, while at boot time when we switch root, there may be a `disable zincati.service` preset with higher precedence. In that case, we want systemd to disable the service. This is essentially a revert of 304b3079a203. It seems like systemd *used* to do this, but it was changed to try to make the container workflow a bit faster. Resolves: https://github.com/coreos/fedora-coreos-tracker/issues/392 Co-authored-by: Zbigniew Jędrzejewski-Szmek --- meson.build | 3 +++ meson_options.txt | 2 ++ src/core/manager.c | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 582e33c9a7..72e586aa97 100644 --- a/meson.build +++ b/meson.build @@ -285,6 +285,8 @@ conf.set10('MEMORY_ACCOUNTING_DEFAULT', memory_accounting_ conf.set('STATUS_UNIT_FORMAT_DEFAULT', 'STATUS_UNIT_FORMAT_' + status_unit_format_default.to_upper()) conf.set_quoted('STATUS_UNIT_FORMAT_DEFAULT_STR', status_unit_format_default) +conf.set10('FIRST_BOOT_FULL_PRESET', get_option('first-boot-full-preset')) + ##################################################################### cc = meson.get_compiler('c') @@ -4271,6 +4273,7 @@ foreach tuple : [ ['link-networkd-shared', get_option('link-networkd-shared')], ['link-timesyncd-shared', get_option('link-timesyncd-shared')], ['link-boot-shared', get_option('link-boot-shared')], + ['first-boot-full-preset'], ['fexecve'], ['standalone-binaries', get_option('standalone-binaries')], ['coverage', get_option('b_coverage')], diff --git a/meson_options.txt b/meson_options.txt index 2a030ac28e..28765f900e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -27,6 +27,8 @@ option('link-timesyncd-shared', type: 'boolean', description : 'link systemd-timesyncd and its helpers to libsystemd-shared.so') option('link-boot-shared', type: 'boolean', description : 'link bootctl and systemd-bless-boot against libsystemd-shared.so') +option('first-boot-full-preset', type: 'boolean', value: false, + description : 'during first boot, do full preset-all (default will be changed to true later)') option('static-libsystemd', type : 'combo', choices : ['false', 'true', 'pic', 'no-pic'], diff --git a/src/core/manager.c b/src/core/manager.c index 18daff66c7..f4dacef100 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1728,7 +1728,9 @@ static void manager_preset_all(Manager *m) { return; /* If this is the first boot, and we are in the host system, then preset everything */ - r = unit_file_preset_all(LOOKUP_SCOPE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0); + UnitFilePresetMode mode = FIRST_BOOT_FULL_PRESET ? UNIT_FILE_PRESET_FULL : UNIT_FILE_PRESET_ENABLE_ONLY; + + r = unit_file_preset_all(LOOKUP_SCOPE_SYSTEM, 0, NULL, mode, NULL, 0); if (r < 0) log_full_errno(r == -EEXIST ? LOG_NOTICE : LOG_WARNING, r, "Failed to populate /etc with preset unit settings, ignoring: %m");