tsol-unix-domain.patch revision 919
548N/A/*
548N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
919N/A * Use is subject to license terms.
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
606N/Adiff -urp -x '*~' -x '*.orig' Xtranssock.c Xtranssock.c
851N/A--- Xtranssock.c 2009-11-12 16:54:25.972675041 -0800
851N/A+++ Xtranssock.c 2009-11-12 16:54:26.157813536 -0800
606N/A@@ -74,6 +74,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
606N/A #if defined(linux) || defined(__GLIBC__)
606N/A@@ -192,6 +195,7 @@ static int TRANS(SocketINETClose) (Xtran
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"
851N/A@@ -1067,6 +1071,29 @@ TRANS(SocketUNIXCreateListener) (XtransC
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) {
548N/A+ PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
548N/A+ TSOL_UNIX_DIR, errno, 0);
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) {
548N/A+ PRMSG (1,
548N/A+ "SocketUNIXCreateListener: symlink to %s failed, errno = %d\n",
548N/A+ TSOL_UNIX_DIR, errno, 0);
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) {
548N/A PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
548N/A UNIX_DIR, errno, 0);
851N/A@@ -1962,10 +1989,28 @@ TRANS(SocketUNIXConnect) (XtransConnInfo
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) {
548N/A+ PRMSG (1, "SocketUNIXConnect:: symlink to %s failed, errno = %d\n",
548N/A+ TSOL_UNIX_DIR, errno, 0);
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 */
548N/A-
548N/A+
548N/A sockname.sun_family = AF_UNIX;
548N/A
606N/A if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {