]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: create leading dirs when "bootctl random-seed" is called if needed 13935/head
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Nov 2019 13:25:57 +0000 (14:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Nov 2019 13:26:53 +0000 (14:26 +0100)
Prompted by: #13603

src/boot/bootctl.c

index 72c2115d89eeaf56afcf2ebe579be0b236a46c99..d8e8d8ce4099384b19fadc65d0ba5f06d154a0e0 100644 (file)
@@ -27,6 +27,7 @@
 #include "fs-util.h"
 #include "locale-util.h"
 #include "main-func.h"
+#include "mkdir.h"
 #include "pager.h"
 #include "parse-util.h"
 #include "pretty-print.h"
@@ -1364,6 +1365,13 @@ static int install_random_seed(const char *esp) {
         if (r < 0)
                 return log_error_errno(r, "Failed to acquire random seed: %m");
 
+        /* Normally create_subdirs() should already have created everything we need, but in case "bootctl
+         * random-seed" is called we want to just create the minimum we need for it, and not the full
+         * list. */
+        r = mkdir_parents(path, 0755);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create parent directory for %s: %m", path);
+
         r = tempfn_random(path, "bootctl", &tmp);
         if (r < 0)
                 return log_oom();