1 # Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice (including the next
11 # paragraph) shall be included in all copies or substantial portions of the
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 # DEALINGS IN THE SOFTWARE.
23 --- libXext-1.3.5/src/XShm.c.orig
24 +++ libXext-1.3.5/src/XShm.c
26 #include <X11/extensions/Xext.h>
27 #include <X11/extensions/extutil.h>
31 +#include <sys/types.h>
32 +#include <sys/stat.h>
36 static XExtensionInfo _shm_info_data;
37 static XExtensionInfo *shm_info = &_shm_info_data;
38 static const char *shm_extension_name = SHMNAME;
45 + * Function to determine if a connection is local or not.
46 + * Returns: 0 for remote, 1 for local
50 +LocalConnection(Display *dpy)
52 + int c = ConnectionNumber(dpy);
54 + struct stat statbuf;
55 + ucred_t *ucred = NULL;
59 + * First stat the connection fd. If we succeed and the type of file
60 + * is a FIFO, then we must be local.
62 + if ((fstat(c, &statbuf) >= 0) && S_ISFIFO(statbuf.st_mode)) {
67 + * Then call getpeerucred - if it succeeds, the other end of the
68 + * connection must be on the same machine (though possibly in a
71 + if (getpeerucred(c, &ucred) == 0) {
72 + if (ucred_getzoneid(ucred) != -1) {
83 /*****************************************************************************
85 * public Shared Memory Extension routines *
87 Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
89 XExtDisplayInfo *info = find_display (dpy);
92 + * Sun Mod -- if we're dealing with a remote connection, then the
93 + * shared memory extension is not valid. Sigh -- this should really
94 + * be in the server somewhere... Required for pipe transport PIPECONN
96 + if(!LocalConnection(dpy))
100 if (XextHasExtension(info)) {
101 /* *event_basep = info->codes->first_event;
103 XExtDisplayInfo *info = find_display (dpy);
104 xShmQueryVersionReply rep;
105 register xShmQueryVersionReq *req;
108 + * Sun Mod -- if we're dealing with a remote connection, then the
109 + * shared memory extension is not valid. Sigh -- this should really
110 + * be in the server somewhere...
112 + if(!LocalConnection(dpy))
114 +#endif /* SUNSOFT */
116 ShmCheckExtension (dpy, info, False);