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

Reload config on SELinux policy load #379

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/util/selinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <c-stdaux.h>
#include <selinux/selinux.h>
#include <selinux/avc.h>
#include <signal.h>
#include <stdlib.h>
#include "util/audit.h"
#include "util/error.h"
Expand Down Expand Up @@ -340,6 +341,17 @@ static int bus_selinux_log(int type, const char *fmt, ...) {
return 0;
}

/**
* On a policy reload we need to reparse the SELinux configuration file, since
* this could have changed. The call back is registered in the broker, and
* the SIGHUP is caught in the launcher. So, send a SIGHUP to our parent to
* reload all configs.
*/
static int policy_reload_callback(int seqno) {
pid_t ppid = getppid();
return kill(ppid, SIGHUP);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The launcher/controller is not necessarily the parent PID. We need to pass this through the controller interface, just like the other activation related messages.

}

/**
* bus_selinux_init_global() - initialize the global SELinux context
*
Expand Down Expand Up @@ -386,6 +398,7 @@ int bus_selinux_init_global(void) {
}

selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback)bus_selinux_log);
selinux_set_callback(SELINUX_CB_POLICYLOAD, (union selinux_callback)policy_reload_callback);

/* XXX: set audit callback to get more metadata in the audit log? */

Expand Down
Loading