chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
always use the same code for creating temporary files
[elogind.git]
/
src
/
shared
/
label.c
diff --git
a/src/shared/label.c
b/src/shared/label.c
index 1fe4574633ef888089d3fbb4ea612f7badb84a0c..4a26ba9c5d1393a5a14d6981980473a6e2f5db9e 100644
(file)
--- a/
src/shared/label.c
+++ b/
src/shared/label.c
@@
-20,7
+20,6
@@
***/
#include <errno.h>
***/
#include <errno.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <malloc.h>
#include <sys/socket.h>
#include <unistd.h>
#include <malloc.h>
#include <sys/socket.h>
@@
-257,14
+256,14
@@
void label_free(const char *label) {
#endif
}
#endif
}
-int label_mkdir(const char *path, mode_t mode
, bool apply
) {
+int label_mkdir(const char *path, mode_t mode) {
/* Creates a directory and labels it according to the SELinux policy */
#ifdef HAVE_SELINUX
int r;
security_context_t fcon = NULL;
/* Creates a directory and labels it according to the SELinux policy */
#ifdef HAVE_SELINUX
int r;
security_context_t fcon = NULL;
- if (!
apply || !
use_selinux() || !label_hnd)
+ if (!use_selinux() || !label_hnd)
goto skipped;
if (path_is_absolute(path))
goto skipped;
if (path_is_absolute(path))
@@
-384,3
+383,15
@@
skipped:
#endif
return bind(fd, addr, addrlen) < 0 ? -errno : 0;
}
#endif
return bind(fd, addr, addrlen) < 0 ? -errno : 0;
}
+
+int label_apply(const char *path, const char *label) {
+ int r = 0;
+
+#ifdef HAVE_SELINUX
+ if (!use_selinux())
+ return 0;
+
+ r = setfilecon(path, (char *)label);
+#endif
+ return r;
+}