Debian Codegraph @

libselinux/man/man5/selabel_x.5

raw
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Author: Eamon Walsh ([email protected]) 2007
4 .TH "selabel_x" "5" "29 Nov 2011" "Security Enhanced Linux" "SELinux API documentation"
5 .SH "NAME"
6 selabel_x \- userspace SELinux labeling interface and configuration file format for the X Window System contexts backend. This backend is also used to determine the default context for labeling remotely connected X clients
7 .
8 .SH "SYNOPSIS"
9 .B #include <selinux/label.h>
10 .sp
11 .BI "int selabel_lookup(struct selabel_handle *" hnd ,
12 .in +\w'int selabel_lookup('u
13 .BI "char **" context ,
14 .br
15 .BI "const char *" object_name ", int " object_type ");"
16 .in
17 .sp
18 .BI "int selabel_lookup_raw(struct selabel_handle *" hnd ,
19 .in +\w'int selabel_lookup('u
20 .BI "char **" context ,
21 .br
22 .BI "const char *" object_name ", int " object_type ");"
23 .
24 .SH "DESCRIPTION"
25 The X contexts backend maps from X Window System object names into security contexts. It is used to find the appropriate context for X Window System objects whose significance and/or usage semantics are determined primarily by name. The returned \fIcontext\fR must be freed using \fBfreecon\fR(3).
26 .br
27 \fBselabel_lookup\fR(3) describes the function with its return and error codes.
28 .sp
29 This backend is also used to determine the default context for labeling remotely connected X clients.
30 .sp
31 The \fIobject_type\fR argument should be set to one of the following values:
32 .RS
33 .TP
34 .B SELABEL_X_PROP
35 The
36 .I object_name
37 argument specifies the name of a window property, such as "WM_NAME".
38 .TP
39 .B SELABEL_X_SELN
40 The
41 .I object_name
42 argument specifies the name of a selection, such as "PRIMARY".
43 .TP
44 .B SELABEL_X_EXT
45 The
46 .I object_name
47 argument specifies the name of a protocol extension, such as "RENDER".
48 .TP
49 .B SELABEL_X_EVENT
50 The
51 .I object_name
52 argument specifies the name of an event type, such as "X11:ButtonPress".
53 .TP
54 .B SELABEL_X_CLIENT
55 The
56 .I object_name
57 argument is ignored, however it should be set to either \fI*\fR (an asterisk or 'wildcard' that will select the default entry) or a specific entry such as "remote" in the X contexts file as shown in the \fBEXAMPLE\fR section. The default context for labeling remote X clients is then returned.
58 .TP
59 .B SELABEL_X_POLYPROP
60 Like
61 .BR SELABEL_X_PROP ,
62 but checks if the property was marked as being polyinstantiated. See \fBNOTES\fR below.
63 .TP
64 .B SELABEL_X_POLYSELN
65 Like
66 .BR SELABEL_X_SELN ,
67 but checks if the selection was marked as being polyinstantiated. See \fBNOTES\fR below.
68 .RE
69 .sp
70 Any messages generated by \fBselabel_lookup\fR(3) are sent to \fIstderr\fR by default, although this can be changed by \fBselinux_set_callback\fR(3).
71 .sp
72 .B selabel_lookup_raw
73 behaves identically to \fBselabel_lookup\fR but does not perform context translation.
74 .sp
75 The \fBFILES\fR section details the configuration files used to determine the X object context.
76 .
77 .SH "OPTIONS"
78 In addition to the global options described in \fBselabel_open\fR(3), this backend recognizes the following options:
79 .RS
80 .TP
81 .B SELABEL_OPT_PATH
82 A non-null value for this option specifies a path to a file that will be opened in lieu of the standard X contexts file (see the \fBFILES\fR section for details).
83 .RE
84 .
85 .SH "FILES"
86 The X context file used to retrieve a default context depends on the \fBSELABEL_OPT_PATH\fR parameter passed to \fBselabel_open\fR(3). If \fINULL\fR, then the \fBSELABEL_OPT_PATH\fR value will default to the active policy X contexts location (as returned by \fBselinux_x_context_path\fR(3)), otherwise the actual \fBSELABEL_OPT_PATH\fR value specified is used.
87 .sp
88 The default X object contexts file is:
89 .RS
90 .I /etc/selinux/{SELINUXTYPE}/contexts/x_contexts
91 .RE
92 .sp
93 Where \fI{SELINUXTYPE}\fR is the entry from the selinux configuration file \fIconfig\fR (see \fBselinux_config\fR(5)).
94 .sp
95 The entries within the X contexts file are shown in the \fBObject Name String Values\fR and \fBFILE FORMAT\fR sections.
96 .
97 .SH "Object Name String Values"
98 The string name assigned to each \fIobject_type\fR argument that can be present in the X contexts file are:
99 .TS
100 center, allbox, tab(@);
101 lI lB
102 lB l .
103 object_type@Text Name
104 SELABEL_X_PROP@property
105 SELABEL_X_SELN@selection
106 SELABEL_X_EXT@extension
107 SELABEL_X_EVENT@event
108 SELABEL_X_CLIENT@client
109 SELABEL_X_POLYPROP@poly_property
110 SELABEL_X_POLYSELN@poly_selection
111 .TE
112 .
113 .SH "FILE FORMAT"
114 Each line within the X contexts file is as follows:
115 .RS
116 .I object_type object_name context
117 .RE
118 .sp
119 Where:
120 .RS
121 .I object_type
122 .RS
123 This is the string representation of the object type shown in the \fBObject Name String Values\fR section.
124 There can be multiple lines with the same \fIobject_type\fR string that will form a block of entries (each with a different \fIobject_name\fR entry).
125 .RE
126 .I object_name
127 .RS
128 These are the object names of the specific X-server resource such as
129 \fBPRIMARY\fR, \fBCUT_BUFFER0\fR etc. They are generally defined in the
130 X-server source code (\fIprotocol.txt\fR and \fIBuiltInAtoms\fR in the
131 dix directory of the xorg\-server source package).
132 The entry can contain '*' for wildcard matching or '?' for substitution.
133 Note that if the '*' is used, then be aware that the order of entries in the file is important. The '*' on its own is used to ensure a default fallback context is assigned and should be the last entry in the \fIobject_type\fR block.
134 .RE
135 .I context
136 .RS
137 The security context that will be applied to the object.
138 .RE
139 .RE
140 .sp
141 Example 1:
142 .sp
143 .nf
144 # object_type object_name context
145 selection PRIMARY system_u:object_r:clipboard_xselection_t:s0
146 selection * system_u:object_r:xselection_t:s0
147 .fi
148 .sp
149 Example 2 - This example shows how a client entry can be configured to
150 ensure an entry is always found:
151 .sp
152 .nf
153 # object_type object_name context
154 client * system_u:object_r:remote_t:s0
155 .fi
156 .
157 .SH "NOTES"
158 .IP "1." 4
159 Properties and selections are marked as either polyinstantiated or not. For these name types, the "POLY" option searches only the names marked as being polyinstantiated, while the other option searches only the names marked as not being polyinstantiated. Users of the interface should check both mappings, optionally taking action based on the result (e.g. polyinstantiating the object).
160 .IP "2." 4
161 If contexts are to be validated, then the global option \fBSELABEL_OPT_VALIDATE\fR must be set before calling \fBselabel_open\fR(3). If this is not set, then it is possible for an invalid context to be returned.
162 .
163 .SH "SEE ALSO"
164 .ad l
165 .nh
166 .BR selinux "(8), " selabel_open "(3), " selabel_lookup "(3), " selabel_stats "(3), " selabel_close "(3), " selinux_set_callback "(3), " selinux_x_context_path "(3), " freecon "(3), " selinux_config "(5) "