2008-01-28 21:37:16 +00:00
|
|
|
/* source: xioopen.c */
|
2016-07-22 06:54:31 +00:00
|
|
|
/* Copyright Gerhard Rieger and contributors (see file CHANGES) */
|
2008-01-27 12:00:08 +00:00
|
|
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
|
|
|
|
|
|
|
/* this is the source file of the extended open function */
|
|
|
|
|
|
|
|
#include "xiosysincludes.h"
|
|
|
|
|
|
|
|
#include "xioopen.h"
|
|
|
|
#include "xiomodes.h"
|
2023-07-13 07:06:35 +00:00
|
|
|
#include "xiohelp.h"
|
2008-01-27 12:00:08 +00:00
|
|
|
#include "nestlex.h"
|
|
|
|
|
|
|
|
static xiofile_t *xioallocfd(void);
|
|
|
|
|
|
|
|
static xiosingle_t *xioparse_single(const char **addr);
|
|
|
|
static xiofile_t *xioparse_dual(const char **addr);
|
|
|
|
static int xioopen_dual(xiofile_t *xfd, int xioflags);
|
|
|
|
|
|
|
|
const struct addrname addressnames[] = {
|
|
|
|
#if 1
|
|
|
|
#if WITH_STDIO
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "-", &xioaddr_stdio },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if defined(WITH_UNIX) && defined(WITH_ABSTRACT_UNIXSOCKET)
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "ABSTRACT", &xioaddr_abstract_client },
|
|
|
|
{ "ABSTRACT-CLIENT", &xioaddr_abstract_client },
|
|
|
|
{ "ABSTRACT-CONNECT", &xioaddr_abstract_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "ABSTRACT-LISTEN", &xioaddr_abstract_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "ABSTRACT-RECV", &xioaddr_abstract_recv },
|
|
|
|
{ "ABSTRACT-RECVFROM", &xioaddr_abstract_recvfrom },
|
|
|
|
{ "ABSTRACT-SENDTO", &xioaddr_abstract_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif /* defined(WITH_UNIX) && defined(WITH_ABSTRACT_UNIXSOCKET) */
|
2023-10-01 17:53:55 +00:00
|
|
|
#if WITH_LISTEN && WITH_FDNUM
|
2023-09-30 16:39:13 +00:00
|
|
|
{ "ACCEPT", &xioaddr_accept_fd },
|
|
|
|
{ "ACCEPT-FD", &xioaddr_accept_fd },
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_CREAT
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "CREAT", &xioaddr_creat },
|
|
|
|
{ "CREATE", &xioaddr_creat },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2008-08-17 21:28:11 +00:00
|
|
|
#if WITH_GENERICSOCKET
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "DATAGRAM", &xioaddr_socket_datagram },
|
|
|
|
{ "DGRAM", &xioaddr_socket_datagram },
|
2008-08-17 21:28:11 +00:00
|
|
|
#endif
|
2020-12-30 18:46:42 +00:00
|
|
|
#if WITH_OPENSSL
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "DTLS", &xioaddr_openssl_dtls_client },
|
|
|
|
{ "DTLS-C", &xioaddr_openssl_dtls_client },
|
|
|
|
{ "DTLS-CLIENT", &xioaddr_openssl_dtls_client },
|
|
|
|
{ "DTLS-CONNECT", &xioaddr_openssl_dtls_client },
|
2020-12-30 18:46:42 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "DTLS-L", &xioaddr_openssl_dtls_server },
|
|
|
|
{ "DTLS-LISTEN", &xioaddr_openssl_dtls_server },
|
|
|
|
{ "DTLS-SERVER", &xioaddr_openssl_dtls_server },
|
2020-12-30 18:46:42 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_PIPE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "ECHO", &xioaddr_pipe },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_EXEC
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "EXEC", &xioaddr_exec },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_FDNUM
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "FD", &xioaddr_fd },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_PIPE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "FIFO", &xioaddr_pipe },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_FILE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "FILE", &xioaddr_open },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_GOPEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "GOPEN", &xioaddr_gopen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2008-09-20 21:37:56 +00:00
|
|
|
#if WITH_INTERFACE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "IF", &xioaddr_interface },
|
2008-09-20 21:37:56 +00:00
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET", &xioaddr_tcp_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET-L", &xioaddr_tcp_listen },
|
|
|
|
{ "INET-LISTEN", &xioaddr_tcp_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET4", &xioaddr_tcp4_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET4-L", &xioaddr_tcp4_listen },
|
|
|
|
{ "INET4-LISTEN", &xioaddr_tcp4_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET6", &xioaddr_tcp6_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INET6-L", &xioaddr_tcp6_listen },
|
|
|
|
{ "INET6-LISTEN", &xioaddr_tcp6_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2008-09-20 21:37:56 +00:00
|
|
|
#if WITH_INTERFACE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "INTERFACE", &xioaddr_interface },
|
2008-09-20 21:37:56 +00:00
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_RAWIP
|
|
|
|
#if (WITH_IP4 || WITH_IP6)
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "IP", &xioaddr_rawip_sendto },
|
|
|
|
{ "IP-DATAGRAM", &xioaddr_rawip_datagram },
|
|
|
|
{ "IP-DGRAM", &xioaddr_rawip_datagram },
|
|
|
|
{ "IP-RECV", &xioaddr_rawip_recv },
|
|
|
|
{ "IP-RECVFROM", &xioaddr_rawip_recvfrom },
|
|
|
|
{ "IP-SEND", &xioaddr_rawip_sendto },
|
|
|
|
{ "IP-SENDTO", &xioaddr_rawip_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "IP4", &xioaddr_rawip4_sendto },
|
|
|
|
{ "IP4-DATAGRAM", &xioaddr_rawip4_datagram },
|
|
|
|
{ "IP4-DGRAM", &xioaddr_rawip4_datagram },
|
|
|
|
{ "IP4-RECV", &xioaddr_rawip4_recv },
|
|
|
|
{ "IP4-RECVFROM", &xioaddr_rawip4_recvfrom },
|
|
|
|
{ "IP4-SEND", &xioaddr_rawip4_sendto },
|
|
|
|
{ "IP4-SENDTO", &xioaddr_rawip4_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "IP6", &xioaddr_rawip6_sendto },
|
|
|
|
{ "IP6-DATAGRAM", &xioaddr_rawip6_datagram },
|
|
|
|
{ "IP6-DGRAM", &xioaddr_rawip6_datagram },
|
|
|
|
{ "IP6-RECV", &xioaddr_rawip6_recv },
|
|
|
|
{ "IP6-RECVFROM", &xioaddr_rawip6_recvfrom },
|
|
|
|
{ "IP6-SEND", &xioaddr_rawip6_sendto },
|
|
|
|
{ "IP6-SENDTO", &xioaddr_rawip6_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#endif /* WITH_RAWIP */
|
|
|
|
#if WITH_UNIX
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "LOCAL", &xioaddr_unix_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_FILE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "OPEN", &xioaddr_open },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_OPENSSL
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "OPENSSL", &xioaddr_openssl },
|
|
|
|
{ "OPENSSL-CONNECT", &xioaddr_openssl },
|
|
|
|
{ "OPENSSL-DTLS-CLIENT", &xioaddr_openssl_dtls_client },
|
|
|
|
{ "OPENSSL-DTLS-CONNECT", &xioaddr_openssl_dtls_client },
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "OPENSSL-DTLS-LISTEN", &xioaddr_openssl_dtls_server },
|
|
|
|
{ "OPENSSL-DTLS-SERVER", &xioaddr_openssl_dtls_server },
|
|
|
|
{ "OPENSSL-LISTEN", &xioaddr_openssl_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if WITH_PIPE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "PIPE", &xioaddr_pipe },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2023-09-30 17:32:14 +00:00
|
|
|
#if WITH_POSIXMQ
|
|
|
|
{ "POSIXMQ-BIDIRECTIONAL", &xioaddr_posixmq_bidir },
|
|
|
|
{ "POSIXMQ-READ", &xioaddr_posixmq_read },
|
|
|
|
{ "POSIXMQ-RECEIVE", &xioaddr_posixmq_receive },
|
|
|
|
{ "POSIXMQ-RECV", &xioaddr_posixmq_receive },
|
|
|
|
{ "POSIXMQ-SEND", &xioaddr_posixmq_send },
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_PROXY
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "PROXY", &xioaddr_proxy_connect },
|
|
|
|
{ "PROXY-CONNECT", &xioaddr_proxy_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_PTY
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "PTY", &xioaddr_pty },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_READLINE
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "READLINE", &xioaddr_readline },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2008-09-22 21:21:26 +00:00
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_SCTP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP", &xioaddr_sctp_connect },
|
|
|
|
{ "SCTP-CONNECT", &xioaddr_sctp_connect },
|
2008-09-22 21:21:26 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP-L", &xioaddr_sctp_listen },
|
|
|
|
{ "SCTP-LISTEN", &xioaddr_sctp_listen },
|
2008-09-22 21:21:26 +00:00
|
|
|
#endif
|
2008-09-24 14:14:42 +00:00
|
|
|
#if WITH_IP4
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP4", &xioaddr_sctp4_connect },
|
|
|
|
{ "SCTP4-CONNECT", &xioaddr_sctp4_connect },
|
2008-09-22 21:21:26 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP4-L", &xioaddr_sctp4_listen },
|
|
|
|
{ "SCTP4-LISTEN", &xioaddr_sctp4_listen },
|
2008-09-22 21:21:26 +00:00
|
|
|
#endif
|
2008-09-24 14:14:42 +00:00
|
|
|
#endif /* WITH_IP4 */
|
|
|
|
#if WITH_IP6
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP6", &xioaddr_sctp6_connect },
|
|
|
|
{ "SCTP6-CONNECT", &xioaddr_sctp6_connect },
|
2008-09-22 21:21:26 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SCTP6-L", &xioaddr_sctp6_listen },
|
|
|
|
{ "SCTP6-LISTEN", &xioaddr_sctp6_listen },
|
2008-09-22 21:21:26 +00:00
|
|
|
#endif
|
2008-09-24 14:14:42 +00:00
|
|
|
#endif /* WITH_IP6 */
|
2008-09-22 21:21:26 +00:00
|
|
|
#endif /* (WITH_IP4 || WITH_IP6) && WITH_SCTP */
|
2008-08-17 21:28:11 +00:00
|
|
|
#if WITH_GENERICSOCKET
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SENDTO", &xioaddr_socket_sendto },
|
2008-08-17 21:28:11 +00:00
|
|
|
#endif
|
2023-10-01 19:24:46 +00:00
|
|
|
#if WITH_SHELL
|
|
|
|
{ "SHELL", &xioaddr_shell },
|
|
|
|
#endif
|
2008-08-17 21:28:11 +00:00
|
|
|
#if WITH_GENERICSOCKET
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SOCKET-CONNECT", &xioaddr_socket_connect },
|
|
|
|
{ "SOCKET-DATAGRAM", &xioaddr_socket_datagram },
|
2008-09-24 14:14:42 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SOCKET-LISTEN", &xioaddr_socket_listen },
|
2008-09-24 14:14:42 +00:00
|
|
|
#endif /* WITH_LISTEN */
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SOCKET-RECV", &xioaddr_socket_recv },
|
|
|
|
{ "SOCKET-RECVFROM", &xioaddr_socket_recvfrom },
|
|
|
|
{ "SOCKET-SENDTO", &xioaddr_socket_sendto },
|
2008-08-17 21:28:11 +00:00
|
|
|
#endif
|
2023-09-30 16:30:56 +00:00
|
|
|
#if WITH_SOCKETPAIR
|
|
|
|
{ "SOCKETPAIR", &xioaddr_socketpair },
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_SOCKS4
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SOCKS", &xioaddr_socks4_connect },
|
|
|
|
{ "SOCKS4", &xioaddr_socks4_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_SOCKS4A
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SOCKS4A", &xioaddr_socks4a_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2023-11-05 19:46:22 +00:00
|
|
|
#if WITH_SOCKS5
|
|
|
|
{ "SOCKS5", &xioaddr_socks5_connect },
|
|
|
|
{ "SOCKS5-BIND", &xioaddr_socks5_listen },
|
|
|
|
{ "SOCKS5-CONNECT", &xioaddr_socks5_connect },
|
|
|
|
{ "SOCKS5-LISTEN", &xioaddr_socks5_listen },
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_OPENSSL
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SSL", &xioaddr_openssl },
|
2008-01-27 12:00:08 +00:00
|
|
|
#if WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SSL-L", &xioaddr_openssl_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if WITH_STDIO
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "STDERR", &xioaddr_stderr },
|
|
|
|
{ "STDIN", &xioaddr_stdin },
|
|
|
|
{ "STDIO", &xioaddr_stdio },
|
|
|
|
{ "STDOUT", &xioaddr_stdout },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_SYSTEM
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "SYSTEM", &xioaddr_system },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP", &xioaddr_tcp_connect },
|
|
|
|
{ "TCP-CONNECT", &xioaddr_tcp_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP-L", &xioaddr_tcp_listen },
|
|
|
|
{ "TCP-LISTEN", &xioaddr_tcp_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP4", &xioaddr_tcp4_connect },
|
|
|
|
{ "TCP4-CONNECT", &xioaddr_tcp4_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP4-L", &xioaddr_tcp4_listen },
|
|
|
|
{ "TCP4-LISTEN", &xioaddr_tcp4_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_TCP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP6", &xioaddr_tcp6_connect },
|
|
|
|
{ "TCP6-CONNECT", &xioaddr_tcp6_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_TCP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TCP6-L", &xioaddr_tcp6_listen },
|
|
|
|
{ "TCP6-LISTEN", &xioaddr_tcp6_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_TUN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "TUN", &xioaddr_tun },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP", &xioaddr_udp_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP-CONNECT", &xioaddr_udp_connect },
|
|
|
|
{ "UDP-DATAGRAM", &xioaddr_udp_datagram },
|
|
|
|
{ "UDP-DGRAM", &xioaddr_udp_datagram },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_UDP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP-L", &xioaddr_udp_listen },
|
|
|
|
{ "UDP-LISTEN", &xioaddr_udp_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if (WITH_IP4 || WITH_IP6) && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP-RECV", &xioaddr_udp_recv },
|
|
|
|
{ "UDP-RECVFROM", &xioaddr_udp_recvfrom },
|
|
|
|
{ "UDP-SEND", &xioaddr_udp_sendto },
|
|
|
|
{ "UDP-SENDTO", &xioaddr_udp_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP4", &xioaddr_udp4_connect },
|
|
|
|
{ "UDP4-CONNECT", &xioaddr_udp4_connect },
|
|
|
|
{ "UDP4-DATAGRAM", &xioaddr_udp4_datagram },
|
|
|
|
{ "UDP4-DGRAM", &xioaddr_udp4_datagram },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_UDP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP4-L", &xioaddr_udp4_listen },
|
|
|
|
{ "UDP4-LISTEN", &xioaddr_udp4_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP4 && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP4-RECV", &xioaddr_udp4_recv },
|
|
|
|
{ "UDP4-RECVFROM", &xioaddr_udp4_recvfrom },
|
|
|
|
{ "UDP4-SEND", &xioaddr_udp4_sendto },
|
|
|
|
{ "UDP4-SENDTO", &xioaddr_udp4_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP6", &xioaddr_udp6_connect },
|
|
|
|
{ "UDP6-CONNECT", &xioaddr_udp6_connect },
|
|
|
|
{ "UDP6-DATAGRAM", &xioaddr_udp6_datagram },
|
|
|
|
{ "UDP6-DGRAM", &xioaddr_udp6_datagram },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_UDP && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP6-L", &xioaddr_udp6_listen },
|
|
|
|
{ "UDP6-LISTEN", &xioaddr_udp6_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_IP6 && WITH_UDP
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UDP6-RECV", &xioaddr_udp6_recv },
|
|
|
|
{ "UDP6-RECVFROM", &xioaddr_udp6_recvfrom },
|
|
|
|
{ "UDP6-SEND", &xioaddr_udp6_sendto },
|
|
|
|
{ "UDP6-SENDTO", &xioaddr_udp6_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_UNIX
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UNIX", &xioaddr_unix_client },
|
|
|
|
{ "UNIX-CLIENT", &xioaddr_unix_client },
|
|
|
|
{ "UNIX-CONNECT", &xioaddr_unix_connect },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_UNIX && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UNIX-L", &xioaddr_unix_listen },
|
|
|
|
{ "UNIX-LISTEN", &xioaddr_unix_listen },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_UNIX
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "UNIX-RECV", &xioaddr_unix_recv },
|
|
|
|
{ "UNIX-RECVFROM", &xioaddr_unix_recvfrom },
|
|
|
|
{ "UNIX-SEND", &xioaddr_unix_sendto },
|
|
|
|
{ "UNIX-SENDTO", &xioaddr_unix_sendto },
|
2008-01-27 12:00:08 +00:00
|
|
|
#endif
|
2020-12-26 21:46:36 +00:00
|
|
|
#if WITH_VSOCK
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "VSOCK", &xioaddr_vsock_connect },
|
|
|
|
{ "VSOCK-CONNECT", &xioaddr_vsock_connect },
|
2020-12-26 21:46:36 +00:00
|
|
|
#endif
|
|
|
|
#if WITH_VSOCK && WITH_LISTEN
|
2023-10-26 12:56:50 +00:00
|
|
|
{ "VSOCK-L", &xioaddr_vsock_listen },
|
|
|
|
{ "VSOCK-LISTEN", &xioaddr_vsock_listen },
|
2020-12-26 21:46:36 +00:00
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
#else /* !0 */
|
|
|
|
# if WITH_INTEGRATE
|
|
|
|
# include "xiointegrate.c"
|
|
|
|
# else
|
|
|
|
# include "xioaddrtab.c"
|
|
|
|
# endif
|
|
|
|
#endif /* !0 */
|
|
|
|
{ NULL } /* end marker */
|
|
|
|
} ;
|
|
|
|
|
|
|
|
int xioopen_single(xiofile_t *xfd, int xioflags);
|
|
|
|
|
|
|
|
|
|
|
|
/* prepares a xiofile_t record for dual address type:
|
|
|
|
sets the tag and allocates memory for the substreams.
|
|
|
|
returns 0 on success, or <0 if an error occurred.
|
|
|
|
*/
|
|
|
|
int xioopen_makedual(xiofile_t *file) {
|
|
|
|
file->tag = XIO_TAG_DUAL;
|
|
|
|
file->common.flags = XIO_RDWR;
|
|
|
|
if ((file->dual.stream[0] = (xiosingle_t *)xioallocfd()) == NULL)
|
|
|
|
return -1;
|
|
|
|
file->dual.stream[0]->flags = XIO_RDONLY;
|
|
|
|
if ((file->dual.stream[1] = (xiosingle_t *)xioallocfd()) == NULL)
|
|
|
|
return -1;
|
|
|
|
file->dual.stream[1]->flags = XIO_WRONLY;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static xiofile_t *xioallocfd(void) {
|
|
|
|
xiofile_t *fd;
|
|
|
|
|
|
|
|
if ((fd = Calloc(1, sizeof(xiofile_t))) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
/* some default values; 0's and NULL's need not be applied (calloc'ed) */
|
|
|
|
fd->common.tag = XIO_TAG_INVALID;
|
|
|
|
/* fd->common.addr = NULL; */
|
|
|
|
fd->common.flags = XIO_RDWR;
|
|
|
|
|
|
|
|
#if WITH_RETRY
|
|
|
|
/* fd->stream.retry = 0; */
|
|
|
|
/* fd->stream.forever = false; */
|
|
|
|
fd->stream.intervall.tv_sec = 1;
|
|
|
|
/* fd->stream.intervall.tv_nsec = 0; */
|
|
|
|
#endif /* WITH_RETRY */
|
|
|
|
/* fd->common.ignoreeof = false; */
|
|
|
|
/* fd->common.eof = 0; */
|
2023-06-23 20:48:26 +00:00
|
|
|
fd->stream.triggerfd = -1;
|
2008-01-27 12:00:08 +00:00
|
|
|
fd->stream.fd = -1;
|
|
|
|
fd->stream.dtype = XIODATA_STREAM;
|
2008-08-17 21:28:11 +00:00
|
|
|
#if _WITH_SOCKET
|
2008-01-27 12:00:08 +00:00
|
|
|
/* fd->stream.salen = 0; */
|
2008-08-17 21:28:11 +00:00
|
|
|
#endif /* _WITH_SOCKET */
|
2008-01-27 12:00:08 +00:00
|
|
|
fd->stream.howtoend = END_UNSPEC;
|
|
|
|
/* fd->stream.name = NULL; */
|
2008-09-20 21:01:10 +00:00
|
|
|
fd->stream.escape = -1;
|
2008-01-27 12:00:08 +00:00
|
|
|
/* fd->stream.para.exec.pid = 0; */
|
|
|
|
fd->stream.lineterm = LINETERM_RAW;
|
2023-11-06 05:19:18 +00:00
|
|
|
#if WITH_RESOLVE
|
|
|
|
#if HAVE_RES_RETRANS
|
|
|
|
fd->stream.para.socket.ip.res.retrans = -1;
|
|
|
|
#endif
|
|
|
|
#if HAVE_RES_RETRY
|
|
|
|
fd->stream.para.socket.ip.res.retry = -1;
|
|
|
|
#endif
|
|
|
|
#endif /* WITH_RESOLVE */
|
2008-01-27 12:00:08 +00:00
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* parse the argument that specifies a two-directional data stream
|
|
|
|
and open the resulting address
|
|
|
|
*/
|
|
|
|
xiofile_t *xioopen(const char *addr, /* address specification */
|
|
|
|
int xioflags) {
|
|
|
|
xiofile_t *xfd;
|
|
|
|
|
2020-10-13 17:25:21 +00:00
|
|
|
Debug1("xioopen(\"%s\")", addr);
|
|
|
|
|
2008-01-27 12:00:08 +00:00
|
|
|
if ((xfd = xioparse_dual(&addr)) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2016-02-06 15:36:39 +00:00
|
|
|
/*!! support n socks */
|
|
|
|
if (!sock[0]) {
|
|
|
|
sock[0] = xfd;
|
|
|
|
} else {
|
|
|
|
sock[1] = xfd;
|
|
|
|
}
|
2008-01-27 12:00:08 +00:00
|
|
|
if (xioopen_dual(xfd, xioflags) < 0) {
|
|
|
|
/*!!! free something? */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xfd;
|
|
|
|
}
|
|
|
|
|
2020-10-13 17:25:21 +00:00
|
|
|
/* parse an address string that might contain !!
|
|
|
|
return NULL on error */
|
2008-01-27 12:00:08 +00:00
|
|
|
static xiofile_t *xioparse_dual(const char **addr) {
|
|
|
|
xiofile_t *xfd;
|
|
|
|
xiosingle_t *sfd1;
|
|
|
|
|
|
|
|
/* we parse a single address */
|
|
|
|
if ((sfd1 = xioparse_single(addr)) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* and now we see if we reached a dual-address separator */
|
2023-06-23 14:21:05 +00:00
|
|
|
if (!strncmp(*addr, xioparms.pipesep, strlen(xioparms.pipesep))) {
|
2008-01-27 12:00:08 +00:00
|
|
|
/* yes we reached it, so we parse the second single address */
|
2023-06-23 14:21:05 +00:00
|
|
|
*addr += strlen(xioparms.pipesep);
|
2008-01-27 12:00:08 +00:00
|
|
|
|
|
|
|
if ((xfd = xioallocfd()) == NULL) {
|
|
|
|
free(sfd1); /*! and maybe have free some if its contents */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
xfd->tag = XIO_TAG_DUAL;
|
|
|
|
xfd->dual.stream[0] = sfd1;
|
|
|
|
if ((xfd->dual.stream[1] = xioparse_single(addr)) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* a truly single address */
|
|
|
|
xfd = (xiofile_t *)sfd1; sfd1 = NULL;
|
|
|
|
|
|
|
|
return xfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int xioopen_dual(xiofile_t *xfd, int xioflags) {
|
|
|
|
|
|
|
|
if (xfd->tag == XIO_TAG_DUAL) {
|
|
|
|
/* a really dual address */
|
|
|
|
if ((xioflags&XIO_ACCMODE) != XIO_RDWR) {
|
|
|
|
Warn("unidirectional open of dual address");
|
|
|
|
}
|
|
|
|
if (((xioflags&XIO_ACCMODE)+1) & (XIO_RDONLY+1)) {
|
|
|
|
if (xioopen_single((xiofile_t *)xfd->dual.stream[0], XIO_RDONLY|(xioflags&~XIO_ACCMODE&~XIO_MAYEXEC))
|
|
|
|
< 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (((xioflags&XIO_ACCMODE)+1) & (XIO_WRONLY+1)) {
|
|
|
|
if (xioopen_single((xiofile_t *)xfd->dual.stream[1], XIO_WRONLY|(xioflags&~XIO_ACCMODE&~XIO_MAYEXEC))
|
|
|
|
< 0) {
|
|
|
|
xioclose((xiofile_t *)xfd->dual.stream[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xioopen_single(xfd, xioflags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static xiosingle_t *xioparse_single(const char **addr) {
|
2020-10-13 17:25:21 +00:00
|
|
|
const char *addr0 = *addr; /* save for error messages */
|
2008-01-27 12:00:08 +00:00
|
|
|
xiofile_t *xfd;
|
|
|
|
xiosingle_t *sfd;
|
|
|
|
struct addrname *ae;
|
|
|
|
const struct addrdesc *addrdesc = NULL;
|
|
|
|
const char *ends[4+1];
|
|
|
|
const char *hquotes[] = {
|
|
|
|
"'",
|
|
|
|
NULL
|
|
|
|
} ;
|
|
|
|
const char *squotes[] = {
|
|
|
|
"\"",
|
|
|
|
NULL
|
|
|
|
} ;
|
|
|
|
const char *nests[] = {
|
|
|
|
"'", "'",
|
|
|
|
"(", ")",
|
|
|
|
"[", "]",
|
|
|
|
"{", "}",
|
|
|
|
NULL
|
|
|
|
} ;
|
|
|
|
char token[512], *tokp;
|
|
|
|
size_t len;
|
|
|
|
int i;
|
2022-04-15 09:23:47 +00:00
|
|
|
int result;
|
2008-01-27 12:00:08 +00:00
|
|
|
|
|
|
|
/* init */
|
|
|
|
i = 0;
|
2023-06-23 14:21:05 +00:00
|
|
|
/*ends[i++] = xioparms.chainsep;*/ /* default: "|" */
|
|
|
|
ends[i++] = xioparms.pipesep; /* default: "!!" */
|
|
|
|
ends[i++] = ","/*xioparms.comma*/; /* default: "," */
|
|
|
|
ends[i++] = ":"/*xioparms.colon*/; /* default: ":" */
|
2008-01-27 12:00:08 +00:00
|
|
|
ends[i++] = NULL;
|
|
|
|
|
|
|
|
if ((xfd = xioallocfd()) == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
sfd = &xfd->stream;
|
|
|
|
sfd->argc = 0;
|
|
|
|
|
|
|
|
len = sizeof(token); tokp = token;
|
2022-04-15 09:23:47 +00:00
|
|
|
result = nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests,
|
|
|
|
true, true, false);
|
|
|
|
if (result < 0) {
|
2008-01-27 12:00:08 +00:00
|
|
|
Error2("keyword too long, in address \"%s%s\"", token, *addr);
|
2022-04-15 09:23:47 +00:00
|
|
|
} else if (result > 0){
|
|
|
|
Error1("unexpected end of address \"%s\"", *addr);
|
2008-01-27 12:00:08 +00:00
|
|
|
}
|
|
|
|
*tokp = '\0'; /*! len? */
|
|
|
|
ae = (struct addrname *)
|
|
|
|
keyw((struct wordent *)&addressnames, token,
|
|
|
|
sizeof(addressnames)/sizeof(struct addrname)-1);
|
|
|
|
|
|
|
|
if (ae) {
|
|
|
|
addrdesc = ae->desc;
|
|
|
|
/* keyword */
|
|
|
|
if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
|
|
|
|
Error1("strdup(\"%s\"): out of memory", token);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (false) {
|
|
|
|
;
|
|
|
|
#if WITH_FDNUM
|
|
|
|
} else if (isdigit(token[0]&0xff) && token[1] == '\0') {
|
|
|
|
Info1("interpreting address \"%s\" as file descriptor", token);
|
2023-10-26 12:56:50 +00:00
|
|
|
addrdesc = &xioaddr_fd;
|
2008-01-27 12:00:08 +00:00
|
|
|
if ((sfd->argv[sfd->argc++] = strdup("FD")) == NULL) {
|
|
|
|
Error("strdup(\"FD\"): out of memory");
|
|
|
|
}
|
|
|
|
if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
|
|
|
|
Error1("strdup(\"%s\"): out of memory", token);
|
|
|
|
}
|
|
|
|
/*! check argc overflow */
|
|
|
|
#endif /* WITH_FDNUM */
|
|
|
|
#if WITH_GOPEN
|
|
|
|
} else if (strchr(token, '/')) {
|
|
|
|
Info1("interpreting address \"%s\" as file name", token);
|
2023-10-26 12:56:50 +00:00
|
|
|
addrdesc = &xioaddr_gopen;
|
2008-01-27 12:00:08 +00:00
|
|
|
if ((sfd->argv[sfd->argc++] = strdup("GOPEN")) == NULL) {
|
|
|
|
Error("strdup(\"GOPEN\"): out of memory");
|
|
|
|
}
|
|
|
|
if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
|
|
|
|
Error1("strdup(\"%s\"): out of memory", token);
|
|
|
|
}
|
|
|
|
/*! check argc overflow */
|
|
|
|
#endif /* WITH_GOPEN */
|
|
|
|
} else {
|
|
|
|
Error1("unknown device/address \"%s\"", token);
|
|
|
|
/*!!! free something*/ return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sfd->tag = XIO_TAG_RDWR;
|
|
|
|
sfd->addr = addrdesc;
|
|
|
|
|
2023-06-23 14:21:05 +00:00
|
|
|
while (!strncmp(*addr, xioparms.paramsep, strlen(xioparms.paramsep))) {
|
|
|
|
*addr += strlen(xioparms.paramsep);
|
2008-01-27 12:00:08 +00:00
|
|
|
len = sizeof(token); tokp = token;
|
2022-04-15 09:23:47 +00:00
|
|
|
result = nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests,
|
|
|
|
true, true, false);
|
|
|
|
if (result < 0) {
|
|
|
|
Error1("address \"%s\" too long", addr0);
|
|
|
|
} else if (result > 0){
|
|
|
|
Error1("unexpected end of address \"%s\"", addr0);
|
2008-01-27 12:00:08 +00:00
|
|
|
}
|
|
|
|
*tokp = '\0';
|
|
|
|
if ((sfd->argv[sfd->argc++] = strdup(token)) == NULL) {
|
|
|
|
Error1("strdup(\"%s\"): out of memory", token);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parseopts(addr, addrdesc->groups, &sfd->opts) < 0) {
|
|
|
|
free(xfd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sfd;
|
|
|
|
}
|
|
|
|
|
|
|
|
int xioopen_single(xiofile_t *xfd, int xioflags) {
|
2023-11-05 18:39:01 +00:00
|
|
|
struct single *sfd = &xfd->stream;
|
2008-01-27 12:00:08 +00:00
|
|
|
const struct addrdesc *addrdesc;
|
2023-06-21 18:44:29 +00:00
|
|
|
const char *modetext[4] = { "none", "read-only", "write-only", "read-write" } ;
|
2023-07-19 19:51:59 +00:00
|
|
|
/* Values to be saved until xioopen() is finished */
|
2023-10-02 05:56:51 +00:00
|
|
|
char *orig_dir = NULL;
|
2023-07-19 19:51:59 +00:00
|
|
|
bool have_umask = false;
|
|
|
|
mode_t orig_umask, tmp_umask;
|
2008-01-27 12:00:08 +00:00
|
|
|
int result;
|
2023-11-05 18:39:01 +00:00
|
|
|
/* Values to be saved until xioopen() is finished */
|
2023-11-06 05:19:18 +00:00
|
|
|
#if WITH_RESOLVE && HAVE_RESOLV_H
|
2023-07-21 05:10:38 +00:00
|
|
|
int do_res;
|
2023-11-05 18:39:01 +00:00
|
|
|
struct __res_state save_res;
|
2023-11-06 05:19:18 +00:00
|
|
|
#endif /* WITH_RESOLVE && HAVE_RESOLV_H */
|
2023-07-21 05:10:38 +00:00
|
|
|
#if WITH_NAMESPACES
|
|
|
|
int save_netfd = -1;
|
|
|
|
#endif
|
2008-01-27 12:00:08 +00:00
|
|
|
|
2023-06-21 18:44:29 +00:00
|
|
|
addrdesc = xfd->stream.addr;
|
|
|
|
if (((xioflags+1)&XIO_ACCMODE) & ~(addrdesc->directions)) {
|
|
|
|
Warn2("address is opened in %s mode but only supports %s", modetext[(xioflags+1)&XIO_ACCMODE], modetext[addrdesc->directions]);
|
|
|
|
}
|
2008-01-27 12:00:08 +00:00
|
|
|
if ((xioflags&XIO_ACCMODE) == XIO_RDONLY) {
|
|
|
|
xfd->tag = XIO_TAG_RDONLY;
|
|
|
|
} else if ((xioflags&XIO_ACCMODE) == XIO_WRONLY) {
|
|
|
|
xfd->tag = XIO_TAG_WRONLY;
|
|
|
|
} else if ((xioflags&XIO_ACCMODE) == XIO_RDWR) {
|
|
|
|
xfd->tag = XIO_TAG_RDWR;
|
|
|
|
} else {
|
|
|
|
Error1("invalid mode for address \"%s\"", xfd->stream.argv[0]);
|
|
|
|
}
|
|
|
|
xfd->stream.flags &= (~XIO_ACCMODE);
|
|
|
|
xfd->stream.flags |= (xioflags & XIO_ACCMODE);
|
2023-07-19 19:51:59 +00:00
|
|
|
|
2023-10-02 05:56:51 +00:00
|
|
|
/* Apply "temporary" process properties, save value for later restore */
|
|
|
|
|
|
|
|
if (applyopts_single(sfd, sfd->opts, PH_OFFSET) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#if WITH_NAMESPACES
|
|
|
|
if ((save_netfd = xio_apply_namespace(sfd->opts)) < 0)
|
|
|
|
return -1;
|
|
|
|
#endif /* WITH_NAMESPACES */
|
|
|
|
|
|
|
|
#if HAVE_RESOLV_H
|
|
|
|
if ((do_res = xio_res_init(sfd, &save_res)) < 0)
|
|
|
|
return STAT_NORETRY;
|
|
|
|
#endif /* HAVE_RESOLV_H */
|
|
|
|
|
|
|
|
if (xio_chdir(sfd->opts, &orig_dir) < 0)
|
|
|
|
return STAT_NORETRY;
|
|
|
|
|
2023-07-19 19:51:59 +00:00
|
|
|
if (retropt_mode(xfd->stream.opts, OPT_UMASK, &tmp_umask) >= 0) {
|
|
|
|
Info1("changing umask to 0%3o", tmp_umask);
|
|
|
|
orig_umask = Umask(tmp_umask);
|
|
|
|
have_umask = true;
|
|
|
|
}
|
|
|
|
|
2023-10-02 05:56:51 +00:00
|
|
|
/* Call the specific xioopen function */
|
2008-01-27 12:00:08 +00:00
|
|
|
result = (*addrdesc->func)(xfd->stream.argc, xfd->stream.argv,
|
2023-06-12 21:01:54 +00:00
|
|
|
xfd->stream.opts, xioflags, xfd,
|
2023-07-13 07:06:35 +00:00
|
|
|
addrdesc);
|
2023-11-05 18:39:01 +00:00
|
|
|
|
2023-07-19 19:51:59 +00:00
|
|
|
/* Restore process properties */
|
|
|
|
if (have_umask) {
|
|
|
|
Info1("restoring umask to 0%3o", orig_umask);
|
|
|
|
Umask(orig_umask);
|
|
|
|
}
|
|
|
|
|
2023-10-02 05:56:51 +00:00
|
|
|
if (orig_dir != NULL) {
|
|
|
|
if (Chdir(orig_dir) < 0) {
|
|
|
|
Error2("chdir(\"%s\"): %s", orig_dir, strerror(errno));
|
|
|
|
free(orig_dir);
|
|
|
|
return STAT_NORETRY;
|
|
|
|
}
|
|
|
|
free(orig_dir);
|
|
|
|
}
|
|
|
|
|
2023-11-06 05:19:18 +00:00
|
|
|
#if WITH_RESOLVE && HAVE_RESOLV_H
|
2023-11-05 18:39:01 +00:00
|
|
|
if (do_res)
|
2023-11-06 05:19:18 +00:00
|
|
|
xio_res_restore(&save_res);
|
|
|
|
#endif /* WITH_RESOLVE && HAVE_RESOLV_H */
|
2023-11-05 18:39:01 +00:00
|
|
|
|
2023-07-21 05:10:38 +00:00
|
|
|
#if WITH_NAMESPACES
|
2023-10-02 05:56:51 +00:00
|
|
|
if (save_netfd > 0) {
|
|
|
|
xio_reset_namespace(save_netfd);
|
2023-07-21 05:10:38 +00:00
|
|
|
}
|
|
|
|
#endif /* WITH_NAMESPACES */
|
|
|
|
|
2008-01-27 12:00:08 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-07-13 07:06:35 +00:00
|
|
|
int xio_syntax(
|
|
|
|
const char *addr,
|
|
|
|
int expectnum,
|
|
|
|
int isnum,
|
|
|
|
const char *syntax)
|
|
|
|
{
|
|
|
|
return xiohelp_syntax(addr, expectnum, isnum, syntax);
|
|
|
|
}
|