diff options
author | Gary Tierney <gary.tierney@gmx.com> | 2017-05-02 17:42:19 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-07-25 09:46:52 +0200 |
commit | e666102220558dbb43210176129b3ea8245c578c (patch) | |
tree | fedc9056d8431171f29b5ec35295f389b0d30234 /src/basic/selinux-util.c | |
parent | d5aacbb6077b4e45fd36fbff6843595aa64d2288 (diff) |
Revert "selinux: split up mac_selinux_have() from mac_selinux_use()"
This reverts commit 6355e75610a8d47fc3ba5ab8bd442172a2cfe574.
The previously mentioned commit inadvertently broke a lot of SELinux related
functionality for both unprivileged users and elogind instances running as
MANAGER_USER. In particular, setting the correct SELinux context after a User=
directive is used would fail to work since we attempt to set the security
context after changing UID. Additionally, it causes activated socket units to
be mislabeled for elogind --user processes since setsockcreatecon() would never
be called.
Reverting this fixes the issues with labeling outlined above, and reinstates
SELinux access checks on unprivileged user services.
Diffstat (limited to 'src/basic/selinux-util.c')
-rw-r--r-- | src/basic/selinux-util.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/basic/selinux-util.c b/src/basic/selinux-util.c index 2a9dd7c8c..79ce6a856 100644 --- a/src/basic/selinux-util.c +++ b/src/basic/selinux-util.c @@ -53,7 +53,7 @@ static struct selabel_handle *label_hnd = NULL; #define log_enforcing(...) log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG, __VA_ARGS__) #endif -bool mac_selinux_have(void) { +bool mac_selinux_use(void) { #ifdef HAVE_SELINUX if (cached_use < 0) cached_use = is_selinux_enabled() > 0; @@ -64,16 +64,6 @@ bool mac_selinux_have(void) { #endif } -bool mac_selinux_use(void) { - if (!mac_selinux_have()) - return false; - - /* Never try to configure SELinux features if we aren't - * root */ - - return getuid() == 0; -} - void mac_selinux_retest(void) { #ifdef HAVE_SELINUX cached_use = -1; @@ -206,7 +196,7 @@ int mac_selinux_get_create_label_from_exe(const char *exe, char **label) { assert(exe); assert(label); - if (!mac_selinux_have()) + if (!mac_selinux_use()) return -EOPNOTSUPP; r = getcon_raw(&mycon); @@ -232,7 +222,7 @@ int mac_selinux_get_our_label(char **label) { assert(label); #ifdef HAVE_SELINUX - if (!mac_selinux_have()) + if (!mac_selinux_use()) return -EOPNOTSUPP; r = getcon_raw(label); @@ -256,7 +246,7 @@ int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char * assert(exe); assert(label); - if (!mac_selinux_have()) + if (!mac_selinux_use()) return -EOPNOTSUPP; r = getcon_raw(&mycon); @@ -311,7 +301,7 @@ char* mac_selinux_free(char *label) { if (!label) return NULL; - if (!mac_selinux_have()) + if (!mac_selinux_use()) return NULL; |