[systemd-devel] [PATCH] nspawn: Give a more helpful error message when -D argument is bogus.

Shawn Landden shawn at churchofgit.com
Mon Nov 25 16:01:01 PST 2013


---
 src/nspawn/nspawn.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 0973a00..1ee4ab3 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -200,6 +200,11 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'D':
                         free(arg_directory);
+                        if (access(optarg, F_OK) < 0) {
+                                log_error("Root directory %s is not accessable: %m", optarg);
+                                return -EACCES;
+                        }
+
                         arg_directory = canonicalize_file_name(optarg);
                         if (!arg_directory) {
                                 log_error("Failed to canonicalize root directory.");
-- 
1.8.4.4



More information about the systemd-devel mailing list