summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-11-04 14:25:57 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-11-19 11:07:30 +0100
commit7b0d0331d0513cbe1d55878169a75fa98c221ebc (patch)
treea7b8bda76b8efbcedf2336b2681d46fb9f9c6fb6
parent5aab35aac9db1a69f9b584f45583280db725ce99 (diff)
downloadsystemd-7b0d0331d0513cbe1d55878169a75fa98c221ebc.tar.gz
bootctl: create leading dirs when "bootctl random-seed" is called if needed
Prompted by: #13603 (cherry picked from commit a4a55e9ace3e97ee35c89bb2964330cba69e4edb)
-rw-r--r--src/boot/bootctl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index ddc267401f..bac8f0c36d 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -32,6 +32,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"
@@ -1368,6 +1369,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();