From 050bab470f8187e40f6dba587d335af9c645c392 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 23 Jun 2023 11:58:57 +0200 Subject: key2root-addkey: mkdir /etc/key2root before saving changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- key2root-addkey.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'key2root-addkey.c') diff --git a/key2root-addkey.c b/key2root-addkey.c index ad3554b..f61063e 100644 --- a/key2root-addkey.c +++ b/key2root-addkey.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include +#include #include #include #include @@ -113,6 +114,10 @@ main(int argc, char *argv[]) exit(1); } + if (mkdir(KEYPATH, 0700) && errno != EEXIST) { + fprintf(stderr, "%s: mkdir %s: %s\n", argv0, KEYPATH, strerror(errno)); + exit(1); + } fd = open(path2, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fd < 0) { fprintf(stderr, "%s: open %s O_WRONLY|O_CREAT|O_EXCL 0600: %s\n", argv0, path2, strerror(errno)); -- cgit v1.2.3-70-g09d2