X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_20,J_CHICKENPOX_41,J_CHICKENPOX_45,J_CHICKENPOX_55,J_CHICKENPOX_64 X-Spam-Check-By: sourceware.org Message-ID: <435581.23119.qm@web110512.mail.gq1.yahoo.com> Date: Sat, 13 Jun 2009 01:50:01 -0700 (PDT) From: Xiaoqiang Zheng Subject: [BUG 1.7 getopt_long() and recv()] has problem for tftp-hpa-5.0 on cygwin-1.7/win2003 To: cygwin AT cygwin DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com * getopt_long() not work properly for tftp-hpa-5.0 on cygwin-1.7/win2003 * recv() has problem for tftp-hpa-5.0 on cygwin-1.7/win2003 recv() has same problem for tftpd of inetutils-1.5.6 on cygwin-1.7/win2003 * there's no problem on cygwin 1.5.25-15/win2003 for tftp-hpa-5.0: 1. ./configure ================== $ ./configure --without-tcpwrappers --without-remap --without-readline --without-ipv6 checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for library containing strerror... none required checking for gcc... (cached) gcc checking whether we are using the GNU C compiler... (cached) yes checking whether gcc accepts -g... (cached) yes checking for gcc option to accept ISO C89... (cached) none needed checking for an ANSI C-conforming const... yes checking for inline... inline checking if gcc accepts -W... yes checking if gcc accepts -Wall... yes checking if gcc accepts -Wpointer-arith... yes checking if gcc accepts -Wbad-function-cast... yes checking if gcc accepts -Wcast-equal... no checking if gcc accepts -Wstrict-prototypes... yes checking if gcc accepts -Wmissing-prototypes... yes checking if gcc accepts -Wmissing-declarations... yes checking if gcc accepts -Wnested-externs... yes checking if gcc accepts -Winline... yes checking if gcc accepts -Wwrite-strings... yes checking if gcc accepts -Wundef... yes checking if gcc accepts -Wshadow... yes checking if gcc accepts -Wsign-compare... yes checking if gcc accepts -pipe... yes checking if gcc accepts -fno-strict-aliasing... yes checking for ANSI C header files... (cached) yes checking for inttypes.h... (cached) yes checking for stdint.h... (cached) yes checking for inttypes.h... (cached) yes checking if inttypes.h is sane... yes checking fcntl.h usability... yes checking fcntl.h presence... yes checking for fcntl.h... yes checking grp.h usability... yes checking grp.h presence... yes checking for grp.h... yes checking libgen.h usability... yes checking libgen.h presence... yes checking for libgen.h... yes checking for memory.h... (cached) yes checking setjmp.h usability... yes checking setjmp.h presence... yes checking for setjmp.h... yes checking stddef.h usability... yes checking stddef.h presence... yes checking for stddef.h... yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking for strings.h... (cached) yes checking sysexits.h usability... yes checking sysexits.h presence... yes checking for sysexits.h... yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking for unistd.h... (cached) yes checking sys/filio.h usability... no checking sys/filio.h presence... no checking for sys/filio.h... no checking for sys/stat.h... (cached) yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking for sys/types.h... (cached) yes checking arpa/inet.h usability... yes checking arpa/inet.h presence... yes checking for arpa/inet.h... yes checking netdb.h usability... yes checking netdb.h presence... yes checking for netdb.h... yes checking whether time.h and sys/time.h may both be included... yes checking machine/param.h usability... yes checking machine/param.h presence... yes checking for machine/param.h... yes checking sys/socket.h usability... yes checking sys/socket.h presence... yes checking for sys/socket.h... yes checking winsock2.h usability... no checking winsock2.h presence... yes configure: WARNING: winsock2.h: present but cannot be compiled configure: WARNING: winsock2.h: check for missing prerequisite headers? configure: WARNING: winsock2.h: see the Autoconf documentation configure: WARNING: winsock2.h: section "Present But Cannot Be Compiled" configure: WARNING: winsock2.h: proceeding with the preprocessor's result configure: WARNING: winsock2.h: in the future, the compiler will take precedence checking for winsock2.h... yes checking winsock.h usability... no checking winsock.h presence... yes configure: WARNING: winsock.h: present but cannot be compiled configure: WARNING: winsock.h: check for missing prerequisite headers? configure: WARNING: winsock.h: see the Autoconf documentation configure: WARNING: winsock.h: section "Present But Cannot Be Compiled" configure: WARNING: winsock.h: proceeding with the preprocessor's result configure: WARNING: winsock.h: in the future, the compiler will take precedence checking for winsock.h... yes checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... no checking for off_t... yes checking for pid_t... yes checking for mode_t... yes checking for size_t... yes checking for intmax_t... yes checking for long long... yes checking for uint16_t... yes checking for uint32_t... yes checking for u_short... yes checking for u_long... yes checking for socklen_t... yes checking for library containing socket... none required checking for fcntl... yes checking for setsid... yes checking for recvmsg... yes checking for ftruncate... yes checking for setreuid... yes checking for setregid... yes checking for initgroups... yes checking for setgroups... yes checking for strtoumax... yes checking for strtoull... yes checking for struct msghdr.msg_control... yes checking for struct in_pktinfo.ipi_addr... yes checking for struct addrinfo.ai_addr... yes checking if fcntl.h defines O_NONBLOCK... yes checking if fcntl.h defines O_BINARY... yes checking if fcntl.h defines O_TEXT... yes checking for sigsetjmp... yes checking for library containing xmalloc... -liberty checking for library containing xstrdup... none required checking for library containing bsd_signal... no checking for library containing getopt_long... none required checking for library containing getaddrinfo... none required checking for library containing freeaddrinfo... none required checking for library containing gai_strerror... none required checking for library containing inet_ntop... none required checking for library containing inet_aton... none required checking for daemon... yes checking for dup2... yes checking if netinet/in.h defines IPPORT_TFTP... yes checking for struct sockaddr_in6.sin6_addr... yes checking for IPv6 support... disabled checking whether ln -s works... yes checking for ranlib... ranlib checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating MCONFIG config.status: creating aconfig.h ================= 2. make ================== $ make echo \#define VERSION \"tftp-hpa `cat version`\" > version.h make -C lib make[1]: Entering directory `/home/Administrator/tftp-hpa-5.0/lib' gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c bsdsignal.c rm -f libxtra.a ar cq libxtra.a bsdsignal.o ranlib libxtra.a make[1]: Leaving directory `/home/Administrator/tftp-hpa-5.0/lib' make -C common make[1]: Entering directory `/home/Administrator/tftp-hpa-5.0/common' gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c tftpsubs.c rm -f libcommon.a ar cq libcommon.a tftpsubs.o ranlib libcommon.a make[1]: Leaving directory `/home/Administrator/tftp-hpa-5.0/common' make -C tftp make[1]: Entering directory `/home/Administrator/tftp-hpa-5.0/tftp' gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c tftp.c gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c main.c main.c: In function 'makeargv': main.c:879: warning: array subscript has type 'char' main.c:885: warning: array subscript has type 'char' gcc tftp.o main.o ../common/libcommon.a -liberty /home/Administrator/tftp-hpa- 5.0/lib/libxtra.a -o tftp.exe sed -e 's/@@VERSION@@/5.0/g' < tftp.1.in > tftp.1 make[1]: Leaving directory `/home/Administrator/tftp-hpa-5.0/tftp' make -C tftpd make[1]: Entering directory `/home/Administrator/tftp-hpa-5.0/tftpd' gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c tftpd.c tftpd.c: In function 'pmtu_discovery_off': tftpd.c:194: warning: unused parameter 'fd' tftpd.c: In function 'tftp': tftpd.c:1033: warning: array subscript has type 'char' gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c recvfrom.c recvfrom.c: In function 'myrecvfrom': recvfrom.c:179: warning: comparison between signed and unsigned gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmi ssing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-string s -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/home/Administrat or/tftp-hpa-5.0 -c misc.c gcc tftpd.o recvfrom.o misc.o ../common/libcommon.a -liberty /home/Administrat or/tftp-hpa-5.0/lib/libxtra.a -o tftpd.exe sed -e 's/@@VERSION@@/5.0/g' < tftpd.8.in > tftpd.8 make[1]: Leaving directory `/home/Administrator/tftp-hpa-5.0/tftpd' ================== 3. running in foreground and it exits imediately automatically ================== $ tftpd/tftpd -u SYSTEM -L -p -c -s /home/Administrator ================== 4. log messages: ================== $ tail /var/log/messages Jun 13 10:47:43 mms tftpd: PID 3656: too many -s directories ================== 5. modify tftpd.c to hard code the user and dir, and let it print some messges when processing options ================== --- tftp-hpa-5.0-src/tftpd/tftpd.c 2009-02-17 06:51:22.000000000 +0800 +++ tftp-hpa-5.0/tftpd/tftpd.c 2009-06-13 11:43:26.948182400 +0800 @@ -242,6 +242,7 @@ set_socket_nonblock(s, 1); rv = recv(s, rbuf, len, flags); + printf("cygwin: recv() rv = %d errno=%d\n", rv, errno); err = errno; set_socket_nonblock(s, 0); @@ -376,19 +377,25 @@ #endif case 'c': cancreate = 1; + printf("cygwin: cancreate=%d optind=%d\n", cancreate, optind); break; case 's': secure = 1; + printf("cygwin: secure=%d optind=%d\n", secure, optind); break; case 'p': unixperms = 1; + printf("cygwin: uniperm=%d optind=%d\n", unixperms, optind); break; case 'l': standalone = 1; + printf("cygwin: standalone=%d optind=%d\n", standalone, optind); break; case 'L': standalone = 1; + printf("cygwin: standalone=%d optind=%d\n", standalone, optind); nodaemon = 1; + printf("cygwin: nodaemon=%d optind=%d\n", nodaemon, optind); break; case 'a': address = optarg; @@ -433,6 +440,7 @@ break; case 'u': user = optarg; + printf("cygwin: user=%s optarg=%s optind=%d\n", user, optarg, optind); break; case 'U': my_umask = strtoul(optarg, &ep, 8); @@ -465,9 +473,11 @@ #endif case 'v': verbosity++; + printf("cygwin: user=%d\n", verbosity); break; case OPT_VERBOSITY: verbosity = atoi(optarg); + printf("cygwin: user=%d\n", verbosity); break; case 'V': /* Print configuration to stdout and exit */ @@ -481,7 +491,10 @@ dirs = xmalloc((argc - optind + 1) * sizeof(char *)); for (ndirs = 0; optind != argc; optind++) + { dirs[ndirs++] = argv[optind]; + printf("cygwin: dirs[%d]=%s argv[%d]=%s\n", ndirs -1, dirs[ndirs -1], optind, argv[optind]); + } dirs[ndirs] = NULL; @@ -492,14 +505,18 @@ } if (ndirs > 1) { syslog(LOG_ERR, "too many -s directories"); - exit(EX_USAGE); + //exit(EX_USAGE); } + dirs[0]="/etc"; + printf("cygwin: dirs[0]=%s\n", dirs[0]); if (chdir(dirs[0])) { syslog(LOG_ERR, "%s: %m", dirs[0]); exit(EX_NOINPUT); } } + user="Administrator"; + printf("cygwin: user=%s\n", user); pw = getpwnam(user); if (!pw) { syslog(LOG_ERR, "no user %s: %m", user); ================== 6. make and run again ================== $ tftpd/tftpd -u SYSTEM -L -p -c -s /var/log cygwin: user=(null) optarg=(null) optind=1 cygwin: standalone=1 optind=1 cygwin: nodaemon=1 optind=1 cygwin: uniperm=1 optind=1 cygwin: cancreate=1 optind=1 cygwin: secure=1 optind=1 cygwin: dirs[0]=-u argv[1]=-u cygwin: dirs[1]=SYSTEM argv[2]=SYSTEM cygwin: dirs[2]=-L argv[3]=-L cygwin: dirs[3]=-p argv[4]=-p cygwin: dirs[4]=-c argv[5]=-c cygwin: dirs[5]=-s argv[6]=-s cygwin: dirs[6]=/var/log argv[7]=/var/log cygwin: dirs[0]=/etc cygwin: user=Administrator ================== 7. tftp some files ================== $ tftp 192.168.0.254 tftp> mode binary tftp> trace Packet tracing on. tftp> verbose Verbose mode on. tftp> get hosts.allow getting from 192.168.0.254:hosts.allow to hosts.allow [octet] sent RRQ received DATA Received 469 bytes in 0.1 seconds [37520 bits/sec] tftp> get passwd getting from 192.168.0.254:passwd to passwd [octet] sent RRQ received DATA sent ACK sent ACK ================== 8. message for tftpd recv() ================== cygwin: recv() rv = -1 errno=14 cygwin: recv() rv = -1 errno=14 ================== 9. log messages: ================== $ tail /var/log/messages Jun 13 12:08:57 mms tftpd: PID 3372: too many -s directories Jun 13 12:09:28 mms Jun 13 12:09:28 mms tftpd: PID 2924: tftpd: read(ack): Bad address Jun 13 12:09:55 mms Jun 13 12:09:55 mms tftpd: PID 612: tftpd: read(ack): Bad address ================== -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/