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