352N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
352N/A# Use is subject to license terms.
352N/A# Permission is hereby granted, free of charge, to any person obtaining a
352N/A# copy of this software and associated documentation files (the
352N/A# "Software"), to deal in the Software without restriction, including
352N/A# without limitation the rights to use, copy, modify, merge, publish,
352N/A# distribute,
and/or sell copies of the Software, and to permit persons
352N/A# to whom the Software is furnished to do so, provided that the above
352N/A# copyright notice(s) and this permission notice appear in all copies of
352N/A# the Software and that both the above copyright notice(s) and this
352N/A# permission notice appear in supporting documentation.
352N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
352N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
352N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
352N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
352N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
352N/A# INDIRECT OR CONSEQUENTIAL EXTS, OR ANY EXTS WHATSOEVER RESULTING
352N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
352N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
352N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
352N/A# Except as contained in this notice, the name of a copyright holder
352N/A# shall not be used in advertising or otherwise to promote the sale, use
560N/A# or other dealings in this Software without prior written authorization
560N/A# of the copyright holder.
352N/A@@ -43,6 +43,13 @@ in this Software without prior written a
665N/A static XExtensionInfo _shm_info_data;
665N/A static XExtensionInfo *shm_info = &_shm_info_data;
876N/A static /* const */ char *shm_extension_name = SHMNAME;
560N/A@@ -140,6 +147,46 @@ event_to_wire (Display *dpy, XEvent *re,
352N/A+ * Function to determine if a connection is local or not.
352N/A+ * Returns: 0 for remote, 1 for local
352N/A+LocalConnection(Display *dpy)
352N/A+ int c = ConnectionNumber(dpy);
861N/A+ ucred_t *ucred = NULL;
352N/A+ * First stat the connection fd. If we succeed and the type of file
352N/A+ * is a FIFO, then we must be local.
352N/A+ * Then call getpeerucred - if it succeeds, the other end of the
352N/A+ * connection must be on the same machine (though possibly in a
377N/A+ if (getpeerucred(c, &ucred) == 0) {
352N/A+ if (ucred_getzoneid(ucred) != -1) {
489N/A /*****************************************************************************
352N/A * public Shared Memory Extension routines *
352N/A@@ -149,6 +196,15 @@ event_to_wire (Display *dpy, XEvent *re,
352N/A Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
352N/A XExtDisplayInfo *info = find_display (dpy);
352N/A+ * Sun Mod -- if we're dealing with a remote connection, then the
365N/A+ * shared memory extension is not valid. Sigh -- this should really
365N/A+ * be in the server somewhere... Required for pipe transport PIPECONN
365N/A+ if(!LocalConnection(dpy))
365N/A if (XextHasExtension(info)) {
365N/A /* *event_basep = info->codes->first_event;
489N/A@@ -181,6 +237,15 @@ Bool XShmQueryVersion(
365N/A XExtDisplayInfo *info = find_display (dpy);
365N/A xShmQueryVersionReply rep;
365N/A register xShmQueryVersionReq *req;
480N/A+ * Sun Mod -- if we're dealing with a remote connection, then the
480N/A+ * shared memory extension is not valid. Sigh -- this should really
480N/A+ * be in the server somewhere...
480N/A+ if(!LocalConnection(dpy))
480N/A ShmCheckExtension (dpy, info, False);