summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xtrans.c5
-rw-r--r--Xtranslcl.c234
2 files changed, 187 insertions, 52 deletions
diff --git a/Xtrans.c b/Xtrans.c
index 056804f..82ab729 100644
--- a/Xtrans.c
+++ b/Xtrans.c
@@ -80,6 +80,7 @@ from The Open Group.
#define TRANS_LOCAL_ISC_INDEX 12
#define TRANS_LOCAL_SCO_INDEX 13
#define TRANS_SOCKET_INET6_INDEX 14
+#define TRANS_LOCAL_PIPE_INDEX 15
static
@@ -116,7 +117,9 @@ Xtransport_table Xtransports[] = {
#ifdef SVR4
{ &TRANS(NAMEDFuncs), TRANS_LOCAL_NAMED_INDEX },
#endif
-#ifndef sun
+#ifdef sun
+ { &TRANS(PIPEFuncs), TRANS_LOCAL_PIPE_INDEX },
+#else /* !sun */
#if !defined(__SCO__) && !defined(__UNIXWARE__)
{ &TRANS(ISCFuncs), TRANS_LOCAL_ISC_INDEX },
#endif
diff --git a/Xtranslcl.c b/Xtranslcl.c
index 6165d36..e994fe5 100644
--- a/Xtranslcl.c
+++ b/Xtranslcl.c
@@ -87,7 +87,11 @@ from The Open Group.
#include <sys/ptms.h>
#endif
#endif
-#include <sys/stropts.h>
+#ifdef sun
+# include <stropts.h>
+#else
+# include <sys/stropts.h>
+#endif
#include <sys/wait.h>
#include <sys/types.h>
@@ -108,6 +112,26 @@ typedef unsigned short mode_t;
/* POSIX needed for mode_t define in sys/types.h */
#endif
+/* Types of local connections supported:
+ * - PTS
+ * - named pipes
+ * - ISC
+ * - SCO
+ */
+#if !defined(sun)
+# define LOCAL_TRANS_PTS
+#endif
+#if defined(SVR4) || defined(__SVR4)
+# define LOCAL_TRANS_NAMED
+#endif
+#if !defined(sun) && !defined(__SCO__) && !defined(__UNIXWARE__)
+/* SCO doesnt use the ISC transport type - it causes problems */
+# define LOCAL_TRANS_ISC
+#endif
+#if defined(__SCO__) || defined(__UNIXWARE__)
+# define LOCAL_TRANS_SCO
+#endif
+
/*
* These functions actually implement the local connection mechanisms.
*/
@@ -195,6 +219,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
+#ifdef LOCAL_TRANS_PTS
/* PTS */
#if defined(SYSV) && !defined(__SCO__) && !defined(ISC)
@@ -215,6 +240,7 @@ static void _dummy(int sig)
{
}
+#endif /* LOCAL_TRANS_PTS */
#ifndef sun
#define X_STREAMS_DIR "/dev/X"
@@ -236,11 +262,10 @@ static void _dummy(int sig)
#if defined(X11_t)
#define PTSNODENAME "/dev/X/server."
-#ifndef sun
-#define NAMEDNODENAME "/dev/X/Nserver."
-#else
+#ifdef sun
#define NAMEDNODENAME "/tmp/.X11-pipe/X"
-#endif
+#else
+#define NAMEDNODENAME "/dev/X/Nserver."
/*
* ISC is only defined for X11 since they are there for
@@ -252,14 +277,22 @@ static void _dummy(int sig)
#define ISCTMPNODENAME "/tmp/.X11-unix/X%s"
#define SCORNODENAME "/dev/X%1sR"
#define SCOSNODENAME "/dev/X%1sS"
+#endif /* !sun */
#endif
#if defined(XIM_t)
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.XIM-pipe/XIM"
+#else
#define PTSNODENAME "/dev/X/XIM."
#define NAMEDNODENAME "/dev/X/NXIM."
#define SCORNODENAME "/dev/XIM.%sR"
#define SCOSNODENAME "/dev/XIM.%sS"
#endif
+#endif
#if defined(FS_t) || defined (FONT_t)
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.font-pipe/fs"
+#else
/*
* USL has already defined something here. We need to check with them
* and see if their choice is usable here.
@@ -269,13 +302,21 @@ static void _dummy(int sig)
#define SCORNODENAME "/dev/fontserver.%sR"
#define SCOSNODENAME "/dev/fontserver.%sS"
#endif
+#endif
#if defined(ICE_t)
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.ICE-pipe/"
+#else
#define PTSNODENAME "/dev/X/ICE."
#define NAMEDNODENAME "/dev/X/NICE."
#define SCORNODENAME "/dev/ICE.%sR"
#define SCOSNODENAME "/dev/ICE.%sS"
#endif
+#endif
#if defined(TEST_t)
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.Test-unix/test"
+#endif
#define PTSNODENAME "/dev/X/transtest."
#define NAMEDNODENAME "/dev/X/Ntranstest."
#define SCORNODENAME "/dev/transtest.%sR"
@@ -284,7 +325,7 @@ static void _dummy(int sig)
-#ifndef sun
+#ifdef LOCAL_TRANS_PTS
#ifdef TRANS_CLIENT
static int
@@ -630,10 +671,10 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
}
#endif /* TRANS_SERVER */
-#endif /* sun */
+#endif /* LOCAL_TRANS_PTS */
-#ifdef SVR4
+#ifdef LOCAL_TRANS_NAMED
/* NAMED */
@@ -647,7 +688,9 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port)
int fd;
char server_path[64];
struct stat filestat;
- extern int isastream();
+# ifndef sun
+ extern int isastream(int);
+# endif
#endif
PRMSG(2,"NAMEDOpenClient(%s)\n", port, 0,0 );
@@ -658,29 +701,32 @@ TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port)
#else
if ( port && *port ) {
if( *port == '/' ) { /* A full pathname */
- (void) sprintf(server_path, "%s", port);
+ (void) snprintf(server_path, sizeof(server_path), "%s", port);
} else {
- (void) sprintf(server_path, "%s%s", NAMEDNODENAME, port);
+ (void) snprintf(server_path, sizeof(server_path), "%s%s", NAMEDNODENAME, port);
}
} else {
- (void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid());
+ (void) snprintf(server_path, sizeof(server_path), "%s%ld", NAMEDNODENAME, (long)getpid());
}
- if (stat(server_path, &filestat) < 0 ) {
- PRMSG(1,"NAMEDOpenClient: No device %s for NAMED connection\n", server_path, 0,0 );
+ if ((fd = open(server_path, O_RDWR)) < 0) {
+ PRMSG(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path, 0,0 );
+ return -1;
+ }
+
+ if (fstat(fd, &filestat) < 0 ) {
+ PRMSG(1,"NAMEDOpenClient: Cannot stat %s for NAMED connection\n", server_path, 0,0 );
+ (void) close(fd);
return -1;
}
if ((filestat.st_mode & S_IFMT) != S_IFIFO) {
PRMSG(1,"NAMEDOpenClient: Device %s is not a FIFO\n", server_path, 0,0 );
/* Is this really a failure? */
+ (void) close(fd);
return -1;
}
- if ((fd = open(server_path, O_RDWR)) < 0) {
- PRMSG(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path, 0,0 );
- return -1;
- }
if (isastream(fd) <= 0) {
PRMSG(1,"NAMEDOpenClient: %s is not a streams device\n", server_path, 0,0 );
@@ -737,11 +783,15 @@ TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port)
(void) sprintf(server_path, "%s%ld", NAMEDNODENAME, (long)getpid());
}
+#ifdef sun
+ mode = 0775; /* Solaris requires uid or gid 0 to create X pipes */
+#else
#ifdef HAS_STICKY_DIR_BIT
mode = 01777;
#else
mode = 0777;
#endif
+#endif
if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
PRMSG (1, "NAMEDOpenServer: mkdir(%s) failed, errno = %d\n",
X_STREAMS_DIR, errno, 0);
@@ -820,7 +870,7 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
newciptr->addrlen=ciptr->addrlen;
if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) {
PRMSG(1,
- "NAMEDAccept: failed to allocate memory for peer addr\n",
+ "NAMEDAccept: failed to allocate memory for pipe addr\n",
0,0,0);
close(str.fd);
*status = TRANS_ACCEPT_BAD_MALLOC;
@@ -849,11 +899,11 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
#endif /* TRANS_SERVER */
-#endif /* SVR4 */
+#endif /* LOCAL_TRANS_NAMED */
-#ifndef sun
+#if defined(LOCAL_TRANS_ISC) || defined(LOCAL_TRANS_SCO)
/*
* connect_spipe is used by the SCO and ISC connection types.
@@ -907,8 +957,10 @@ named_spipe(int fd, char *path)
return(ret);
}
-/* SCO doesnt use the ISC transport type - it causes problems */
-#if !defined(__SCO__) && !defined(__UNIXWARE__)
+#endif /* defined(LOCAL_TRANS_ISC) || defined(LOCAL_TRANS_SCO) */
+
+
+#if defined(LOCAL_TRANS_ISC)
/* ISC */
@@ -1192,9 +1244,10 @@ TRANS(ISCAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
}
#endif /* TRANS_SERVER */
-#endif /* !__SCO__ && !__UNIXWARE__ */
+#endif /* LOCAL_TRANS_ISC */
+#ifdef LOCAL_TRANS_SCO
/* SCO */
/*
@@ -1469,12 +1522,12 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
}
#endif /* TRANS_SERVER */
-#endif /* sun */
+#endif /* LOCAL_TRANS_SCO */
#ifdef TRANS_REOPEN
-#ifndef sun
+#ifdef LOCAL_TRANS_PTS
static int
TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port)
@@ -1512,7 +1565,9 @@ TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port)
#endif /* !PTSNODENAME */
}
-#endif /* !sun */
+#endif /* LOCAL_TRANS_PTS */
+
+#ifdef LOCAL_TRANS_NAMED
static int
TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd, char *port)
@@ -1550,8 +1605,9 @@ TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd, char *port)
#endif /* !NAMEDNODENAME */
}
-#ifndef sun
-#if !defined(__SCO__) && !defined(__UNIXWARE__)
+#endif /* LOCAL_TRANS_NAMED */
+
+#ifdef LOCAL_TRANS_ISC
static int
TRANS(ISCReopenServer)(XtransConnInfo ciptr, int fd, char *port)
@@ -1579,8 +1635,9 @@ TRANS(ISCReopenServer)(XtransConnInfo ciptr, int fd, char *port)
#endif /* !ISCDEVNODENAME */
}
-#endif /* !__SCO__ && !__UNIXWARE__ */
+#endif /* LOCAL_TRANS_ISC */
+#ifdef LOCAL_TRANS_SCO
static int
TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port)
@@ -1614,7 +1671,7 @@ TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port)
#endif /* SCORNODENAME */
}
-#endif /* !sun */
+#endif /* LOCAL_TRANS_SCO */
#endif /* TRANS_REOPEN */
@@ -1687,7 +1744,7 @@ typedef struct _LOCALtrans2dev {
} LOCALtrans2dev;
static LOCALtrans2dev LOCALtrans2devtab[] = {
-#ifndef sun
+#ifdef LOCAL_TRANS_PTS
{"",
#ifdef TRANS_CLIENT
TRANS(PTSOpenClient),
@@ -1753,7 +1810,7 @@ static LOCALtrans2dev LOCALtrans2devtab[] = {
TRANS(PTSAccept)
#endif /* TRANS_SERVER */
},
-#else /* sun */
+#else /* !LOCAL_TRANS_PTS */
{"",
#ifdef TRANS_CLIENT
TRANS(NAMEDOpenClient),
@@ -1797,9 +1854,9 @@ static LOCALtrans2dev LOCALtrans2devtab[] = {
TRANS(NAMEDAccept)
#endif /* TRANS_SERVER */
},
-#endif /* sun */
+#endif /* !LOCAL_TRANS_PTS */
-#ifdef SVR4
+#ifdef LOCAL_TRANS_NAMED
{"named",
#ifdef TRANS_CLIENT
TRANS(NAMEDOpenClient),
@@ -1821,10 +1878,33 @@ static LOCALtrans2dev LOCALtrans2devtab[] = {
TRANS(NAMEDAccept)
#endif /* TRANS_SERVER */
},
-#endif /* SVR4 */
-#ifndef sun
-#if !defined(__SCO__) && !defined(__UNIXWARE__)
+#ifdef sun /* Alias "pipe" to named, since that's what Solaris called it */
+{"pipe",
+#ifdef TRANS_CLIENT
+ TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(NAMEDReopenServer),
+ TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+ TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* sun */
+#endif /* LOCAL_TRANS_NAMED */
+
+#ifdef LOCAL_TRANS_ISC
{"isc",
#ifdef TRANS_CLIENT
TRANS(ISCOpenClient),
@@ -1846,8 +1926,9 @@ static LOCALtrans2dev LOCALtrans2devtab[] = {
TRANS(ISCAccept)
#endif /* TRANS_SERVER */
},
-#endif /* !__SCO__ && !__UNIXWARE__ */
+#endif /* LOCAL_TRANS_ISC */
+#ifdef LOCAL_TRANS_SCO
{"sco",
#ifdef TRANS_CLIENT
TRANS(SCOOpenClient),
@@ -1869,7 +1950,7 @@ static LOCALtrans2dev LOCALtrans2devtab[] = {
TRANS(SCOAccept)
#endif /* TRANS_SERVER */
},
-#endif /* sun */
+#endif /* LOCAL_TRANS_SCO */
};
#define NUMTRANSPORTS (sizeof(LOCALtrans2devtab)/sizeof(LOCALtrans2dev))
@@ -1882,6 +1963,8 @@ static char *freeXLOCAL=NULL;
#define DEF_XLOCAL "SCO:UNIX:PTS"
#elif defined(__UNIXWARE__)
#define DEF_XLOCAL "UNIX:PTS:NAMED:SCO"
+#elif defined(sun)
+#define DEF_XLOCAL "UNIX:NAMED"
#else
#define DEF_XLOCAL "UNIX:PTS:NAMED:ISC:SCO"
#endif
@@ -1942,7 +2025,7 @@ TRANS(LocalGetNextTransport)(void)
for(i=0;i<NUMTRANSPORTS;i++)
{
/*
- * This is equivilent to a case insensitive strcmp(),
+ * This is equivalent to a case insensitive strcmp(),
* but should be more portable.
*/
strncpy(typebuf,typetocheck,TYPEBUFSIZE);
@@ -2534,14 +2617,17 @@ TRANS(LocalCloseForCloning)(XtransConnInfo ciptr)
#ifdef TRANS_SERVER
static char * local_aliases[] = {
-# ifndef sun
+# ifdef LOCAL_TRANS_PTS
"pts",
# endif
"named",
-# ifndef sun
-# if !defined(__SCO__) && !defined(__UNIXWARE__)
+# ifdef sun
+ "pipe", /* compatibility with Solaris Xlib */
+# endif
+# ifdef LOCAL_TRANS_ISC
"isc",
-# endif
+# endif
+# ifdef LOCAL_TRANS_SCO
"sco",
# endif
NULL };
@@ -2587,7 +2673,7 @@ Xtransport TRANS(LocalFuncs) = {
TRANS(LocalCloseForCloning),
};
-#ifndef sun
+#ifdef LOCAL_TRANS_PTS
Xtransport TRANS(PTSFuncs) = {
/* Local Interface */
@@ -2629,7 +2715,9 @@ Xtransport TRANS(PTSFuncs) = {
TRANS(LocalCloseForCloning),
};
-#endif /* sun */
+#endif /* LOCAL_TRANS_PTS */
+
+#ifdef LOCAL_TRANS_NAMED
Xtransport TRANS(NAMEDFuncs) = {
/* Local Interface */
@@ -2671,8 +2759,50 @@ Xtransport TRANS(NAMEDFuncs) = {
TRANS(LocalCloseForCloning),
};
-#ifndef sun
-#if !defined(__SCO__) && !defined(__UNIXWARE__)
+#ifdef sun
+Xtransport TRANS(PIPEFuncs) = {
+ /* Local Interface */
+ "pipe",
+ TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ NULL,
+ TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+ TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+ TRANS(LocalReopenCOTSServer),
+ TRANS(LocalReopenCLTSServer),
+#endif
+ TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+ TRANS(LocalCreateListener),
+ NULL, /* ResetListener */
+ TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+ TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+ TRANS(LocalBytesReadable),
+ TRANS(LocalRead),
+ TRANS(LocalWrite),
+ TRANS(LocalReadv),
+ TRANS(LocalWritev),
+ TRANS(LocalDisconnect),
+ TRANS(LocalClose),
+ TRANS(LocalCloseForCloning),
+};
+#endif /* sun */
+#endif /* LOCAL_TRANS_NAMED */
+
+#ifdef LOCAL_TRANS_ISC
Xtransport TRANS(ISCFuncs) = {
/* Local Interface */
"isc",
@@ -2712,7 +2842,9 @@ Xtransport TRANS(ISCFuncs) = {
TRANS(LocalClose),
TRANS(LocalCloseForCloning),
};
-#endif /* !__SCO__ && !__UNIXWARE__ */
+#endif /* LOCAL_TRANS_ISC */
+
+#ifdef LOCAL_TRANS_SCO
Xtransport TRANS(SCOFuncs) = {
/* Local Interface */
"sco",
@@ -2752,4 +2884,4 @@ Xtransport TRANS(SCOFuncs) = {
TRANS(LocalClose),
TRANS(LocalCloseForCloning),
};
-#endif /* sun */
+#endif /* LOCAL_TRANS_SCO */