]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: fix userns_mkdir() invocation
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Nov 2024 11:16:57 +0000 (12:16 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 23 Nov 2024 08:33:06 +0000 (17:33 +0900)
The wrong error code was logged.

But actually given that userns_mkdir() is fine with existing dirs, let's
drop the redundant conditionalization.

Follow-up for: a1fcaa1549d86098d0ba75254b6afc96c786b3b6

src/nspawn/nspawn.c

index 5dd289c1b463d219d0e5775a537185049b6f37e2..0a8f1af821dffe88533e9ef189979353e4286600 100644 (file)
@@ -2280,10 +2280,9 @@ static int copy_devnode_one(const char *dest, const char *node, bool ignore_mkno
         r = path_extract_directory(from, &parent);
         if (r < 0)
                 return log_error_errno(r, "Failed to extract directory from %s: %m", from);
-        if (!path_equal(parent, "/dev/")) {
-                if (userns_mkdir(dest, parent, 0755, 0, 0) < 0)
-                        return log_error_errno(r, "Failed to create directory %s: %m", parent);
-        }
+        r = userns_mkdir(dest, parent, 0755, 0, 0);
+        if (r < 0)
+                return log_error_errno(r, "Failed to create directory %s: %m", parent);
 
         if (mknod(to, st.st_mode, st.st_rdev) < 0) {
                 r = -errno; /* Save the original error code. */