Debian Codegraph @

libselinux/man/man3/getsockcreatecon.3

raw
1 .TH "getsockcreatecon" "3" "24 September 2008" "[email protected]" "SELinux API documentation"
2 .SH "NAME"
3 getsockcreatecon, setsockcreatecon \- get or set the SELinux security context used for creating a new labeled sockets
4 .
5 .SH "SYNOPSIS"
6 .B #include <selinux/selinux.h>
7 .sp
8 .BI "int getsockcreatecon(char **" con );
9 .sp
10 .BI "int getsockcreatecon_raw(char **" con );
11 .sp
12 .BI "int setsockcreatecon(char *" context );
13 .sp
14 .BI "int setsockcreatecon_raw(char *" context );
15 .
16 .SH "DESCRIPTION"
17 .BR getsockcreatecon ()
18 retrieves the context used for creating a new labeled network socket.
19 This returned context should be freed with
20 .BR freecon (3)
21 if non-NULL.
22 .BR getsockcreatecon ()
23 sets *con to NULL if no sockcreate context has been explicitly
24 set by the program (i.e. using the default policy behavior).
25
26 .BR setsockcreatecon ()
27 sets the context used for creating a new labeled network sockets
28 NULL can be passed to
29 .BR setsockcreatecon ()
30 to reset to the default policy behavior.
31 The sockcreate context is automatically reset after the next
32 .BR execve (2),
33 so a program doesn't need to explicitly sanitize it upon startup.
34
35 .BR setsockcreatecon ()
36 can be applied prior to library
37 functions that internally perform an file creation,
38 in order to set an file context on the objects.
39
40 .BR getsockcreatecon_raw ()
41 and
42 .BR setsockcreatecon_raw ()
43 behave identically to their non-raw counterparts but do not perform context
44 translation.
45
46 .B Note:
47 Signal handlers that perform a
48 .BR setsockcreatecon ()
49 must take care to
50 save, reset, and restore the sockcreate context to avoid unexpected behavior.
51 .
52
53 .br
54 .B Note:
55 Contexts are thread specific.
56
57 .SH "RETURN VALUE"
58 On error \-1 is returned.
59 On success 0 is returned.
60 .
61 .SH "SEE ALSO"
62 .BR selinux "(8), " freecon "(3), " getcon "(3)