]> git.ipfire.org Git - thirdparty/util-linux.git/blob - login-utils/selinux_utils.c
man pages: Change a HYPHEN-MINUS (-) to a minus (\-) for options and numbers
[thirdparty/util-linux.git] / login-utils / selinux_utils.c
1 #include <selinux/context.h>
2 #include <selinux/selinux.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <sys/types.h>
6
7 #include "selinux_utils.h"
8
9 access_vector_t get_access_vector(const char *tclass, const char *op)
10 {
11 security_class_t tc = string_to_security_class(tclass);
12
13 return tc ? string_to_av_perm(tc, op) : 0;
14 }
15
16 int setupDefaultContext(char *orig_file)
17 {
18 if (is_selinux_enabled() > 0) {
19 security_context_t scontext;
20 if (getfilecon(orig_file, &scontext) < 0)
21 return 1;
22 if (setfscreatecon(scontext) < 0) {
23 freecon(scontext);
24 return 1;
25 }
26 freecon(scontext);
27 }
28 return 0;
29 }