<?Pub UDT _bookmark _target?><?Pub EntList bsol dash hellip gt lt minus?><?Pub CX solbook(book(title()bookinfo()chapter()?><chapter id="windowapi-1"><title>Trusted X Window System</title><indexterm><primary>Trusted X Window System</primary><secondary>protocol extensions</secondary>
</indexterm><indexterm><primary>APIs</primary><secondary>Trusted X Window System</secondary>
</indexterm><indexterm><primary>label APIs</primary><secondary>Trusted X Window System</secondary>
</indexterm><highlights><para>This chapter describes the Trusted Extensions X Window System APIs. This chapter also includes a short Motif application that is used to describe the Trusted X Window System security policy and the Solaris Trusted Extensions interfaces.</para><para>For examples of how the Trusted Extensions APIs are used in the Solaris OS, see the Solaris source code. Go to the <ulink url="http://opensolaris.org/" type="text_url">OpenSolaris web site</ulink> and click Source Browser in the left navigation bar. Use the Source Browser to search through the Solaris source code.</para><itemizedlist><para>This chapter covers the following topics:</para><listitem><para><olink targetptr="windowapi-13" remap="internal">Trusted X Window System Environment</olink></para>
</listitem><listitem><para><olink targetptr="windowapi-33" remap="internal">Trusted X Window System Security Attributes</olink></para>
</listitem><listitem><para><olink targetptr="windowapi-11" remap="internal">Trusted X Window System Security Policy</olink></para>
</listitem><listitem><para><olink targetptr="windowapi-14" remap="internal">Privileged Operations and the Trusted X Window System</olink></para>
</listitem><listitem><para><olink targetptr="windowapi-15" remap="internal">Trusted Extensions X Window System APIs</olink></para>
</listitem><listitem><para><olink targetptr="windowapi-16" remap="internal">Using Trusted X Window System Interfaces</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="windowapi-13"><title>Trusted X Window System Environment</title><para><indexterm><primary>DAC (discretionary access control)</primary></indexterm><indexterm><primary>MAC (mandatory access control)</primary></indexterm>A system that is configured with Solaris Trusted Extensions uses the Solaris Trusted Extensions CDE, which is an enhanced version of the Common Desktop Environment (CDE). The Solaris Trusted Extensions CDE uses the Trusted Extensions X Window System. The Trusted Extensions X Window System includes protocol extensions to support mandatory access control (MAC), discretionary access control (DAC), and the use of privileges.</para><para><indexterm><primary>polyinstantiation</primary><secondary>description of</secondary></indexterm>Data transfer sessions are <firstterm>polyinstantiated</firstterm>, meaning that they are instantiated at different sensitivity labels and user IDs. Polyinstantiation ensures that data in an unprivileged client at one sensitivity label or user ID is not transferred to another client at another sensitivity label or user ID. Such a transfer might violate the Trusted X Window System DAC policies and the MAC policies of write-equal and read-down.</para><para>The Trusted Extensions X Window System APIs enable you to obtain and set security-related attribute information. These APIs also enable you to translate labels to strings by using a font list and width to apply a style to the text string output. For example, the font might be 14-point, bold Helvetica. These interfaces are usually called by administrative applications that are written with Motif widgets, Xt Intrinsics, Xlib, and CDE interfaces.</para><itemizedlist><listitem><para><emphasis role="strong">Obtaining security-related information &ndash;</emphasis> These interfaces operate at the Xlib level where X protocol requests are made. Use Xlib interfaces to obtain data for the input parameter values.</para>
</listitem><listitem><para><emphasis role="strong">Translating labels to strings &ndash;</emphasis> These interfaces operate at the Motif level. The input parameters are the label, a font list that specifies the appearance of the text string output, and the desired width. A compound string of the specified style and width is returned.</para>
</listitem>
</itemizedlist><para>For declarations of these routines, see <olink targetptr="windowapi-15" remap="internal">Trusted Extensions X Window System APIs</olink>.</para>
</sect1><sect1 id="windowapi-33"><title>Trusted X Window System Security Attributes</title><indexterm><primary>Trusted X Window System</primary><secondary>security attributes</secondary><tertiary>description of</tertiary>
</indexterm><indexterm><primary>security attributes</primary><secondary>Trusted X Window System</secondary><tertiary>description of</tertiary>
</indexterm><para>The Trusted X Window System interfaces manage security-related attribute information for various X Window System objects. You can choose to create a GUI application with Motif only. The Motif application should use XToolkit routines to retrieve the Xlib object IDs underlying the Motif widgets to handle security attribute information for an Xlib object.</para><para><indexterm><primary>Xlib</primary><secondary>objects</secondary></indexterm><indexterm><primary>GUIs</primary><secondary>Xlib objects</secondary></indexterm>The X Window System objects for which security attribute information can be retrieved by the Trusted X Window System interfaces are window, property, X Window Server, and the connection between the client and the X Window Server. Xlib provides calls to retrieve the window, property, display, and client connection IDs.</para><para><indexterm><primary>windows</primary><secondary>description of</secondary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>objects</secondary></indexterm>A window displays output to the user and accepts input from clients.</para><para><indexterm><primary>properties</primary><secondary>description of</secondary></indexterm>A property is an arbitrary collection of data that is accessed by the property name. Property names and property types can be referenced by an <firstterm>atom</firstterm>, which is a unique, 32-bit identifier and a character name string.</para><para><indexterm><primary>connection requests</primary><secondary>security attributes</secondary></indexterm>The security attributes for windows, properties, and client connections consist of ownership IDs and sensitivity label information. For information about the structures for capturing some of these attributes, see <olink targetptr="windowapi-12" remap="internal">Data Types for X11</olink>. For information about the interfaces that obtain and set security attribute information, see <olink targetptr="windowapi-15" remap="internal">Trusted Extensions X Window System APIs</olink>.</para>
</sect1><sect1 id="windowapi-11"><title>Trusted X Window System Security Policy</title><indexterm><primary>Trusted X Window System</primary><secondary>security policy</secondary>
</indexterm><indexterm><primary>security policy</primary><secondary>Trusted X Window System</secondary>
</indexterm><para>Window, property, and pixmap objects have a user ID, a client ID, and a sensitivity label. Graphic contexts, fonts, and cursors have a client ID only. The connection between the client and the X Window Server has a user ID, an X Window Server ID, and a sensitivity label.</para><para>The <firstterm>user ID</firstterm> is the ID of the client that created the object. The <firstterm>client ID</firstterm> is related to the connection number to which the client that creates the object is connected.</para><para>The DAC policy requires a client to own an object to perform any operations on that object. A client owns an object when the client's user ID equals the object's ID. For a connection request, the user ID of the client must be in the access control list (ACL) of the owner of the X Window Server workstation. Or, the client must assert the Trusted Path attribute.</para><itemizedlist><para><indexterm><primary>windows</primary><secondary>security policy</secondary></indexterm><indexterm><primary>access</primary><secondary>checks for</secondary><tertiary>Trusted X Window System</tertiary></indexterm>The MAC policy is write-equal for windows and pixmaps, and read-equal for naming windows. The MAC policy is read-down for properties. The sensitivity label is set to the sensitivity label of the creating client. The following shows the MAC policy for these actions:</para><listitem><para><emphasis role="strong">Modify, create, or delete &ndash;</emphasis> The sensitivity label of the client must equal the object's sensitivity label.</para>
</listitem><listitem><para><emphasis role="strong">Name, read, or retrieve &ndash;</emphasis> The client's sensitivity label must dominate the object's sensitivity label.</para>
</listitem><listitem><para><indexterm><primary>connection requests</primary><secondary>security policy</secondary></indexterm><emphasis role="strong">Connection request &ndash;</emphasis> The sensitivity label of the client must be dominated by the session clearance of the owner of the X Window Server workstation, or the client must assert the Trusted Path attribute.</para>
</listitem>
</itemizedlist><para><indexterm><primary>properties</primary><secondary>description of</secondary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>properties</secondary></indexterm>Windows can have properties that contain information to be shared among clients. Window properties are created at the sensitivity label at which the application is running, so access to the property data is segregated by its sensitivity label. Clients can create properties, store data in a property on a window, and retrieve the data from a property subject to MAC and DAC restrictions. To specify properties that are not polyinstantiated, update the <filename>TrustedExtensionsPolicy</filename> file.</para><itemizedlist><para>The <filename>TrustedExtensionsPolicy</filename> file is supported for the <filename>Xsun</filename> server and the <filename>Xorg</filename> server:</para><listitem><para>SPARC: For <filename>Xsun</filename>, the file is in <filename>/usr/openwin/server/etc</filename>.</para>
</listitem><listitem><para>x86: For <filename>Xorg</filename>, the file is in <filename>/usr/X11/lib/X11/xserver</filename>.</para>
</listitem>
</itemizedlist><itemizedlist><para>These sections describe the security policy for the following:</para><listitem><para>Root window</para>
</listitem><listitem><para>Client windows</para>
</listitem><listitem><para>Override-redirect windows</para>
</listitem><listitem><para>Keyboard, pointer, and server control</para>
</listitem><listitem><para>Selection Manager</para>
</listitem><listitem><para>Default window resources</para>
</listitem><listitem><para>Moving data between windows</para>
</listitem>
</itemizedlist><sect2 id="windowapi-18"><title>Root Window</title><indexterm><primary>Trusted X Window System</primary><secondary>root window</secondary>
</indexterm><indexterm><primary>windows</primary><secondary>root, security policy</secondary>
</indexterm><para>The root window is at the top of the window hierarchy. The root window is a public object that does not belong to any client, but it has data that must be protected. The root window attributes are protected at <constant>ADMIN_LOW</constant>.</para>
</sect2><sect2 id="windowapi-2"><title>Client Windows</title><indexterm><primary>windows</primary><secondary>client, security policy</secondary>
</indexterm><para>A client usually has at least one top-level client window that descends from the root window and additional windows nested within the top-level window. All windows that descend from the client's top-level window have the same sensitivity label.</para>
</sect2><sect2 id="windowapi-3"><title>Override-Redirect Windows</title><para><indexterm><primary>Trusted X Window System</primary><secondary>override-redirect</secondary></indexterm><indexterm><primary>windows</primary><secondary>override-redirect, security policy</secondary></indexterm>Override-redirect windows, such as menus and certain dialog boxes, cannot take the input focus away from another client. This prevents the input focus from accepting input into a file at the wrong sensitivity label. Override-redirect windows are owned by the creating client and cannot be used by other clients to access data at another sensitivity label.</para>
</sect2><sect2 id="windowapi-4"><title>Keyboard, Pointer, and Server Control</title><indexterm><primary>Trusted X Window System</primary><secondary>server control</secondary>
</indexterm><indexterm><primary>Trusted X Window System</primary><secondary>input devices</secondary>
</indexterm><indexterm><primary>privileges</primary><secondary><constant>win_devices</constant></secondary>
</indexterm><para>A client needs MAC and DAC to gain control of the keyboard, pointer, and server. To reset the focus, a client must own the focus or have the <constant>win_devices</constant> privilege in its effective set.</para><para>To warp a pointer, the client needs pointer control and MAC and DAC to the destination window. X and Y coordinate information can be obtained for events that involve explicit user action.</para>
</sect2><sect2 id="windowapi-19"><title>Selection Manager</title><para><indexterm><primary>Selection Manager</primary><secondary>security policy</secondary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>Selection Manager</secondary></indexterm>The Selection Manager application arbitrates user-level interwindow data moves, such as cut and paste or drag and drop, where information is transferred between untrusted windows. When a transfer is attempted, the Selection Manager captures the transfer, verifies the controlling user's authorization, and requests confirmation and labeling information from the user. Any time the user attempts a data move, the Selection Manager automatically appears. You do not need to update your application code to get the Selection Manager to appear.</para><para>The administrator can set automatic confirmation for some transfer types, in which case the Selection Manager does not appear. If the transfer meets the MAC and DAC policies, the data transfer completes. The File Manager and Window Manager also act as selection agents for their private drop sites. See the <filename>/usr/openwin/server/etc/TrustedExtensionsPolicy</filename> file to specify selection targets that are polyinstantiated. See the <filename>/usr/dt/config/sel_config</filename> file to determine which selection targets are automatically confirmed.</para>
</sect2><sect2 id="windowapi-5"><title>Default Window Resources</title><indexterm><primary>windows</primary><secondary>defaults</secondary>
</indexterm><indexterm><primary>Trusted X Window System</primary><secondary>defaults</secondary>
</indexterm><para>Resources that are not created by clients are default resources that are protected at <constant>ADMIN_LOW</constant>. Only clients that run at <constant>ADMIN_LOW</constant> or with the appropriate privileges can modify default resources.</para><itemizedlist><para>The following are window resources:</para><listitem><para><emphasis role="strong">Root window attributes &ndash;</emphasis> All clients have read and create access, but only privileged clients have write or modify access. See <olink targetptr="windowapi-14" remap="internal">Privileged Operations and the Trusted X Window System</olink>.</para>
</listitem><listitem><para><emphasis role="strong">Default cursor &ndash;</emphasis> Clients are free to reference the default cursor in protocol requests.</para>
</listitem><listitem><para><indexterm><primary>atoms</primary><secondary>predefined in X Window System</secondary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>predefined atoms</secondary></indexterm><emphasis role="strong">Predefined atoms &ndash;</emphasis> The <filename>TrustedExtensionsPolicy</filename> file contains a read-only list of predefined atoms.</para>
</listitem>
</itemizedlist>
</sect2><sect2 id="windowapi-27"><title>Moving Data Between Windows</title><para><indexterm><primary>privileges</primary><secondary><constant>win_selection</constant></secondary></indexterm><indexterm><primary><literal>PAF_SELAGNT</literal> flag</primary></indexterm><indexterm><primary>Selection Manager</primary><secondary>bypassing with flag</secondary></indexterm>A client needs the <constant>win_selection</constant> privilege in its effective set to move data between one window and another window without going through the Selection Manager. See <olink targetptr="windowapi-19" remap="internal">Selection Manager</olink>.</para>
</sect2>
</sect1><sect1 id="windowapi-14"><title>Privileged Operations and the Trusted X Window System</title><indexterm><primary>Trusted X Window System</primary><secondary>privileged tasks</secondary>
</indexterm><indexterm><primary>privileged tasks</primary><secondary>Trusted X Window System</secondary>
</indexterm><para>Library routines that access a window, property, or atom name without user involvement require MAC and DAC. Library routines that access frame buffer graphic contexts, fonts, and cursors require discretionary access and might also require additional privileges for special tasks.</para><para><indexterm><primary>privileges</primary><secondary><constant>win_dac_read</constant></secondary></indexterm><indexterm><primary>privileges</primary><secondary><constant>win_dac_write</constant></secondary></indexterm><indexterm><primary><constant>win_dac_write</constant> privilege</primary></indexterm><indexterm><primary><constant>win_dac_read</constant> privilege</primary></indexterm><indexterm><primary><constant>win_mac_write</constant> privilege</primary></indexterm><indexterm><primary><constant>win_mac_read</constant> privilege</primary></indexterm>The client might need one or more of the following privileges in its effective set if access to the object is denied: <constant>win_dac_read</constant>, <constant>win_dac_write</constant>, <constant>win_mac_read</constant>, or <constant>win_mac_write</constant>. See the <filename>TrustedExtensionsPolicy</filename> file to enable or disable these privileges.</para><itemizedlist><para>This list shows the privileges needed to perform the following tasks:</para><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_config</constant></secondary></indexterm><indexterm><primary><constant>win_config</constant> privilege</primary></indexterm><indexterm><primary>properties</primary><secondary>privileges</secondary></indexterm><indexterm><primary>windows</primary><secondary>privileges</secondary></indexterm><emphasis role="strong">Configuring and destroying window resources &ndash;</emphasis> A client process needs the <constant>win_config</constant> privilege in its effective set to configure or destroy windows or properties that are permanently retained by the X Window Server. The screen saver timeout is an example of such a resource.</para>
</listitem><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_devices</constant></secondary></indexterm><indexterm><primary><constant>win_devices</constant> privilege</primary></indexterm><indexterm><primary>devices</primary><secondary>input device privileges</secondary></indexterm><emphasis role="strong">Using window input devices &ndash;</emphasis> A client process needs the <constant>win_devices</constant> privilege in its effective set to obtain and set keyboard and pointer controls, or to modify pointer button mappings and key mappings.</para>
</listitem><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_dga</constant></secondary></indexterm><indexterm><primary><constant>win_dga</constant> privilege</primary></indexterm><indexterm><primary>DGA (direct graphics access)</primary><secondary>privileges</secondary></indexterm><emphasis role="strong">Using direct graphics access &ndash;</emphasis> A client process needs the <constant>win_dga</constant> privilege in its effective set to use the direct graphics access (DGA) X protocol extension.</para>
</listitem><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_downgrade_sl</constant></secondary></indexterm><indexterm><primary><constant>win_downgrade_sl</constant> privilege</primary></indexterm><indexterm><primary>downgrading labels</primary><secondary>Trusted X Window System</secondary></indexterm><emphasis role="strong">Downgrading window labels &ndash;</emphasis> A client process needs the <constant>win_downgrade_sl</constant> privilege in its effective set to change the sensitivity label of a window, pixmap, or property to a new label that does not dominate the existing label.</para>
</listitem><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_upgrade_sl</constant></secondary></indexterm><indexterm><primary><constant>win_upgrade_sl</constant> privilege</primary></indexterm><indexterm><primary>upgrading labels</primary><secondary>Trusted X Window System</secondary></indexterm><emphasis role="strong">Upgrading window labels &ndash;</emphasis> A client process needs the <constant>win_upgrade_sl</constant> privilege in its effective set to change the sensitivity label of a window, pixmap, or property to a new label that dominates the existing label.</para>
</listitem><listitem><para><indexterm><primary>privileges</primary><secondary><constant>win_fontpath</constant></secondary></indexterm><indexterm><primary><constant>win_fontpath</constant> privilege</primary></indexterm><indexterm><primary>fonts</primary><secondary>font path privileges</secondary></indexterm><emphasis role="strong">Setting a font path on a window &ndash;</emphasis> A client process needs the <constant>win_fontpath</constant> privilege in its effective set to modify the font path.</para>
</listitem>
</itemizedlist>
</sect1><sect1 id="windowapi-15"><title>Trusted Extensions X Window System APIs</title><indexterm><primary>APIs</primary><secondary>Trusted X Window System</secondary>
</indexterm><indexterm><primary>label APIs</primary><secondary>Trusted X Window System</secondary>
</indexterm><indexterm><primary>Xlib</primary><secondary>API declarations</secondary>
</indexterm><indexterm><primary>Trusted X Window System</primary><secondary>API declarations</secondary>
</indexterm><para><indexterm><primary>compile</primary><secondary>Trusted X Window System libraries</secondary></indexterm><indexterm><primary>libraries</primary><secondary>Trusted X Window System APIs</secondary></indexterm><indexterm><primary>header files</primary><secondary>Trusted X Window System APIs</secondary></indexterm><indexterm><primary>data types</primary><secondary>Trusted X Window System APIs</secondary></indexterm>To use the Trusted X11 APIs, you need the following header file:</para><screen>#include &lt;X11/extensions/Xtsol.h&gt;</screen><para>The Trusted X11 examples compile with the <option>lXtsol</option> and <option>ltsol</option> library options.</para><para>To use the X11 label-clipping APIs, you need the following header file:</para><screen>#include &lt;Dt/label_clipping.h&gt;</screen><para>The label-clipping examples compile with the <option>lDtTsol</option> and <option>ltsol</option> library options.</para><itemizedlist><para>The following sections provide data types and declarations for the Trusted X11 interfaces and the X11 label-clipping interfaces:</para><listitem><para>Data types for X11</para>
</listitem><listitem><para>Accessing attributes</para>
</listitem><listitem><para>Accessing and setting a window label</para>
</listitem><listitem><para>Accessing and setting a window user ID</para>
</listitem><listitem><para>Accessing and setting a window property label</para>
</listitem><listitem><para>Accessing and setting a window property user ID</para>
</listitem><listitem><para>Accessing and setting a workstation owner ID</para>
</listitem><listitem><para>Setting the X Window Server clearance and minimum label</para>
</listitem><listitem><para>Working with the Trusted Path window</para>
</listitem><listitem><para>Accessing and setting the screen stripe height</para>
</listitem><listitem><para>Setting window polyinstantiation information</para>
</listitem><listitem><para>Working with the X11 label-clipping interface</para>
</listitem>
</itemizedlist><sect2 id="windowapi-12"><title>Data Types for X11</title><itemizedlist><para>The following data types are defined in <filename>X11/extensions/Xtsol.h</filename> and are used for the Trusted Extensions X Window System APIs:</para><listitem><para><indexterm><primary><literal>ResourceType</literal> structure</primary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>object type definition</secondary></indexterm><emphasis role="strong">Object type for X11 &ndash;</emphasis> The <literal>ResourceType</literal> definition indicates the type of resource to be handled. The value can be <constant>IsWindow</constant>, <constant>IsPixmap</constant>, or <constant>IsColormap</constant>.</para><para><literal>ResourceType</literal> is a type definition to represent a clearance. Interfaces accept a structure of type <structname>m_label_t</structname> as parameters and return clearances in a structure of the same type.</para>
</listitem><listitem><para><indexterm><primary><literal>XTsolResAttributes</literal> structure</primary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>object attribute structure</secondary></indexterm><indexterm><primary><literal>sl</literal> field</primary></indexterm><indexterm><primary><literal>uid</literal> field</primary></indexterm><indexterm><primary><literal>ouid</literal> field</primary></indexterm><emphasis role="strong">Object attributes for X11 &ndash;</emphasis>The <literal>XTsolResAttributes</literal> structure contains these resource attributes:</para><programlisting>typedef struct _XTsolResAttributes {
    CARD32     ouid;    /* owner uid */
    CARD32     uid;     /* uid of the window */
    m_label_t  *sl;     /* sensitivity label */
} XTsolResAttributes;</programlisting>
</listitem><listitem><para><indexterm><primary><literal>XTsolPropAttributes</literal> structure</primary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>property attribute structure</secondary></indexterm><indexterm><primary><literal>sl</literal> field</primary></indexterm><indexterm><primary><literal>uid</literal> field</primary></indexterm><emphasis role="strong">Property attributes for X11 &ndash;</emphasis> The <structname>XTsolPropAttributes</structname> structure contains these property attributes:</para><programlisting>typedef struct _XTsolPropAttributes {
    CARD32     uid;     /* uid of the property */
    m_label_t  *sl;     /* sensitivity label */
} XTsolPropAttributes;</programlisting>
</listitem><listitem><para><indexterm><primary><literal>XTsolClientAttributes</literal> structure</primary></indexterm><indexterm><primary>Trusted X Window System</primary><secondary>client attributes structure</secondary></indexterm><indexterm><primary><literal>pid</literal> field</primary></indexterm><indexterm><primary><literal>gid</literal> field</primary></indexterm><indexterm><primary><literal>uid</literal> field</primary></indexterm><indexterm><primary><literal>iaddr</literal> field</primary></indexterm><indexterm><primary><literal>auditid</literal> field</primary></indexterm><indexterm><primary><literal>sessionid</literal> field</primary></indexterm><indexterm><primary><literal>uid</literal> field</primary></indexterm><emphasis role="strong">Client attributes for X11 &ndash;</emphasis> The <structname>XTsolClientAttributes</structname> structure contains these client attributes:</para><programlisting>typedef struct _XTsolClientAttributes {
    int      trustflag; /* true if client masked as trusted */
    uid_t    uid;       /* owner uid who started the client */
    gid_t    gid;       /* group id */
    pid_t    pid;       /* process id */
    u_long   sessionid; /* session id */
    au_id_t  auditid;   /* audit id */
    u_long   iaddr;     /* internet addr of host where client is running */
} XTsolClientAttributes;</programlisting>
</listitem>
</itemizedlist>
</sect2><sect2 id="windowapi-47"><title>Accessing Attributes</title><para>The following routines are used to access resource, property, and client attributes:</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetResAttributes(Display *display, XID object, ResourceType type, XTSOLResAttributes *winattrp);</literal></term><listitem><para><indexterm><primary><function>XTSOLgetResAttributes</function> routine</primary><secondary>declaration</secondary></indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetResAttributes</function></secondary></indexterm>This routine returns the resource attributes for a window ID in <replaceable>winattrp</replaceable>. See the <olink targetdoc="refman" targetptr="xtsolgetresattributes-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetResAttributes</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLgetPropAttributes(Display *display, Window window, Atom property, XTSOLPropAttributes *propattrp);</literal></term><listitem><para><indexterm><primary><function>XTSOLgetPropAttributes</function> routine</primary><secondary>declaration</secondary></indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetPropAttributes</function></secondary></indexterm>This routine returns the property attributes for a property hanging on a window ID in <replaceable>propattrp</replaceable>. See the <olink targetdoc="refman" targetptr="xtsolgetpropattributes-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetPropAttributes</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLgetClientAttributes(Display *display, XID windowid, XTsolClientAttributes *clientattrp);</literal></term><listitem><para><indexterm><primary><function>XTSOLgetClientAttributes</function> routine</primary><secondary>declaration</secondary></indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetClientAttributes</function></secondary></indexterm>This routine returns the client attributes in <replaceable>clientattrp</replaceable>. See the <olink targetdoc="refman" targetptr="xtsolgetclientattributes-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetClientAttributes</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-51"><title>Accessing and Setting a Window Label</title><indexterm><primary><function>XTSOLgetResLabel</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetResLabel</function></secondary>
</indexterm><indexterm><primary><function>XTSOLsetResLabel</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetResLabel</function></secondary>
</indexterm><para>The <function>XTSOLgetResLabel</function> and <function>XTSOLsetResLabel</function> routines are used to obtain and set the sensitivity label of a window.</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetResLabel(Display *display, XID object, ResourceType type, m_label_t *sl);</literal></term><listitem><para>This routine obtains the sensitivity label of a window. See the <olink targetdoc="refman" targetptr="xtsolgetreslabel-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetResLabel</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetResLabel(Display *display, XID object, ResourceType type, m_label_t *sl);</literal></term><listitem><para>This routine sets the sensitivity label of a window. See the <olink targetdoc="refman" targetptr="xtsolsetreslabel-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetResLabel</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-52"><title>Accessing and Setting a Window User ID</title><indexterm><primary><function>XTSOLgetResUID</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetResUID</function></secondary>
</indexterm><indexterm><primary><function>XTSOLsetResUID</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetResUID</function></secondary>
</indexterm><para>The <function>XTSOLgetResUID</function> and <function>XTSOLsetResUID</function> routines are used to obtain and set the user ID of a window.</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetResUID(Display *display, XID object, ResourceType type, uid_t *uidp);</literal></term><listitem><para>This routine obtains the user ID of a window. See the <olink targetdoc="refman" targetptr="xtsolgetresuid-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetResUID</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetResUID(Display *display, XID object, ResourceType type, uid_t *uidp);</literal></term><listitem><para>This routine sets the user ID of a window. See the <olink targetdoc="refman" targetptr="xtsolsetresuid-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetResUID</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-20"><title>Accessing and Setting a Window Property Label</title><indexterm><primary><function>XTSOLsetPropLabel</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetPropLabel</function></secondary>
</indexterm><indexterm><primary><function>XTSOLgetPropLabel</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetPropLabel</function></secondary>
</indexterm><para>The <function>XTSOLgetPropLabel</function> and <function>XTSOLsetPropLabel</function> routines are used to obtain and set the sensitivity label of a property hanging on a window ID.</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetPropLabel(Display *display, Window window, Atom property, m_label_t *sl);</literal></term><listitem><para>This routine obtains the sensitivity label of a property hanging on a window ID. See the <olink targetdoc="refman" targetptr="xtsolgetproplabel-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetPropLabel</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetPropLabel(Display *display, Window window, Atom property, m_label_t *sl);</literal></term><listitem><para>This routine sets the sensitivity label of a property hanging on a window ID. See the <olink targetdoc="refman" targetptr="xtsolsetproplabel-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetPropLabel</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-21"><title>Accessing and Setting a Window Property User ID</title><indexterm><primary><function>XTSOLsetPropUID</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetPropUID</function></secondary>
</indexterm><indexterm><primary><function>XTSOLgetPropUID</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetPropUID</function></secondary>
</indexterm><para>The <function>XTSOLgetPropUID</function> and <function>XTSOLsetPropUID</function> routines are used to obtain and set the user ID of a property hanging on a window ID.</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetPropUID(Display *display, Window window, Atom property, uid_t *uidp);</literal></term><listitem><para>This routine obtains the user ID of a property hanging on a window ID. See the <olink targetdoc="refman" targetptr="xtsolgetpropuid-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetPropUID</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetPropUID(Display *display, Window window, Atom property, uid_t *uidp);</literal></term><listitem><para>This routine sets the user ID of a property hanging on a window ID. See the <olink targetdoc="refman" targetptr="xtsolsetpropuid-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetPropUID</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-22"><title>Accessing and Setting a Workstation Owner ID</title><indexterm><primary><function>XTSOLsetWorkstationOwner</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetWorkstationOwner</function></secondary>
</indexterm><indexterm><primary><function>XTSOLgetWorkstationOwner</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetWorkstationOwner</function></secondary>
</indexterm><para>The <function>XTSOLgetWorkstationOwner</function> and <function>XTSOLsetWorkstationOwner</function> routines are used to obtain and set the user ID of the owner of the workstation server.</para><note><para>The <function>XTSOLsetWorkstationOwner</function> routine should only be used by the Window Manager.</para>
</note><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetWorkstationOwner(Display *display, uid_t *uidp);</literal></term><listitem><para>This routine obtains the user ID of the owner of the workstation server. See the <olink targetdoc="refman" targetptr="xtsolgetworkstationowner-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetWorkstationOwner</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page </para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetWorkstationOwner(Display *display, uid_t *uidp);</literal></term><listitem><para>This routine sets the user ID of the owner of the workstation server. See the <olink targetdoc="refman" targetptr="xtsolsetworkstationowner-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetWorkstationOwner</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-23"><title>Setting the X Window Server Clearance and Minimum Label</title><indexterm><primary><function>XTSOLsetSessionLO</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetSessionLO</function></secondary>
</indexterm><indexterm><primary><function>XTSOLsetSessionHI</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetSessionHI</function></secondary>
</indexterm><para>The <function>XTSOLsetSessionHI</function> and <function>XTSOLsetSessionLO</function> routines are used to set the session high clearance and the session low minimum label for the X Window Server. Session high can be selected from the Label Builder GUI and must be within the user's range. Session low is the same as the user's minimum label for the multilevel session.</para><note><para>These interfaces should only be used by the Window Manager.</para>
</note><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLsetSessionHI(Display *display, m_label_t *sl);</literal></term><listitem><para>The session high clearance is set from the workstation owner's clearance at login. The session high clearance must be dominated by the owner's clearance and by the upper bound of the machine monitor's label range. Once changed, connection requests from clients that run at a sensitivity label higher than the window server clearance are rejected unless they have privileges. See the <olink targetdoc="refman" targetptr="xtsolsetsessionhi-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetSessionHI</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetSessionLO(Display *display, m_label_t *sl);</literal></term><listitem><para>The session low minimum label is set from the workstation owner's minimum label at login. The session low minimum label must be greater than the user's administratively set minimum label and the lower bound of the machine monitor's label range. When this setting is changed, connection requests from clients that run at a sensitivity label lower than the window server sensitivity label are rejected unless they have privileges. See the <olink targetdoc="refman" targetptr="xtsolsetsessionlo-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetSessionLO</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-24"><title>Working With the Trusted Path Window</title><indexterm><primary><function>XTSOLIsWindowTrusted</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLIsWindowTrusted</function></secondary>
</indexterm><indexterm><primary><function>XTSOLmakeTPWindow</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLmakeTPWindow</function></secondary>
</indexterm><para>The <function>XTSOLMakeTPWindow</function> and <function>XTSOLIsWindowTrusted</function> routines are used to make the specified window the Trusted Path window and to test whether the specified window is the Trusted Path window.</para><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLMakeTPWindow(Display *display, Window *w);</literal></term><listitem><para>This routine makes the specified window the Trusted Path window. See the <olink targetdoc="refman" targetptr="xtsolmaketpwindow-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLMakeTPWindow</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Bool XTSOLIsWindowTrusted(Display *display, Window *window);</literal></term><listitem><para>This routine tests whether the specified window is the Trusted Path window. See the <olink targetdoc="refman" targetptr="xtsoliswindowtrusted-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLIsWindowTrusted</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-25"><title>Accessing and Setting the Screen Stripe Height</title><indexterm><primary><function>XTSOLsetSSHeight</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetSSHeight</function></secondary>
</indexterm><indexterm><primary><function>XTSOLgetSSHeight</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLgetSSHeight</function></secondary>
</indexterm><para>The <function>XTSOLgetSSHeight</function> and <function>XTSOLsetSSHeight</function> routines are used to obtain and set the screen stripe height.</para><note><para>These interfaces should only be used by the Window Manager.</para>
</note><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLgetSSHeight(Display *display, int screen_num, int *newHeight);</literal></term><listitem><para>This routine obtains the screen stripe height. See the <olink targetdoc="refman" targetptr="xtsolgetssheight-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLgetSSHeight</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry><varlistentry><term><literal>Status XTSOLsetSSHeight(Display *display, int screen_num, int newHeight);</literal></term><listitem><para>This routine sets the screen stripe height. Be careful that you do not end up without a screen stripe or with a very large screen stripe. See the <olink targetdoc="refman" targetptr="xtsolsetssheight-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetSSHeight</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-38"><title>Setting Window Polyinstantiation Information</title><indexterm><primary><function>XTSOLsetPolyInstInfo</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>XTSOLsetPolyInstInfo</function></secondary>
</indexterm><variablelist termlength="wholeline"><varlistentry><term><literal>Status XTSOLsetPolyInstInfo(Display *display, m_label_t sl, uid_t *uidp, int enabled);</literal></term><listitem><para>The <function>XTSOLsetPolyInstInfo</function> routine enables a client to obtain property information from a property at a different sensitivity label than the client. In the first call, you specify the desired sensitivity label and the user ID, and set the <literal>enabled</literal> property to True. Then, you call <function>XTSOLgetPropAttributes</function>, <function>XTSOLgetPropLabel</function>, or <function>XTSOLgetPropUID</function>. To finish, you call the <function>XTSOLsetPolyInstInfo</function> routine again with the <literal>enabled</literal> property set to False. See the <olink targetdoc="refman" targetptr="xtsolsetpolyinstinfo-3xtsol" remap="external"><citerefentry><refentrytitle>XTSOLsetPolyInstInfo</refentrytitle><manvolnum>3XTSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2><sect2 id="windowapi-35"><title>Working With the X11 Label-Clipping Interface</title><indexterm><primary><function>label_to_str</function> routine</primary><secondary>declaration</secondary>
</indexterm><indexterm><primary>label clipping</primary><secondary>API declaration</secondary>
</indexterm><indexterm><primary>library routines</primary><secondary><function>label_to_str</function></secondary>
</indexterm><variablelist termlength="wholeline"><varlistentry><term><literal>int label_to_str(const  m_label_t *label, char **string, const m_label_str_t conversion_type, uint_t flags);</literal></term><listitem><para>The <function>label_to_str</function> routine translates a sensitivity label or clearance to a string. See the <olink targetdoc="refman" targetptr="label-to-str-3tsol" remap="external"><citerefentry><refentrytitle>label_to_str</refentrytitle><manvolnum>3TSOL</manvolnum></citerefentry></olink> man page.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1><sect1 id="windowapi-16"><title>Using Trusted X Window System Interfaces</title><indexterm><primary>Trusted X Window System</primary><secondary>using interfaces</secondary>
</indexterm><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary>
</indexterm><para>The following sections provide example code excerpts that use Trusted Extensions interface calls. These calls handle security attributes and translate a label to a string. The excerpts focus on handling window security attributes, the most commonly managed attributes in application programs. Often, a client retrieves security attributes by using the appropriate privileges for an object that was created by another application. The client then checks the attributes to determine whether an operation on the object is permitted by the system's security policy. The security policy covers DAC policies and the MAC write-equal and read-down policies. If access is denied, the application
generates an error or uses privileges, as appropriate. See <olink targetptr="windowapi-14" remap="internal">Privileged Operations and the Trusted X Window System</olink> for a discussion about when privileges are needed.</para><para>You must create an object before you can retrieve its ID to pass to the Trusted Extensions APIs.</para><sect2 id="windowapi-39"><title>Obtaining Window Attributes</title><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>obtaining window attributes</tertiary>
</indexterm><indexterm><primary><function>XTSOLgetResAttributes</function> routine</primary><secondary>code example</secondary>
</indexterm><itemizedlist><para>The <function>XTSOLgetResAttributes</function> routine returns security-related attributes for a window. You supply the following:</para><listitem><para>Display ID</para>
</listitem><listitem><para>Window ID</para>
</listitem><listitem><para>Flag to indicate that the object for which you want security attributes is a window</para>
</listitem><listitem><para><literal>XtsolResAttributes</literal> structure to receive the returned attributes</para>
</listitem>
</itemizedlist><para>Because the client is obtaining the security attributes for a window that the client created, no privileges are required.</para><para>Note that the example programs in this book focus on the APIs being shown and do not perform error checking. Your applications should perform the appropriate error checking.</para><programlisting>/* Retrieve underlying window and display IDs with Xlib calls */
   window = XtWindow(topLevel);
   display = XtDisplay(topLevel);

/* Retrieve window security attributes */
   retval = XTSOLgetResAttributes(display, window, IsWindow, &amp;winattrs);

/* Translate labels to strings */
   retval = label_to_str(&amp;winattrs.sl, &amp;plabel, M_LABEL, LONG_NAMES);

/* Print security attribute information */
   printf(&ldquo;Workstation Owner ID = %d\nUser ID = %d\nLabel = %s\n&rdquo;,
   winattrs.ouid, winattrs.uid, string1);</programlisting><para>The <command>printf</command> statement prints the following:</para><screen>Workstation Owner ID = 29378
User ID = 29378
Label = CONFIDENTIAL</screen>
</sect2><sect2 id="windowapi-40"><title>Translating the Window Label With the Font List</title><indexterm><primary>translation</primary><secondary>labels with font list</secondary>
</indexterm><indexterm><primary>fonts</primary><secondary>font list translation</secondary>
</indexterm><indexterm><primary><function>label_to_str</function> routine</primary><secondary>code example</secondary>
</indexterm><indexterm><primary>label clipping</primary><secondary>translating with font list</secondary>
</indexterm><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>translating with font list</tertiary>
</indexterm><para>This example shows how to obtain the process sensitivity label and translate it to a string by using a font list and the pixel width. A label widget is created with the string for its label. The process sensitivity label equals the window
sensitivity label. Therefore, no privileges are required.</para><para>When the final string is longer than the width, the string is clipped and the clipped indicator is used. Note that the X Window System label-translation interfaces clip to the specified number of pixels, while the label-clipping interfaces clip to the number of characters.</para><note><para><indexterm><primary><filename>label_encodings</filename> file</primary><secondary>non-English</secondary></indexterm>If your site uses a <filename>label_encodings</filename> file in a language other than English, the translation might not work on accent characters in the ISO standard above 128. The following example does not work for the Asian character set.</para>
</note><programlisting>	retval = getplabel(&amp;senslabel);

/* Create the font list and translate the label using it */
	italic = XLoadQueryFont(XtDisplay(topLevel),
		&ldquo;-adobe-times-medium-i-*-*-14-*-*-*-*-*-iso8859-1&rdquo;);
	fontlist = XmFontListCreate(italic, &ldquo;italic&rdquo;);
	xmstr = Xbsltos(XtDisplay(topLevel), &amp;senslabel, width, fontlist, 
		LONG_WORDS);
/* Create a label widget using the font list and label text*/
	i=0;
	XtSetArg(args[i], XmNfontList, fontlist); i++;
	XtSetArg(args[i], XmNlabelString, xmstr); i++;
	label = XtCreateManagedWidget(&ldquo;label&rdquo;, xmLabelWidgetClass, 
		form, args, i);</programlisting>
</sect2><sect2 id="windowapi-41"><title>Obtaining a Window Label</title><indexterm><primary>code examples</primary><secondary>labels</secondary><tertiary>obtaining on window</tertiary>
</indexterm><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>obtaining window label</tertiary>
</indexterm><indexterm><primary><function>XTSOLgetResLabel</function> routine</primary><secondary>code example</secondary>
</indexterm><para>This example shows how to obtain the sensitivity label for a window. The process sensitivity label equals the window sensitivity label. Therefore, no privileges are required.</para><programlisting>/* Retrieve window label */
	retval = XTSOLgetResLabel(display, window, IsWindow, &amp;senslabel);

/* Translate labels to string and print */
	retval = label_to_str(label, &amp;string, M_LABEL, LONG_NAMES);
	printf(&ldquo;Label = %s\n&rdquo;, string);</programlisting><para>The <command>printf</command> statement, for example, prints the following:</para><screen>Label = PUBLIC</screen>
</sect2><sect2 id="windowapi-42"><title>Setting a Window Label</title><indexterm><primary>user IDs</primary><secondary>obtaining on window</secondary>
</indexterm><indexterm><primary>code examples</primary><secondary>labels</secondary><tertiary>setting on window</tertiary>
</indexterm><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>setting window label</tertiary>
</indexterm><indexterm><primary><function>XTSOLsetResLabel</function> routine</primary><secondary>code example</secondary>
</indexterm><para><indexterm><primary>privileges</primary><secondary><constant>win_upgrade_sl</constant></secondary></indexterm><indexterm><primary>privileges</primary><secondary><constant>sys_trans_label</constant></secondary></indexterm>This example shows how to set the sensitivity label on a window. The new sensitivity label dominates the sensitivity label of the window and the process. The client needs the <constant>sys_trans_label</constant> privilege in its effective set to translate a label that the client does not dominate. The client also needs the <constant>win_upgrade_sl</constant> privilege to change the window's sensitivity label.</para><para>For more information about using privileges, see <olink targetdoc="gssapipg" remap="external"><citetitle remap="book">Solaris Security for Developers Guide</citetitle></olink>.</para><programlisting>/* Translate text string to sensitivity label */
   retval = label_to_str(string4, &amp;label, M_LABEL, L_NO_CORRECTION, &amp;error);

/* Set sensitivity label with new value */
   retval = XTSOLsetResLabel(display, window, IsWindow, label);</programlisting>
</sect2><sect2 id="windowapi-43"><title>Obtaining the Window User ID</title><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>obtaining window user ID</tertiary>
</indexterm><indexterm><primary><function>XTSOLgetResUID</function> routine</primary><secondary>code example</secondary>
</indexterm><para>This example shows how to obtain the window user ID. The process owns the window resource and is running at the same sensitivity label. Therefore, no privileges are required.</para><programlisting>/* Get the user ID of the window */
	retval = XTSOLgetResUID(display, window, IsWindow, &amp;uid);</programlisting>
</sect2><sect2 id="windowapi-45"><title>Obtaining the X Window Server Workstation Owner ID</title><indexterm><primary>user IDs</primary><secondary>obtaining on workstation</secondary>
</indexterm><indexterm><primary>code examples</primary><secondary>Trusted X Window System</secondary><tertiary>obtaining workstation owner</tertiary>
</indexterm><indexterm><primary><function>XTSOLgetWorkstationOwner</function> routine</primary><secondary>code example</secondary>
</indexterm><para>This example shows how to obtain the ID of the user who is logged in to the X Window Server. The process sensitivity label equals the window sensitivity label. Therefore, no privileges are required.</para><programlisting>/* Get the user ID of the window */
	retval = XTSOLgetWorkstationOwner(display, &amp;uid);</programlisting>
</sect2>
</sect1>
</chapter>