chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v229: Add missing fixes from upstream [1/6] src/basic
[elogind.git]
/
src
/
basic
/
selinux-util.c
diff --git
a/src/basic/selinux-util.c
b/src/basic/selinux-util.c
index 09ee7be917c54c93da482b13a9560d1d9a844a0f..700b2e82960d3f5898f69e4544573c24fd8e18e1 100644
(file)
--- a/
src/basic/selinux-util.c
+++ b/
src/basic/selinux-util.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-21,7
+19,12
@@
#include <errno.h>
#include <malloc.h>
#include <errno.h>
#include <malloc.h>
+#include <stddef.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/un.h>
#include <sys/un.h>
+#include <syslog.h>
#ifdef HAVE_SELINUX
#include <selinux/context.h>
#ifdef HAVE_SELINUX
#include <selinux/context.h>
@@
-30,9
+33,12
@@
#endif
#include "alloc-util.h"
#endif
#include "alloc-util.h"
+#include "log.h"
+#include "macro.h"
#include "path-util.h"
#include "selinux-util.h"
#include "path-util.h"
#include "selinux-util.h"
-#include "strv.h"
+#include "time-util.h"
+#include "util.h"
#ifdef HAVE_SELINUX
DEFINE_TRIVIAL_CLEANUP_FUNC(security_context_t, freecon);
#ifdef HAVE_SELINUX
DEFINE_TRIVIAL_CLEANUP_FUNC(security_context_t, freecon);
@@
-47,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
#define log_enforcing(...) log_full(security_getenforce() == 1 ? LOG_ERR : LOG_DEBUG, __VA_ARGS__)
#endif
-bool mac_selinux_
us
e(void) {
+bool mac_selinux_
hav
e(void) {
#ifdef HAVE_SELINUX
if (cached_use < 0)
cached_use = is_selinux_enabled() > 0;
#ifdef HAVE_SELINUX
if (cached_use < 0)
cached_use = is_selinux_enabled() > 0;
@@
-58,8
+64,17
@@
bool mac_selinux_use(void) {
#endif
}
#endif
}
-/// UNNEEDED by elogind
-#if 0
+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;
+}
+
+#if 0 /// UNNEEDED by elogind
void mac_selinux_retest(void) {
#ifdef HAVE_SELINUX
cached_use = -1;
void mac_selinux_retest(void) {
#ifdef HAVE_SELINUX
cached_use = -1;
@@
-113,8
+128,7
@@
int mac_selinux_init(const char *prefix) {
return r;
}
return r;
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
void mac_selinux_finish(void) {
#ifdef HAVE_SELINUX
void mac_selinux_finish(void) {
#ifdef HAVE_SELINUX
@@
-175,8
+189,7
@@
int mac_selinux_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
return 0;
}
return 0;
}
-/// UNNEDED by elogind
-#if 0
+#if 0 /// UNNEDED by elogind
int mac_selinux_apply(const char *path, const char *label) {
#ifdef HAVE_SELINUX
int mac_selinux_apply(const char *path, const char *label) {
#ifdef HAVE_SELINUX
@@
-205,7
+218,7
@@
int mac_selinux_get_create_label_from_exe(const char *exe, char **label) {
assert(exe);
assert(label);
assert(exe);
assert(label);
- if (!mac_selinux_
us
e())
+ if (!mac_selinux_
hav
e())
return -EOPNOTSUPP;
r = getcon_raw(&mycon);
return -EOPNOTSUPP;
r = getcon_raw(&mycon);
@@
-231,7
+244,7
@@
int mac_selinux_get_our_label(char **label) {
assert(label);
#ifdef HAVE_SELINUX
assert(label);
#ifdef HAVE_SELINUX
- if (!mac_selinux_
us
e())
+ if (!mac_selinux_
hav
e())
return -EOPNOTSUPP;
r = getcon_raw(label);
return -EOPNOTSUPP;
r = getcon_raw(label);
@@
-255,7
+268,7
@@
int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *
assert(exe);
assert(label);
assert(exe);
assert(label);
- if (!mac_selinux_
us
e())
+ if (!mac_selinux_
hav
e())
return -EOPNOTSUPP;
r = getcon_raw(&mycon);
return -EOPNOTSUPP;
r = getcon_raw(&mycon);
@@
-310,7
+323,7
@@
char* mac_selinux_free(char *label) {
if (!label)
return NULL;
if (!label)
return NULL;
- if (!mac_selinux_
us
e())
+ if (!mac_selinux_
hav
e())
return NULL;
return NULL;
@@
-376,8
+389,7
@@
void mac_selinux_create_file_clear(void) {
#endif
}
#endif
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
int mac_selinux_create_socket_prepare(const char *label) {
#ifdef HAVE_SELINUX
int mac_selinux_create_socket_prepare(const char *label) {
#ifdef HAVE_SELINUX