summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r--src/nspawn/nspawn.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 532be148a6..0474f61d43 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -676,9 +676,8 @@ static int parse_argv(int argc, char *argv[]) {
r = free_and_strdup(&arg_machine, optarg);
if (r < 0)
return log_oom();
-
- break;
}
+ break;
case 'Z':
arg_selinux_context = optarg;
@@ -1918,7 +1917,7 @@ static int wait_for_container(pid_t pid, ContainerStatus *container) {
return 0;
}
- /* CLD_KILLED fallthrough */
+ /* fall through */
case CLD_DUMPED:
log_error("Container %s terminated by signal %s.", arg_machine, signal_to_string(status.si_status));
@@ -2131,6 +2130,7 @@ static int inner_child(
NULL, /* NOTIFY_SOCKET */
NULL
};
+ const char *exec_target;
_cleanup_strv_free_ char **env_use = NULL;
int r;
@@ -2317,28 +2317,32 @@ static int inner_child(
memcpy_safe(a + 1, arg_parameters, m * sizeof(char*));
a[1 + m] = NULL;
- a[0] = (char*) "/usr/lib/systemd/systemd";
+ exec_target = a[0] = (char*) "/usr/lib/systemd/systemd";
execve(a[0], a, env_use);
- a[0] = (char*) "/lib/systemd/systemd";
+ exec_target = a[0] = (char*) "/lib/systemd/systemd";
execve(a[0], a, env_use);
- a[0] = (char*) "/sbin/init";
+ exec_target = a[0] = (char*) "/sbin/init";
execve(a[0], a, env_use);
- } else if (!strv_isempty(arg_parameters))
+ } else if (!strv_isempty(arg_parameters)) {
+ exec_target = arg_parameters[0];
execvpe(arg_parameters[0], arg_parameters, env_use);
- else {
+ } else {
if (!arg_chdir)
/* If we cannot change the directory, we'll end up in /, that is expected. */
(void) chdir(home ?: "/root");
+ exec_target = "/bin/bash";
execle("/bin/bash", "-bash", NULL, env_use);
+
+ exec_target = "/bin/sh";
execle("/bin/sh", "-sh", NULL, env_use);
}
r = -errno;
(void) log_open();
- return log_error_errno(r, "execv() failed: %m");
+ return log_error_errno(r, "execv(%s) failed: %m", exec_target);
}
static int setup_sd_notify_child(void) {