tsol-unix-domain.patch revision 606
548N/A/*
548N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
548N/A *
548N/A * Permission is hereby granted, free of charge, to any person obtaining a
548N/A * copy of this software and associated documentation files (the
548N/A * "Software"), to deal in the Software without restriction, including
548N/A * without limitation the rights to use, copy, modify, merge, publish,
548N/A * distribute, and/or sell copies of the Software, and to permit persons
548N/A * to whom the Software is furnished to do so, provided that the above
548N/A * copyright notice(s) and this permission notice appear in all copies of
548N/A * the Software and that both the above copyright notice(s) and this
548N/A * permission notice appear in supporting documentation.
548N/A *
548N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
548N/A * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
548N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
548N/A * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
548N/A * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
548N/A * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
548N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
548N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
548N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
548N/A *
548N/A * Except as contained in this notice, the name of a copyright holder
548N/A * shall not be used in advertising or otherwise to promote the sale, use
548N/A * or other dealings in this Software without prior written authorization
548N/A * of the copyright holder.
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
606N/A--- Xtranssock.c 2008-10-07 09:15:45.707795000 -0700
606N/A+++ Xtranssock.c 2008-10-07 09:15:46.001995000 -0700
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"
606N/A@@ -1093,6 +1097,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);
606N/A@@ -1996,10 +2023,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) {