summaryrefslogtreecommitdiffstats
path: root/src/boot/bootctl.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-01-28 16:40:09 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2022-01-31 14:58:06 +0100
commit17e2e8073f3d387035595fcf6c3aa27acb24e2dc (patch)
tree14bedf9e3b2030278c1e5b569ef6337d0f7869bd /src/boot/bootctl.c
parentMerge pull request #22274 from yuwata/resolve-comment (diff)
downloadsystemd-17e2e8073f3d387035595fcf6c3aa27acb24e2dc.tar.xz
systemd-17e2e8073f3d387035595fcf6c3aa27acb24e2dc.zip
boot: Don't require a machine ID to be available
Regression introduced in https://github.com/systemd/systemd/pull/21807. Fixes #22224
Diffstat (limited to '')
-rw-r--r--src/boot/bootctl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 86391b8def..c76fea0a02 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -141,7 +141,7 @@ static int load_install_machine_id_and_layout(void) {
if (isempty(s)) {
r = sd_id128_get_machine(&arg_machine_id);
- if (r < 0)
+ if (r < 0 && !IN_SET(r, -ENOENT, -ENOMEDIUM))
return log_error_errno(r, "Failed to get machine-id: %m");
} else {
r = sd_id128_from_string(s, &arg_machine_id);
@@ -170,7 +170,7 @@ static int settle_install_machine_id(void) {
bool layout_non_bls = arg_install_layout && !streq(arg_install_layout, "bls");
if (arg_make_machine_id_directory < 0) {
- if (layout_non_bls)
+ if (layout_non_bls || sd_id128_is_null(arg_machine_id))
arg_make_machine_id_directory = 0;
else {
r = path_is_temporary_fs("/etc/machine-id");
@@ -180,6 +180,10 @@ static int settle_install_machine_id(void) {
}
}
+ if (arg_make_machine_id_directory > 0 && sd_id128_is_null(arg_machine_id))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Machine ID not found, but bls directory creation was requested.");
+
if (arg_make_machine_id_directory > 0 && layout_non_bls)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"KERNEL_INSTALL_LAYOUT=%s is configured, but bls directory creation was requested.",
@@ -982,9 +986,8 @@ static int remove_subdirs(const char *root, const char *const *subdirs) {
static int remove_machine_id_directory(const char *root) {
assert(root);
assert(arg_make_machine_id_directory >= 0);
- assert(!sd_id128_is_null(arg_machine_id));
- if (!arg_make_machine_id_directory)
+ if (!arg_make_machine_id_directory || sd_id128_is_null(arg_machine_id))
return 0;
return rmdir_one(root, SD_ID128_TO_STRING(arg_machine_id));