]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/user-util: create /etc from take_etc_passwd_lock
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Jan 2023 15:24:50 +0000 (16:24 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Feb 2023 10:38:35 +0000 (11:38 +0100)
This allows sysusers to operate with --root that is an empty directory.
It may be useful to, for example, populate the user database before installing
anything else.

firstboot was already doing this, so drop the duplicated call there.

src/basic/user-util.c
src/firstboot/firstboot.c

index 734122c2a3c0b12dce1fb6c39ae209d97b5f2f67..6c5041230a1cb38164423c36707ba6dfeaba0f21 100644 (file)
@@ -19,6 +19,7 @@
 #include "fileio.h"
 #include "format-util.h"
 #include "macro.h"
+#include "mkdir.h"
 #include "parse-util.h"
 #include "path-util.h"
 #include "path-util.h"
@@ -688,6 +689,8 @@ int take_etc_passwd_lock(const char *root) {
         if (!path)
                 return log_oom_debug();
 
+        (void) mkdir_parents(path, 0755);
+
         _cleanup_close_ int fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0600);
         if (fd < 0)
                 return log_debug_errno(errno, "Cannot open %s: %m", path);
index 45bb386da2b0a169b54e559790fa8a2f7dfc2661..9e79f846916a82b5cc7baa13a4099767c13f3ed2 100644 (file)
@@ -904,8 +904,6 @@ static int process_root_account(void) {
                 return 0;
         }
 
-        (void) mkdir_parents(etc_passwd, 0755);
-
         lock = take_etc_passwd_lock(arg_root);
         if (lock < 0)
                 return log_error_errno(lock, "Failed to take a lock on %s: %m", etc_passwd);