diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-06-30 10:23:10 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-07-04 23:15:36 +0200 |
commit | 3ed075cf6158b2fadd904aba0abfe9bfe020dbf5 (patch) | |
tree | 4b14fa7ef5763cd1ac43eee5004e0aae956c5f64 | |
parent | test: verify that the getty generator with creds works (diff) | |
download | systemd-3ed075cf6158b2fadd904aba0abfe9bfe020dbf5.tar.xz systemd-3ed075cf6158b2fadd904aba0abfe9bfe020dbf5.zip |
generator: run various generators only run on the host, not in initrd
These 5 generators only make sense on the host,not in the initrd, hence
if they end up in the initrd anyway, make them exit quickly.
-rw-r--r-- | src/boot/bless-boot-generator.c | 4 | ||||
-rw-r--r-- | src/getty-generator/getty-generator.c | 6 | ||||
-rw-r--r-- | src/rc-local-generator/rc-local-generator.c | 6 | ||||
-rw-r--r-- | src/system-update-generator/system-update-generator.c | 6 | ||||
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 6 |
5 files changed, 26 insertions, 2 deletions
diff --git a/src/boot/bless-boot-generator.c b/src/boot/bless-boot-generator.c index 5120b9622e..38b2c3ad7c 100644 --- a/src/boot/bless-boot-generator.c +++ b/src/boot/bless-boot-generator.c @@ -18,9 +18,9 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) { - if (in_initrd() > 0) { + if (in_initrd()) { log_debug("Skipping generator, running in the initrd."); - return 0; + return EXIT_SUCCESS; } if (detect_container() > 0) { diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index 24c35ae987..4379b4b648 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -10,6 +10,7 @@ #include "fd-util.h" #include "fileio.h" #include "generator.h" +#include "initrd-util.h" #include "log.h" #include "mkdir-label.h" #include "parse-util.h" @@ -212,6 +213,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) assert_se(arg_dest = dest); + if (in_initrd()) { + log_debug("Skipping generator, running in the initrd."); + return EXIT_SUCCESS; + } + r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0); if (r < 0) log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m"); diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index d8c06b1d2d..89cc5fadb6 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -5,6 +5,7 @@ #include <unistd.h> #include "generator.h" +#include "initrd-util.h" #include "log.h" #include "mkdir-label.h" #include "string-util.h" @@ -58,6 +59,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) assert_se(arg_dest = dest); + if (in_initrd()) { + log_debug("Skipping generator, running in the initrd."); + return EXIT_SUCCESS; + } + if (check_executable(RC_LOCAL_PATH) >= 0) { log_debug("Automatically adding rc-local.service."); diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c index 83b06902ab..a1782d5c05 100644 --- a/src/system-update-generator/system-update-generator.c +++ b/src/system-update-generator/system-update-generator.c @@ -5,6 +5,7 @@ #include "fs-util.h" #include "generator.h" +#include "initrd-util.h" #include "log.h" #include "path-util.h" #include "proc-cmdline.h" @@ -61,6 +62,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) assert_se(arg_dest = dest_early); + if (in_initrd()) { + log_debug("Skipping generator, running in the initrd."); + return EXIT_SUCCESS; + } + r = generate_symlink(); if (r <= 0) return r; diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 632f4a1aac..30f82d5736 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -14,6 +14,7 @@ #include "generator.h" #include "hashmap.h" #include "hexdecoct.h" +#include "initrd-util.h" #include "install.h" #include "log.h" #include "main-func.h" @@ -899,6 +900,11 @@ static int run(const char *dest, const char *dest_early, const char *dest_late) SysvStub *service; int r; + if (in_initrd()) { + log_debug("Skipping generator, running in the initrd."); + return EXIT_SUCCESS; + } + assert_se(arg_dest = dest_late); r = lookup_paths_init_or_warn(&lp, RUNTIME_SCOPE_SYSTEM, LOOKUP_PATHS_EXCLUDE_GENERATED, NULL); |