X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Flabel.c;h=4a26ba9c5d1393a5a14d6981980473a6e2f5db9e;hb=2d5bdf5bc0e4714d42e5999a4e37553a6bf83575;hp=1fe4574633ef888089d3fbb4ea612f7badb84a0c;hpb=2fa4092c2829dd14e50c430ae2f23551d23c6c1d;p=elogind.git diff --git a/src/shared/label.c b/src/shared/label.c index 1fe457463..4a26ba9c5 100644 --- a/src/shared/label.c +++ b/src/shared/label.c @@ -20,7 +20,6 @@ ***/ #include -#include #include #include #include @@ -257,14 +256,14 @@ void label_free(const char *label) { #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; - if (!apply || !use_selinux() || !label_hnd) + if (!use_selinux() || !label_hnd) goto skipped; if (path_is_absolute(path)) @@ -384,3 +383,15 @@ skipped: #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; +}