From a85f3127d8291e001c788de1d273c3a888061cb9 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 11 Dec 2017 15:38:31 -0500 Subject: [PATCH] Improve error messages on missing runtime Also stat.h is included twice, Add more info on log file name and error when failing to open. Signed-off-by: Daniel J Walsh --- conmon/conmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/conmon/conmon.c b/conmon/conmon.c index b00cb0cd..477b98bf 100644 --- a/conmon/conmon.c +++ b/conmon/conmon.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -350,7 +349,7 @@ static int write_k8s_log(int fd, stdpipe_t pipe, const char *buf, ssize_t buflen /* Open the log path file again */ log_fd = open(opt_log_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0600); if (log_fd < 0) - pexit("Failed to open log file"); + pexit("Failed to open log file %s: %s", opt_log_path, strerror(errno)); fd = log_fd; } @@ -1121,6 +1120,8 @@ int main(int argc, char *argv[]) if (opt_runtime_path == NULL) nexit("Runtime path not provided. Use --runtime"); + if (access(opt_runtime_path, X_OK) < 0) + pexit("Runtime path %s is not valid: %s", opt_runtime_path, strerror(errno)); if (!opt_exec && opt_exit_dir == NULL) nexit("Container exit directory not provided. Use --exit-dir");