Skip to content

Commit 82cd0d7

Browse files
committed
executor: check for all permission related errnos when setting up IPC 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) (cherry picked from commit 524610a)
1 parent bf4d97f commit 82cd0d7

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/core/execute.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4710,12 +4710,14 @@ static int exec_child(
47104710

47114711
if (ns_type_supported(NAMESPACE_NET)) {
47124712
r = setup_shareable_ns(runtime->netns_storage_socket, CLONE_NEWNET);
4713-
if (r == -EPERM)
4714-
log_unit_warning_errno(unit, r,
4715-
"PrivateNetwork=yes is configured, but network namespace setup failed, ignoring: %m");
4716-
else if (r < 0) {
4717-
*exit_status = EXIT_NETWORK;
4718-
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
4713+
if (r < 0) {
4714+
if (ERRNO_IS_PRIVILEGE(r))
4715+
log_unit_warning_errno(unit, r,
4716+
"PrivateNetwork=yes is configured, but network namespace setup failed, ignoring: %m");
4717+
else {
4718+
*exit_status = EXIT_NETWORK;
4719+
return log_unit_error_errno(unit, r, "Failed to set up network namespacing: %m");
4720+
}
47194721
}
47204722
} else if (context->network_namespace_path) {
47214723
*exit_status = EXIT_NETWORK;
@@ -4729,12 +4731,14 @@ static int exec_child(
47294731

47304732
if (ns_type_supported(NAMESPACE_IPC)) {
47314733
r = setup_shareable_ns(runtime->ipcns_storage_socket, CLONE_NEWIPC);
4732-
if (r == -EPERM)
4733-
log_unit_warning_errno(unit, r,
4734-
"PrivateIPC=yes is configured, but IPC namespace setup failed, ignoring: %m");
4735-
else if (r < 0) {
4736-
*exit_status = EXIT_NAMESPACE;
4737-
return log_unit_error_errno(unit, r, "Failed to set up IPC namespacing: %m");
4734+
if (r < 0) {
4735+
if (ERRNO_IS_PRIVILEGE(r))
4736+
log_unit_warning_errno(unit, r,
4737+
"PrivateIPC=yes is configured, but IPC namespace setup failed, ignoring: %m");
4738+
else {
4739+
*exit_status = EXIT_NAMESPACE;
4740+
return log_unit_error_errno(unit, r, "Failed to set up IPC namespacing: %m");
4741+
}
47384742
}
47394743
} else if (context->ipc_namespace_path) {
47404744
*exit_status = EXIT_NAMESPACE;

0 commit comments

Comments
 (0)