From e1a2e37480ab10a2319fad9d28d2bd04373ba17b Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sun, 2 Jan 2022 21:34:10 +0100 Subject: [PATCH] AIX: Fixed runtime issues --- CHANGES | 6 ++++++ xio-gopen.c | 2 +- xio-socket.c | 2 ++ xio-unix.c | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 0749542..e918025 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,12 @@ Porting: Adapted include requirements for IPv6 Guarded MSG_DONTWAIT + Continued porting Socat to AIX-7.1 - Fixed some runtime errors: + UNIX domain sockets of type SEQPACKET are not available. + Connecting to UNIX datagram socket fails with EPROTONOSUPPORT (vs. + EPROTOTYPE on most other OSes). + Streams: Must not push ldterm when it is already active (hangs). + ####################### V 1.7.4.2: Corrections: diff --git a/xio-gopen.c b/xio-gopen.c index 2753fed..1d8f23e 100644 --- a/xio-gopen.c +++ b/xio-gopen.c @@ -89,7 +89,7 @@ static int xioopen_gopen(int argc, const char *argv[], struct opt *opts, int xio if ((result = _xioopen_open(filename, openflags, opts)) < 0) return result; #ifdef I_PUSH - if (S_ISCHR(st_mode)) { + if (S_ISCHR(st_mode) && Ioctl(result, I_FIND, "ldterm\0") == 0) { Ioctl(result, I_PUSH, "ptem\0\0\0"); /* pad string length ... */ Ioctl(result, I_PUSH, "ldterm\0"); /* ... to requirements of ... */ Ioctl(result, I_PUSH, "ttcompat"); /* ... AdressSanitizer */ diff --git a/xio-socket.c b/xio-socket.c index d55d8d3..65a7e94 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -2219,8 +2219,10 @@ xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) { retropt_int(opts, OPT_SO_PROTOTYPE, &proto); result = Socket(pf, socktype, proto); if (result < 0) { + int _errno = errno; Msg4(msglevel, "socket(%d, %d, %d): %s", pf, socktype, proto, strerror(errno)); + errno = _errno; return -1; } return result; diff --git a/xio-unix.c b/xio-unix.c index 0dfd93a..09140b1 100644 --- a/xio-unix.c +++ b/xio-unix.c @@ -576,11 +576,11 @@ _xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups, /* xfd->dtype = DATA_STREAM; // is default */ /* this function handles AF_UNIX with EPROTOTYPE specially for us */ if ((result = - xioopen_connect(xfd, - needbind?&us:NULL, uslen, - &them.soa, themlen, - opts, pf, socktype?socktype:SOCK_STREAM, protocol, - false)) == 0) + _xioopen_connect(xfd, + needbind?&us:NULL, uslen, + &them.soa, themlen, + opts, pf, socktype?socktype:SOCK_STREAM, protocol, + false, E_INFO)) == 0) break; if (errno != EPROTOTYPE || socktype != 0) break; @@ -590,13 +590,13 @@ _xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups, socktype = SOCK_SEQPACKET; if ((result = - xioopen_connect(xfd, - needbind?&us:NULL, uslen, - (struct sockaddr *)&them, themlen, - opts, pf, SOCK_SEQPACKET, protocol, - false)) == 0) + _xioopen_connect(xfd, + needbind?&us:NULL, uslen, + (struct sockaddr *)&them, themlen, + opts, pf, SOCK_SEQPACKET, protocol, + false, E_INFO)) == 0) break; - if (errno != EPROTOTYPE) + if (errno != EPROTOTYPE && errno != EPROTONOSUPPORT/*AIX*/) break; if (needbind) Unlink(us.un.sun_path);