Debian Codegraph @

libselinux/man/man3/getfilecon.3

raw
1 .TH "getfilecon" "3" "1 January 2004" "[email protected]" "SELinux API documentation"
2 .SH "NAME"
3 getfilecon, fgetfilecon, lgetfilecon \- get SELinux security context of a file
4 .
5 .SH "SYNOPSIS"
6 .B #include <selinux/selinux.h>
7 .sp
8 .BI "int getfilecon(const char *" path ", char **" con );
9 .sp
10 .BI "int getfilecon_raw(const char *" path ", char **" con );
11 .sp
12 .BI "int lgetfilecon(const char *" path ", char **" con );
13 .sp
14 .BI "int lgetfilecon_raw(const char *" path ", char **" con );
15 .sp
16 .BI "int fgetfilecon(int "fd ", char **" con );
17 .sp
18 .BI "int fgetfilecon_raw(int "fd ", char **" con );
19 .
20 .SH "DESCRIPTION"
21 .BR getfilecon ()
22 retrieves the context associated with the given path in the file system, the
23 length of the context is returned.
24
25 .BR lgetfilecon ()
26 is identical to
27 .BR getfilecon (),
28 except in the case of a symbolic link, where the
29 link itself is interrogated, not the file that it refers to.
30
31 .BR fgetfilecon ()
32 is identical to
33 .BR getfilecon (),
34 only the open file pointed to by filedes (as returned by
35 .BR open (2))
36 is interrogated in place of path.
37
38 .BR getfilecon_raw (),
39 .BR lgetfilecon_raw ()
40 and
41 .BR fgetfilecon_raw ()
42 behave identically to their non-raw counterparts but do not perform context
43 translation.
44
45 The returned context should be freed with
46 .BR freecon (3)
47 if non-NULL.
48 .
49 .SH "RETURN VALUE"
50 On success, a positive number is returned indicating the size of the
51 extended attribute value. On failure, \-1 is returned and
52 .I errno
53 is set appropriately.
54
55 If the context does not exist, or the process has no access to
56 this attribute,
57 .I errno
58 is set to
59 .BR ENODATA .
60
61 If extended attributes are not supported by the filesystem, or are
62 disabled,
63 .I errno
64 is set to
65 .BR ENOTSUP .
66
67 The errors documented for the
68 .BR stat (2)
69 system call are also applicable here.
70 .
71 .SH "SEE ALSO"
72 .BR selinux "(8), " freecon "(3), " setfilecon "(3), " setfscreatecon "(3)"