gtk+3: fix dependencies for new gnome/accessibility/at-spi2-core
[oi-userland.git] / components / x11 / xtrans / patches / 03-tsol-unix-domain.patch
blobf40524b28750e1729d80fee93dd4223eb2608f26
1 /*
2 * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 Unix domain rendezvous created under /var/tsol/doors/ for Trusted
26 Extensions. This directory is loopback mounted into all labeled
27 zones from the global zone. A link is created from /tmp/.X11-unix
28 to the above loopback mounted dir.
29 (See LSARC/2008/506)
31 diff --git a/Xtranssock.c b/Xtranssock.c
32 index 8c11b9d..8428314 100644
33 --- a/Xtranssock.c
34 +++ b/Xtranssock.c
35 @@ -95,6 +95,9 @@ from the copyright holders.
36 #include <sys/stat.h>
37 #endif
39 +#if defined(X11_t)
40 +#include <tsol/label.h>
41 +#endif /* X11_t */
43 #ifndef NO_TCP_H
44 #if defined(linux) || defined(__GLIBC__)
45 @@ -213,6 +216,7 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
46 #if defined(X11_t)
47 #define UNIX_PATH "/tmp/.X11-unix/X"
48 #define UNIX_DIR "/tmp/.X11-unix"
49 +#define TSOL_UNIX_DIR "/var/tsol/doors/.X11-unix"
50 #endif /* X11_t */
51 #if defined(XIM_t)
52 #define UNIX_PATH "/tmp/.XIM-unix/XIM"
53 @@ -1086,6 +1090,29 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
54 #else
55 mode = 0777;
56 #endif
58 +#ifdef X11_t
59 + if (is_system_labeled()) {
60 + struct stat sbuf;
62 + if (!abstract && trans_mkdir(TSOL_UNIX_DIR, mode) == -1) {
63 + prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
64 + TSOL_UNIX_DIR, errno);
65 + (void) umask (oldUmask);
66 + return TRANS_CREATE_LISTENER_FAILED;
67 + }
69 + /* Create a symlink for UNIX_DIR to TSOL_UNIX_DIR */
70 + if (stat(UNIX_DIR, &sbuf) != 0 && symlink(TSOL_UNIX_DIR, UNIX_DIR) != 0) {
71 + prmsg (1,
72 + "SocketUNIXCreateListener: symlink to %s failed, errno = %d\n",
73 + TSOL_UNIX_DIR, errno);
74 + (void) umask (oldUmask);
75 + return TRANS_CREATE_LISTENER_FAILED;
76 + }
78 + } else
79 +#endif /* X11_t */
80 if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) {
81 prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
82 UNIX_DIR, errno);
83 @@ -1967,6 +1994,24 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
84 return TRANS_CONNECT_FAILED;
87 +#if defined(X11_t)
88 + /*
89 + * Create a symlink for UNIX_DIR to TSOL_UNIX_DIR
90 + * This link is created in the labeled (non-global) zones.
91 + * The rendezvous created by the X server resides in the global zone
92 + * and is mounted read-only to other zones.
93 + */
94 + if (is_system_labeled()) {
95 + struct stat sbuf;
97 + if (stat(UNIX_DIR, &sbuf) != 0 && symlink(TSOL_UNIX_DIR, UNIX_DIR) != 0) {
98 + prmsg (1, "SocketUNIXConnect:: symlink to %s failed, errno = %d\n",
99 + TSOL_UNIX_DIR, errno);
100 + return TRANS_CONNECT_FAILED;
103 +#endif /* X11_t */
106 * Build the socket name.