1getfilecon(3) SELinux API documentation getfilecon(3)
2
3
4
6 getfilecon, fgetfilecon, lgetfilecon - get SELinux security context of
7 a file
8
10 #include <selinux/selinux.h>
11
12 int getfilecon(const char *path, security_context_t *con);
13
14 int lgetfilecon(const char *path, security_context_t *con);
15
16 int fgetfilecon(int fd, security_context_t *con);
17
19 getfilecon retrieves the context associated with the given path in the
20 file system, the length of the context is returned.
21
22 lgetfilecon is identical to getfilecon, except in the case of a sym‐
23 bolic link, where the link itself is interrogated, not the file that it
24 refers to.
25
26 fgetfilecon is identical to getfilecon, only the open file pointed to
27 by filedes (as returned by open(2)) is interrogated in place of path.
28
29
30 The returned context should be freed with freecon if non-NULL.
31
33 On success, a positive number is returned indicating the size of the
34 extended attribute value. On failure, -1 is returned and errno is set
35 appropriately.
36
37 If the context does not exist, or the process has no access to this
38 attribute, errno is set to ENODATA.
39
40 If extended attributes are not supported by the filesystem, or are dis-
41 abled, errno is set to ENOTSUP.
42
43 The errors documented for the stat(2) system call are also applicable
44 here.
45
46
48 selinux(8), freecon(3), setfilecon(3), setfscreatecon(3)
49
50
51
52russell@coker.com.au 1 January 2004 getfilecon(3)