This source file includes following definitions.
- map_to_failure
- rpl_getfilecon
- rpl_lgetfilecon
- rpl_fgetfilecon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <selinux/selinux.h>
22
23 #include <sys/types.h>
24 #include <errno.h>
25 #include <string.h>
26
27
28
29 #ifndef ENODATA
30 # define ENODATA ENOTSUP
31 #endif
32
33 #undef getfilecon
34 #undef lgetfilecon
35 #undef fgetfilecon
36 int getfilecon (char const *file, char **con);
37 int lgetfilecon (char const *file, char **con);
38 int fgetfilecon (int fd, char **con);
39
40
41
42
43
44
45
46
47
48 static int
49 map_to_failure (int ret, char **con)
50 {
51 if (ret == 0)
52 {
53 errno = ENOTSUP;
54 return -1;
55 }
56
57 if (ret == 10 && strcmp (*con, "unlabeled") == 0)
58 {
59 freecon (*con);
60 *con = NULL;
61 errno = ENODATA;
62 return -1;
63 }
64
65 return ret;
66 }
67
68 int
69 rpl_getfilecon (char const *file, char **con)
70 {
71 int ret = getfilecon (file, con);
72 return map_to_failure (ret, con);
73 }
74
75 int
76 rpl_lgetfilecon (char const *file, char **con)
77 {
78 int ret = lgetfilecon (file, con);
79 return map_to_failure (ret, con);
80 }
81
82 int
83 rpl_fgetfilecon (int fd, char**con)
84 {
85 int ret = fgetfilecon (fd, con);
86 return map_to_failure (ret, con);
87 }