From cd5673dbd0786c94e0b3ace7e35fab14c01e3185 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sat, 11 Nov 2023 17:40:52 +0100 Subject: [PATCH] Procan: print umask, CC, and couple more new infos --- CHANGES | 4 + Makefile.in | 3 + fdname.c | 4 +- hostan.c | 212 ++++++++++++++++++++++++++++++++++++++++++++++--- procan-cdefs.c | 15 ++++ procan.c | 33 +++++++- test.sh | 17 ++-- 7 files changed, 264 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index 4dbe5d5..8308220 100644 --- a/CHANGES +++ b/CHANGES @@ -189,6 +189,10 @@ Features: All these are also available in UDPLITE4-* and UDPLITE6-* form; options udplite-recv-cscov and udplite-send-cscov. + Procan now prints info about CC and __STDC_VERSION__, about FD_SETSIZE, + value of SO_PROTOCOL/SO_PROTOTYPE and some other defines, definitions + of many C types, and the actual umask. + Corrections: When a sub process (EXEC, SYSTEM) terminated with exit code other than 0, its last sent data might have been lost depending on timing of read/ diff --git a/Makefile.in b/Makefile.in index a80c5b5..3ecd5d2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -108,6 +108,9 @@ depend: $(CFILES) $(HFILES) socat: socat.o libxio.a $(CC) $(CFLAGS) $(LDFLAGS) -o $@ socat.o libxio.a $(CLIBS) +procan.o: procan.c + $(CC) $(CFLAGS) -c -D CC=\"$(CC)\" -o $@ procan.c + PROCAN_OBJS=procan_main.o procan.o procan-cdefs.o hostan.o error.o sycls.o sysutils.o utils.o vsnprintf_r.o snprinterr.o procan: $(PROCAN_OBJS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(PROCAN_OBJS) $(CLIBS) diff --git a/fdname.c b/fdname.c index 6aaff25..e226bda 100644 --- a/fdname.c +++ b/fdname.c @@ -310,7 +310,7 @@ int sockname(int fd, FILE *outfile, char style) { default: sprintf(protoname, "proto%d", proto); break; } #endif -#else +#else /* ! (defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)) */ if (opttype == SOCK_STREAM) { strcpy(protoname, "(stream)"); } else if (opttype == SOCK_DGRAM) { @@ -338,7 +338,7 @@ int sockname(int fd, FILE *outfile, char style) { } else { strcpy(protoname, "socket"); } -#endif /* defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) */ +#endif /* ! (defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)) */ socknamelen = sizeof(sockname); result = Getsockname(fd, &sockname.soa, &socknamelen); if (result < 0) { diff --git a/hostan.c b/hostan.c index 74d3dbd..c40b4e9 100644 --- a/hostan.c +++ b/hostan.c @@ -32,25 +32,213 @@ int hostan(FILE *outfile) { fprintf(outfile, "sizeof(long long) = %u\n", (unsigned int)sizeof(long long)); #endif fprintf(outfile, "sizeof(size_t) = %u\n", (unsigned int)sizeof(size_t)); + +# if HAVE_BASIC_SIZE_T==2 + fprintf(outfile, "typedef unsigned short size_t; /* sizeof(size_t) = %u */\n", (unsigned int)sizeof(size_t)); +#elif HAVE_BASIC_SIZE_T==4 + fprintf(outfile, "typedef unsigned int size_t; /* sizeof(size_t) = %u */\n", (unsigned int)sizeof(size_t)); +#elif HAVE_BASIC_SIZE_T==6 + fprintf(outfile, "typedef unsigned long size_t; /* sizeof(size_t) = %u */\n", (unsigned int)sizeof(size_t)); +#elif HAVE_BASIC_SIZE_T==8 + fprintf(outfile, "typedef unsigned long long size_t; /* sizeof(size_t) = %u */\n", (unsigned int)sizeof(size_t)); +#endif + +# if HAVE_BASIC_MODE_T==1 + fprintf(outfile, "typedef short mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==2 + fprintf(outfile, "typedef unsigned short mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==3 + fprintf(outfile, "typedef int mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==4 + fprintf(outfile, "typedef unsigned int mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==5 + fprintf(outfile, "typedef long mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==6 + fprintf(outfile, "typedef unsigned long mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==7 + fprintf(outfile, "typedef long long mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#elif HAVE_BASIC_MODE_T==8 + fprintf(outfile, "typedef unsigned long long mode_t; /* sizeof(mode_t) = %u */\n", (unsigned int)sizeof(mode_t)); +#endif + +# if HAVE_BASIC_PID_T==1 + fprintf(outfile, "typedef short pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==2 + fprintf(outfile, "typedef unsigned short pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==3 + fprintf(outfile, "typedef int pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==4 + fprintf(outfile, "typedef unsigned int pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==5 + fprintf(outfile, "typedef long pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==6 + fprintf(outfile, "typedef unsigned long pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==7 + fprintf(outfile, "typedef long long pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#elif HAVE_BASIC_PID_T==8 + fprintf(outfile, "typedef unsigned long long pid_t; /* sizeof(pid_t) = %u */\n", (unsigned int)sizeof(pid_t)); +#endif + +# if HAVE_BASIC_UID_T==1 + fprintf(outfile, "typedef short uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==2 + fprintf(outfile, "typedef unsigned short uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==3 + fprintf(outfile, "typedef int uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==4 + fprintf(outfile, "typedef unsigned int uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==5 + fprintf(outfile, "typedef long uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==6 + fprintf(outfile, "typedef unsigned long uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==7 + fprintf(outfile, "typedef long long uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#elif HAVE_BASIC_UID_T==8 + fprintf(outfile, "typedef unsigned long long uid_t; /* sizeof(uid_t) = %u */\n", (unsigned int)sizeof(uid_t)); +#endif + +# if HAVE_BASIC_GID_T==1 + fprintf(outfile, "typedef short gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==2 + fprintf(outfile, "typedef unsigned short gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==3 + fprintf(outfile, "typedef int gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==4 + fprintf(outfile, "typedef unsigned int gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==5 + fprintf(outfile, "typedef long gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==6 + fprintf(outfile, "typedef unsigned long gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==7 + fprintf(outfile, "typedef long long gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#elif HAVE_BASIC_GID_T==8 + fprintf(outfile, "typedef unsigned long long gid_t; /* sizeof(gid_t) = %u */\n", (unsigned int)sizeof(gid_t)); +#endif + +# if HAVE_BASIC_TIME_T==1 + fprintf(outfile, "typedef short time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==2 + fprintf(outfile, "typedef unsigned short time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==3 + fprintf(outfile, "typedef int time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==4 + fprintf(outfile, "typedef unsigned int time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==5 + fprintf(outfile, "typedef long time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==6 + fprintf(outfile, "typedef unsigned long time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==7 + fprintf(outfile, "typedef long long time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#elif HAVE_BASIC_TIME_T==8 + fprintf(outfile, "typedef unsigned long long time_t; /* sizeof(time_t) = %u */\n", (unsigned int)sizeof(time_t)); +#endif + +# if HAVE_BASIC_SOCKLEN_T==1 + fprintf(outfile, "typedef short socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==2 + fprintf(outfile, "typedef unsigned short socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==3 + fprintf(outfile, "typedef int socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==4 + fprintf(outfile, "typedef unsigned int socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==5 + fprintf(outfile, "typedef long socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==6 + fprintf(outfile, "typedef unsigned long socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==7 + fprintf(outfile, "typedef long long socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#elif HAVE_BASIC_SOCKLEN_T==8 + fprintf(outfile, "typedef unsigned long long socklen_t; /* sizeof(socklen_t) = %u */\n", (unsigned int)sizeof(socklen_t)); +#endif + +# if HAVE_BASIC_OFF_T==1 + fprintf(outfile, "typedef short off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==2 + fprintf(outfile, "typedef unsigned short off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==3 + fprintf(outfile, "typedef int off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==4 + fprintf(outfile, "typedef unsigned int off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==5 + fprintf(outfile, "typedef long off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==6 + fprintf(outfile, "typedef unsigned long off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==7 + fprintf(outfile, "typedef long long off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#elif HAVE_BASIC_OFF_T==8 + fprintf(outfile, "typedef unsigned long long off_t; /* sizeof(off_t) = %u */\n", (unsigned int)sizeof(off_t)); +#endif + +# if HAVE_BASIC_OFF64_T==1 + fprintf(outfile, "typedef short off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==2 + fprintf(outfile, "typedef unsigned short off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==3 + fprintf(outfile, "typedef int off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==4 + fprintf(outfile, "typedef unsigned int off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==5 + fprintf(outfile, "typedef long off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==6 + fprintf(outfile, "typedef unsigned long off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==7 + fprintf(outfile, "typedef long long off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#elif HAVE_BASIC_OFF64_T==8 + fprintf(outfile, "typedef unsigned long long off64_t; /* sizeof(off64_t) = %u */\n", (unsigned int)sizeof(off64_t)); +#endif + +# if HAVE_BASIC_DEV_T==1 + fprintf(outfile, "typedef short dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==2 + fprintf(outfile, "typedef unsigned short dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==3 + fprintf(outfile, "typedef int dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==4 + fprintf(outfile, "typedef unsigned int dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==5 + fprintf(outfile, "typedef long dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==6 + fprintf(outfile, "typedef unsigned long dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==7 + fprintf(outfile, "typedef long long dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#elif HAVE_BASIC_DEV_T==8 + fprintf(outfile, "typedef unsigned long long dev_t; /* sizeof(dev_t) = %u */\n", (unsigned int)sizeof(dev_t)); +#endif + { - union { - uint16_t s; - uint8_t c[2]; - } bo; - bo.c[0] = 0x05; - bo.c[1] = 0xa0; - if (bo.s == 0x05a0) { - fprintf(outfile, "host byte order: network (BE \"big endian\", most significast byte first)\n"); - } else if (bo.s == 0xa005) { - fprintf(outfile, "host byte order: intel (LE \"little endian\", least significast byte first\n"); + struct stat x; +# if HAVE_TYPEOF_ST_INO==1 + fprintf(outfile, "typedef short ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==2 + fprintf(outfile, "typedef unsigned short ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==3 + fprintf(outfile, "typedef int ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==4 + fprintf(outfile, "typedef unsigned int ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==5 + fprintf(outfile, "typedef long ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==6 + fprintf(outfile, "typedef unsigned long ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==7 + fprintf(outfile, "typedef long long ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#elif HAVE_TYPEOF_ST_INO==8 + fprintf(outfile, "typedef unsigned long long ino_t; /* sizeof(ino_t) = %u */\n", (unsigned int)sizeof(x.st_ino)); +#endif + } + { + unsigned short x = 0x100; + if (x == ntohs(0x100)) { + fprintf(outfile, "#define __BYTE_ORDER __BIG_ENDIAN\t/* Motorola ea.*/\n"); } else { - fprintf(outfile, "host byte order: unknown\n"); - fprintf(stderr, "failed to determine host byte order"); + fprintf(outfile, "#define __BYTE_ORDER __LITTLE_ENDIAN\t/* Intel ea.*/\n"); } } #include /* select(); OpenBSD: struct timespec */ fprintf(outfile, "sizeof(struct timespec) = %u\n", (unsigned int)sizeof(struct timespec)); + + fprintf(outfile, "\n"); + fprintf(outfile, "/* Socat types */\n"); fprintf(outfile, "sizeof(struct diag_dgram) = %u\n", (unsigned int)sizeof(struct diag_dgram)); fprintf(outfile, "((struct diag_dgram *)0)->op-((struct diag_dgram *)0) = %u\n", (unsigned int)((char *)(&((struct diag_dgram *)0)->op)-(char *)((struct diag_dgram *)0))); fprintf(outfile, "((struct diag_dgram *)0)->now-((struct diag_dgram *)0) = %u\n", (unsigned int)((char *)(&((struct diag_dgram *)0)->now)-(char *)((struct diag_dgram *)0))); diff --git a/procan-cdefs.c b/procan-cdefs.c index 3f8e660..e0cade7 100644 --- a/procan-cdefs.c +++ b/procan-cdefs.c @@ -85,6 +85,9 @@ int procan_cdefs(FILE *outfile) { #endif /* socket constants */ +#ifdef PF_UNSPEC + fprintf(outfile, "#define PF_UNSPEC %d\n", PF_UNSPEC); +#endif #ifdef PF_UNIX fprintf(outfile, "#define PF_UNIX %d\n", PF_UNIX); #elif defined(PF_LOCAL) @@ -102,6 +105,9 @@ int procan_cdefs(FILE *outfile) { #ifdef PF_PACKET fprintf(outfile, "#define PF_PACKET %d\n", PF_PACKET); #endif +#ifdef PF_VSOCK + fprintf(outfile, "#define PF_VSOCK %d\n", PF_VSOCK); +#endif #ifdef SOCK_STREAM fprintf(outfile, "#define SOCK_STREAM %d\n", SOCK_STREAM); #endif @@ -135,6 +141,9 @@ int procan_cdefs(FILE *outfile) { #ifdef IPPROTO_UDPLITE fprintf(outfile, "#define IPPROTO_UDPLITE %d\n", IPPROTO_UDPLITE); #endif +#ifdef IPPROTO_RAW + fprintf(outfile, "#define IPPROTO_RAW %d\n", IPPROTO_RAW); +#endif #ifdef SOL_SOCKET fprintf(outfile, "#define SOL_SOCKET 0x%x\n", SOL_SOCKET); #endif @@ -159,6 +168,12 @@ int procan_cdefs(FILE *outfile) { #ifdef SOL_DCCP fprintf(outfile, "#define SOL_DCCP 0x%x\n", SOL_DCCP); #endif +#ifdef SO_PROTOCOL + fprintf(outfile, "#define SO_PROTOCOL %d\n", SO_PROTOCOL); +#endif +#ifdef SO_PROTOTYPE + fprintf(outfile, "#define SO_PROTOTYPE %d\n", SO_PROTOTYPE); +#endif #ifdef SO_REUSEADDR fprintf(outfile, "#define SO_REUSEADDR %d\n", SO_REUSEADDR); #endif diff --git a/procan.c b/procan.c index 05e9b5a..1ad8a68 100644 --- a/procan.c +++ b/procan.c @@ -71,10 +71,28 @@ int procan(FILE *outfile) { fprintf(outfile, "group id = "F_gid"\n", Getgid()); fprintf(outfile, "effective group id = "F_gid"\n", Getegid()); + /* Simple process features */ + fprintf(outfile, "\n"); + { + mode_t mask; +#if LATER + char procpath[PATH_MAX]; + sprintf(procpath, "/proc/"F_pid"/status", Getpid()); + if (Stat()) { + + } else +#endif + { + mask = Umask(0066); + Umask(mask); + } + fprintf(outfile, "umask = "F_mode"\n", mask); + } + { struct rlimit rlim; - fprintf(outfile, "\nRESOURCE LIMITS\n"); + fprintf(outfile, "\n/* Resource limits */\n"); fprintf(outfile, "resource current maximum\n"); if (getrlimit(RLIMIT_CPU, &rlim) < 0) { Warn2("getrlimit(RLIMIT_CPU, %p): %s", &rlim, strerror(errno)); @@ -156,10 +174,18 @@ int procan(FILE *outfile) { rlim.rlim_cur, rlim.rlim_max); } #endif + fputc('\n', outfile); + } +#ifdef CC + fprintf(outfile, "// CC: "CC"\n"); +#endif +#ifdef __STDC_VERSION__ + fprintf(outfile, "#define __STDC_VERSION__ %ld\n", __STDC_VERSION__); +#endif #ifdef SIZE_MAX - fprintf(outfile, "SIZE_MAX = %-24lu\n", SIZE_MAX); + fprintf(outfile, "SIZE_MAX = "F_Zu" /* maximum value of size_t */\n", SIZE_MAX); #endif #ifdef P_tmpdir fprintf(outfile, "P_tmpdir = \"%s\"\n", P_tmpdir); @@ -170,6 +196,9 @@ int procan(FILE *outfile) { #ifdef TMP_MAX fprintf(outfile, "TMP_MAX = %d\n", TMP_MAX); #endif +#ifdef FD_SETSIZE + fprintf(outfile, "FD_SETSIZE = %d /* maximum number of FDs for select() */\n", FD_SETSIZE); +#endif #ifdef PIPE_BUF fprintf(outfile, "PIPE_BUF = %-24d\n", PIPE_BUF); #endif diff --git a/test.sh b/test.sh index f76d044..f4a7f90 100755 --- a/test.sh +++ b/test.sh @@ -188,7 +188,7 @@ TIOCEXCL="$($PROCAN -c |grep "^#define[[:space:]]*TIOCEXCL[[:space:]]" |cut -d' SOL_SOCKET="$($PROCAN -c |grep "^#define[[:space:]]*SOL_SOCKET[[:space:]]" |cut -d' ' -f3)" SO_REUSEADDR="$($PROCAN -c |grep "^#define[[:space:]]*SO_REUSEADDR[[:space:]]" |cut -d' ' -f3)" TCP_MAXSEG="$($PROCAN -c |grep "^#define[[:space:]]*TCP_MAXSEG[[:space:]]" |cut -d' ' -f3)" -SIZE_T=$($PROCAN |grep size_t |awk '{print($3);}') +SIZE_T=$($PROCAN |grep "^[^[:space:]]*size_t" |awk '{print($3);}') #AI_ADDRCONFIG=; if [ "$($SOCAT -hhh |grep ai-addrconfig)" ]; then AI_ADDRCONFIG="ai-addrconfig=0"; fi # SSL certificate contents @@ -3491,7 +3491,7 @@ N=$((N+1)) # I cannot remember the clou of this test, seems rather useless NAME=CHILDDEFAULT case "$TESTS" in -*%$N%*|*%functions%*|*%$NAME%*) +*%$N%*|*%functions%*|*%procan%*|*%$NAME%*) if ! eval $NUMCOND; then : elif ! F=$(testfeats STDIO EXEC); then $PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not configured in $SOCAT${NORMAL}\n" $N @@ -3535,7 +3535,7 @@ N=$((N+1)) NAME=CHILDSETSID case "$TESTS" in -*%$N%*|*%functions%*|*%$NAME%*) +*%$N%*|*%functions%*|*%procan%*|*%$NAME%*) TEST="$NAME: child process with setsid" if ! eval $NUMCOND; then :; else tf="$td/test$N.stdout" @@ -3568,12 +3568,12 @@ N=$((N+1)) NAME=MAINSETSID case "$TESTS" in -*%$N%*|*%functions%*|*%$NAME%*) +*%$N%*|*%functions%*|*%stdio%*|*%exec%*|*%procan%*|*%$NAME%*) TEST="$NAME: main process with setsid" if ! eval $NUMCOND; then :; else tf="$td/test$N.stdout" te="$td/test$N.stderr" -CMD="$TRACE $SOCAT $opts -U -,setsid exec:$PROCAN" +CMD="$TRACE $SOCAT $opts -U -,setsid EXEC:$PROCAN" printf "test $F_n $TEST... " $N $CMD >$tf 2>$te MYPID=`grep "process id =" $tf |(expr "\`cat\`" : '[^0-9]*\([0-9]*\).*')` @@ -10826,7 +10826,7 @@ else if [ -n "$debug" ]; then cat "${te}0" "${te}1" "${te}2"; fi numOK=$((numOK+1)) fi -fi # NUMCOND, SO_REUSEADDR +fi # NUMCOND ;; esac N=$((N+1)) @@ -13347,6 +13347,7 @@ case $SIZE_T in 4) CHKSIZE=2147483648 ;; 8) CHKSIZE=9223372036854775808 ;; 16) CHKSIZE=170141183460469231731687303715884105728 ;; + *) echo "Unsupported SIZE_T=\"$SIZE_T\"" >2 ;; esac CMD0="$TRACE $SOCAT $opts -T 1 -b $CHKSIZE /dev/null PIPE" printf "test $F_n $TEST... " $N @@ -18798,10 +18799,10 @@ if [ "$OPT_EXPECT_FAIL" ]; then ln -sf "$td/failed.diff" . #grep "^" grep "^> " "$td/failed.diff" |awk '{print($2);}' >"$td/failed.unexp" - ln -s "$td/failed.unexp" . + ln -sf "$td/failed.unexp" . echo "FAILED unexpected: $(cat "$td/failed.unexp" |xargs echo)" grep "^< " "$td/failed.diff" |awk '{print($2);}' >"$td/ok.unexp" - ln -s "$td/ok.unexp" . + ln -sf "$td/ok.unexp" . echo "OK unexpected: $(cat "$td/ok.unexp" |xargs echo)" else touch "$td/failed.diff"