
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://selinuxproject.org/w/skins/common/feed.css?63"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;action=history&amp;feed=atom</id>
		<title>Experimenting With X-Windows - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;action=history&amp;feed=atom"/>
		<link rel="alternate" type="text/html" href="http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;action=history"/>
		<updated>2013-05-21T13:36:42Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.10.4</generator>

	<entry>
		<id>http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;diff=912&amp;oldid=prev</id>
		<title>RichardHaines at 15:10, 15 March 2010</title>
		<link rel="alternate" type="text/html" href="http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;diff=912&amp;oldid=prev"/>
				<updated>2010-03-15T15:10:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table border='0' width='98%' cellpadding='0' cellspacing='4' style=&quot;background-color: white;&quot;&gt;
			&lt;tr&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' width='50%' align='center' style=&quot;background-color: white;&quot;&gt;Revision as of 15:10, 15 March 2010&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 217:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 217:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;* The Base Module described in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section. This will install the base policy module and supporting files in the &amp;lt;tt&amp;gt;/etc/selinux/modular-test&amp;lt;/tt&amp;gt; area. &lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;* The Base Module described in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section. This will install the base policy module and supporting files in the &amp;lt;tt&amp;gt;/etc/selinux/modular-test&amp;lt;/tt&amp;gt; area. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; font-size: smaller;&quot;&gt;* Two modified &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files. The Reference Policy sample has been modified to capture additional entries and for each entry allocate its own unique object label. There is one file to support the way the Reference Policy (build 20090730) supports these objects&amp;lt;ref name=&amp;quot;&lt;del style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;ftn3&lt;/del&gt;&amp;quot;&amp;gt;Also known as 'derived type' because the objects are assigned labels that are derivied from a name based on the SELinux user or a prefix (e.g. from the '&amp;lt;tt&amp;gt;users_extra&amp;lt;/tt&amp;gt;' configuration file) and then uses a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; statement to transition the object to the new label on creation.&amp;lt;/ref&amp;gt;, and the other has the additional '&amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt;' keyword added to support polyinstantiated property and selection entries. &lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;* Two modified &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files. The Reference Policy sample has been modified to capture additional entries and for each entry allocate its own unique object label. There is one file to support the way the Reference Policy (build 20090730) supports these objects&amp;lt;ref name=&amp;quot;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;ref1&lt;/ins&gt;&amp;quot;&amp;gt;Also known as 'derived type' because the objects are assigned labels that are derivied from a name based on the SELinux user or a prefix (e.g. from the '&amp;lt;tt&amp;gt;users_extra&amp;lt;/tt&amp;gt;' configuration file) and then uses a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; statement to transition the object to the new label on creation.&amp;lt;/ref&amp;gt;, and the other has the additional '&amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt;' keyword added to support polyinstantiated property and selection entries. &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;Important note - These sample &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files must not be used with the reference policy as they are incompatible and will cause the system to hang when X-Windows is being loaded&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;Important note - These sample &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files must not be used with the reference policy as they are incompatible and will cause the system to hang when X-Windows is being loaded&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 578:&lt;/strong&gt;&lt;/td&gt;
&lt;td colspan=&quot;2&quot; align=&quot;left&quot;&gt;&lt;strong&gt;Line 578:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;allow x_select_paste_t self:x_selection { getattr setattr read };&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;allow x_select_paste_t self:x_selection { getattr setattr read };&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; font-size: smaller;&quot;&gt;&amp;lt;/pre&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; font-size: smaller;&quot;&gt;&amp;lt;references/&amp;gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>RichardHaines</name></author>	</entry>

	<entry>
		<id>http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;diff=907&amp;oldid=prev</id>
		<title>RichardHaines: New page: = Experimenting with X-Windows = == Section Overview == The main objectives of this section are to:  * Demonstrate the use of '&lt;tt&gt;selections&lt;/tt&gt;' using polyinstantiation and non- polyins...</title>
		<link rel="alternate" type="text/html" href="http://selinuxproject.org/w/?title=Experimenting_With_X-Windows&amp;diff=907&amp;oldid=prev"/>
				<updated>2010-03-14T16:47:11Z</updated>
		
		<summary type="html">&lt;p&gt;New page: = Experimenting with X-Windows = == Section Overview == The main objectives of this section are to:  * Demonstrate the use of '&amp;lt;tt&amp;gt;selections&amp;lt;/tt&amp;gt;' using polyinstantiation and non- polyins...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Experimenting with X-Windows =&lt;br /&gt;
== Section Overview ==&lt;br /&gt;
The main objectives of this section are to:&lt;br /&gt;
&lt;br /&gt;
* Demonstrate the use of '&amp;lt;tt&amp;gt;selections&amp;lt;/tt&amp;gt;' using polyinstantiation and non- polyinstantiation services of the XSELinux Object Manager (OM) with simple Xlib simple select and paste applications.&lt;br /&gt;
* Use the XSELinux OM &amp;lt;tt&amp;gt;SELinuxGet..&amp;lt;/tt&amp;gt; series of functions to display various context information that is available while executing the select and paste examples.&lt;br /&gt;
* Build a simple menu driven test application that will allow all the &amp;lt;tt&amp;gt;SELinuxGet/Set..&amp;lt;/tt&amp;gt; functions to be called and view the results. This is shown in the [[Building the XSELinux Function Test Application]] section.&lt;br /&gt;
&lt;br /&gt;
It is recommended that the [http://taiga.selinuxproject.org/~rhaines/notebook-source-1.1.0-1.tar.gz Notebook Source] file is installed in your &amp;lt;tt&amp;gt;$HOME&amp;lt;/tt&amp;gt; as this contains all the configuration files and source code required to produce the required modules. It also contains README and a simple Makefile for each section.&lt;br /&gt;
&lt;br /&gt;
This section assumes the following:&lt;br /&gt;
* The message filter modules have been removed before starting this exercise, however it is not mandatory.&lt;br /&gt;
* SELinux is configured to use the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy in permissive mode initially to build the services. The &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy is decribed in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview of Modules and Applications ==&lt;br /&gt;
The loadable modules used to support these exercises are built using standard SELinux language statements and rules with customised &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files to support the labeling of objects.&lt;br /&gt;
&lt;br /&gt;
The test applications are written in 'C' and use the Xlib function library with Xdevice functions provided by the Xi library. There were a few problems encountered that are discussed in the [[#Calling the XSELinux Functions|Calling the XSELinux Functions]] section.&lt;br /&gt;
&lt;br /&gt;
=== The x_contexts Files and Supporting Loadable Module ===&lt;br /&gt;
The source files required to build and manage the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files and supporting loadable module are located in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./notebook-source/x-windows/x-contexts-base-module&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As the objective of the demonstration is to show how different entries in the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file affect the use of selections it was decided to build two &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files based on those in the Reference Policy 20090730 build. To support the new entries created in these &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files, required an additional loadable module (&amp;lt;tt&amp;gt;x_context_base.conf&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files are expanded to give each entry a unique label so that it could be detected in the audit log with &amp;lt;tt&amp;gt;audit2allow&amp;lt;/tt&amp;gt; when in enforcing mode, a decision could then be made as to whether an &amp;lt;tt&amp;gt;allow&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;dontaudit&amp;lt;/tt&amp;gt; rule would be added to the policy. Additional entries were also added just to experiment. A second copy of the file was made that had the &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; keyword added to the property and selection entries to test polyinstantiation.&lt;br /&gt;
&lt;br /&gt;
The only entry that caused problems during testing was the:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
poly_property _XKB_RULES_NAMES .....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This entry had to have the &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; keyword removed in the polyinstantiated file as it stopped various keys from working (up/down etc. keys) on the keyboard.&lt;br /&gt;
&lt;br /&gt;
The new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files generated are called:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''x_contexts-file-with-new-labels'''&amp;lt;/tt&amp;gt; - This file is similar to that used by the reference policy. The select and paste policy uses the same method to manage the labeling as the reference policy - called derived labeling as the objects label is derived from an SELinux user name or a prefix (from the '&amp;lt;tt&amp;gt;users_extra&amp;lt;/tt&amp;gt;' configuration file), then use a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; to transition the object to the new label on creation. For example (using standard Refpolicy):&lt;br /&gt;
&lt;br /&gt;
An &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; entry of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
event X11:MapNotifysystem_u:object_r:manage_xevent_t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the ssh policy module (after expansion) having a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; statement generated by the build process of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
type_transition ssh_t manage_xevent_t : x_event ssh_manage_xevent_t;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will relabel any objects created from &amp;lt;tt&amp;gt;manage_xevent_t&amp;lt;/tt&amp;gt; to &amp;lt;tt&amp;gt;ssh_manage_xevent_t&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''x_contexts-file-with-new-polylabels'''&amp;lt;/tt&amp;gt; - This is used to support polyinstantiated entries (note - the reference policy does not currently use polyinstantiated entries). With polyinstantiation enabled, the select and paste policy uses the &amp;lt;tt&amp;gt;type_member&amp;lt;/tt&amp;gt; rule to enforce the selection to a specific domain (in this example the &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domain) as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
type_member x_select_paste_t primary_xselection_t : x_selection  x_select_paste_t; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To support these new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file entries an additional policy module was built that defines a &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; for each entry and a corresponding &amp;lt;tt&amp;gt;allow&amp;lt;/tt&amp;gt; rule. This module is called &amp;lt;tt&amp;gt;x_context_base.conf&amp;lt;/tt&amp;gt; and must be loaded and active when the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy is loaded with either of the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files. Failure to do this will probably result in the system hanging as it tries to load X-Windows with no defined &amp;lt;tt&amp;gt;type&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;allow&amp;lt;/tt&amp;gt; rules for the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To experiment with additional &amp;lt;tt&amp;gt;x_context&amp;lt;/tt&amp;gt; entries:&lt;br /&gt;
&lt;br /&gt;
* Add a new entry in the appropriate &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file such as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
property WM_ZOOM_HINTS system_u:object_r:wm_zoom_hints_xproperty_t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
poly_property WM_ZOOM_HINTS system_u:object_r:wm_zoom_hints_xproperty_t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Add new entries in the &amp;lt;tt&amp;gt;x_context_base.conf&amp;lt;/tt&amp;gt; for the&amp;lt;tt&amp;gt; type&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;allow&amp;lt;/tt&amp;gt; statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
type wm_zoom_hints_xproperty_t;&lt;br /&gt;
allow unconfined_t wm_zoom_hints_xproperty_t : x_property *;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Run the &amp;lt;tt&amp;gt;make module&amp;lt;/tt&amp;gt; command (in the &amp;lt;tt&amp;gt;./x-windows/x-contexts-base-module&amp;lt;/tt&amp;gt; directory) and copy over the appropriate &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file to &amp;lt;tt&amp;gt;/etc/selinux/modular-test/contexts&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== The Select - Paste Applications and Loadable Module ===&lt;br /&gt;
The source files required to build and manage the application and loadable module are located in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 ./notebook-source/x-windows/x-select+paste&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are two simple X-Windows applications that select (X-select) and paste (X-paste) “Hello World” using Xlib selection functions. When they are loaded they show the application name and their context in the title bar as shown in [http://taiga.selinuxproject.org/~rhaines/diagrams/Derived-Test1.png Figure 1]. Integrated with these applications are calls to the &amp;lt;tt&amp;gt;XSELinuxGet..&amp;lt;/tt&amp;gt; functions to return context information as the Xlib functions are executed. &lt;br /&gt;
&lt;br /&gt;
The output from the applications can also be captured in a file by adding the capture file name as an argument:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X-select poly-demo.txt&lt;br /&gt;
&lt;br /&gt;
# The output will be in poly-demo.txt, with some text also&lt;br /&gt;
# displayed on the screen.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the two applications are built they are moved to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; and have the default label of &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt;. When they are both loaded in the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; domain, there are no enforced rules (i.e. there are no restrictions). If the &amp;lt;tt&amp;gt;x_select_paste.conf&amp;lt;/tt&amp;gt; module is built and loaded, then when they are run as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
runcon -t x_select_paste_t X-select&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
runcon -t x_select_paste_t X-paste&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Policy will be enforced as required depending on a boolean that when set to:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setsebool -P poly-selection false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the &amp;lt;tt&amp;gt;x_contexts-file-with-new-labels&amp;lt;/tt&amp;gt; file is installed as the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file, then the derived policy rules will be enforced.&lt;br /&gt;
&lt;br /&gt;
If the boolean is set to:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setsebool -P poly-selection true&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the &amp;lt;tt&amp;gt;x_contexts-file-with-new-polylabels&amp;lt;/tt&amp;gt; file is installed as the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file, then the polyinstantiated policy rules will be enforced.&lt;br /&gt;
&lt;br /&gt;
==== Test Conclusions ====&lt;br /&gt;
After a number of experiments the following conclusions were reached:&lt;br /&gt;
&lt;br /&gt;
* Using the non-polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file (with &amp;lt;tt&amp;gt;poly-selection = FALSE&amp;lt;/tt&amp;gt;), resulted in selections being seen across all windows whether running in &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains.&lt;br /&gt;
* Using the polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file (with &amp;lt;tt&amp;gt;poly-selection = TRUE&amp;lt;/tt&amp;gt;), resulted in selections being restricted to windows running in their own domains (e.g. if running the X-select in the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; domain and X-paste in the &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains, the selected text will not be pasted).&lt;br /&gt;
* If the following multiple selection entries are added to the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file, then the non &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; entry takes precedence. This means that polyinstantiation for selections will not work (even if a different label is used for each entry).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# The poly and non-poly entries cannot be in the x_contexts&lt;br /&gt;
# file as the non-poly entry takes precedence:&lt;br /&gt;
poly_selection PRIMARY system_u:object_r:primary_xselection_t&lt;br /&gt;
selection      PRIMARY system_u:object_r:primary_xselection_t&lt;br /&gt;
&lt;br /&gt;
# Even if different labels are used:&lt;br /&gt;
poly_selection PRIMARY system_u:object_r:poly_primary_xselection_t&lt;br /&gt;
selection      PRIMARY system_u:object_r:primary_xselection_t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Therefore the overall conclusion is that for non-MLS policies, the only effective way to control selections is using polyinstatiation with the &amp;lt;tt&amp;gt;type_member&amp;lt;/tt&amp;gt; rule.&lt;br /&gt;
&lt;br /&gt;
The reason for stating non-MLS policy is that the MLS policy uses &amp;lt;tt&amp;gt;mlsconstrain&amp;lt;/tt&amp;gt; rules to manage restrictions. Various constrain rules were used for non-MLS policy testing but no satisfactory result could be obtained - do you know different !!!&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* When using polyinstantiation the &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; keyword must be present in the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file and there must be a corresponding &amp;lt;tt&amp;gt;type_member&amp;lt;/tt&amp;gt; rule in the policy.&lt;br /&gt;
* When analysing the output from the XSELinux function calls between non-polyinstantiated (or derived) and polyinstantiated services when the X-select and X-paste applications are running (apart from their context information), the only major difference was that when calling the &amp;lt;tt&amp;gt;SELinuxListSelections&amp;lt;/tt&amp;gt; function, the polyinstantiated service had an additional &amp;lt;tt&amp;gt;PRIMARY&amp;lt;/tt&amp;gt; entry as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Non-polyinstantiated (derived) running in x_select_paste_t:&lt;br /&gt;
#&lt;br /&gt;
Calling SELinuxListSelections (21) for this display:&lt;br /&gt;
&lt;br /&gt;
SELinuxListSelections (1 of 10) - Atom: CLIPBOARD&lt;br /&gt;
Object Context: system_u:object_r:clipboard_xselection_t&lt;br /&gt;
Data Context: system_u:object_r:clipboard_xselection_t&lt;br /&gt;
&lt;br /&gt;
SELinuxListSelections (2 of 10) - Atom: PRIMARY&lt;br /&gt;
Object Context: system_u:object_r:primary_xselection_t&lt;br /&gt;
Data Context: system_u:object_r:primary_xselection_t&lt;br /&gt;
&lt;br /&gt;
# Polyinstantiated (derived) running in x_select_paste_t:&lt;br /&gt;
#&lt;br /&gt;
Calling SELinuxListSelections (21) for this display:&lt;br /&gt;
&lt;br /&gt;
SELinuxListSelections (1 of 11) - Atom: CLIPBOARD&lt;br /&gt;
Object Context: system_u:object_r:clipboard_xselection_t&lt;br /&gt;
Data Context: system_u:object_r:clipboard_xselection_t&lt;br /&gt;
&lt;br /&gt;
SELinuxListSelections (2 of 11) - Atom: PRIMARY&lt;br /&gt;
Object Context: system_u:object_r:primary_xselection_t&lt;br /&gt;
Data Context: system_u:object_r:primary_xselection_t&lt;br /&gt;
&lt;br /&gt;
SELinuxListSelections (3 of 11) - Atom: PRIMARY&lt;br /&gt;
Object Context: system_u:object_r:x_select_paste_t&lt;br /&gt;
Data Context: system_u:object_r:x_select_paste_t&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The Reference Policy does not use polyinstantiation but supports isolation only with the MLS policy where &amp;lt;tt&amp;gt;mlsconstrain&amp;lt;/tt&amp;gt; rules are enforced (see the &amp;lt;tt&amp;gt;mlsconstrain x_selection&amp;lt;/tt&amp;gt; entries in the &amp;lt;tt&amp;gt;mls&amp;lt;/tt&amp;gt; configuration file). &lt;br /&gt;
* Various &amp;lt;tt&amp;gt;constrain&amp;lt;/tt&amp;gt; rules were tried to limit selections with the non-polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file, but no satisfactory solution was found - any offers !!, therefore when using non-MLS policy, the only way to limit selections is via polyinstantiation. Some example constrain rules tried that had the following results:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Add constrain rule to base.conf:&lt;br /&gt;
constrain x_selection { read getattr } (t1 == unconfined_t);&lt;br /&gt;
&lt;br /&gt;
# When running &amp;quot;runcon -t x_select_paste_t X-paste&amp;quot; it flags the following&lt;br /&gt;
# AVC entry in the Xorg.0.log file:&lt;br /&gt;
&lt;br /&gt;
(WW) avc: denied { getattr } for request=X11:GetSelectionOwner comm=X-paste selection=PRIMARY scontext=user_u:unconfined_r:x_select_paste_t tcontext=system_u:object_r:primary_xselection_t tclass=x_selection&lt;br /&gt;
&lt;br /&gt;
# When running X-paste (in unconfined_t) then no errors in log.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Add constrain rule to base.conf:&lt;br /&gt;
constrain x_selection { read getattr } (t1 == secure_select); &lt;br /&gt;
# Where secure_select is an attribute declared in base.conf&lt;br /&gt;
&lt;br /&gt;
# With the following added to x_select_paste.conf:&lt;br /&gt;
require { attribute secure_select; .... }&lt;br /&gt;
typeattribute x_select_paste_t secure_select;&lt;br /&gt;
&lt;br /&gt;
# When running &amp;quot;runcon -t x_select_paste_t X-paste&amp;quot; there are no errors in&lt;br /&gt;
# the log.&lt;br /&gt;
&lt;br /&gt;
# When running X-paste (in unconfined_t) it flags the following AVC entry&lt;br /&gt;
# in the Xorg.0.log file:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(WW) avc: denied { getattr } for request=X11:GetSelectionOwner comm=X-paste selection=PRIMARY scontext=user_u:unconfined_r:unconfined_t tcontext=system_u:object_r:primary_xselection_t tclass=x_selection&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Calling the XSELinux Functions ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;X-paste&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;X-setest&amp;lt;/tt&amp;gt; applications call the object manager &amp;lt;tt&amp;gt;XSELinuxGet/Set..&amp;lt;/tt&amp;gt; functions to get and set contexts as required. To use these functions the standard Xlib &amp;lt;tt&amp;gt;GetReq&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;_XSend&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_XReply&amp;lt;/tt&amp;gt; functions need to be called to manage the request / response sequences. As there are 23 functions it was decided to build these into a separate 'C' module called &amp;lt;tt&amp;gt;XSELinuxOMFunctions.c&amp;lt;/tt&amp;gt; that is supported by a header file called &amp;lt;tt&amp;gt;Xlib-selinux.h&amp;lt;/tt&amp;gt;. that are located in the &amp;lt;tt&amp;gt;./x-windows/x-common&amp;lt;/tt&amp;gt; directory. &lt;br /&gt;
&lt;br /&gt;
The header file is based on the XSELinux extension source header &amp;lt;tt&amp;gt;xselinux.h&amp;lt;/tt&amp;gt; and has been expanded to support the Xlib &amp;lt;tt&amp;gt;GetReq&amp;lt;/tt&amp;gt; macro and associated functions. The only point to note is that the &amp;lt;tt&amp;gt;SELinuxQueryVersion&amp;lt;/tt&amp;gt; request header structure size had to be set to 4 instead of 6 as the &amp;lt;tt&amp;gt;client_major&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;client_minor&amp;lt;/tt&amp;gt; entries were not used and caused errors when added.&lt;br /&gt;
&lt;br /&gt;
The error handling caused much grief (as not an Xlib expert), and it will be seen that there are a number of flags to indicate certain error sequences. The source code has plenty of comments regarding these and if anyone has better methods let the author know.&lt;br /&gt;
&lt;br /&gt;
== Building the X-Windows Select and Paste Examples ==&lt;br /&gt;
To build and test the infrastructure to support modified &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files for the X-Windows object manager, the following will be required:&lt;br /&gt;
&lt;br /&gt;
* The Base Module described in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section. This will install the base policy module and supporting files in the &amp;lt;tt&amp;gt;/etc/selinux/modular-test&amp;lt;/tt&amp;gt; area. &lt;br /&gt;
* Two modified &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files. The Reference Policy sample has been modified to capture additional entries and for each entry allocate its own unique object label. There is one file to support the way the Reference Policy (build 20090730) supports these objects&amp;lt;ref name=&amp;quot;ftn3&amp;quot;&amp;gt;Also known as 'derived type' because the objects are assigned labels that are derivied from a name based on the SELinux user or a prefix (e.g. from the '&amp;lt;tt&amp;gt;users_extra&amp;lt;/tt&amp;gt;' configuration file) and then uses a &amp;lt;tt&amp;gt;type_transition&amp;lt;/tt&amp;gt; statement to transition the object to the new label on creation.&amp;lt;/ref&amp;gt;, and the other has the additional '&amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt;' keyword added to support polyinstantiated property and selection entries. &lt;br /&gt;
&lt;br /&gt;
Important note - These sample &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files must not be used with the reference policy as they are incompatible and will cause the system to hang when X-Windows is being loaded&lt;br /&gt;
&lt;br /&gt;
* A loadable module (&amp;lt;tt&amp;gt;x_context_base.conf&amp;lt;/tt&amp;gt;) that contains the policy type statements and allow rules of the newly defined &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file entries described in bullet b). This will allow the X-Windows object manager to load the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file without any errors.&lt;br /&gt;
* Two simple X-Windows applications - &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt; to automatically select some text (&amp;lt;tt&amp;gt;Hello World&amp;lt;/tt&amp;gt;), and &amp;lt;tt&amp;gt;X-paste&amp;lt;/tt&amp;gt; to paste the text onto the screen. These applications use the minimum &amp;lt;tt&amp;gt;Xlib&amp;lt;/tt&amp;gt; functions possible, however they also contain calls to the SELinux X-Windows functions that are built into the object manager to retrieve context information as the applications execute. &lt;br /&gt;
* A loadable module (&amp;lt;tt&amp;gt;x_select_paste.conf&amp;lt;/tt&amp;gt;) that contains the policy for enforcing the &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;X-paste&amp;lt;/tt&amp;gt; applications when running in the &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domain. This policy supports the polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file by setting a boolean (&amp;lt;tt&amp;gt;poly-selection&amp;lt;/tt&amp;gt;) to &amp;lt;tt&amp;gt;TRUE&amp;lt;/tt&amp;gt; and the the derived &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file by setting the boolean to &amp;lt;tt&amp;gt;FALSE&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The build and testing will be carried out in the following stages:&lt;br /&gt;
&lt;br /&gt;
* Ensure that the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; base module has been built and tested as described in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section.&lt;br /&gt;
* Build the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; files and a loadable module (&amp;lt;tt&amp;gt;x_context_base.conf&amp;lt;/tt&amp;gt;). The files to are available in the source file and located in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-contexts-base-module&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
* Build the X-select, X-paste applications and their supporting loadable module for running in the &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domain.&lt;br /&gt;
* Install the derived (non-polyinstantiated) &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file and test using the X-select and X-paste applications in various scenarios using the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains, recording the results.&lt;br /&gt;
* Install the polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file and test using the X-select and X-paste applications in various scenarios using the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains, recording the results.&lt;br /&gt;
&lt;br /&gt;
=== Building the x_contexts Files and Loadable Module ===&lt;br /&gt;
Before building and installing these, ensure that the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; base module has been built, if it has proceed as follows:&lt;br /&gt;
&lt;br /&gt;
* Ensure you are logged on as root and SELinux is running in permissive mode (setenforce 0) to perform the build process. It is assumed that the files are built in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-contexts-base-module&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
* Produce a derived &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file called [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-contexts-base-module/x_contexts-file-with-new-labels x_contexts-file-with-new-labels]&lt;br /&gt;
* Produce a polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file called [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-contexts-base-module/x_contexts-file-with-new-polylabels x_contexts-file-with-new-polylabels].&lt;br /&gt;
* Produce the  policy file [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-contexts-base-module/x_context_base.conf x_context_base.conf].&lt;br /&gt;
* Compile, package and load the module as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
checkmodule -m x_context_base.conf -o x_context_base.mod&lt;br /&gt;
semodule_package -o x_context_base.pp -m x_context_base.mod&lt;br /&gt;
semodule -v -s modular-test -i x_context_base.pp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the semodule command to check the module has loaded as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
semodule -l&lt;br /&gt;
&lt;br /&gt;
x_context_base 1.0.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Copy the derived &amp;lt;tt&amp;gt;x_contexts-file-with-new-labels&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy area as the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp x_contexts-file-with-new-labels /etc/selinux/modular-test/contexts/x_contexts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Optionally clear the log file so that they are clear for easier reading after the reboot:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; /var/log/audit/audit.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure that SELinux is configured to run in permissive mode with the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy enabled, then reboot the system to ensure X-windows loads the new &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file entries.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
reboot&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The system should reload with no errors, however if the screen should remain blank then the chances are that the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file is incorrect and the repair disk will be required to replace the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file with the one produced in the [[Building a Basic Policy#Building the Base Policy Module|Building the Base Policy Module]] section. Alternatively, reboot with a know good policy and check the &amp;lt;tt&amp;gt;modular-test&amp;lt;/tt&amp;gt; policy &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; entries.&lt;br /&gt;
&lt;br /&gt;
Run the &amp;lt;tt&amp;gt;setenforce 1&amp;lt;/tt&amp;gt; command and then check the audit log for &amp;lt;tt&amp;gt;USER_AVC&amp;lt;/tt&amp;gt; errors (there should not be any errors).&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file currently loaded is the standard (non-poly) version.&lt;br /&gt;
&lt;br /&gt;
=== Building the X-select and X-paste Applications ===&lt;br /&gt;
Before building and installing these applications, ensure that the libraries and development packages have been installed. &lt;br /&gt;
&lt;br /&gt;
The easiest way to build these applications is to use the notebook-source files (the X-select and X-paste code is in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory). The code to manage the XSELinux functions is quite long and also requires a header file (these are contained in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-common&amp;lt;/tt&amp;gt; directory). The source files also contain a pre-compiled set of applications that only need to be copied to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt;. However to build from scratch proceed as follows:&lt;br /&gt;
&lt;br /&gt;
* Ensure you are logged on as root and SELinux is running in permissive mode (setenforce 0) to perform the build process. It is assumed that the applications will be built in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory, but the XSELinux function call code will be in the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-common&amp;lt;/tt&amp;gt; directory as it is shared by the &amp;lt;tt&amp;gt;X-setest&amp;lt;/tt&amp;gt; application as well.&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-common&amp;lt;/tt&amp;gt; directory, produce the  header file with the following entries [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-common/Xlib-selinux.h Xlib-selinux.h].&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-common&amp;lt;/tt&amp;gt; directory, produce the [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-common/XSELinuxOMFunctions.c XSELinuxOMFunctions.c] source file.&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory, produce the [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-select+paste/X-select.c X-select.c]] source file.&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory, produce the [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-select+paste/X-paste.c X-paste.c] source file.&lt;br /&gt;
* From the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory, compile and link the X-select and X-paste applications as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gcc X-paste.c ../x-common/XSELinuxOMFunctions.c -o X-paste -l selinux -l X11 -l Xi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gcc X-select.c ../x-common/XSELinuxOMFunctions.c -o X-select -l selinux -l X11 -l Xi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Copy the X-select and X-paste application binaries to &amp;lt;tt&amp;gt;/usr/local/bin&amp;lt;/tt&amp;gt; as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp X-select /usr/local/bin&lt;br /&gt;
cp X-paste /usr/local/bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The applications can be tested by calling them from separate virtual terminals, although they will only be running in the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; domain as shown in [http://taiga.selinuxproject.org/~rhaines/diagrams/Derived-Test1.png Figure 1] (until the policy module is built as described in the next section). Note that the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file loaded in the previous section is the standard (non-poly) version.&lt;br /&gt;
&lt;br /&gt;
=== Building the X-select and X-paste Loadable Module ===&lt;br /&gt;
This loadable module is to enforce policy on the X-select and X-paste applications when they are run in the &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domain using the SELinux &amp;lt;tt&amp;gt;runcon&amp;lt;/tt&amp;gt; commands as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Note the runcon commands would be run from different virtual&lt;br /&gt;
# terminals to activate and test the applications.&lt;br /&gt;
&lt;br /&gt;
runcon -t x_select_paste_t X-select&lt;br /&gt;
runcon -t x_select_paste_t X-select&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The policy has a &amp;lt;tt&amp;gt;poly-selection&amp;lt;/tt&amp;gt; boolean that by default is set to &amp;lt;tt&amp;gt;FALSE&amp;lt;/tt&amp;gt; and controls what policy rules are enforced depending on what verion of the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file is loaded (although note that the boolean does NOT control what file is loaded, that is a user copy function):&lt;br /&gt;
&lt;br /&gt;
* Testing the standard &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file &amp;lt;tt&amp;gt;poly-selection = FALSE&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Testing the polyinstantiated &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file &amp;lt;tt&amp;gt;poly-selection = TRUE&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The [[#Testing Derived Labels|Testing Derived Labels]] and [[#Testing Polyinstantiated Labels|Testing Polyinstantiated Labels]] sections run through a number of tests to check what happens with each setting. &lt;br /&gt;
&lt;br /&gt;
To build the loadable module:&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x-select+paste&amp;lt;/tt&amp;gt; directory, produce the [http://taiga.selinuxproject.org/~rhaines/notebook-source/x-windows/x-select+paste/x_select_paste.conf x_select_paste.conf] policy configuration file.&lt;br /&gt;
* Compile and load the policy module using the following SELinux commands:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
checkmodule -m x_select_paste.conf -o x_select_paste.mod&lt;br /&gt;
semodule_package -o x_select_paste.pp -m x_select_paste.mod&lt;br /&gt;
semodule -v -s modular-test -i x_select_paste.pp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The policy modules loaded should now consist of the following:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
semodule -l&lt;br /&gt;
x_context_base 1.0.0&lt;br /&gt;
x_select_paste 1.0.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The system is now ready for testing various select / paste scenarios. Note that by default the &amp;lt;tt&amp;gt;poly-selection&amp;lt;/tt&amp;gt; boolean is set to &amp;lt;tt&amp;gt;FALSE&amp;lt;/tt&amp;gt; and the &amp;lt;tt&amp;gt;x_contexts-file-with-new-labels&amp;lt;/tt&amp;gt; file has been installed as the &amp;lt;tt&amp;gt;/etc/selinux/modular-test/contexts/x_contexts&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
=== Testing Derived Labels ===&lt;br /&gt;
The following steps will determine if the test set-up is correct:&lt;br /&gt;
&lt;br /&gt;
* Check the correct modules are loaded by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
semodule -l&lt;br /&gt;
x_context_base 1.0.0&lt;br /&gt;
x_select_paste 1.0.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Check the Boolean is set correctly by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
getsebool poly-selection&lt;br /&gt;
poly-selection --&amp;gt; off&lt;br /&gt;
&lt;br /&gt;
# If 'on', then run:&lt;br /&gt;
setsebool -P poly-selection false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure the correct &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file is installed. This can be done by checking that there are no &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; entries in the &amp;lt;tt&amp;gt;/etc/selinux/modular-test/contexts/x_contexts&amp;lt;/tt&amp;gt; file. If the file is not correct, then copy the correct version over by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp $HOME/notebook-source/x-windows/x-contexts-base-module/x_contexts-file-with-new-labels /etc/selinux/modular-test/contexts/x_contexts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If the X-select and X-paste applications were not built as described in the [[#Building the X-select and X-paste Applications|Building the X-select and X-paste Applications]] section, then the executables can be copied from the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x_select+paste&amp;lt;/tt&amp;gt; directory to the &amp;lt;tt&amp;gt;/usr/local/bin directory&amp;lt;/tt&amp;gt;. They should default to &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; that can be checked as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls -Z /usr/local/bin&lt;br /&gt;
-rwxr-xr-x. root root system_u:object_r:unconfined_t X-paste&lt;br /&gt;
-rwxr-xr-x. root root system_u:object_r:unconfined_t X-select&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Open two virtual terminal sessions so that the applications can be run. A third can be opened for monitoring the audit log for errors.&lt;br /&gt;
* Run &amp;lt;tt&amp;gt;setenforce 1&amp;lt;/tt&amp;gt; for enforcing mode.&lt;br /&gt;
&lt;br /&gt;
'''Test 1:'''&lt;br /&gt;
&lt;br /&gt;
The X-select and X-paste applications are called directly, one in each terminal session and will therefore run under the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; domain:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results can be seen in [http://taiga.selinuxproject.org/~rhaines/diagrams/Derived-Test1.png Figure 1]  where &amp;quot;Hello World&amp;quot; is displayed on Terminal 1 (note that if any text has been selected by another window, then that text will probably be displayed instead of &amp;quot;Hello World&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
There is other information displayed that shows the various context information using the &amp;lt;tt&amp;gt;SELinuxGet..&amp;lt;/tt&amp;gt; functions that can be examined if required.&lt;br /&gt;
&lt;br /&gt;
To exit the applications '&amp;lt;tt&amp;gt;Ctrl c&amp;lt;/tt&amp;gt;' is used.&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded using &amp;lt;tt&amp;gt;runcon&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results can be seen in [http://taiga.selinuxproject.org/~rhaines/diagrams/Derived-Test2.png Figure 2] where &amp;quot;Hello World&amp;quot; is displayed on Terminal 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded as follows:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As shown in [http://taiga.selinuxproject.org/~rhaines/diagrams/Derived-Test3.png Figure 3], the X-paste application still receives &amp;quot;Hello World&amp;quot;, showing that selections are not blocked.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 4:'''&lt;br /&gt;
&lt;br /&gt;
With this test the &amp;lt;tt&amp;gt;poly-selection&amp;lt;/tt&amp;gt; boolean is set to TRUE:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setsebool -P poly-selection true&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded as follows:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results are the same as Test 3 in that “Hello World” is displayed.&lt;br /&gt;
&lt;br /&gt;
==== Derived Object Test Conclusions ====&lt;br /&gt;
As can be seen the selected text can be pasted from both the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains. This means that using standard reference policy type x_contexts file entries for selections, separation cannot be achieved (although note that the MLS version of reference policy may do - need to check one day).&lt;br /&gt;
&lt;br /&gt;
If the policy is analysed, it will be seen that even though a type transition has been defined for the &amp;lt;tt&amp;gt;primary_xselection_t&amp;lt;/tt&amp;gt; object:&lt;br /&gt;
&lt;br /&gt;
* Extracts from the x_select_paste.conf policy:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Added type with derived name to transition new object instances:&lt;br /&gt;
type user_primary_xselection_t;&lt;br /&gt;
&lt;br /&gt;
#Added type transition for the object:&lt;br /&gt;
type_transition x_select_paste_t primary_xselection_t : x_selection user_primary_xselection_t;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
a new object is never created: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# audit2allow never indicated that an allow rule was needed&lt;br /&gt;
# like this (that would be required if a new instance was created)&lt;br /&gt;
&lt;br /&gt;
allow x_select_paste_t user_ primary_xselection_t : x_selection { read ... };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Testing Polyinstantiated Labels ===&lt;br /&gt;
The following steps will determine if the test set-up is correct:&lt;br /&gt;
&lt;br /&gt;
* Check the correct modules are loaded by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
semodule -l&lt;br /&gt;
x_context_base 1.0.0&lt;br /&gt;
x_select_paste 1.0.0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Check the Boolean is set correctly by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
getsebool poly-selection&lt;br /&gt;
poly-selection --&amp;gt; on&lt;br /&gt;
&lt;br /&gt;
# If 'on', then run:&lt;br /&gt;
setsebool -P poly-selection true&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Ensure the correct &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file is installed. This can be done by checking that there are &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; entries in the &amp;lt;tt&amp;gt;/etc/selinux/modular-test/contexts/x_contexts&amp;lt;/tt&amp;gt; file. If the file is not correct, then copy the correct version over by:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cp $HOME/notebook-source/x-windows/x-contexts-base-module/x_contexts-file-with-new-polylabels /etc/selinux/modular-test/contexts/x_contexts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If the X-select and X-paste applications were not built as described in the [[#Building the X-select and X-paste Applications|Building the X-select and X-paste Applications]] section, then the executables can be copied from the &amp;lt;tt&amp;gt;./notebook-source/x-windows/x_select+paste&amp;lt;/tt&amp;gt; directory to the &amp;lt;tt&amp;gt;/usr/local/bin directory&amp;lt;/tt&amp;gt;. They should default to &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; that can be checked as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ls -Z /usr/local/bin&lt;br /&gt;
-rwxr-xr-x. root root system_u:object_r:unconfined_t X-paste&lt;br /&gt;
-rwxr-xr-x. root root system_u:object_r:unconfined_t X-select&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Open two virtual terminal sessions so that the applications can be run. A third can be opened for monitoring the audit log for errors.&lt;br /&gt;
* Run &amp;lt;tt&amp;gt;setenforce 1&amp;lt;/tt&amp;gt; for enforcing mode.&lt;br /&gt;
&lt;br /&gt;
'''Test 1:'''&lt;br /&gt;
&lt;br /&gt;
The X-select and X-paste applications are called directly, one in each terminal session and will therefore run under the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; domain:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results can be seen in [http://taiga.selinuxproject.org/~rhaines/diagrams/Poly-Test1.png Figure 4] where &amp;quot;Hello World&amp;quot; is displayed on Terminal 1 (note that if any text has been selected by another window, then that text will probably be displayed instead of &amp;quot;Hello World&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
There is other information displayed that shows the various context information using the &amp;lt;tt&amp;gt;SELinuxGet..&amp;lt;/tt&amp;gt; functions that can be examined if required.&lt;br /&gt;
&lt;br /&gt;
To exit the applications '&amp;lt;tt&amp;gt;Ctrl c&amp;lt;/tt&amp;gt;' is used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 2:'''&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded using &amp;lt;tt&amp;gt;runcon&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The results can be seen in [http://taiga.selinuxproject.org/~rhaines/diagrams/Poly-Test2.png Figure 5] where &amp;quot;Hello World&amp;quot; is displayed on Terminal 1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 3:'''&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded as follows:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As shown in [http://taiga.selinuxproject.org/~rhaines/diagrams/Poly-Test3.png  Figure 6], the X-paste application does NOT receive &amp;quot;Hello World” as the selections are blocked by the polyinstantiation functionality.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Test 4:'''&lt;br /&gt;
&lt;br /&gt;
With this test the &amp;lt;tt&amp;gt;poly-selection&amp;lt;/tt&amp;gt; boolean is set to FALSE:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
setsebool -P poly-selection false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The applications are then loaded as follows:&lt;br /&gt;
&lt;br /&gt;
Terminal 1: &amp;lt;tt&amp;gt;runcon -t x_select_paste_t X-paste&amp;lt;/tt&amp;gt;&lt;br /&gt;
Terminal 2: &amp;lt;tt&amp;gt;X-select&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As shown in [http://taiga.selinuxproject.org/~rhaines/diagrams/Poly-Test4.png  Figure 7], the X-paste application running on terminal 1 does not receive &amp;quot;Hello World&amp;quot; for the following reasons:&lt;br /&gt;
&lt;br /&gt;
* The selections are being detected by the X-paste application because the &amp;lt;tt&amp;gt;type_member&amp;lt;/tt&amp;gt; rule has been disabled, therefore polyinstantiation is not being enforced by the policy (as to enforce polyinstantiation both the &amp;lt;tt&amp;gt;poly_&amp;lt;/tt&amp;gt; entries in the &amp;lt;tt&amp;gt;x_contexts&amp;lt;/tt&amp;gt; file is required plus a supporting &amp;lt;tt&amp;gt;type_member&amp;lt;/tt&amp;gt; rule (and of course any &amp;lt;tt&amp;gt;allow&amp;lt;/tt&amp;gt; rules)).&lt;br /&gt;
* The application name and context is not displayed in the X-Window title bar and the terminal screen shows two error returns when getting the property context entries as shown below (the &amp;lt;tt&amp;gt;resourceID: 39&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;WM_NAME&amp;lt;/tt&amp;gt; - see &amp;lt;tt&amp;gt;Xatom.h&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Calling SELinuxGetPropertyContext (12) with WM_NAME for Property Owner Window:&lt;br /&gt;
&lt;br /&gt;
The SELinuxGetPropertyContext (12) function returned an _XReply error:&lt;br /&gt;
BadMatch - Lookup failed for resourceID: 39&lt;br /&gt;
&lt;br /&gt;
Calling SELinuxGetPropertyDataContext (13) with WM_NAME for Property Owner Window:&lt;br /&gt;
The SELinuxGetPropertyDataContext (13) function returned an _XReply error:&lt;br /&gt;
BadMatch - Lookup failed for resourceID: 39&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If apol is used to view the Conditional Expressions for the policy, the following will be seen: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
conditional expression 1: [poly-selection]&lt;br /&gt;
&lt;br /&gt;
TRUE list:&lt;br /&gt;
allow x_select_paste_t wm_name_xproperty_t : x_property { write create }; [Disabled]&lt;br /&gt;
allow x_select_paste_t x_select_paste_t : x_selection { getattr setattr read }; [Disabled]&lt;br /&gt;
type_member x_select_paste_t primary_xselection_t : x_selection x_select_paste_t; [Disabled]&lt;br /&gt;
&lt;br /&gt;
FALSE list:&lt;br /&gt;
type_transition x_select_paste_t wm_name_xproperty_t : x_property user_wm_name_xproperty_t;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Whereas, they should be:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
conditional expression 1: [poly-selection]&lt;br /&gt;
&lt;br /&gt;
TRUE list:&lt;br /&gt;
allow x_select_paste_t wm_name_xproperty_t : x_property { write create }; [Enabled]&lt;br /&gt;
allow x_select_paste_t x_select_paste_t : x_selection { getattr setattr read }; [Enabled]&lt;br /&gt;
type_member x_select_paste_t primary_xselection_t : x_selection x_select_paste_t; [Enabled]&lt;br /&gt;
&lt;br /&gt;
FALSE list:&lt;br /&gt;
type_transition x_select_paste_t wm_name_xproperty_t : x_property user_wm_name_xproperty_t;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Polyinstantiated Object Test Conclusions ====&lt;br /&gt;
As can be seen the selected text cannot be pasted between the &amp;lt;tt&amp;gt;unconfined_t&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;x_select_paste_t&amp;lt;/tt&amp;gt; domains. This means that using polyinstantiated entries will allow selections to be isolated. &lt;br /&gt;
&lt;br /&gt;
If the policy is analysed, it will be seen that the policy enforces the separation with a type member rule. The X-Windows object manager / XACE manages the actual selection polyinstantiation.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Extracts from the x_select_paste.conf policy:&lt;br /&gt;
&lt;br /&gt;
# This type_member rules enforces polyinstantiation of the&lt;br /&gt;
# &amp;quot;poly_selection PRIMARY primary_xselection_t&amp;quot; x_contexts entry:&lt;br /&gt;
type_member x_select_paste_t primary_xselection_t : x_selection x_select_paste_t;&lt;br /&gt;
&lt;br /&gt;
# Additional allow rules:&lt;br /&gt;
allow x_select_paste_t self:x_selection { getattr setattr read };&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>RichardHaines</name></author>	</entry>

	</feed>