struct cmsghdr.cmsg is system dependend; more print format corrections

This commit is contained in:
Gerhard Rieger 2014-03-26 20:24:58 +01:00
parent 4a0e282c97
commit fc013607d2
16 changed files with 99 additions and 53 deletions

View file

@ -174,6 +174,9 @@ porting:
autoconf now prefers configure.ac over configure.in autoconf now prefers configure.ac over configure.in
Thanks to Michael Vastola for sending a patch. Thanks to Michael Vastola for sending a patch.
type of struct cmsghdr.cmsg is system dependend, determine it with
configure; some more print format corrections
libwrap always logs to syslog libwrap always logs to syslog
added actual text version of GPLv2 added actual text version of GPLv2

View file

@ -99,7 +99,7 @@
# define SIZET_MAX UINT_MAX # define SIZET_MAX UINT_MAX
# define SSIZET_MIN INT_MIN # define SSIZET_MIN INT_MIN
# define SSIZET_MAX INT_MAX # define SSIZET_MAX INT_MAX
# define F_Zd "%d" # define F_Zd "%""d"
# define F_Zu "%u" # define F_Zu "%u"
#elif HAVE_BASIC_SIZE_T==6 #elif HAVE_BASIC_SIZE_T==6
# define SIZET_MAX ULONG_MAX # define SIZET_MAX ULONG_MAX
@ -153,7 +153,7 @@
# elif HAVE_BASIC_PID_T==2 # elif HAVE_BASIC_PID_T==2
#define F_pid "%hu" #define F_pid "%hu"
# elif HAVE_BASIC_PID_T==3 # elif HAVE_BASIC_PID_T==3
#define F_pid "%d" #define F_pid "%""d"
# elif HAVE_BASIC_PID_T==4 # elif HAVE_BASIC_PID_T==4
#define F_pid "%u" #define F_pid "%u"
# elif HAVE_BASIC_PID_T==5 # elif HAVE_BASIC_PID_T==5
@ -177,7 +177,7 @@
# elif HAVE_BASIC_UID_T==2 # elif HAVE_BASIC_UID_T==2
#define F_uid "%hu" #define F_uid "%hu"
# elif HAVE_BASIC_UID_T==3 # elif HAVE_BASIC_UID_T==3
#define F_uid "%d" #define F_uid "%""d"
# elif HAVE_BASIC_UID_T==4 # elif HAVE_BASIC_UID_T==4
#define F_uid "%u" #define F_uid "%u"
# elif HAVE_BASIC_UID_T==5 # elif HAVE_BASIC_UID_T==5
@ -201,7 +201,7 @@
# elif HAVE_BASIC_GID_T==2 # elif HAVE_BASIC_GID_T==2
#define F_gid "%hu" #define F_gid "%hu"
# elif HAVE_BASIC_GID_T==3 # elif HAVE_BASIC_GID_T==3
#define F_gid "%d" #define F_gid "%""d"
# elif HAVE_BASIC_GID_T==4 # elif HAVE_BASIC_GID_T==4
#define F_gid "%u" #define F_gid "%u"
# elif HAVE_BASIC_GID_T==5 # elif HAVE_BASIC_GID_T==5
@ -225,7 +225,7 @@
# elif HAVE_BASIC_TIME_T==2 # elif HAVE_BASIC_TIME_T==2
#define F_time "%hu" #define F_time "%hu"
# elif HAVE_BASIC_TIME_T==3 # elif HAVE_BASIC_TIME_T==3
#define F_time "%d" #define F_time "%""d"
# elif HAVE_BASIC_TIME_T==4 # elif HAVE_BASIC_TIME_T==4
#define F_time "%u" #define F_time "%u"
# elif HAVE_BASIC_TIME_T==5 # elif HAVE_BASIC_TIME_T==5
@ -253,7 +253,7 @@
# elif HAVE_BASIC_SOCKLEN_T==2 # elif HAVE_BASIC_SOCKLEN_T==2
#define F_socklen "%hu" #define F_socklen "%hu"
# elif HAVE_BASIC_SOCKLEN_T==3 # elif HAVE_BASIC_SOCKLEN_T==3
#define F_socklen "%d" #define F_socklen "%""d"
# elif HAVE_BASIC_SOCKLEN_T==4 # elif HAVE_BASIC_SOCKLEN_T==4
#define F_socklen "%u" #define F_socklen "%u"
# elif HAVE_BASIC_SOCKLEN_T==5 # elif HAVE_BASIC_SOCKLEN_T==5
@ -275,7 +275,7 @@
#endif #endif
#ifndef F_off #ifndef F_off
# if HAVE_BASIC_OFF_T==3 # if HAVE_BASIC_OFF_T==3
# define F_off "%d" # define F_off "%""d"
# elif HAVE_BASIC_OFF_T==5 # elif HAVE_BASIC_OFF_T==5
# define F_off "%ld" # define F_off "%ld"
# else # else
@ -294,7 +294,7 @@
# elif HAVE_BASIC_OFF64_T==2 # elif HAVE_BASIC_OFF64_T==2
#define F_off64 "%hu" #define F_off64 "%hu"
# elif HAVE_BASIC_OFF64_T==3 # elif HAVE_BASIC_OFF64_T==3
#define F_off64 "%d" #define F_off64 "%""d"
# elif HAVE_BASIC_OFF64_T==4 # elif HAVE_BASIC_OFF64_T==4
#define F_off64 "%u" #define F_off64 "%u"
# elif HAVE_BASIC_OFF64_T==5 # elif HAVE_BASIC_OFF64_T==5
@ -322,7 +322,7 @@
# elif HAVE_BASIC_DEV_T==2 # elif HAVE_BASIC_DEV_T==2
#define F_dev "%hu" #define F_dev "%hu"
# elif HAVE_BASIC_DEV_T==3 # elif HAVE_BASIC_DEV_T==3
#define F_dev "%d" #define F_dev "%""d"
# elif HAVE_BASIC_DEV_T==4 # elif HAVE_BASIC_DEV_T==4
#define F_dev "%u" #define F_dev "%u"
# elif HAVE_BASIC_DEV_T==5 # elif HAVE_BASIC_DEV_T==5
@ -349,7 +349,7 @@
# elif HAVE_TYPEOF_ST_INO==2 # elif HAVE_TYPEOF_ST_INO==2
#define F_st_ino "%hu" #define F_st_ino "%hu"
# elif HAVE_TYPEOF_ST_INO==3 # elif HAVE_TYPEOF_ST_INO==3
#define F_st_ino "%d" #define F_st_ino "%""d"
# elif HAVE_TYPEOF_ST_INO==4 # elif HAVE_TYPEOF_ST_INO==4
#define F_st_ino "%u" #define F_st_ino "%u"
# elif HAVE_TYPEOF_ST_INO==5 # elif HAVE_TYPEOF_ST_INO==5
@ -376,7 +376,7 @@
# elif HAVE_TYPEOF_ST64_INO==2 # elif HAVE_TYPEOF_ST64_INO==2
#define F_st64_ino "%hu" #define F_st64_ino "%hu"
# elif HAVE_TYPEOF_ST64_INO==3 # elif HAVE_TYPEOF_ST64_INO==3
#define F_st64_ino "%d" #define F_st64_ino "%""d"
# elif HAVE_TYPEOF_ST64_INO==4 # elif HAVE_TYPEOF_ST64_INO==4
#define F_st64_ino "%u" #define F_st64_ino "%u"
# elif HAVE_TYPEOF_ST64_INO==5 # elif HAVE_TYPEOF_ST64_INO==5
@ -403,7 +403,7 @@
# elif HAVE_TYPEOF_ST_NLINK==2 # elif HAVE_TYPEOF_ST_NLINK==2
#define F_st_nlink "%hu" #define F_st_nlink "%hu"
# elif HAVE_TYPEOF_ST_NLINK==3 # elif HAVE_TYPEOF_ST_NLINK==3
#define F_st_nlink "%d" #define F_st_nlink "%""d"
# elif HAVE_TYPEOF_ST_NLINK==4 # elif HAVE_TYPEOF_ST_NLINK==4
#define F_st_nlink "%u" #define F_st_nlink "%u"
# elif HAVE_TYPEOF_ST_NLINK==5 # elif HAVE_TYPEOF_ST_NLINK==5
@ -430,7 +430,7 @@
# elif HAVE_TYPEOF_ST_SIZE==2 # elif HAVE_TYPEOF_ST_SIZE==2
#define F_st_size "%hu" #define F_st_size "%hu"
# elif HAVE_TYPEOF_ST_SIZE==3 # elif HAVE_TYPEOF_ST_SIZE==3
#define F_st_size "%d" #define F_st_size "%""d"
# elif HAVE_TYPEOF_ST_SIZE==4 # elif HAVE_TYPEOF_ST_SIZE==4
#define F_st_size "%u" #define F_st_size "%u"
# elif HAVE_TYPEOF_ST_SIZE==5 # elif HAVE_TYPEOF_ST_SIZE==5
@ -457,7 +457,7 @@
# elif HAVE_TYPEOF_ST64_SIZE==2 # elif HAVE_TYPEOF_ST64_SIZE==2
#define F_st64_size "%hu" #define F_st64_size "%hu"
# elif HAVE_TYPEOF_ST64_SIZE==3 # elif HAVE_TYPEOF_ST64_SIZE==3
#define F_st64_size "%d" #define F_st64_size "%""d"
# elif HAVE_TYPEOF_ST64_SIZE==4 # elif HAVE_TYPEOF_ST64_SIZE==4
#define F_st64_size "%u" #define F_st64_size "%u"
# elif HAVE_TYPEOF_ST64_SIZE==5 # elif HAVE_TYPEOF_ST64_SIZE==5
@ -484,7 +484,7 @@
# elif HAVE_TYPEOF_ST_BLKSIZE==2 # elif HAVE_TYPEOF_ST_BLKSIZE==2
#define F_st_blksize "%hu" #define F_st_blksize "%hu"
# elif HAVE_TYPEOF_ST_BLKSIZE==3 # elif HAVE_TYPEOF_ST_BLKSIZE==3
#define F_st_blksize "%d" #define F_st_blksize "%""d"
# elif HAVE_TYPEOF_ST_BLKSIZE==4 # elif HAVE_TYPEOF_ST_BLKSIZE==4
#define F_st_blksize "%u" #define F_st_blksize "%u"
# elif HAVE_TYPEOF_ST_BLKSIZE==5 # elif HAVE_TYPEOF_ST_BLKSIZE==5
@ -511,7 +511,7 @@
# elif HAVE_TYPEOF_ST_BLOCKS==2 # elif HAVE_TYPEOF_ST_BLOCKS==2
#define F_st_blocks "%hu" #define F_st_blocks "%hu"
# elif HAVE_TYPEOF_ST_BLOCKS==3 # elif HAVE_TYPEOF_ST_BLOCKS==3
#define F_st_blocks "%d" #define F_st_blocks "%""d"
# elif HAVE_TYPEOF_ST_BLOCKS==4 # elif HAVE_TYPEOF_ST_BLOCKS==4
#define F_st_blocks "%u" #define F_st_blocks "%u"
# elif HAVE_TYPEOF_ST_BLOCKS==5 # elif HAVE_TYPEOF_ST_BLOCKS==5
@ -538,7 +538,7 @@
# elif HAVE_TYPEOF_ST64_BLOCKS==2 # elif HAVE_TYPEOF_ST64_BLOCKS==2
#define F_st64_blocks "%hu" #define F_st64_blocks "%hu"
# elif HAVE_TYPEOF_ST64_BLOCKS==3 # elif HAVE_TYPEOF_ST64_BLOCKS==3
#define F_st64_blocks "%d" #define F_st64_blocks "%""d"
# elif HAVE_TYPEOF_ST64_BLOCKS==4 # elif HAVE_TYPEOF_ST64_BLOCKS==4
#define F_st64_blocks "%u" #define F_st64_blocks "%u"
# elif HAVE_TYPEOF_ST64_BLOCKS==5 # elif HAVE_TYPEOF_ST64_BLOCKS==5
@ -612,6 +612,33 @@
# endif # endif
#endif #endif
/* default: socklen_t */
#if !defined(HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN) || !HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
# undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
# define HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN HAVE_BASIC_SOCKLEN_T
#endif
#ifndef F_cmsg_len
# if HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==1
#define F_cmsg_len "%""hd"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==2
#define F_cmsg_len "%""hu"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==3
#define F_cmsg_len "%""d"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==4
#define F_cmsg_len "%""u"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==5
#define F_cmsg_len "%""ld"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==6
#define F_cmsg_len "%""lu"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==7
#define F_cmsg_len "%""Ld"
# elif HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN==8
#define F_cmsg_len "%""Lu"
# else
#error "HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN is out of range:" HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
# endif
#endif
#define F_thread "%lu" #define F_thread "%lu"
/* Cygwin 1.3.22 has the prototypes, but not the type... */ /* Cygwin 1.3.22 has the prototypes, but not the type... */

View file

@ -495,6 +495,8 @@
#undef HAVE_TYPEOF_RLIM_MAX #undef HAVE_TYPEOF_RLIM_MAX
#undef HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN
/* Define if you have the /proc filesystem */ /* Define if you have the /proc filesystem */
#undef HAVE_PROC_DIR #undef HAVE_PROC_DIR

View file

@ -1710,6 +1710,8 @@ AC_TYPEOF_COMPONENT([#include <sys/types.h>
#include <sys/resource.h>], #include <sys/resource.h>],
struct rlimit, rlim_max, HAVE_TYPEOF_RLIM_MAX, sc_cv_type_rlimit_rlimmax_basic) struct rlimit, rlim_max, HAVE_TYPEOF_RLIM_MAX, sc_cv_type_rlimit_rlimmax_basic)
# Fedora-19 doc says it is socklen_t which is equivalent to unsigned int, but it is equivalent to size_t (x86_64)
AC_TYPEOF_COMPONENT([#include "sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len)
### snprintf, vsnprintf ### snprintf, vsnprintf

View file

@ -20,7 +20,7 @@ int procan_cdefs(FILE *outfile) {
fprintf(outfile, "#define FD_SETSIZE %u\n", FD_SETSIZE); fprintf(outfile, "#define FD_SETSIZE %u\n", FD_SETSIZE);
#endif #endif
#ifdef NFDBITS #ifdef NFDBITS
fprintf(outfile, "#define NFDBITS %d\n", NFDBITS); fprintf(outfile, "#define NFDBITS %d\n", (int)NFDBITS);
#endif #endif
#ifdef O_RDONLY #ifdef O_RDONLY
fprintf(outfile, "#define O_RDONLY %u\n", O_RDONLY); fprintf(outfile, "#define O_RDONLY %u\n", O_RDONLY);

20
sycls.c
View file

@ -938,12 +938,12 @@ int Socket(int domain, int type, int protocol) {
#endif /* _WITH_SOCKET */ #endif /* _WITH_SOCKET */
#if _WITH_SOCKET #if _WITH_SOCKET
int Bind(int sockfd, struct sockaddr *my_addr, int addrlen) { int Bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen) {
int result, _errno; int result, _errno;
char infobuff[256]; char infobuff[256];
sockaddr_info(my_addr, addrlen, infobuff, sizeof(infobuff)); sockaddr_info(my_addr, addrlen, infobuff, sizeof(infobuff));
Debug3("bind(%d, %s, "F_Zd")", sockfd, infobuff, addrlen); Debug3("bind(%d, %s, "F_socklen")", sockfd, infobuff, addrlen);
result = bind(sockfd, my_addr, addrlen); result = bind(sockfd, my_addr, addrlen);
_errno = errno; _errno = errno;
Debug1("bind() -> %d", result); Debug1("bind() -> %d", result);
@ -953,14 +953,14 @@ int Bind(int sockfd, struct sockaddr *my_addr, int addrlen) {
#endif /* _WITH_SOCKET */ #endif /* _WITH_SOCKET */
#if _WITH_SOCKET #if _WITH_SOCKET
int Connect(int sockfd, const struct sockaddr *serv_addr, int addrlen) { int Connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) {
int result, _errno; int result, _errno;
char infobuff[256]; char infobuff[256];
/*sockaddr_info(serv_addr, infobuff, sizeof(infobuff)); /*sockaddr_info(serv_addr, infobuff, sizeof(infobuff));
Debug3("connect(%d, %s, "F_Zd")", sockfd, infobuff, addrlen);*/ Debug3("connect(%d, %s, "F_Zd")", sockfd, infobuff, addrlen);*/
#if 0 #if 0
Debug18("connect(%d,{0x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x}, "F_Zd")", Debug18("connect(%d,{0x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x}, "F_socklen")",
sockfd, sockfd,
((unsigned char *)serv_addr)[0], ((unsigned char *)serv_addr)[1], ((unsigned char *)serv_addr)[0], ((unsigned char *)serv_addr)[1],
((unsigned char *)serv_addr)[2], ((unsigned char *)serv_addr)[3], ((unsigned char *)serv_addr)[2], ((unsigned char *)serv_addr)[3],
@ -1008,7 +1008,7 @@ int Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
if (result >= 0) { if (result >= 0) {
char infobuff[256]; char infobuff[256];
sockaddr_info(addr, *addrlen, infobuff, sizeof(infobuff)); sockaddr_info(addr, *addrlen, infobuff, sizeof(infobuff));
Info5("accept(%d, {%d, %s}, "F_Zd") -> %d", s, Info5("accept(%d, {%d, %s}, "F_socklen") -> %d", s,
addr->sa_family, addr->sa_family,
sockaddr_info(addr, *addrlen, infobuff, sizeof(infobuff)), sockaddr_info(addr, *addrlen, infobuff, sizeof(infobuff)),
*addrlen, result); *addrlen, result);
@ -1057,7 +1057,7 @@ int Getpeername(int s, struct sockaddr *name, socklen_t *namelen) {
#if _WITH_SOCKET #if _WITH_SOCKET
int Getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) { int Getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) {
int result, _errno; int result, _errno;
Debug5("getsockopt(%d, %d, %d, %p, {"F_Zd"})", Debug5("getsockopt(%d, %d, %d, %p, {"F_socklen"})",
s, level, optname, optval, *optlen); s, level, optname, optval, *optlen);
result = getsockopt(s, level, optname, optval, optlen); result = getsockopt(s, level, optname, optval, optlen);
_errno = errno; _errno = errno;
@ -1105,12 +1105,12 @@ int Recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from,
socklen_t *fromlen) { socklen_t *fromlen) {
int retval, _errno; int retval, _errno;
char infobuff[256]; char infobuff[256];
Debug6("recvfrom(%d, %p, "F_Zu", %d, %p, "F_Zu")", Debug6("recvfrom(%d, %p, "F_Zu", %d, %p, "F_socklen")",
s, buf, len, flags, from, *fromlen); s, buf, len, flags, from, *fromlen);
retval = recvfrom(s, buf, len, flags, from, fromlen); retval = recvfrom(s, buf, len, flags, from, fromlen);
_errno = errno; _errno = errno;
if (from) { if (from) {
Debug4("recvfrom(,,,, {%d,%s}, "F_Zd") -> %d", Debug4("recvfrom(,,,, {%d,%s}, "F_socklen") -> %d",
from->sa_family, from->sa_family,
sockaddr_info(from, *fromlen, infobuff, sizeof(infobuff)), sockaddr_info(from, *fromlen, infobuff, sizeof(infobuff)),
*fromlen, retval); *fromlen, retval);
@ -1138,7 +1138,7 @@ int Recvmsg(int s, struct msghdr *msgh, int flags) {
retval = recvmsg(s, msgh, flags); retval = recvmsg(s, msgh, flags);
_errno = errno; _errno = errno;
#if defined(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN) #if defined(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN)
Debug5("recvmsg(, {%s,%u,,%u,,%u,}, ) -> %d", Debug5("recvmsg(, {%s,%u,,"F_Zu",,"F_Zu",}, ) -> %d",
msgh->msg_name?sockaddr_info(msgh->msg_name, msgh->msg_namelen, infobuff, sizeof(infobuff)):"NULL", msgh->msg_name?sockaddr_info(msgh->msg_name, msgh->msg_namelen, infobuff, sizeof(infobuff)):"NULL",
msgh->msg_namelen, msgh->msg_iovlen, msgh->msg_controllen, msgh->msg_namelen, msgh->msg_iovlen, msgh->msg_controllen,
retval); retval);
@ -1259,7 +1259,7 @@ struct hostent *Gethostbyname(const char *name) {
int Getaddrinfo(const char *node, const char *service, int Getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res) { const struct addrinfo *hints, struct addrinfo **res) {
int result; int result;
Debug15("getaddrinfo(%s%s%s, %s%s%s, {%d,%d,%d,%d,"F_Zu",%p,%p,%p}, %p)", Debug15("getaddrinfo(%s%s%s, %s%s%s, {%d,%d,%d,%d,"F_socklen",%p,%p,%p}, %p)",
node?"\"":"", node?node:"NULL", node?"\"":"", node?"\"":"", node?node:"NULL", node?"\"":"",
service?"\"":"", service?service:"NULL", service?"\"":"", service?"\"":"", service?service:"NULL", service?"\"":"",
hints->ai_flags, hints->ai_family, hints->ai_socktype, hints->ai_flags, hints->ai_family, hints->ai_socktype,

View file

@ -96,8 +96,8 @@ int System(const char *string);
int Socketpair(int d, int type, int protocol, int sv[2]); int Socketpair(int d, int type, int protocol, int sv[2]);
#if _WITH_SOCKET #if _WITH_SOCKET
int Socket(int domain, int type, int protocol); int Socket(int domain, int type, int protocol);
int Bind(int sockfd, struct sockaddr *my_addr, int addrlen); int Bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
int Connect(int sockfd, const struct sockaddr *serv_addr, int addrlen); int Connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
int Listen(int s, int backlog); int Listen(int s, int backlog);
int Accept(int s, struct sockaddr *addr, socklen_t *addrlen); int Accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int Getsockname(int s, struct sockaddr *name, socklen_t *namelen); int Getsockname(int s, struct sockaddr *name, socklen_t *namelen);

14
test.sh
View file

@ -9851,7 +9851,7 @@ test_proto="$(echo "$KEYW" |tr A-Z a-z)"
NAME=${KEYW}LISTENENV NAME=${KEYW}LISTENENV
case "$TESTS" in case "$TESTS" in
*%$N%*|*%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%$test_proto%*|*%envvar%*|*%$NAME%*) *%$N%*|*%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%$test_proto%*|*%envvar%*|*%$NAME%*)
TEST="$NAME: $KEYW-LISTEN fills environment variables with socket addresses" TEST="$NAME: $KEYW-LISTEN sets environment variables with socket addresses"
# have a server accepting a connection and invoking some shell code. The shell # have a server accepting a connection and invoking some shell code. The shell
# code extracts and prints the SOCAT related environment vars. # code extracts and prints the SOCAT related environment vars.
# outside code then checks if the environment contains the variables correctly # outside code then checks if the environment contains the variables correctly
@ -9919,6 +9919,8 @@ else
cat "${te}0" cat "${te}0"
echo "$CMD1" echo "$CMD1"
cat "${te}1" cat "${te}1"
echo -e "SOCAT_SOCKADDR=$TEST_SOCKADDR\nSOCAT_PEERADDR=$TEST_PEERADDR\nSOCAT_SOCKPORT=$TEST_SOCKPORT\nSOCAT_PEERPORT=$TEST_PEERPORT" |
diff - "${tf}"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
fi fi
@ -11638,6 +11640,7 @@ else
cat "${te}0" cat "${te}0"
cat "${te}1" cat "${te}1"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
fi fi
fi # NUMCOND fi # NUMCOND
;; ;;
@ -11650,7 +11653,7 @@ N=$((N+1))
# Linux) with "Invalid argument". # Linux) with "Invalid argument".
NAME=OPENSSL_CONNECT_BIND NAME=OPENSSL_CONNECT_BIND
case "$TESTS" in case "$TESTS" in
*%functions%*|*%bugs%*|*%socket%*|*%ssl%*|*%$NAME%*) *%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%ssl%*|*%$NAME%*)
TEST="$NAME: test OPENSSL-CONNECT with bind option" TEST="$NAME: test OPENSSL-CONNECT with bind option"
# have a simple SSL server that just echoes data. # have a simple SSL server that just echoes data.
# connect with socat using OPENSSL-CONNECT with bind, send data and check if the # connect with socat using OPENSSL-CONNECT with bind, send data and check if the
@ -11678,6 +11681,7 @@ if [ "$rc1" -ne 0 ]; then
cat "$te0" cat "$te0"
cat "$te1" cat "$te1"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
elif ! echo "$da" |diff - $tf1 >"$tdiff"; then elif ! echo "$da" |diff - $tf1 >"$tdiff"; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED\n"
echo "$CMD0 &" echo "$CMD0 &"
@ -11686,6 +11690,7 @@ elif ! echo "$da" |diff - $tf1 >"$tdiff"; then
cat "${te}1" cat "${te}1"
cat "$tdiff" cat "$tdiff"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
else else
$PRINTF "$OK\n" $PRINTF "$OK\n"
numOK=$((numOK+1)) numOK=$((numOK+1))
@ -11701,7 +11706,7 @@ N=$((N+1))
# had a bug that converted a bit mask of 0 internally to 0xffffffff # had a bug that converted a bit mask of 0 internally to 0xffffffff
NAME=TCP4RANGE_0BITS NAME=TCP4RANGE_0BITS
case "$TESTS" in case "$TESTS" in
*%functions%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%range%*|*%$NAME%*) *%$N%*|*%functions%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%range%*|*%$NAME%*)
TEST="$NAME: correct evaluation of range mask 0" TEST="$NAME: correct evaluation of range mask 0"
if ! eval $NUMCOND; then :; if ! eval $NUMCOND; then :;
elif [ -z "$SECONDADDR" ]; then elif [ -z "$SECONDADDR" ]; then
@ -11732,6 +11737,7 @@ elif ! [ -f "$tf" ]; then
cat "${te}0" cat "${te}0"
cat "${te}1" cat "${te}1"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
$PRINTF "${YELLOW}diff failed${NORMAL}\n" $PRINTF "${YELLOW}diff failed${NORMAL}\n"
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
@ -12171,7 +12177,7 @@ esac
N=$((N+1)) N=$((N+1))
echo "summary: $((N-1)) tests, $((numOK+numFAILD+numCANT)) selected; $numOK ok, $numFAIL failed, $numCANT could not be performed" echo "summary: $((N-1)) tests, $((numOK+numFAILED+numCANT)) selected; $numOK ok, $numFAIL failed, $numCANT could not be performed"
if [ "$numFAIL" -gt 0 ]; then if [ "$numFAIL" -gt 0 ]; then
echo "FAILED: $listFAIL" echo "FAILED: $listFAIL"

View file

@ -153,7 +153,7 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
applyopts(xfd->rfd, opts, PH_PREBIND); applyopts(xfd->rfd, opts, PH_PREBIND);
applyopts(xfd->rfd, opts, PH_BIND); applyopts(xfd->rfd, opts, PH_BIND);
if (Bind(xfd->rfd, (struct sockaddr *)us, uslen) < 0) { if (Bind(xfd->rfd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", xfd->rfd, Msg4(level, "bind(%d, {%s}, "F_socklen"): %s", xfd->rfd,
sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), uslen, sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), uslen,
strerror(errno)); strerror(errno));
Close(xfd->rfd); Close(xfd->rfd);
@ -237,18 +237,18 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
Notice1("listening on %s", sockaddr_info(us, uslen, lisname, sizeof(lisname))); Notice1("listening on %s", sockaddr_info(us, uslen, lisname, sizeof(lisname)));
ps = Accept(xfd->rfd, (struct sockaddr *)&sa, &salen); ps = Accept(xfd->rfd, (struct sockaddr *)&sa, &salen);
if (ps >= 0) { if (ps >= 0) {
/*0 Info4("accept(%d, %p, {"F_Zu"}) -> %d", xfd->fd1, &sa, salen, ps);*/ /*0 Info4("accept(%d, %p, {"F_socklen"}) -> %d", xfd->fd1, &sa, salen, ps);*/
break; /* success, break out of loop */ break; /* success, break out of loop */
} }
if (errno == EINTR) { if (errno == EINTR) {
continue; continue;
} }
if (errno == ECONNABORTED) { if (errno == ECONNABORTED) {
Notice4("accept(%d, %p, {"F_Zu"}): %s", Notice4("accept(%d, %p, {"F_socklen"}): %s",
xfd->rfd, &sa, salen, strerror(errno)); xfd->rfd, &sa, salen, strerror(errno));
continue; continue;
} }
Msg4(level, "accept(%d, %p, {"F_Zu"}): %s", Msg4(level, "accept(%d, %p, {"F_socklen"}): %s",
xfd->rfd, &sa, salen, strerror(errno)); xfd->rfd, &sa, salen, strerror(errno));
Close(xfd->rfd); Close(xfd->rfd);
return STAT_RETRYLATER; return STAT_RETRYLATER;

View file

@ -40,7 +40,7 @@ int _xioopen_setdelayeduser(void) {
if (delayeduser) { if (delayeduser) {
#if HAVE_SETGROUPS #if HAVE_SETGROUPS
if ((Setgroups(delayeduser_ngids, delayeduser_gids)) != 0) { if ((Setgroups(delayeduser_ngids, delayeduser_gids)) != 0) {
Error3("setgroups("F_Zu", %p): %s", Error3("setgroups(%d, %p): %s",
delayeduser_ngids, delayeduser_gids, strerror(errno)); delayeduser_ngids, delayeduser_gids, strerror(errno));
} }
#endif /* HAVE_SETGROUPS */ #endif /* HAVE_SETGROUPS */

View file

@ -625,7 +625,7 @@ int _xioopen_proxy_connect(struct single *xfd,
} }
if (offset >= BUFLEN) { if (offset >= BUFLEN) {
Msg1(level, "proxy answer exceeds "F_Zu" bytes, aborting", BUFLEN); Msg1(level, "proxy answer exceeds %d bytes, aborting", BUFLEN);
return STAT_NORETRY; return STAT_NORETRY;
} }

View file

@ -829,7 +829,7 @@ int _xioopen_connect(struct single *xfd, struct sockaddr *us, size_t uslen,
*port = htons(i); *port = htons(i);
if (Bind(xfd->rfd, (struct sockaddr *)sinp, sizeof(*sinp)) < 0) { if (Bind(xfd->rfd, (struct sockaddr *)sinp, sizeof(*sinp)) < 0) {
Msg4(errno==EADDRINUSE?E_INFO:level, Msg4(errno==EADDRINUSE?E_INFO:level,
"bind(%d, {%s}, "F_Zd"): %s", xfd->rfd, "bind(%d, {%s}, "F_socklen"): %s", xfd->rfd,
sockaddr_info(&sinp->soa, sizeof(*sinp), infobuff, sizeof(infobuff)), sockaddr_info(&sinp->soa, sizeof(*sinp), infobuff, sizeof(infobuff)),
sizeof(*sinp), strerror(errno)); sizeof(*sinp), strerror(errno));
if (errno != EADDRINUSE) { if (errno != EADDRINUSE) {
@ -852,7 +852,7 @@ int _xioopen_connect(struct single *xfd, struct sockaddr *us, size_t uslen,
if (us) { if (us) {
if (Bind(xfd->rfd, us, uslen) < 0) { if (Bind(xfd->rfd, us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", Msg4(level, "bind(%d, {%s}, "F_socklen"): %s",
xfd->rfd, sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), xfd->rfd, sockaddr_info(us, uslen, infobuff, sizeof(infobuff)),
uslen, strerror(errno)); uslen, strerror(errno));
Close(xfd->rfd); Close(xfd->rfd);
@ -1100,7 +1100,7 @@ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
if (us) { if (us) {
if (Bind(xfd->rfd, (struct sockaddr *)us, uslen) < 0) { if (Bind(xfd->rfd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", Msg4(level, "bind(%d, {%s}, "F_socklen"): %s",
xfd->rfd, sockaddr_info((struct sockaddr *)us, uslen, infobuff, sizeof(infobuff)), xfd->rfd, sockaddr_info((struct sockaddr *)us, uslen, infobuff, sizeof(infobuff)),
uslen, strerror(errno)); uslen, strerror(errno));
Close(xfd->rfd); Close(xfd->rfd);
@ -1680,7 +1680,7 @@ int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv) {
xiodump(CMSG_DATA(cmsg), xiodump(CMSG_DATA(cmsg),
cmsg->cmsg_len-((char *)CMSG_DATA(cmsg)-(char *)cmsg), cmsg->cmsg_len-((char *)CMSG_DATA(cmsg)-(char *)cmsg),
valbuff, sizeof(valbuff)-1, 0); valbuff, sizeof(valbuff)-1, 0);
Debug4("ancillary message: len="F_socklen", level=%d, type=%d, data=%s", Debug4("ancillary message: len="F_cmsg_len", level=%d, type=%d, data=%s",
cmsg->cmsg_len, cmsg->cmsg_level, cmsg->cmsg_type, cmsg->cmsg_len, cmsg->cmsg_level, cmsg->cmsg_type,
valbuff); valbuff);
} }

View file

@ -422,7 +422,7 @@ int _xioopen_socks4_connect(struct single *xfd,
char msgbuff[3*SIZEOF_STRUCT_SOCKS4]; char msgbuff[3*SIZEOF_STRUCT_SOCKS4];
* xiohexdump((const unsigned char *)replyhead+bytes, result, msgbuff) * xiohexdump((const unsigned char *)replyhead+bytes, result, msgbuff)
= '\0'; = '\0';
Debug2("received socks4 reply data (offset %u): %s", bytes, msgbuff); Debug2("received socks4 reply data (offset "F_Zd"): %s", bytes, msgbuff);
} }
#endif /* WITH_MSGLEVEL <= E_DEBUG */ #endif /* WITH_MSGLEVEL <= E_DEBUG */
bytes += result; bytes += result;
@ -430,7 +430,7 @@ int _xioopen_socks4_connect(struct single *xfd,
Debug1("received all "F_Zd" bytes", bytes); Debug1("received all "F_Zd" bytes", bytes);
break; break;
} }
Debug2("received "F_Zd" bytes, waiting for "F_Zu" more bytes", Debug2("received %d bytes, waiting for "F_Zu" more bytes",
result, SIZEOF_STRUCT_SOCKS4-bytes); result, SIZEOF_STRUCT_SOCKS4-bytes);
} }
if (result <= 0) { /* we had a problem while reading socks answer */ if (result <= 0) { /* we had a problem while reading socks answer */

View file

@ -214,7 +214,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
applyopts(fd->stream.rfd, opts, PH_PREBIND); applyopts(fd->stream.rfd, opts, PH_PREBIND);
applyopts(fd->stream.rfd, opts, PH_BIND); applyopts(fd->stream.rfd, opts, PH_BIND);
if (Bind(fd->stream.rfd, &us.soa, uslen) < 0) { if (Bind(fd->stream.rfd, &us.soa, uslen) < 0) {
Error4("bind(%d, {%s}, "F_Zd"): %s", fd->stream.rfd, Error4("bind(%d, {%s}, "F_socklen"): %s", fd->stream.rfd,
sockaddr_info(&us.soa, uslen, infobuff, sizeof(infobuff)), sockaddr_info(&us.soa, uslen, infobuff, sizeof(infobuff)),
uslen, strerror(errno)); uslen, strerror(errno));
return STAT_RETRYLATER; return STAT_RETRYLATER;
@ -240,7 +240,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
&them->soa, &themlen); &them->soa, &themlen);
} while (result < 0 && errno == EINTR); } while (result < 0 && errno == EINTR);
if (result < 0) { if (result < 0) {
Error5("recvfrom(%d, %p, 1, MSG_PEEK, {%s}, {"F_Zu"}): %s", Error5("recvfrom(%d, %p, 1, MSG_PEEK, {%s}, {"F_socklen"}): %s",
fd->stream.rfd, buff1, fd->stream.rfd, buff1,
sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)), sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)),
themlen, strerror(errno)); themlen, strerror(errno));
@ -283,7 +283,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
applyopts(fd->stream.rfd, opts, PH_CONNECT); applyopts(fd->stream.rfd, opts, PH_CONNECT);
if ((result = Connect(fd->stream.rfd, &them->soa, themlen)) < 0) { if ((result = Connect(fd->stream.rfd, &them->soa, themlen)) < 0) {
Error4("connect(%d, {%s}, "F_Zd"): %s", Error4("connect(%d, {%s}, "F_socklen"): %s",
fd->stream.rfd, fd->stream.rfd,
sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)), sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)),
themlen, strerror(errno)); themlen, strerror(errno));

View file

@ -733,7 +733,9 @@ const struct optname optionnames[] = {
#endif #endif
IF_IP ("iptos", &opt_ip_tos) IF_IP ("iptos", &opt_ip_tos)
IF_IP ("ipttl", &opt_ip_ttl) IF_IP ("ipttl", &opt_ip_ttl)
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("ipv6-add-membership", &opt_ipv6_join_group) IF_IP6 ("ipv6-add-membership", &opt_ipv6_join_group)
#endif
#ifdef IPV6_AUTHHDR #ifdef IPV6_AUTHHDR
IF_IP6 ("ipv6-authhdr", &opt_ipv6_authhdr) IF_IP6 ("ipv6-authhdr", &opt_ipv6_authhdr)
#endif #endif
@ -749,7 +751,9 @@ const struct optname optionnames[] = {
#ifdef IPV6_HOPOPTS #ifdef IPV6_HOPOPTS
IF_IP6 ("ipv6-hopopts", &opt_ipv6_hopopts) IF_IP6 ("ipv6-hopopts", &opt_ipv6_hopopts)
#endif #endif
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("ipv6-join-group", &opt_ipv6_join_group) IF_IP6 ("ipv6-join-group", &opt_ipv6_join_group)
#endif
#ifdef IPV6_PKTINFO #ifdef IPV6_PKTINFO
IF_IP6 ("ipv6-pktinfo", &opt_ipv6_pktinfo) IF_IP6 ("ipv6-pktinfo", &opt_ipv6_pktinfo)
#endif #endif
@ -799,7 +803,9 @@ const struct optname optionnames[] = {
IF_TERMIOS("ixany", &opt_ixany) IF_TERMIOS("ixany", &opt_ixany)
IF_TERMIOS("ixoff", &opt_ixoff) IF_TERMIOS("ixoff", &opt_ixoff)
IF_TERMIOS("ixon", &opt_ixon) IF_TERMIOS("ixon", &opt_ixon)
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("join-group", &opt_ipv6_join_group) IF_IP6 ("join-group", &opt_ipv6_join_group)
#endif
#if WITH_EXT2 && defined(EXT2_JOURNAL_DATA_FL) #if WITH_EXT2 && defined(EXT2_JOURNAL_DATA_FL)
IF_ANY ("journal", &opt_ext2_journal_data) IF_ANY ("journal", &opt_ext2_journal_data)
IF_ANY ("journal-data", &opt_ext2_journal_data) IF_ANY ("journal-data", &opt_ext2_journal_data)
@ -3039,7 +3045,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
if (Setsockopt(fd, opt->desc->major, opt->desc->minor, if (Setsockopt(fd, opt->desc->major, opt->desc->minor,
opt->value.u_bin.b_data, opt->value.u_bin.b_len) opt->value.u_bin.b_data, opt->value.u_bin.b_len)
< 0) { < 0) {
Error6("setsockopt(%d, %d, %d, %p, %d): %s", Error6("setsockopt(%d, %d, %d, %p, "F_Zu"): %s",
fd, opt->desc->major, opt->desc->minor, fd, opt->desc->major, opt->desc->minor,
opt->value.u_bin.b_data, opt->value.u_bin.b_len, opt->value.u_bin.b_data, opt->value.u_bin.b_len,
strerror(errno)); strerror(errno));
@ -3171,7 +3177,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
if (Getsockopt(fd, opt->desc->major, opt->desc->minor, if (Getsockopt(fd, opt->desc->major, opt->desc->minor,
data, &oldlen) data, &oldlen)
< 0) { < 0) {
Error6("getsockopt(%d, %d, %d, %p, {"F_Zu"}): %s", Error6("getsockopt(%d, %d, %d, %p, {"F_socklen"}): %s",
fd, opt->desc->major, opt->desc->minor, data, oldlen, fd, opt->desc->major, opt->desc->minor, data, oldlen,
strerror(errno)); strerror(errno));
opt->desc = ODESC_ERROR; ++opt; continue; opt->desc = ODESC_ERROR; ++opt; continue;

View file

@ -1,5 +1,5 @@
/* source: xiosigchld.c */ /* source: xiosigchld.c */
/* Copyright Gerhard Rieger 2001-2012 */ /* Copyright Gerhard Rieger */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this is the source of the extended child signal handler */ /* this is the source of the extended child signal handler */
@ -139,7 +139,7 @@ void childdied(int signum
nextunknown = 0; nextunknown = 0;
} }
diedunknown[nextunknown++] = pid; diedunknown[nextunknown++] = pid;
Debug1("saving pid in diedunknown%u", Debug1("saving pid in diedunknown"F_Zu,
nextunknown/*sic, for compatibility*/); nextunknown/*sic, for compatibility*/);
} }
#else #else