]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: improve error message when we cannot look into a container tree due to perms
authorLennart Poettering <lennart@poettering.net>
Wed, 27 Nov 2024 09:21:23 +0000 (10:21 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Nov 2024 15:14:04 +0000 (00:14 +0900)
src/nspawn/nspawn.c

index 81531ac173feaf1e6402d7178f7f7c6867fbef04..500725d35f651346cbee16c0fca2a4b45b6a5bb9 100644 (file)
@@ -6200,9 +6200,12 @@ static int run(int argc, char *argv[]) {
                                 goto finish;
                         }
 
-                        if (access_nofollow(p, F_OK) < 0) {
-                                r = log_error_errno(SYNTHETIC_ERRNO(EINVAL),
-                                                    "Directory %s doesn't look like it has an OS tree (/usr/ directory is missing). Refusing.", arg_directory);
+                        r = access_nofollow(p, F_OK);
+                        if (r == -ENOENT) {
+                                log_error_errno(r, "Directory %s doesn't look like it has an OS tree (/usr/ directory is missing). Refusing.", arg_directory);
+                                goto finish;
+                        } else if (r < 0) {
+                                log_error_errno(r, "Unable to determine if %s looks like it has an OS tree (i.e. whether /usr/ exists): %m", arg_directory);
                                 goto finish;
                         }
                 }