Skip to content

Commit

Permalink
executor: check for all permission related errnos when setting up IPC…
Browse files Browse the repository at this point in the history
… namespace

Denials from AppArmor are raised as EACCES, so EPERM is not enough. Do
the same check as PrivateNetwork above.

Fixes systemd/systemd#31037

Related to 06384eb

(cherry picked from commit cafe40e)
(cherry picked from commit e481710)
(cherry picked from commit da9a6a5)
  • Loading branch information
bluca committed May 28, 2024
1 parent 6ee5aa1 commit 524610a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/core/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -4851,12 +4851,14 @@ static int exec_child(

if (ns_type_supported(NAMESPACE_NET)) {
r = setup_shareable_ns(runtime->netns_storage_socket, CLONE_NEWNET);
if (r == -EPERM)
log_unit_warning_errno(unit, r,
"PrivateNetwork=yes is configured, but network namespace setup failed, ignoring: %m");
else if (r < 0) {
*exit_status = EXIT_NETWORK;
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
if (r < 0) {
if (ERRNO_IS_PRIVILEGE(r))
log_unit_warning_errno(unit, r,
"PrivateNetwork=yes is configured, but network namespace setup failed, ignoring: %m");
else {
*exit_status = EXIT_NETWORK;
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
}
}
} else if (context->network_namespace_path) {
*exit_status = EXIT_NETWORK;
Expand All @@ -4870,12 +4872,14 @@ static int exec_child(

if (ns_type_supported(NAMESPACE_IPC)) {
r = setup_shareable_ns(runtime->ipcns_storage_socket, CLONE_NEWIPC);
if (r == -EPERM)
log_unit_warning_errno(unit, r,
"PrivateIPC=yes is configured, but IPC namespace setup failed, ignoring: %m");
else if (r < 0) {
*exit_status = EXIT_NAMESPACE;
return log_unit_error_errno(unit, r, "Failed to set up IPC namespacing: %m");
if (r < 0) {
if (ERRNO_IS_PRIVILEGE(r))
log_unit_warning_errno(unit, r,
"PrivateIPC=yes is configured, but IPC namespace setup failed, ignoring: %m");
else {
*exit_status = EXIT_NAMESPACE;
return log_unit_error_errno(unit, r, "Failed to set up IPC namespacing: %m");
}
}
} else if (context->ipc_namespace_path) {
*exit_status = EXIT_NAMESPACE;
Expand Down

0 comments on commit 524610a

Please sign in to comment.