-
Notifications
You must be signed in to change notification settings - Fork 84
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,10 @@ | |
#include "util/sockopt.h" | ||
#include "util/user.h" | ||
|
||
static int broker_propagate_sighup(Broker *broker) { | ||
return controller_dbus_send_sighup(&broker->controller); | ||
} | ||
|
||
static int broker_dispatch_signals(DispatchFile *file) { | ||
Broker *broker = c_container_of(file, Broker, signals_file); | ||
struct signalfd_siginfo si; | ||
|
@@ -37,6 +41,10 @@ static int broker_dispatch_signals(DispatchFile *file) { | |
|
||
c_assert(l == sizeof(si)); | ||
|
||
if (si.ssi_signo == SIGHUP) { | ||
broker_propagate_sighup(broker); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You probably want to propagate the return value of this call via error_fold(). You currently fall-through to DISPATCH_EXIT, which will terminate the broker (which likely is what you are seeing in your tests). |
||
} | ||
|
||
return DISPATCH_E_EXIT; | ||
} | ||
|
||
|
@@ -134,6 +142,7 @@ int broker_new(Broker **brokerp, const char *machine_id, int log_fd, int control | |
sigemptyset(&sigmask); | ||
sigaddset(&sigmask, SIGTERM); | ||
sigaddset(&sigmask, SIGINT); | ||
sigaddset(&sigmask, SIGHUP); | ||
|
||
broker->signals_fd = signalfd(-1, &sigmask, SFD_CLOEXEC | SFD_NONBLOCK); | ||
if (broker->signals_fd < 0) | ||
|
@@ -210,6 +219,7 @@ int broker_run(Broker *broker) { | |
sigemptyset(&signew); | ||
sigaddset(&signew, SIGTERM); | ||
sigaddset(&signew, SIGINT); | ||
sigaddset(&signew, SIGHUP); | ||
|
||
sigprocmask(SIG_BLOCK, &signew, &sigold); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -340,6 +341,15 @@ 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, but | ||
* we need to reload the configuration in the launcher. | ||
*/ | ||
static int policy_reload_callback(int seqno) { | ||
return raise(SIGHUP); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does SELinux do with return values from this callback? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In our case nothing. If the callback returns non-zero |
||
} | ||
|
||
/** | ||
* bus_selinux_init_global() - initialize the global SELinux context | ||
* | ||
|
@@ -386,6 +396,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? */ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.