548N/A/*
943N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
548N/A *
548N/A * Permission is hereby granted, free of charge, to any person obtaining a
919N/A * copy of this software and associated documentation files (the "Software"),
919N/A * to deal in the Software without restriction, including without limitation
919N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A * and/or sell copies of the Software, and to permit persons to whom the
919N/A * Software is furnished to do so, subject to the following conditions:
548N/A *
919N/A * The above copyright notice and this permission notice (including the next
919N/A * paragraph) shall be included in all copies or substantial portions of the
919N/A * Software.
548N/A *
919N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A * DEALINGS IN THE SOFTWARE.
548N/A *
548N/A */
548N/A
548N/AUnix domain rendezvous created under /var/tsol/doors/ for Trusted
548N/AExtensions. This directory is loopback mounted into all labeled
548N/Azones from the global zone. A link is created from /tmp/.X11-unix
548N/Ato the above loopback mounted dir.
548N/A(See LSARC/2008/506)
548N/A
1276N/Adiff --git a/Xtranssock.c b/Xtranssock.c
1276N/Aindex 8c11b9d..8428314 100644
1276N/A--- a/Xtranssock.c
1276N/A+++ b/Xtranssock.c
1072N/A@@ -95,6 +95,9 @@ from the copyright holders.
548N/A #include <sys/stat.h>
548N/A #endif
548N/A
548N/A+#if defined(X11_t)
548N/A+#include <tsol/label.h>
548N/A+#endif /* X11_t */
606N/A
606N/A #ifndef NO_TCP_H
1276N/A #if defined(linux) || defined(__GLIBC__)
1276N/A@@ -213,6 +216,7 @@ static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
548N/A #if defined(X11_t)
548N/A #define UNIX_PATH "/tmp/.X11-unix/X"
548N/A #define UNIX_DIR "/tmp/.X11-unix"
548N/A+#define TSOL_UNIX_DIR "/var/tsol/doors/.X11-unix"
548N/A #endif /* X11_t */
548N/A #if defined(XIM_t)
548N/A #define UNIX_PATH "/tmp/.XIM-unix/XIM"
1276N/A@@ -1086,6 +1090,29 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
548N/A #else
548N/A mode = 0777;
548N/A #endif
548N/A+
548N/A+#ifdef X11_t
548N/A+ if (is_system_labeled()) {
548N/A+ struct stat sbuf;
548N/A+
606N/A+ if (!abstract && trans_mkdir(TSOL_UNIX_DIR, mode) == -1) {
1276N/A+ prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
1276N/A+ TSOL_UNIX_DIR, errno);
548N/A+ (void) umask (oldUmask);
548N/A+ return TRANS_CREATE_LISTENER_FAILED;
548N/A+ }
548N/A+
548N/A+ /* Create a symlink for UNIX_DIR to TSOL_UNIX_DIR */
548N/A+ if (stat(UNIX_DIR, &sbuf) != 0 && symlink(TSOL_UNIX_DIR, UNIX_DIR) != 0) {
1276N/A+ prmsg (1,
548N/A+ "SocketUNIXCreateListener: symlink to %s failed, errno = %d\n",
1276N/A+ TSOL_UNIX_DIR, errno);
548N/A+ (void) umask (oldUmask);
548N/A+ return TRANS_CREATE_LISTENER_FAILED;
548N/A+ }
548N/A+
548N/A+ } else
548N/A+#endif /* X11_t */
606N/A if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) {
1276N/A prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
1276N/A UNIX_DIR, errno);
1276N/A@@ -1967,6 +1994,24 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
548N/A return TRANS_CONNECT_FAILED;
548N/A }
548N/A
548N/A+#if defined(X11_t)
548N/A+ /*
548N/A+ * Create a symlink for UNIX_DIR to TSOL_UNIX_DIR
548N/A+ * This link is created in the labeled (non-global) zones.
548N/A+ * The rendezvous created by the X server resides in the global zone
548N/A+ * and is mounted read-only to other zones.
548N/A+ */
548N/A+ if (is_system_labeled()) {
548N/A+ struct stat sbuf;
548N/A+
548N/A+ if (stat(UNIX_DIR, &sbuf) != 0 && symlink(TSOL_UNIX_DIR, UNIX_DIR) != 0) {
1276N/A+ prmsg (1, "SocketUNIXConnect:: symlink to %s failed, errno = %d\n",
1276N/A+ TSOL_UNIX_DIR, errno);
548N/A+ return TRANS_CONNECT_FAILED;
548N/A+ }
548N/A+ }
548N/A+#endif /* X11_t */
548N/A+
548N/A /*
548N/A * Build the socket name.
548N/A */