Skip to content

Commit 2ad2925

Browse files
topimiettinenyuwata
authored andcommitted
execute: respect selinux_context_ignore
When `SELinuxContext=` parameter is prefixed with `-`, the documentation states that any errors determining or changing context should be ignored, but this doesn't actually happen and the service may fail with `229/SELINUX_CONTEXT`. Fix by adding checks to `context->selinux_context_ignore`. Closes: systemd#21057
1 parent 6b64d74 commit 2ad2925

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,7 +4566,7 @@ static int exec_child(
45664566

45674567
if (fd >= 0) {
45684568
r = mac_selinux_get_child_mls_label(fd, executable, context->selinux_context, &mac_selinux_context_net);
4569-
if (r < 0) {
4569+
if (r < 0 && !context->selinux_context_ignore) {
45704570
*exit_status = EXIT_SELINUX_CONTEXT;
45714571
return log_unit_error_errno(unit, r, "Failed to determine SELinux context: %m");
45724572
}
@@ -4700,7 +4700,7 @@ static int exec_child(
47004700

47014701
if (exec_context) {
47024702
r = setexeccon(exec_context);
4703-
if (r < 0) {
4703+
if (r < 0 && !context->selinux_context_ignore) {
47044704
*exit_status = EXIT_SELINUX_CONTEXT;
47054705
return log_unit_error_errno(unit, r, "Failed to change SELinux context to %s: %m", exec_context);
47064706
}

0 commit comments

Comments
 (0)