Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report executable not found errors after tty has been setup #1548

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,20 +1248,6 @@ container_init_setup (void *args, pid_t own_pid, char *notify_socket,
crun_error_release (err);
}

if (def->process && def->process->args)
{
*exec_path = find_executable (def->process->args[0], def->process->cwd);
if (UNLIKELY (*exec_path == NULL))
{
if (entrypoint_args->custom_handler == NULL && errno == ENOENT)
return crun_make_error (err, errno, "executable file `%s` not found in $PATH", def->process->args[0]);
}
/* If it fails for any other reason, ignore the failure. We'll try again the lookup
once the process switched to the use that runs in the container. This might be necessary
when opening a file that is on a network file system like NFS, where CAP_DAC_OVERRIDE
is not honored. */
}

ret = setsid ();
if (UNLIKELY (ret < 0))
return crun_make_error (err, errno, "setsid");
Expand Down Expand Up @@ -1293,6 +1279,20 @@ container_init_setup (void *args, pid_t own_pid, char *notify_socket,
}
}

if (def->process && def->process->args)
{
*exec_path = find_executable (def->process->args[0], def->process->cwd);
if (UNLIKELY (*exec_path == NULL))
{
if (entrypoint_args->custom_handler == NULL && errno == ENOENT)
return crun_make_error (err, errno, "executable file `%s` not found in $PATH", def->process->args[0]);
}
/* If it fails for any other reason, ignore the failure. We'll try again the lookup
once the process switched to the use that runs in the container. This might be necessary
when opening a file that is on a network file system like NFS, where CAP_DAC_OVERRIDE
is not honored. */
}

ret = libcrun_set_hostname (container, err);
if (UNLIKELY (ret < 0))
return ret;
Expand Down
Loading