Allow systemd-imds-import to be ordered early and update enablement (#42308)

It seems that the enablement of this unit was somewhat confused…
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-26 16:49:23 +02:00
committed by GitHub
2 changed files with 10 additions and 7 deletions
+7 -4
View File
@@ -6,6 +6,7 @@
#include "fileio.h"
#include "generator.h"
#include "imds-util.h"
#include "initrd-util.h"
#include "log.h"
#include "parse-util.h"
#include "proc-cmdline.h"
@@ -13,8 +14,8 @@
#include "string-util.h"
#include "virt.h"
static int arg_enabled = -1; /* Whether we shall offer local IMDS APIs */
static bool arg_import = true; /* Whether we shall import IMDS credentials, SSH keys, … into the local system */
static int arg_enabled = -1; /* Whether we shall offer local IMDS APIs */
static int arg_import = -1; /* Whether we shall import IMDS credentials, SSH keys, … into the local system */
static ImdsNetworkMode arg_network_mode = IMDS_NETWORK_DEFAULT;
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
@@ -179,8 +180,10 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
if (r < 0)
return log_error_errno(r, "Failed to hook DMI id device before systemd-imdsd@.service: %m");
if (arg_import) {
/* Enable that we import IMDS data */
if (arg_import < 0)
arg_import = in_initrd();
if (arg_import > 0) {
/* Enable the import of IMDS data */
r = generator_add_symlink(dest_early, SPECIAL_SYSINIT_TARGET, "wants", SYSTEM_DATA_UNIT_DIR "/systemd-imds-import.service");
if (r < 0)
return log_error_errno(r, "Failed to hook in systemd-imds-import.service: %m");
+3 -3
View File
@@ -11,13 +11,13 @@
Description=Import System Credentials from IMDS
Documentation=man:systemd-imds(1)
Documentation=man:systemd.system-credentials(7)
DefaultDependencies=no
Wants=systemd-imdsd.socket network-online.target
After=systemd-imdsd.socket network-online.target
Wants=systemd-imdsd.socket
After=systemd-imdsd.socket
Before=sysinit.target systemd-firstboot.service
Conflicts=shutdown.target
Before=shutdown.target
ConditionPathExists=/etc/initrd-release
[Service]
Type=oneshot