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

This commit is contained in:
Gerhard Rieger 2014-03-09 22:08:19 +01:00
parent 93cfe88290
commit 80c7fa0bca
18 changed files with 141 additions and 66 deletions

View file

@ -84,6 +84,9 @@ porting:
autoconf now prefers configure.ac over configure.in
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
docu:
libwrap always logs to syslog

View file

@ -99,7 +99,7 @@
# define SIZET_MAX UINT_MAX
# define SSIZET_MIN INT_MIN
# define SSIZET_MAX INT_MAX
# define F_Zd "%d"
# define F_Zd "%""d"
# define F_Zu "%u"
#elif HAVE_BASIC_SIZE_T==6
# define SIZET_MAX ULONG_MAX
@ -153,7 +153,7 @@
# elif HAVE_BASIC_PID_T==2
#define F_pid "%hu"
# elif HAVE_BASIC_PID_T==3
#define F_pid "%d"
#define F_pid "%""d"
# elif HAVE_BASIC_PID_T==4
#define F_pid "%u"
# elif HAVE_BASIC_PID_T==5
@ -177,7 +177,7 @@
# elif HAVE_BASIC_UID_T==2
#define F_uid "%hu"
# elif HAVE_BASIC_UID_T==3
#define F_uid "%d"
#define F_uid "%""d"
# elif HAVE_BASIC_UID_T==4
#define F_uid "%u"
# elif HAVE_BASIC_UID_T==5
@ -201,7 +201,7 @@
# elif HAVE_BASIC_GID_T==2
#define F_gid "%hu"
# elif HAVE_BASIC_GID_T==3
#define F_gid "%d"
#define F_gid "%""d"
# elif HAVE_BASIC_GID_T==4
#define F_gid "%u"
# elif HAVE_BASIC_GID_T==5
@ -225,7 +225,7 @@
# elif HAVE_BASIC_TIME_T==2
#define F_time "%hu"
# elif HAVE_BASIC_TIME_T==3
#define F_time "%d"
#define F_time "%""d"
# elif HAVE_BASIC_TIME_T==4
#define F_time "%u"
# elif HAVE_BASIC_TIME_T==5
@ -253,7 +253,7 @@
# elif HAVE_BASIC_SOCKLEN_T==2
#define F_socklen "%hu"
# elif HAVE_BASIC_SOCKLEN_T==3
#define F_socklen "%d"
#define F_socklen "%""d"
# elif HAVE_BASIC_SOCKLEN_T==4
#define F_socklen "%u"
# elif HAVE_BASIC_SOCKLEN_T==5
@ -275,7 +275,7 @@
#endif
#ifndef F_off
# if HAVE_BASIC_OFF_T==3
# define F_off "%d"
# define F_off "%""d"
# elif HAVE_BASIC_OFF_T==5
# define F_off "%ld"
# elif HAVE_BASIC_OFF_T==7
@ -296,7 +296,7 @@
# elif HAVE_BASIC_OFF64_T==2
#define F_off64 "%hu"
# elif HAVE_BASIC_OFF64_T==3
#define F_off64 "%d"
#define F_off64 "%""d"
# elif HAVE_BASIC_OFF64_T==4
#define F_off64 "%u"
# elif HAVE_BASIC_OFF64_T==5
@ -324,7 +324,7 @@
# elif HAVE_BASIC_DEV_T==2
#define F_dev "%hu"
# elif HAVE_BASIC_DEV_T==3
#define F_dev "%d"
#define F_dev "%""d"
# elif HAVE_BASIC_DEV_T==4
#define F_dev "%u"
# elif HAVE_BASIC_DEV_T==5
@ -351,7 +351,7 @@
# elif HAVE_TYPEOF_ST_INO==2
#define F_st_ino "%hu"
# elif HAVE_TYPEOF_ST_INO==3
#define F_st_ino "%d"
#define F_st_ino "%""d"
# elif HAVE_TYPEOF_ST_INO==4
#define F_st_ino "%u"
# elif HAVE_TYPEOF_ST_INO==5
@ -378,7 +378,7 @@
# elif HAVE_TYPEOF_ST64_INO==2
#define F_st64_ino "%hu"
# elif HAVE_TYPEOF_ST64_INO==3
#define F_st64_ino "%d"
#define F_st64_ino "%""d"
# elif HAVE_TYPEOF_ST64_INO==4
#define F_st64_ino "%u"
# elif HAVE_TYPEOF_ST64_INO==5
@ -405,7 +405,7 @@
# elif HAVE_TYPEOF_ST_NLINK==2
#define F_st_nlink "%hu"
# elif HAVE_TYPEOF_ST_NLINK==3
#define F_st_nlink "%d"
#define F_st_nlink "%""d"
# elif HAVE_TYPEOF_ST_NLINK==4
#define F_st_nlink "%u"
# elif HAVE_TYPEOF_ST_NLINK==5
@ -432,7 +432,7 @@
# elif HAVE_TYPEOF_ST_SIZE==2
#define F_st_size "%hu"
# elif HAVE_TYPEOF_ST_SIZE==3
#define F_st_size "%d"
#define F_st_size "%""d"
# elif HAVE_TYPEOF_ST_SIZE==4
#define F_st_size "%u"
# elif HAVE_TYPEOF_ST_SIZE==5
@ -459,7 +459,7 @@
# elif HAVE_TYPEOF_ST64_SIZE==2
#define F_st64_size "%hu"
# elif HAVE_TYPEOF_ST64_SIZE==3
#define F_st64_size "%d"
#define F_st64_size "%""d"
# elif HAVE_TYPEOF_ST64_SIZE==4
#define F_st64_size "%u"
# elif HAVE_TYPEOF_ST64_SIZE==5
@ -486,7 +486,7 @@
# elif HAVE_TYPEOF_ST_BLKSIZE==2
#define F_st_blksize "%hu"
# elif HAVE_TYPEOF_ST_BLKSIZE==3
#define F_st_blksize "%d"
#define F_st_blksize "%""d"
# elif HAVE_TYPEOF_ST_BLKSIZE==4
#define F_st_blksize "%u"
# elif HAVE_TYPEOF_ST_BLKSIZE==5
@ -513,7 +513,7 @@
# elif HAVE_TYPEOF_ST_BLOCKS==2
#define F_st_blocks "%hu"
# elif HAVE_TYPEOF_ST_BLOCKS==3
#define F_st_blocks "%d"
#define F_st_blocks "%""d"
# elif HAVE_TYPEOF_ST_BLOCKS==4
#define F_st_blocks "%u"
# elif HAVE_TYPEOF_ST_BLOCKS==5
@ -540,7 +540,7 @@
# elif HAVE_TYPEOF_ST64_BLOCKS==2
#define F_st64_blocks "%hu"
# elif HAVE_TYPEOF_ST64_BLOCKS==3
#define F_st64_blocks "%d"
#define F_st64_blocks "%""d"
# elif HAVE_TYPEOF_ST64_BLOCKS==4
#define F_st64_blocks "%u"
# elif HAVE_TYPEOF_ST64_BLOCKS==5
@ -614,6 +614,33 @@
# 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
/* Cygwin 1.3.22 has the prototypes, but not the type... */
#ifndef HAVE_TYPE_STAT64
# undef HAVE_STAT64

View file

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

1
configure.ac Symbolic link
View file

@ -0,0 +1 @@
configure.in

View file

@ -1694,6 +1694,8 @@ AC_TYPEOF_COMPONENT([#include <sys/types.h>
#include <sys/resource.h>],
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

View file

@ -10,7 +10,7 @@ def(Filan)(0)(bf(Filan))
def(procan)(0)(bf(procan))
def(Procan)(0)(bf(Procan))
manpage(socat)(1)(Dec 2011)()()
manpage(socat)(1)(Mar 2014)()()
whenhtml(
label(CONTENTS)

View file

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

22
sycls.c
View file

@ -898,12 +898,12 @@ int Socket(int domain, int type, int protocol) {
#endif /* _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;
char infobuff[256];
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);
_errno = errno;
Debug1("bind() -> %d", result);
@ -913,7 +913,7 @@ int Bind(int sockfd, struct sockaddr *my_addr, int addrlen) {
#endif /* _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;
char infobuff[256];
@ -932,7 +932,7 @@ int Connect(int sockfd, const struct sockaddr *serv_addr, int addrlen) {
((unsigned char *)serv_addr)[14], ((unsigned char *)serv_addr)[15],
addrlen);
#else
Debug4("connect(%d, {%d,%s}, "F_Zd")",
Debug4("connect(%d, {%d,%s}, "F_socklen")",
sockfd, serv_addr->sa_family,
sockaddr_info(serv_addr, addrlen, infobuff, sizeof(infobuff)),
addrlen);
@ -968,7 +968,7 @@ int Accept(int s, struct sockaddr *addr, socklen_t *addrlen) {
if (result >= 0) {
char infobuff[256];
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,
sockaddr_info(addr, *addrlen, infobuff, sizeof(infobuff)),
*addrlen, result);
@ -1017,7 +1017,7 @@ int Getpeername(int s, struct sockaddr *name, socklen_t *namelen) {
#if _WITH_SOCKET
int Getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) {
int result, _errno;
Debug5("getsockopt(%d, %d, %d, %p, {"F_Zd"})",
Debug5("getsockopt(%d, %d, %d, %p, {"F_socklen"})",
s, level, optname, optval, *optlen);
result = getsockopt(s, level, optname, optval, optlen);
_errno = errno;
@ -1065,12 +1065,12 @@ int Recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from,
socklen_t *fromlen) {
int retval, _errno;
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);
retval = recvfrom(s, buf, len, flags, from, fromlen);
_errno = errno;
if (from) {
Debug4("recvfrom(,,,, {%d,%s}, "F_Zd") -> %d",
Debug4("recvfrom(,,,, {%d,%s}, "F_socklen") -> %d",
from->sa_family,
sockaddr_info(from, *fromlen, infobuff, sizeof(infobuff)),
*fromlen, retval);
@ -1087,7 +1087,7 @@ int Recvmsg(int s, struct msghdr *msgh, int flags) {
int retval, _errno;
char infobuff[256];
#if defined(HAVE_STRUCT_MSGHDR_MSGCONTROL) && defined(HAVE_STRUCT_MSGHDR_MSGCONTROLLEN) && defined(HAVE_STRUCT_MSGHDR_MSGFLAGS)
Debug10("recvmsg(%d, %p{%p,%u,%p,%u,%p,%u,%d}, %d)", s, msgh,
Debug10("recvmsg(%d, %p{%p,%u,%p,"F_Zu",%p,"F_Zu",%d}, %d)", s, msgh,
msgh->msg_name, msgh->msg_namelen, msgh->msg_iov, msgh->msg_iovlen,
msgh->msg_control, msgh->msg_controllen, msgh->msg_flags, flags);
#else
@ -1098,7 +1098,7 @@ int Recvmsg(int s, struct msghdr *msgh, int flags) {
retval = recvmsg(s, msgh, flags);
_errno = errno;
#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_namelen, msgh->msg_iovlen, msgh->msg_controllen,
retval);
@ -1219,7 +1219,7 @@ struct hostent *Gethostbyname(const char *name) {
int Getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints, struct addrinfo **res) {
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?"\"":"",
service?"\"":"", service?service:"NULL", service?"\"":"",
hints->ai_flags, hints->ai_family, hints->ai_socktype,

View file

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

62
test.sh
View file

@ -153,6 +153,27 @@ DragonFly) IFCONFIG=/sbin/ifconfig ;;
*) IFCONFIG=/sbin/ifconfig ;;
esac
# need output like "644"
case "$UNAME" in
Linux) fileperms() { stat -L --print "%a\n" "$1" 2>/dev/null; } ;;
FreeBSD) fileperms() { stat -L -x "$1" |grep ' Mode:' |sed 's/.* Mode:[[:space:]]*([0-9]\([0-7][0-7][0-7]\).*/\1/'; } ;;
*) fileperms() {
local p s=0 c
p="$(ls -l -L "$1" |awk '{print($1);}')"
p="${p:1:9}"
while [ "$p" ]; do c=${p:0:1}; p=${p:1}; [ "x$c" == x- ]; let "s=2*s+$?"; done
printf "%03o\n" $s;
} ;;
esac
# need user (owner) of filesystem entry
case "$UNAME" in
Linux) fileuser() { stat -L --print "%U\n" "$tsock" 2>/dev/null; } ;;
FreeBSD) fileuser() { ls -l test.sh |awk '{print($3);}'; } ;;
*) fileuser() { ls -l test.sh |awk '{print($3);}'; } ;;
esac
# for some tests we need a second local IPv4 address
case "$UNAME" in
Linux)
@ -9633,7 +9654,7 @@ test_proto="$(echo "$KEYW" |tr A-Z a-z)"
NAME=${KEYW}LISTENENV
case "$TESTS" in
*%$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
# code extracts and prints the SOCAT related environment vars.
# outside code then checks if the environment contains the variables correctly
@ -9706,6 +9727,8 @@ else
cat "${te}0"
echo "$CMD1"
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))
listFAIL="$listFAIL $N"
fi
@ -11155,7 +11178,7 @@ fi # false
# and TCP options only to the listening socket instead of the connection socket.
NAME=LISTEN_KEEPALIVE
case "$TESTS" in
*%functions%*|*%bugs%*|*%listen%*|*%keepalive%*|*%socket%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%listen%*|*%keepalive%*|*%socket%*|*%$NAME%*)
TEST="$NAME: keepalive option is applied to connection socket"
# instance 0 has TCP-LISTEN with option so-keepalive and invokes filan after
# accept(). filan writes its output to the socket. instance 1 connects to
@ -11193,6 +11216,7 @@ else
cat "${te}0"
cat "${te}1"
numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
fi
fi # NUMCOND
;;
@ -11205,7 +11229,7 @@ N=$((N+1))
# Linux) with "Invalid argument".
NAME=OPENSSL_CONNECT_BIND
case "$TESTS" in
*%functions%*|*%bugs%*|*%socket%*|*%ssl%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%ssl%*|*%$NAME%*)
TEST="$NAME: test OPENSSL-CONNECT with bind option"
# have a simple SSL server that just echoes data.
# connect with socat using OPENSSL-CONNECT with bind, send data and check if the
@ -11233,6 +11257,7 @@ if [ "$rc1" -ne 0 ]; then
cat "$te0"
cat "$te1"
numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
elif ! echo "$da" |diff - $tf1 >"$tdiff"; then
$PRINTF "$FAILED\n"
echo "$CMD0 &"
@ -11241,6 +11266,7 @@ elif ! echo "$da" |diff - $tf1 >"$tdiff"; then
cat "${te}1"
cat "$tdiff"
numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
else
$PRINTF "$OK\n"
numOK=$((numOK+1))
@ -11256,7 +11282,7 @@ N=$((N+1))
# had a bug that converted a bit mask of 0 internally to 0xffffffff
NAME=TCP4RANGE_0BITS
case "$TESTS" in
*%functions%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%range%*|*%$NAME%*)
*%$N%*|*%functions%*|*%tcp%*|*%tcp4%*|*%ip4%*|*%range%*|*%$NAME%*)
TEST="$NAME: correct evaluation of range mask 0"
if ! eval $NUMCOND; then :;
elif [ -z "$SECONDADDR" ]; then
@ -11287,6 +11313,7 @@ elif ! [ -f "$tf" ]; then
cat "${te}0"
cat "${te}1"
numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
$PRINTF "${YELLOW}diff failed${NORMAL}\n"
numCANT=$((numCANT+1))
@ -11315,7 +11342,7 @@ if [ "$fileopt" = "." ]; then fileopt=; fi
if [ "$addropts" = "." ]; then addropts=; fi
NAME=${ADDR_}_UMASK
case "$TESTS" in
*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%$NAME%*)
TEST="$NAME: $ADDR applies option umask"
# start a socat process with passive/listening file system entry. Check the
# permissions of the FS entry, then terminate the process.
@ -11335,7 +11362,7 @@ $CMD0 >/dev/null 2>"$te0" &
pid0=$!
wait${proto} $tsock 1 2>"$tlog"
ERRNOENT=; if ! [ -e "$tsock" ]; then ERRNOENT=1; fi
perms=$(stat -L --print "%a\n" "$tsock" 2>/dev/null)
perms=$(fileperms "$tsock")
kill $pid0 2>>"$tlog"
wait
if [ "$ERRNOENT" ]; then
@ -11344,11 +11371,13 @@ if [ "$ERRNOENT" ]; then
cat "$te0"
cat "$tlog"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
elif [ "$perms" != "600" ]; then
$PRINTF "${RED}perms \"$perms\", expected \"600\" ${NORMAL}\n"
echo "$CMD0 &"
cat "$te0"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
else
$PRINTF "$OK\n"
let numOK=numOK+1
@ -11386,7 +11415,7 @@ if [ "$fileopt" = "." ]; then fileopt=; fi
if [ "$addropts" = "." ]; then addropts=; fi
NAME=${ADDR_}_PERM
case "$TESTS" in
*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%$NAME%*)
TEST="$NAME: $ADDR applies option perm"
# start a socat process with passive/listening file system entry. Check the
# permissions of the FS entry, then terminate the process.
@ -11406,7 +11435,7 @@ $CMD0 >/dev/null 2>"$te0" &
pid0=$!
wait${proto} $tsock 1 2>"$tlog"
ERRNOENT=; if ! [ -e "$tsock" ]; then ERRNOENT=1; fi
perms=$(stat -L --print "%a\n" "$tsock" 2>/dev/null)
perms=$(fileperms "$tsock")
kill $pid0 2>>"$tlog"
wait
if [ "$ERRNOENT" ]; then
@ -11415,11 +11444,13 @@ if [ "$ERRNOENT" ]; then
cat "$te0"
cat "$tlog"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
elif [ "$perms" != "511" ]; then
$PRINTF "${RED}perms \"$perms\", expected \"511\" ${NORMAL}\n"
echo "$CMD0 &"
cat "$te0"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
else
$PRINTF "$OK\n"
let numOK=numOK+1
@ -11456,7 +11487,7 @@ if [ "$fileopt" = "." ]; then fileopt=; fi
if [ "$addropts" = "." ]; then addropts=; fi
NAME=${ADDR_}_USER
case "$TESTS" in
*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%root%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%root%*|*%$NAME%*)
TEST="$NAME: $ADDR applies option user"
# start a socat process with passive/listening file system entry with user option.
# Check the owner of the FS entry, then terminate the process.
@ -11480,7 +11511,7 @@ $CMD0 >/dev/null 2>"$te0" &
pid0=$!
wait${proto} $tsock 1 2>"$tlog"
ERRNOENT=; if ! [ -e "$tsock" ]; then ERRNOENT=1; fi
user=$(stat -L --print "%U\n" "$tsock" 2>/dev/null)
user=$(fileuser "$tsock")
kill $pid0 2>>"$tlog"
wait
if [ "$ERRNOENT" ]; then
@ -11489,11 +11520,13 @@ if [ "$ERRNOENT" ]; then
cat "$te0"
cat "$tlog"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
elif [ "$user" != "$SUBSTUSER" ]; then
$PRINTF "${RED}user \"$user\", expected \"$SUBSTUSER\" ${NORMAL}\n"
echo "$CMD0 &"
cat "$te0"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
else
$PRINTF "$OK\n"
let numOK=numOK+1
@ -11532,7 +11565,7 @@ if [ "$addropts" = "." ]; then addropts=; fi
# $ADDR removes the file system entry when the process is terminated
NAME=${ADDR_}_REMOVE
case "$TESTS" in
*%functions%*|*%bugs%*|*%unix%*|*%socket%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%unix%*|*%socket%*|*%$NAME%*)
TEST="$NAME: $ADDR removes socket entry when terminated during accept"
# start a socat process with listening unix domain socket etc. Terminate the
# process and check if the file system socket entry still exists.
@ -11568,6 +11601,7 @@ else
cat "$te0"
cat "$tlog"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
fi
fi # NUMCOND
;;
@ -11599,7 +11633,7 @@ if [ "$addropts" = "." ]; then addropts=; fi
# $ADDR with fork removes the file system entry when the process is terminated
NAME=${ADDR_}_REMOVE_FORK
case "$TESTS" in
*%functions%*|*%bugs%*|*%unix%*|*%socket%*|*%$NAME%*)
*%$N%*|*%functions%*|*%bugs%*|*%unix%*|*%socket%*|*%$NAME%*)
TEST="$NAME: $ADDR with fork removes socket entry when terminated during accept"
# start a socat process with listening unix domain socket etc and option fork.
# Terminate the process and check if the file system socket entry still exists.
@ -11635,6 +11669,7 @@ else
cat "$te0"
cat "$tlog"
let numFAIL=numFAIL+1
listFAIL="$listFAIL $N"
fi
fi # NUMCOND
;;
@ -11718,7 +11753,7 @@ esac
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+numFAIL+numCANT)) selected; $numOK ok, $numFAIL failed, $numCANT could not be performed"
if [ "$numFAIL" -gt 0 ]; then
echo "FAILED: $listFAIL"
@ -11773,6 +11808,7 @@ else
cat "${te}0"
cat "${te}1"
numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N"
fi
fi # NUMCOND
;;

View file

@ -152,7 +152,7 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
applyopts(xfd->fd, opts, PH_PREBIND);
applyopts(xfd->fd, opts, PH_BIND);
if (Bind(xfd->fd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", xfd->fd,
Msg4(level, "bind(%d, {%s}, "F_socklen"): %s", xfd->fd,
sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), uslen,
strerror(errno));
Close(xfd->fd);
@ -237,11 +237,11 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
continue;
}
if (errno == ECONNABORTED) {
Notice4("accept(%d, %p, {"F_Zu"}): %s",
Notice4("accept(%d, %p, {"F_socklen"}): %s",
xfd->fd, &sa, salen, strerror(errno));
continue;
}
Msg4(level, "accept(%d, %p, {"F_Zu"}): %s",
Msg4(level, "accept(%d, %p, {"F_socklen"}): %s",
xfd->fd, &sa, salen, strerror(errno));
Close(xfd->fd);
return STAT_RETRYLATER;

View file

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

View file

@ -552,7 +552,7 @@ int _xioopen_proxy_connect(struct single *xfd,
}
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;
}

View file

@ -1055,7 +1055,7 @@ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
if (us) {
if (Bind(xfd->fd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s",
Msg4(level, "bind(%d, {%s}, "F_socklen"): %s",
xfd->fd, sockaddr_info((struct sockaddr *)us, uslen, infobuff, sizeof(infobuff)),
uslen, strerror(errno));
Close(xfd->fd);
@ -1216,7 +1216,7 @@ int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags,
applyopts(xfd->fd, opts, PH_PREBIND);
applyopts(xfd->fd, opts, PH_BIND);
if ((us != NULL) && Bind(xfd->fd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", xfd->fd,
Msg4(level, "bind(%d, {%s}, "F_socklen"): %s", xfd->fd,
sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), uslen,
strerror(errno));
Close(xfd->fd);
@ -1467,7 +1467,7 @@ int _xioopen_dgram_recv(struct single *xfd, int xioflags,
applyopts(xfd->fd, opts, PH_PREBIND);
applyopts(xfd->fd, opts, PH_BIND);
if ((us != NULL) && Bind(xfd->fd, (struct sockaddr *)us, uslen) < 0) {
Msg4(level, "bind(%d, {%s}, "F_Zd"): %s", xfd->fd,
Msg4(level, "bind(%d, {%s}, "F_socklen"): %s", xfd->fd,
sockaddr_info(us, uslen, infobuff, sizeof(infobuff)), uslen,
strerror(errno));
Close(xfd->fd);
@ -1600,7 +1600,7 @@ int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv) {
xiodump(CMSG_DATA(cmsg),
cmsg->cmsg_len-((char *)CMSG_DATA(cmsg)-(char *)cmsg),
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,
valbuff);
}
@ -1843,7 +1843,6 @@ xiolog_ancillary_socket(struct cmsghdr *cmsg, int *num,
cmsgname = "timestamp";
cmsgenvn = "TIMESTAMP";
{ time_t t = tv->tv_sec; ctime_r(&t, valbuff); }
//sprintf(strchr(valbuff, '\0')-1/*del \n*/, ", %06ld usecs", (long)tv->tv_usec);
snprintf(strchr(valbuff, '\0')-1/*del \n*/, vallen-strlen(valbuff)+1, ", %06ld usecs", (long)tv->tv_usec);
break;
#endif /* defined(SO_TIMESTAMP) */

View file

@ -236,7 +236,6 @@ int _xioopen_socks4_prepare(const char *targetport, struct opt *opts, char **soc
}
}
}
/*strncpy(sockhead->userid, userid, *headlen-SIZEOF_STRUCT_SOCKS4);*/
sockhead->userid[0] = '\0'; strncat(sockhead->userid, userid, *headlen-SIZEOF_STRUCT_SOCKS4-1);
*headlen = SIZEOF_STRUCT_SOCKS4+strlen(userid)+1;
return STAT_OK;
@ -365,7 +364,7 @@ int _xioopen_socks4_connect(struct single *xfd,
char msgbuff[3*SIZEOF_STRUCT_SOCKS4];
* xiohexdump((const unsigned char *)replyhead+bytes, result, msgbuff)
= '\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 */
bytes += result;
@ -373,7 +372,7 @@ int _xioopen_socks4_connect(struct single *xfd,
Debug1("received all "F_Zd" bytes", bytes);
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);
}
if (result <= 0) { /* we had a problem while reading socks answer */

View file

@ -1,5 +1,5 @@
/* source: xio-udp.c */
/* Copyright Gerhard Rieger 2001-2011 */
/* Copyright Gerhard Rieger */
/* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for handling UDP addresses */
@ -195,7 +195,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
applyopts(fd->stream.fd, opts, PH_PREBIND);
applyopts(fd->stream.fd, opts, PH_BIND);
if (Bind(fd->stream.fd, &us.soa, uslen) < 0) {
Error4("bind(%d, {%s}, "F_Zd"): %s", fd->stream.fd,
Error4("bind(%d, {%s}, "F_socklen"): %s", fd->stream.fd,
sockaddr_info(&us.soa, uslen, infobuff, sizeof(infobuff)),
uslen, strerror(errno));
return STAT_RETRYLATER;
@ -221,7 +221,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
&them->soa, &themlen);
} while (result < 0 && errno == EINTR);
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.fd, buff1,
sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)),
themlen, strerror(errno));
@ -265,7 +265,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts,
applyopts(fd->stream.fd, opts, PH_CONNECT);
if ((result = Connect(fd->stream.fd, &them->soa, themlen)) < 0) {
Error4("connect(%d, {%s}, "F_Zd"): %s",
Error4("connect(%d, {%s}, "F_socklen"): %s",
fd->stream.fd,
sockaddr_info(&them->soa, themlen, infobuff, sizeof(infobuff)),
themlen, strerror(errno));

View file

@ -726,7 +726,9 @@ const struct optname optionnames[] = {
#endif
IF_IP ("iptos", &opt_ip_tos)
IF_IP ("ipttl", &opt_ip_ttl)
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("ipv6-add-membership", &opt_ipv6_join_group)
#endif
#ifdef IPV6_AUTHHDR
IF_IP6 ("ipv6-authhdr", &opt_ipv6_authhdr)
#endif
@ -742,7 +744,9 @@ const struct optname optionnames[] = {
#ifdef IPV6_HOPOPTS
IF_IP6 ("ipv6-hopopts", &opt_ipv6_hopopts)
#endif
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("ipv6-join-group", &opt_ipv6_join_group)
#endif
#ifdef IPV6_PKTINFO
IF_IP6 ("ipv6-pktinfo", &opt_ipv6_pktinfo)
#endif
@ -792,7 +796,9 @@ const struct optname optionnames[] = {
IF_TERMIOS("ixany", &opt_ixany)
IF_TERMIOS("ixoff", &opt_ixoff)
IF_TERMIOS("ixon", &opt_ixon)
#ifdef IPV6_JOIN_GROUP
IF_IP6 ("join-group", &opt_ipv6_join_group)
#endif
#if WITH_EXT2 && defined(EXT2_JOURNAL_DATA_FL)
IF_ANY ("journal", &opt_ext2_journal_data)
IF_ANY ("journal-data", &opt_ext2_journal_data)
@ -3046,7 +3052,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
if (Setsockopt(fd, opt->desc->major, opt->desc->minor,
opt->value.u_bin.b_data, opt->value.u_bin.b_len)
< 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,
opt->value.u_bin.b_data, opt->value.u_bin.b_len,
strerror(errno));
@ -3178,7 +3184,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
if (Getsockopt(fd, opt->desc->major, opt->desc->minor,
data, &oldlen)
< 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,
strerror(errno));
opt->desc = ODESC_ERROR; ++opt; continue;

View file

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