.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" Author: Eamon Walsh (ewalsh@tycho.nsa.gov) 2007 .TH "selabel_x" "5" "29 Nov 2011" "Security Enhanced Linux" "SELinux API documentation" .SH "NAME" 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 . .SH "SYNOPSIS" .B #include .sp .BI "int selabel_lookup(struct selabel_handle *" hnd , .in +\w'int selabel_lookup('u .BI "char **" context , .br .BI "const char *" object_name ", int " object_type ");" .in .sp .BI "int selabel_lookup_raw(struct selabel_handle *" hnd , .in +\w'int selabel_lookup('u .BI "char **" context , .br .BI "const char *" object_name ", int " object_type ");" . .SH "DESCRIPTION" 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). .br \fBselabel_lookup\fR(3) describes the function with its return and error codes. .sp This backend is also used to determine the default context for labeling remotely connected X clients. .sp The \fIobject_type\fR argument should be set to one of the following values: .RS .TP .B SELABEL_X_PROP The .I object_name argument specifies the name of a window property, such as "WM_NAME". .TP .B SELABEL_X_SELN The .I object_name argument specifies the name of a selection, such as "PRIMARY". .TP .B SELABEL_X_EXT The .I object_name argument specifies the name of a protocol extension, such as "RENDER". .TP .B SELABEL_X_EVENT The .I object_name argument specifies the name of an event type, such as "X11:ButtonPress". .TP .B SELABEL_X_CLIENT The .I object_name 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. .TP .B SELABEL_X_POLYPROP Like .BR SELABEL_X_PROP , but checks if the property was marked as being polyinstantiated. See \fBNOTES\fR below. .TP .B SELABEL_X_POLYSELN Like .BR SELABEL_X_SELN , but checks if the selection was marked as being polyinstantiated. See \fBNOTES\fR below. .RE .sp 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). .sp .B selabel_lookup_raw behaves identically to \fBselabel_lookup\fR but does not perform context translation. .sp The \fBFILES\fR section details the configuration files used to determine the X object context. . .SH "OPTIONS" In addition to the global options described in \fBselabel_open\fR(3), this backend recognizes the following options: .RS .TP .B SELABEL_OPT_PATH 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). .RE . .SH "FILES" 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. .sp The default X object contexts file is: .RS .I /etc/selinux/{SELINUXTYPE}/contexts/x_contexts .RE .sp Where \fI{SELINUXTYPE}\fR is the entry from the selinux configuration file \fIconfig\fR (see \fBselinux_config\fR(5)). .sp The entries within the X contexts file are shown in the \fBObject Name String Values\fR and \fBFILE FORMAT\fR sections. . .SH "Object Name String Values" The string name assigned to each \fIobject_type\fR argument that can be present in the X contexts file are: .TS center, allbox, tab(@); lI lB lB l . object_type@Text Name SELABEL_X_PROP@property SELABEL_X_SELN@selection SELABEL_X_EXT@extension SELABEL_X_EVENT@event SELABEL_X_CLIENT@client SELABEL_X_POLYPROP@poly_property SELABEL_X_POLYSELN@poly_selection .TE . .SH "FILE FORMAT" Each line within the X contexts file is as follows: .RS .I object_type object_name context .RE .sp Where: .RS .I object_type .RS This is the string representation of the object type shown in the \fBObject Name String Values\fR section. 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). .RE .I object_name .RS These are the object names of the specific X-server resource such as \fBPRIMARY\fR, \fBCUT_BUFFER0\fR etc. They are generally defined in the X-server source code (\fIprotocol.txt\fR and \fIBuiltInAtoms\fR in the dix directory of the xorg\-server source package). The entry can contain '*' for wildcard matching or '?' for substitution. 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. .RE .I context .RS The security context that will be applied to the object. .RE .RE .sp Example 1: .sp .nf # object_type object_name context selection PRIMARY system_u:object_r:clipboard_xselection_t:s0 selection * system_u:object_r:xselection_t:s0 .fi .sp Example 2 - This example shows how a client entry can be configured to ensure an entry is always found: .sp .nf # object_type object_name context client * system_u:object_r:remote_t:s0 .fi . .SH "NOTES" .IP "1." 4 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). .IP "2." 4 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. . .SH "SEE ALSO" .ad l .nh .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) "