]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
generator: run various generators only run on the host, not in initrd
authorLennart Poettering <lennart@poettering.net>
Fri, 30 Jun 2023 08:23:10 +0000 (10:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Jul 2023 21:15:36 +0000 (23:15 +0200)
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.

src/boot/bless-boot-generator.c
src/getty-generator/getty-generator.c
src/rc-local-generator/rc-local-generator.c
src/system-update-generator/system-update-generator.c
src/sysv-generator/sysv-generator.c

index 5120b9622e1fb2d2543a768ac82241d0cdb4ed56..38b2c3ad7cd87ec3375b37270c29c78b393a0581 100644 (file)
@@ -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) {
index 24c35ae9871be994953059c3b7569d3208cb30ab..4379b4b6480dadc32aec2ecc456a95500986fde4 100644 (file)
@@ -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");
index d8c06b1d2dcdf1bc78d6beb652ffdd931dcea52c..89cc5fadb6ae9c643e3b05c8f62d295fb5724945 100644 (file)
@@ -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.");
 
index 83b06902ab3046046d381474c4bb6c4ecfbacb1f..a1782d5c059524fd74329811cc02546c377532bb 100644 (file)
@@ -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;
index 632f4a1aac7a09dd4f88e43c858a588d08ba7198..30f82d573699d3ed4902ede2ea0024f39d82d3f9 100644 (file)
@@ -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);