Debian Codegraph @

libselinux/man/man3/setfilecon.3

raw
1 .TH "setfilecon" "3" "1 January 2004" "[email protected]" "SELinux API documentation"
2 .SH "NAME"
3 setfilecon, fsetfilecon, lsetfilecon \- set SELinux security context of a file
4 .
5 .SH "SYNOPSIS"
6 .B #include <selinux/selinux.h>
7 .sp
8 .BI "int setfilecon(const char *" path ", char *" con );
9 .sp
10 .BI "int setfilecon_raw(const char *" path ", char *" con );
11 .sp
12 .BI "int lsetfilecon(const char *" path ", char *" con );
13 .sp
14 .BI "int lsetfilecon_raw(const char *" path ", char *" con );
15 .sp
16 .BI "int fsetfilecon(int "fd ", char *" con );
17 .sp
18 .BI "int fsetfilecon_raw(int "fd ", char *" con );
19 .
20 .SH "DESCRIPTION"
21 .BR setfilecon ()
22 sets the security context of the file system object.
23
24 .BR lsetfilecon ()
25 is identical to setfilecon, except in the case of a symbolic link, where the
26 link itself has it's context set, not the file that it refers to.
27
28 .BR fsetfilecon ()
29 is identical to setfilecon, only the open file pointed to by filedes (as
30 returned by
31 .BR open (2))
32 has it's context set in place of path.
33
34 .BR setfilecon_raw (),
35 .BR lsetfilecon_raw (),
36 and
37 .BR fsetfilecon_raw ()
38 behave identically to their non-raw counterparts but do not perform context
39 translation.
40 .
41 .SH "RETURN VALUE"
42 On success, zero is returned. On failure, \-1 is returned and
43 .I errno
44 is set appropriately.
45 .
46 .SH "ERRORS"
47 If there is insufficient space remaining to store the extended
48 attribute,
49 .I errno
50 is set to either
51 .BR ENOSPC ,
52 or
53 .B EDQUOT
54 if quota enforcement was the cause.
55
56 If extended attributes are not supported by the filesystem, or are disabled,
57 .I errno
58 is set to
59 .BR ENOTSUP .
60
61 The errors documented for the
62 .BR stat (2)
63 system call are also applicable here.
64 .
65 .SH "SEE ALSO"
66 .BR selinux "(3), " freecon "(3), " getfilecon "(3), " setfscreatecon "(3)"