diff options
author | lukem <lukem> | 2005-05-11 09:58:55 +0000 |
---|---|---|
committer | lukem <lukem> | 2005-05-11 09:58:55 +0000 |
commit | 91e0e31a797e1d4da306b248d6f059668f79b6ec (patch) | |
tree | c47608e04af6eeda9c5a95dc6f536acc3db74e58 /net | |
parent | 5959b132e0cd43ffafbe40de26c052665dec0853 (diff) | |
download | pkgsrc-91e0e31a797e1d4da306b248d6f059668f79b6ec.tar.gz |
Merge tnftp 20050511.
(Future merges should be easier as this time I froze the vendor RCSIDs)
Diffstat (limited to 'net')
45 files changed, 829 insertions, 523 deletions
diff --git a/net/tnftp/files/COPYING b/net/tnftp/files/COPYING index 0168f7cb036..3019e95559c 100644 --- a/net/tnftp/files/COPYING +++ b/net/tnftp/files/COPYING @@ -1,4 +1,4 @@ -$Id: COPYING,v 1.2 2005/01/04 23:44:24 lukem Exp $ +NetBSD: COPYING,v 1.4 2005/05/11 03:03:42 lukem Exp Copyright (c) 2001-2005 The NetBSD Foundation, Inc. All rights reserved. diff --git a/net/tnftp/files/ChangeLog b/net/tnftp/files/ChangeLog index 7de88bb7abc..53b5a6ce4bb 100644 --- a/net/tnftp/files/ChangeLog +++ b/net/tnftp/files/ChangeLog @@ -1,4 +1,103 @@ -$Id: ChangeLog,v 1.2 2005/01/04 23:44:24 lukem Exp $ +NetBSD: ChangeLog,v 1.16 2005/05/11 04:21:53 lukem Exp + +Wed May 11 04:19:43 UTC 2005 lukem + + * Release "tnftp 20050511" + +Wed May 11 04:10:01 UTC 2005 lukem + + * Update the THANKS file. + + * Only use poll() to implement xpoll() if it's available, + otherwise attempt to use select() if that's available, + otherwise #error. + + * Detect if struct pollfd is available in <poll.h> or <sys/poll.h>. + Improve consistency in use of autoconf macros. + +Wed May 11 02:42:08 UTC 2005 lukem + + * Merge NetBSD-ftp 20050511: + - Use socklen_t instead of int as the 5th argument to + getsockopt(). Improve invocation of setsockopt() and + associated failure messages. + +Wed May 11 01:46:29 UTC 2005 lukem + + * Clean up RCSID usage in vendor-derived code, restoring original + IDs where possible. + +Wed May 11 00:08:16 UTC 2005 lukem + + * Merge NetBSD-ftp 20050510: + - Prevent an overly-long input line causing a core dump when + editing is enabled. + Issue noted by Ryoji Kanai in FreeBSD Problem Report # 77158. + - Implement a timeout on the accept(2) in dataconn() and the + connect(2) in xconnect() by temporarily setting O_NONBLOCK + on the socket and using xpoll() to wait for the operation + to succeed. The timeout used is the '-q quittime' argument + (defaults to 60s for accept(2), and the system default for + connect(2)). Idea inspired by discussion with Chuck Cranor. + This may (indirectly) fix various problems with timeouts in + active mode through broken firewalls. + - Implement xpoll() as a wrapper around poll(2), to make it + easier to replace on systems without a functional poll(2). + Unconditionally use xpoll() instead of conditionally using + select(2) or poll(2). + - In fetch_url(), don't call freeaddrinfo(res0) too early, as + we use pointers to its contents later in the function. + Problem found by Onno van der Linden. + - Fix ftp url reget when globs are being used. + Provided by Mathieu Arnold <mat@FreeBSD.org>. + - Factor out common string processing code eliminating static + buffers, making functions that should be static be static, + and cleaning up const usage. Added a guard against buffer + overflow, but the domap function is a bit too complicated + to tackle right now. + - Clean up whitespace. + - Expand description of http_proxy by suggesting the use of + RFC 1738 '%xx' encoding for "unsafe URL" characters in + usernames and passwords. + +Wed Jan 5 05:53:59 UTC 2005 lukem + + * For now, assume libedit is not up-to-date and use our own version. + + * Merge libedit from NetBSD 20020605 to 20050105. Changes include: + - Improve vi-mode. + - Delete-previous-char and delete-next-char without an + argument are not supposed to modify the yank buffer in + emacs-mode. + - Improve incremental searching. + - Improve memory allocation & usage. + - Move UCB-licensed code from 4-clause to 3-clause. + - Make the tokenization functions publically available. + - Various tty access bug-fixes. + - Improve readline emulation. + +Tue Jan 4 13:33:40 UTC 2005 lukem + + * Unixware 7.1.1 implements RFC 2133 (Basic Socket Interface + Extensions for IPv6) but not the successor RFC 2553. The configure + script detects this and decides that tnftp needs to compile its own + version of getaddrinfo(). This produces the error message + /usr/include/netdb.h:248: `getaddrinfo' previously defined here + because Unixware provides an implementation of getaddrinfo() in + netdb.h instead of a prototype declaration :-/. Since netdb.h + cannot be omitted, we will always get this definition and tnftp's + version of getaddrinfo will always create a conflict. This ugly + preprocessor hack works around the problem. Hints for a better + solution welcome. Fix from pkgsrc/net/tnftp. + + * Workaround poll() being a compatibility function on Darwin 7 + (MacOSX 10.3) by adding a custom test for _POLL_EMUL_H_ which + is defined in poll.h on some MacOSX 10.3 systems. Not all 10.3 + systems have poll.h, so only do the poll() test if at least one + of the header files is found. Fix from pkgsrc/net/tnftp. + + * Add a utimes() replacement (using utime()) for Interix. + From pkgsrc/net/tnftp. Mon Jan 3 10:21:57 UTC 2005 lukem diff --git a/net/tnftp/files/Makefile.in b/net/tnftp/files/Makefile.in index 789d8b60589..4098824edb0 100644 --- a/net/tnftp/files/Makefile.in +++ b/net/tnftp/files/Makefile.in @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.in,v 1.1.1.3 2005/05/11 09:03:42 lukem Exp $ +# NetBSD: Makefile.in,v 1.3 2005/05/11 03:03:42 lukem Exp # srcdir = @srcdir@ diff --git a/net/tnftp/files/README b/net/tnftp/files/README index 84294e3f857..910c3a4cf53 100644 --- a/net/tnftp/files/README +++ b/net/tnftp/files/README @@ -42,7 +42,8 @@ Refer to `INSTALL' for more information on how to compile and install tnftp. FEEDBACK / BUG REPORTS ---------------------- -Please email feedback back to the maintainer: <lukem@NetBSD.org>. +Please email feedback back to the maintainer: + Luke Mewburn <lukem@NetBSD.org>. COPYRIGHT @@ -57,3 +58,8 @@ AVAILABILITY The primary ftp site for tnftp is: ftp://ftp.NetBSD.org/pub/NetBSD/misc/tnftp/ + + +DOCUMENT REFERENCE +------------------ +NetBSD: README,v 1.6 2005/05/11 03:05:52 lukem Exp diff --git a/net/tnftp/files/acconfig.h b/net/tnftp/files/acconfig.h index b2a80c24149..5dfe37b2928 100644 --- a/net/tnftp/files/acconfig.h +++ b/net/tnftp/files/acconfig.h @@ -1,4 +1,4 @@ -/* $Id: acconfig.h,v 1.2 2004/04/25 02:48:12 grant Exp $ */ +/* NetBSD: acconfig.h,v 1.6 2005/05/11 03:10:05 lukem Exp */ @TOP@ @BOTTOM@ @@ -69,6 +69,9 @@ /* Define if we have poll() and it is not emulated */ #undef HAVE_POLL +/* Define if we have struct pollfd in <poll.h> or <sys/poll.h> */ +#undef HAVE_STRUCT_POLLFD + /* * Define this if compiling with SOCKS (the firewall traversal library). * Also, you must define connect, getsockname, bind, accept, listen, and diff --git a/net/tnftp/files/config.h.in b/net/tnftp/files/config.h.in index 77670aa4dd5..18f8aa8b990 100644 --- a/net/tnftp/files/config.h.in +++ b/net/tnftp/files/config.h.in @@ -1,5 +1,5 @@ /* config.h.in. Generated automatically from configure.in by autoheader. */ -/* $Id: config.h.in,v 1.4 2005/01/04 23:51:00 lukem Exp $ */ +/* NetBSD: config.h.in,v 1.8 2005/05/11 03:10:26 lukem Exp */ /* Define if on AIX 3. @@ -255,6 +255,9 @@ /* Define if we have poll() and it is not emulated */ #undef HAVE_POLL +/* Define if we have struct pollfd in <poll.h> or <sys/poll.h> */ +#undef HAVE_STRUCT_POLLFD + /* * Define this if compiling with SOCKS (the firewall traversal library). * Also, you must define connect, getsockname, bind, accept, listen, and diff --git a/net/tnftp/files/configure b/net/tnftp/files/configure index acdd53c3100..1e6bf3b5a3d 100755 --- a/net/tnftp/files/configure +++ b/net/tnftp/files/configure @@ -1,6 +1,6 @@ #! /bin/sh -# From configure.in Revision: 1.4 +# From configure.in Revision: 1.12 @@ -2386,7 +2386,7 @@ EOF fi -for ac_hdr in arpa/nameser.h err.h regex.h paths.h \ +for ac_hdr in arpa/nameser.h err.h regex.h paths.h poll.h sys/poll.h \ sys/syslimits.h termcap.h util.h libutil.h vis.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` @@ -3713,58 +3713,14 @@ done fi -# handle Darwin 7 having a poll() compatibility function. be -# conservative, if we don't find one of poll.h or sys/poll.h, don't -# attempt to use poll(). -for ac_hdr in poll.h sys/poll.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3724: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext <<EOF -#line 3729 "configure" -#include "confdefs.h" -#include <$ac_hdr> -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3734: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <<EOF -#define $ac_tr_hdr 1 -EOF - -else - echo "$ac_t""no" 1>&6 -fi -done - - if test $ac_cv_header_poll_h = yes || test $ac_cv_header_sys_poll_h = yes; then echo $ac_n "checking for poll""... $ac_c" 1>&6 -echo "configure:3763: checking for poll" >&5 +echo "configure:3719: checking for poll" >&5 if eval "test \"`echo '$''{'ac_cv_func_poll'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3768 "configure" +#line 3724 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char poll(); below. */ @@ -3787,7 +3743,7 @@ poll(); ; return 0; } EOF -if { (eval echo configure:3791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3747: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_poll=yes" else @@ -3803,29 +3759,31 @@ if eval "test \"`echo '$ac_cv_func_'poll`\" = yes"; then echo "$ac_t""yes" 1>&6 echo $ac_n "checking if poll() is implemented natively""... $ac_c" 1>&6 -echo "configure:3807: checking if poll() is implemented natively" >&5 +echo "configure:3763: checking if poll() is implemented natively" >&5 if eval "test \"`echo '$''{'ftp_cv_POLL_NATIVE'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3813 "configure" +#line 3769 "configure" #include "confdefs.h" - #if HAVE_POLL_H - #include <poll.h> - #endif - #if HAVE_SYS_POLL_H - #include <sys/poll.h> - #endif - + +#if HAVE_POLL_H +#include <poll.h> +#endif +#if HAVE_SYS_POLL_H +#include <sys/poll.h> +#endif + int main() { - #ifdef _POLL_EMUL_H_ - #error "poll() is emulated" - #endif - ; + +#ifdef _POLL_EMUL_H_ +#error "poll() is emulated" +#endif + ; ; return 0; } EOF -if { (eval echo configure:3829: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3787: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ftp_cv_POLL_NATIVE=yes else @@ -3840,7 +3798,7 @@ fi echo "$ac_t""$ftp_cv_POLL_NATIVE" 1>&6 if test "x$ftp_cv_POLL_NATIVE" = "xyes"; then - cat >> confdefs.h <<\EOF + cat >> confdefs.h <<\EOF #define HAVE_POLL 1 EOF @@ -3854,19 +3812,67 @@ else echo "$ac_t""no" 1>&6 fi + + + echo $ac_n "checking for struct pollfd""... $ac_c" 1>&6 +echo "configure:3819: checking for struct pollfd" >&5 +if eval "test \"`echo '$''{'ftp_cv_HAVE_STRUCT_POLLFD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + cat > conftest.$ac_ext <<EOF +#line 3825 "configure" +#include "confdefs.h" + +#if HAVE_POLL_H +#include <poll.h> +#endif +#if HAVE_SYS_POLL_H +#include <sys/poll.h> +#endif + +int main() { + struct pollfd X ; +; return 0; } +EOF +if { (eval echo configure:3839: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ftp_cv_HAVE_STRUCT_POLLFD=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ftp_cv_HAVE_STRUCT_POLLFD=no +fi +rm -f conftest* + fi +echo "$ac_t""$ftp_cv_HAVE_STRUCT_POLLFD" 1>&6 + if test "x$ftp_cv_HAVE_STRUCT_POLLFD" = "xyes"; then + cat >> confdefs.h <<\EOF +#define HAVE_STRUCT_POLLFD 1 +EOF + + else + : + : + fi + +fi + + if test $opt_editcomplete = yes; then if test $have_libedit = yes; then echo $ac_n "checking for EL_RPROMPT in libedit""... $ac_c" 1>&6 -echo "configure:3864: checking for EL_RPROMPT in libedit" >&5 +echo "configure:3870: checking for EL_RPROMPT in libedit" >&5 if eval "test \"`echo '$''{'ftp_cv_have_libedit'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3870 "configure" +#line 3876 "configure" #include "confdefs.h" #include <histedit.h> @@ -3875,7 +3881,7 @@ int main() { int X = EL_RPROMPT ; ; return 0; } EOF -if { (eval echo configure:3879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3885: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ftp_cv_have_libedit=yes else @@ -3898,8 +3904,10 @@ echo "$ac_t""$ftp_cv_have_libedit" 1>&6 fi - echo $ac_n "checking for working libedit""... $ac_c" 1>&6 -echo "configure:3903: checking for working libedit" >&5 + have_libedit=no + + echo $ac_n "checking for up-to-date libedit""... $ac_c" 1>&6 +echo "configure:3911: checking for up-to-date libedit" >&5 if test $have_libedit = no; then echo "$ac_t""no - using my own" 1>&6 INCLUDES="-I\${srcdir}/../libedit $INCLUDES" @@ -3917,13 +3925,13 @@ fi if test $ac_cv_func_sl_init = yes; then echo $ac_n "checking if sl_add() returns int""... $ac_c" 1>&6 -echo "configure:3921: checking if sl_add() returns int" >&5 +echo "configure:3929: checking if sl_add() returns int" >&5 if eval "test \"`echo '$''{'ftp_cv_INT_SL_ADD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3927 "configure" +#line 3935 "configure" #include "confdefs.h" #include <stringlist.h> @@ -3934,7 +3942,7 @@ int main() { ; ; return 0; } EOF -if { (eval echo configure:3938: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3946: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ftp_cv_INT_SL_ADD=yes else @@ -3962,13 +3970,13 @@ have_rfc2553_netdb=no if test $ac_cv_func_getaddrinfo = yes -a ! -n "$socks"; then echo $ac_n "checking for AI_NUMERICHOST""... $ac_c" 1>&6 -echo "configure:3966: checking for AI_NUMERICHOST" >&5 +echo "configure:3974: checking for AI_NUMERICHOST" >&5 if eval "test \"`echo '$''{'ftp_cv_have_ai_numerichost'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 3972 "configure" +#line 3980 "configure" #include "confdefs.h" #include <sys/types.h> @@ -3979,7 +3987,7 @@ int main() { int X = AI_NUMERICHOST ; ; return 0; } EOF -if { (eval echo configure:3983: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ftp_cv_have_ai_numerichost=yes else @@ -4002,7 +4010,7 @@ echo "$ac_t""$ftp_cv_have_ai_numerichost" 1>&6 fi echo $ac_n "checking for working getaddrinfo()""... $ac_c" 1>&6 -echo "configure:4006: checking for working getaddrinfo()" >&5 +echo "configure:4014: checking for working getaddrinfo()" >&5 if test $have_rfc2553_netdb = yes; then cat >> confdefs.h <<\EOF #define HAVE_RFC2553_NETDB 1 @@ -4022,13 +4030,13 @@ fi if test $ac_cv_header_vis_h = yes; then echo $ac_n "checking for VIS_WHITE in vis.h""... $ac_c" 1>&6 -echo "configure:4026: checking for VIS_WHITE in vis.h" >&5 +echo "configure:4034: checking for VIS_WHITE in vis.h" >&5 if eval "test \"`echo '$''{'ftp_cv_have_vis_white'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 4032 "configure" +#line 4040 "configure" #include "confdefs.h" #include <sys/types.h> @@ -4038,7 +4046,7 @@ int main() { int X = VIS_WHITE ; ; return 0; } EOF -if { (eval echo configure:4042: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:4050: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ftp_cv_have_vis_white=yes else diff --git a/net/tnftp/files/configure.in b/net/tnftp/files/configure.in index 725afa866ae..4a2142861fd 100644 --- a/net/tnftp/files/configure.in +++ b/net/tnftp/files/configure.in @@ -1,10 +1,10 @@ -dnl $Id: configure.in,v 1.4 2005/01/04 23:44:24 lukem Exp $ +dnl NetBSD: configure.in,v 1.12 2005/05/11 03:10:05 lukem Exp dnl dnl configure.in -- dnl process this file with autoconf to produce a configure script. dnl -AC_REVISION($Revision: 1.4 $)dnl +AC_REVISION(Revision: 1.12)dnl AC_INIT(tnftp.h) @@ -60,8 +60,8 @@ dnl AC_CONFIG_HEADER(config.h) AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS(arpa/nameser.h err.h regex.h paths.h \ - sys/syslimits.h termcap.h util.h libutil.h vis.h) +AC_CHECK_HEADERS([arpa/nameser.h err.h regex.h paths.h poll.h sys/poll.h \ + sys/syslimits.h termcap.h util.h libutil.h vis.h]) dnl Checks for typedefs, structures, and compiler characteristics. @@ -69,7 +69,7 @@ dnl AC_HEADER_TIME AC_TYPE_OFF_T AC_CHECK_SIZEOF(off_t, 0) -AC_MSG_TRY_LINK(for long long, ftp_cv_HAVE_LONG_LONG, [ +AC_MSG_TRY_LINK([for long long], ftp_cv_HAVE_LONG_LONG, [ #include <sys/types.h> ] , [ long long X = 2, Y = 1, Z; @@ -79,17 +79,17 @@ AC_MSG_TRY_LINK(for long long, ftp_cv_HAVE_LONG_LONG, [ have_long_long=yes ], [have_long_long=no]) -AC_MSG_TRY_COMPILE(for in_port_t, ftp_cv_HAVE_IN_PORT_T, [ +AC_MSG_TRY_COMPILE([for in_port_t], ftp_cv_HAVE_IN_PORT_T, [ #include <sys/types.h> #include <netinet/in.h> ], [ in_port_t X ], [AC_DEFINE(HAVE_IN_PORT_T, 1)]) -AC_MSG_TRY_COMPILE(for sa_family_t, ftp_cv_HAVE_SA_FAMILY_T, [ +AC_MSG_TRY_COMPILE([for sa_family_t], ftp_cv_HAVE_SA_FAMILY_T, [ #include <sys/types.h> #include <sys/socket.h> ], [ sa_family_t X ], [AC_DEFINE(HAVE_SA_FAMILY_T, 1)]) -AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ftp_cv_HAVE_SOCKADDR_SA_LEN, [ +AC_MSG_TRY_COMPILE([for sockaddr_in.sin_len], ftp_cv_HAVE_SOCKADDR_SA_LEN, [ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -98,19 +98,20 @@ AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ftp_cv_HAVE_SOCKADDR_SA_LEN, [ int X = sin.sin_len ], [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1)]) -AC_MSG_TRY_COMPILE(for socklen_t, ftp_cv_HAVE_SOCKLEN_T, [ +AC_MSG_TRY_COMPILE([for socklen_t], ftp_cv_HAVE_SOCKLEN_T, [ #include <sys/types.h> #include <sys/socket.h> ], [ socklen_t X ], [AC_DEFINE(HAVE_SOCKLEN_T, 1)]) if test $opt_ipv6 = yes; then - AC_MSG_TRY_COMPILE(for AF_INET6, ftp_cv_HAVE_AF_INET6, [ + AC_MSG_TRY_COMPILE([for AF_INET6], ftp_cv_HAVE_AF_INET6, [ #include <sys/types.h> #include <sys/socket.h> ], [ int X = AF_INET6 ], [AC_DEFINE(HAVE_AF_INET6, 1)]) - AC_MSG_TRY_COMPILE(for struct sockaddr_in6, ftp_cv_HAVE_SOCKADDR_IN6, [ + AC_MSG_TRY_COMPILE([for struct sockaddr_in6], + ftp_cv_HAVE_SOCKADDR_IN6, [ #include <sys/types.h> #include <netinet/in.h> ], [ @@ -119,7 +120,7 @@ if test $opt_ipv6 = yes; then ], [AC_DEFINE(HAVE_SOCKADDR_IN6, 1)]) if test $ac_cv_header_arpa_nameser_h = yes; then - AC_MSG_TRY_COMPILE(for IN6ADDRSZ in arpa/nameser.h, + AC_MSG_TRY_COMPILE([for IN6ADDRSZ in arpa/nameser.h], ftp_cv_HAVE_IN6ADDRSZ, [ #include <sys/types.h> #include <arpa/nameser.h> @@ -128,13 +129,13 @@ if test $opt_ipv6 = yes; then fi -AC_MSG_TRY_COMPILE(for struct addrinfo, ftp_cv_HAVE_ADDRINFO, [ +AC_MSG_TRY_COMPILE([for struct addrinfo], ftp_cv_HAVE_ADDRINFO, [ #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> ], [ struct addrinfo X ], [AC_DEFINE(HAVE_ADDRINFO, 1)]) -AC_MSG_TRY_COMPILE(for d_namlen in struct dirent, ftp_cv_HAVE_D_NAMLEN, [ +AC_MSG_TRY_COMPILE([for d_namlen in struct dirent], ftp_cv_HAVE_D_NAMLEN, [ #if HAVE_DIRENT_H # include <dirent.h> #else @@ -154,30 +155,30 @@ AC_MSG_TRY_COMPILE(for d_namlen in struct dirent, ftp_cv_HAVE_D_NAMLEN, [ int X = dp.d_namlen; ], [AC_DEFINE(HAVE_D_NAMLEN, 1)]) -AC_MSG_TRY_COMPILE(for h_errno declaration, ftp_cv_HAVE_H_ERRNO_D, [ +AC_MSG_TRY_COMPILE([for h_errno declaration], ftp_cv_HAVE_H_ERRNO_D, [ #include <netdb.h> ], [ int X = h_errno ], [AC_DEFINE(HAVE_H_ERRNO_D, 1)]) -AC_MSG_TRY_COMPILE(for fclose() declaration, ftp_cv_HAVE_FCLOSE_D, [ +AC_MSG_TRY_COMPILE([for fclose() declaration], ftp_cv_HAVE_FCLOSE_D, [ #include <stdio.h> ], [ int (*X)() = fclose ], [AC_DEFINE(HAVE_FCLOSE_D, 1)]) -AC_MSG_TRY_COMPILE(for getpass() declaration, ftp_cv_HAVE_GETPASS_D, [ +AC_MSG_TRY_COMPILE([for getpass() declaration], ftp_cv_HAVE_GETPASS_D, [ #include <stdlib.h> #include <unistd.h> ], [ char *(*X)() = getpass ], [ AC_DEFINE(HAVE_GETPASS_D, 1)]) -AC_MSG_TRY_COMPILE(for optarg declaration, ftp_cv_HAVE_OPTARG_D, [ +AC_MSG_TRY_COMPILE([for optarg declaration], ftp_cv_HAVE_OPTARG_D, [ #include <stdlib.h> #include <unistd.h> ], [ char *X = optarg ], [AC_DEFINE(HAVE_OPTARG_D, 1)]) -AC_MSG_TRY_COMPILE(for optind declaration, ftp_cv_HAVE_OPTIND_D, [ +AC_MSG_TRY_COMPILE([for optind declaration], ftp_cv_HAVE_OPTIND_D, [ #include <stdlib.h> #include <unistd.h> ], [ int X = optind ], [AC_DEFINE(HAVE_OPTIND_D, 1)]) -AC_MSG_TRY_COMPILE(for pclose() declaration, ftp_cv_HAVE_PCLOSE_D, [ +AC_MSG_TRY_COMPILE([for pclose() declaration], ftp_cv_HAVE_PCLOSE_D, [ #include <stdio.h> ], [ int (*X)() = pclose ], [AC_DEFINE(HAVE_PCLOSE_D, 1)]) @@ -198,7 +199,8 @@ fi LIBOBJS="$LIBOBJS glob.o" if test $ac_cv_func_strptime = yes; then - AC_MSG_TRY_COMPILE(for strptime() declaration, ftp_cv_HAVE_STRPTIME_D, [ + AC_MSG_TRY_COMPILE([for strptime() declaration], + ftp_cv_HAVE_STRPTIME_D, [ #include <time.h> ], [ char *X = strptime("", "", NULL) @@ -252,40 +254,54 @@ int main() { fi -# handle Darwin 7 having a poll() compatibility function. be -# conservative, if we don't find one of poll.h or sys/poll.h, don't -# attempt to use poll(). -AC_CHECK_HEADERS([poll.h sys/poll.h]) - +dnl Handle Darwin 7 having a poll() compatibility function. +dnl Be conservative, if we don't find one of poll.h or sys/poll.h, +dnl don't attempt to use poll(). +dnl if test $ac_cv_header_poll_h = yes || test $ac_cv_header_sys_poll_h = yes; then AC_CHECK_FUNC(poll, AC_MSG_TRY_COMPILE([if poll() is implemented natively], - ftp_cv_POLL_NATIVE, - [ #if HAVE_POLL_H - #include <poll.h> - #endif - #if HAVE_SYS_POLL_H - #include <sys/poll.h> - #endif - ], - [ #ifdef _POLL_EMUL_H_ - #error "poll() is emulated" - #endif - ], - [AC_DEFINE(HAVE_POLL, 1)], [:]) + ftp_cv_POLL_NATIVE, [ +#if HAVE_POLL_H +#include <poll.h> +#endif +#if HAVE_SYS_POLL_H +#include <sys/poll.h> +#endif + ], [ +#ifdef _POLL_EMUL_H_ +#error "poll() is emulated" +#endif + ], [ AC_DEFINE(HAVE_POLL, 1)], [:]) ) + +dnl Detect if struct pollfd is present. +dnl +AC_MSG_TRY_COMPILE([for struct pollfd], ftp_cv_HAVE_STRUCT_POLLFD, [ +#if HAVE_POLL_H +#include <poll.h> +#endif +#if HAVE_SYS_POLL_H +#include <sys/poll.h> +#endif + ], [ struct pollfd X ], [ AC_DEFINE(HAVE_STRUCT_POLLFD, 1)], [:]) fi + if test $opt_editcomplete = yes; then if test $have_libedit = yes; then - AC_MSG_TRY_COMPILE(for EL_RPROMPT in libedit, + AC_MSG_TRY_COMPILE([for EL_RPROMPT in libedit], ftp_cv_have_libedit, [ #include <histedit.h> ], [ int X = EL_RPROMPT ], [:], have_libedit=no ) fi - AC_MSG_CHECKING(for working libedit) +dnl For now, assume libedit is not up-to-date and force own version. +dnl + have_libedit=no + + AC_MSG_CHECKING(for up-to-date libedit) if test $have_libedit = no; then AC_MSG_RESULT(no - using my own) INCLUDES="-I\${srcdir}/../libedit $INCLUDES" @@ -301,7 +317,7 @@ else fi if test $ac_cv_func_sl_init = yes; then - AC_MSG_TRY_COMPILE(if sl_add() returns int, ftp_cv_INT_SL_ADD, [ + AC_MSG_TRY_COMPILE([if sl_add() returns int], ftp_cv_INT_SL_ADD, [ #include <stringlist.h> ], [ int f = sl_add((StringList *)0, "foo") @@ -311,7 +327,7 @@ fi have_rfc2553_netdb=no if test $ac_cv_func_getaddrinfo = yes -a ! -n "$socks"; then - AC_MSG_TRY_COMPILE(for AI_NUMERICHOST, + AC_MSG_TRY_COMPILE([for AI_NUMERICHOST], ftp_cv_have_ai_numerichost, [ #include <sys/types.h> #include <sys/socket.h> @@ -333,7 +349,7 @@ fi if test $ac_cv_header_vis_h = yes; then - AC_MSG_TRY_COMPILE(for VIS_WHITE in vis.h, + AC_MSG_TRY_COMPILE([for VIS_WHITE in vis.h], ftp_cv_have_vis_white, [ #include <sys/types.h> #include <vis.h> diff --git a/net/tnftp/files/libedit/chared.h b/net/tnftp/files/libedit/chared.h index 315ee75d02a..963dc7a86d3 100644 --- a/net/tnftp/files/libedit/chared.h +++ b/net/tnftp/files/libedit/chared.h @@ -1,4 +1,4 @@ -/* $NetBSD: chared.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: chared.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp */ /*- diff --git a/net/tnftp/files/libedit/editrc.5 b/net/tnftp/files/libedit/editrc.5 index ea8bf8d80da..93879d6d2b7 100644 --- a/net/tnftp/files/libedit/editrc.5 +++ b/net/tnftp/files/libedit/editrc.5 @@ -1,4 +1,4 @@ -.\" $NetBSD: editrc.5,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ +.\" NetBSD: editrc.5,v 1.2 2005/05/11 01:17:39 lukem Exp .\" from NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp .\" .\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc. diff --git a/net/tnftp/files/libedit/el.h b/net/tnftp/files/libedit/el.h index 1918afd816a..6bc47e93c59 100644 --- a/net/tnftp/files/libedit/el.h +++ b/net/tnftp/files/libedit/el.h @@ -1,4 +1,4 @@ -/* $NetBSD: el.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: el.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp */ /*- diff --git a/net/tnftp/files/libedit/hist.h b/net/tnftp/files/libedit/hist.h index ba021db195a..3799ca1fb28 100644 --- a/net/tnftp/files/libedit/hist.h +++ b/net/tnftp/files/libedit/hist.h @@ -1,4 +1,4 @@ -/* $NetBSD: hist.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: hist.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/key.h b/net/tnftp/files/libedit/key.h index c4625fce43e..71f84a48bf0 100644 --- a/net/tnftp/files/libedit/key.h +++ b/net/tnftp/files/libedit/key.h @@ -1,4 +1,4 @@ -/* $NetBSD: key.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: key.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/makelist.in b/net/tnftp/files/libedit/makelist.in index 75a2407bd22..6c5321ae9e1 100644 --- a/net/tnftp/files/libedit/makelist.in +++ b/net/tnftp/files/libedit/makelist.in @@ -1,7 +1,7 @@ #!/bin/sh - # @configure_input@ # -# $NetBSD: makelist.in,v 1.1.1.3 2005/05/11 09:40:05 lukem Exp $ +# NetBSD: makelist.in,v 1.2 2005/01/05 04:40:05 lukem Exp # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. diff --git a/net/tnftp/files/libedit/map.h b/net/tnftp/files/libedit/map.h index 3a1eebf96f1..372a11d12bc 100644 --- a/net/tnftp/files/libedit/map.h +++ b/net/tnftp/files/libedit/map.h @@ -1,4 +1,4 @@ -/* $NetBSD: map.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: map.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/prompt.h b/net/tnftp/files/libedit/prompt.h index e7538cd5dfc..6e30674b8b9 100644 --- a/net/tnftp/files/libedit/prompt.h +++ b/net/tnftp/files/libedit/prompt.h @@ -1,4 +1,4 @@ -/* $NetBSD: prompt.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: prompt.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/read.h b/net/tnftp/files/libedit/read.h index 20739c32f69..dc4bcff5274 100644 --- a/net/tnftp/files/libedit/read.h +++ b/net/tnftp/files/libedit/read.h @@ -1,4 +1,4 @@ -/* $NetBSD: read.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: read.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp */ /*- diff --git a/net/tnftp/files/libedit/readline/Makefile b/net/tnftp/files/libedit/readline/Makefile deleted file mode 100644 index f5e52005f9b..00000000000 --- a/net/tnftp/files/libedit/readline/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2004/03/11 13:01:01 grant Exp $ - -.PATH: ${CURDIR}/.. - -INCS= readline.h -INCSDIR= /usr/include/readline -SYMLINKS= readline.h ${INCSDIR}/history.h - -NOOBJ= # defined - -incinstall:: linksinstall - -.include <bsd.prog.mk> diff --git a/net/tnftp/files/libedit/refresh.h b/net/tnftp/files/libedit/refresh.h index 8fc1209b507..f8bfdbc9cd9 100644 --- a/net/tnftp/files/libedit/refresh.h +++ b/net/tnftp/files/libedit/refresh.h @@ -1,4 +1,4 @@ -/* $NetBSD: refresh.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: refresh.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: refresh.h,v 1.5 2003/08/07 16:44:33 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/search.h b/net/tnftp/files/libedit/search.h index 1c0f6fe34f4..f8b90284281 100644 --- a/net/tnftp/files/libedit/search.h +++ b/net/tnftp/files/libedit/search.h @@ -1,4 +1,4 @@ -/* $NetBSD: search.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: search.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: search.h,v 1.8 2003/10/18 23:27:36 christos Exp */ /*- diff --git a/net/tnftp/files/libedit/sig.h b/net/tnftp/files/libedit/sig.h index 774188b2c8a..e478d64cfbe 100644 --- a/net/tnftp/files/libedit/sig.h +++ b/net/tnftp/files/libedit/sig.h @@ -1,4 +1,4 @@ -/* $NetBSD: sig.h,v 1.1.1.3 2005/05/11 09:17:39 lukem Exp $ */ +/* NetBSD: sig.h,v 1.2 2005/05/11 01:17:39 lukem Exp */ /* from NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp */ /*- diff --git a/net/tnftp/files/libedit/tokenizer.h b/net/tnftp/files/libedit/tokenizer.h deleted file mode 100644 index e20c79af68f..00000000000 --- a/net/tnftp/files/libedit/tokenizer.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: tokenizer.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Christos Zoulas of Cornell University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)tokenizer.h 8.1 (Berkeley) 6/4/93 - */ - -/* - * tokenizer.h: Header file for tokenizer routines - */ -#ifndef _h_tokenizer -#define _h_tokenizer - -typedef struct tokenizer Tokenizer; - -Tokenizer *tok_init(const char *); -void tok_reset(Tokenizer *); -void tok_end(Tokenizer *); -int tok_line(Tokenizer *, const char *, int *, const char ***); - -#endif /* _h_tokenizer */ diff --git a/net/tnftp/files/libnetbsd/err.c b/net/tnftp/files/libnetbsd/err.c index 2683ae841ba..64004688c56 100644 --- a/net/tnftp/files/libnetbsd/err.c +++ b/net/tnftp/files/libnetbsd/err.c @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.1.1.3 2005/05/11 09:01:56 lukem Exp $ */ +/* NetBSD: err.c,v 1.4 2005/05/11 01:01:56 lukem Exp */ /* * Copyright 1997-2000 Luke Mewburn <lukem@NetBSD.org>. diff --git a/net/tnftp/files/libnetbsd/fseeko.c b/net/tnftp/files/libnetbsd/fseeko.c index 3c4bc7881d1..e6752d7469f 100644 --- a/net/tnftp/files/libnetbsd/fseeko.c +++ b/net/tnftp/files/libnetbsd/fseeko.c @@ -1,4 +1,4 @@ -/* $NetBSD: fseeko.c,v 1.1.1.3 2005/05/11 09:01:56 lukem Exp $ */ +/* NetBSD: fseeko.c,v 1.4 2005/05/11 01:01:56 lukem Exp */ /* * Copyright 2002 Luke Mewburn <lukem@NetBSD.org>. diff --git a/net/tnftp/files/libnetbsd/setprogname.c b/net/tnftp/files/libnetbsd/setprogname.c index 3e7404bc746..6e60d5d22ae 100644 --- a/net/tnftp/files/libnetbsd/setprogname.c +++ b/net/tnftp/files/libnetbsd/setprogname.c @@ -1,4 +1,4 @@ -/* $NetBSD: setprogname.c,v 1.1.1.3 2005/05/11 09:01:56 lukem Exp $ */ +/* NetBSD: setprogname.c,v 1.3 2005/05/11 01:01:56 lukem Exp */ /* from NetBSD: setprogname.c,v 1.3 2002/01/31 19:21:58 tv Exp */ /*- diff --git a/net/tnftp/files/libnetbsd/strerror.c b/net/tnftp/files/libnetbsd/strerror.c index 1aa64b5371b..7d610c042fa 100644 --- a/net/tnftp/files/libnetbsd/strerror.c +++ b/net/tnftp/files/libnetbsd/strerror.c @@ -1,4 +1,4 @@ -/* $NetBSD: strerror.c,v 1.1.1.3 2005/05/11 09:01:56 lukem Exp $ */ +/* NetBSD: strerror.c,v 1.3 2005/05/11 01:01:56 lukem Exp */ #include "tnftp.h" diff --git a/net/tnftp/files/libnetbsd/timegm.c b/net/tnftp/files/libnetbsd/timegm.c index 5ae2c409ab0..094f8d1aaee 100644 --- a/net/tnftp/files/libnetbsd/timegm.c +++ b/net/tnftp/files/libnetbsd/timegm.c @@ -1,4 +1,4 @@ -/* $NetBSD: timegm.c,v 1.1.1.3 2005/05/11 09:01:56 lukem Exp $ */ +/* NetBSD: timegm.c,v 1.3 2005/05/11 01:01:56 lukem Exp */ /* from ? */ #include "tnftp.h" diff --git a/net/tnftp/files/libnetbsd/utimes.c b/net/tnftp/files/libnetbsd/utimes.c index 96badf51955..eedc89dbc93 100644 --- a/net/tnftp/files/libnetbsd/utimes.c +++ b/net/tnftp/files/libnetbsd/utimes.c @@ -1,4 +1,4 @@ -/* $NetBSD: utimes.c,v 1.2 2004/03/11 13:51:07 grant Exp $ */ +/* NetBSD: utimes.c,v 1.3 2005/05/11 01:01:56 lukem Exp */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. diff --git a/net/tnftp/files/src/cmds.c b/net/tnftp/files/src/cmds.c index 104966639f0..96f931b8fde 100644 --- a/net/tnftp/files/src/cmds.c +++ b/net/tnftp/files/src/cmds.c @@ -1,4 +1,5 @@ -/* $NetBSD: cmds.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: cmds.c,v 1.6 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: cmds.c,v 1.112 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. @@ -72,7 +73,7 @@ /* * Copyright (C) 1997 and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -84,7 +85,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -104,7 +105,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: cmds.c,v 1.6 2005/05/11 02:41:28 lukem Exp"); #endif #endif /* not lint */ #endif @@ -137,6 +138,11 @@ const char *mname; static int confirm(const char *, const char *); +static const char *doprocess(char *, size_t, const char *, int, int, int); +static const char *domap(char *, size_t, const char *); +static const char *docase(char *, size_t, const char *); +static const char *dotrans(char *, size_t, const char *); + static int confirm(const char *cmd, const char *file) { @@ -378,9 +384,11 @@ setstruct(int argc, char *argv[]) void put(int argc, char *argv[]) { + char buf[MAXPATHLEN]; char *cmd; int loc = 0; - char *locfile, *remfile; + char *locfile; + const char *remfile; if (argc == 2) { argc++; @@ -404,15 +412,26 @@ put(int argc, char *argv[]) if (loc) /* If argv[2] is a copy of the old argv[1], update it */ remfile = locfile; cmd = (argv[0][0] == 'a') ? "APPE" : ((sunique) ? "STOU" : "STOR"); - if (loc && ntflag) - remfile = dotrans(remfile); - if (loc && mapflag) - remfile = domap(remfile); + remfile = doprocess(buf, sizeof(buf), remfile, + 0, loc && ntflag, loc && mapflag); sendrequest(cmd, locfile, remfile, locfile != argv[1] || remfile != argv[2]); free(locfile); } +static const char * +doprocess(char *dst, size_t dlen, const char *src, + int casef, int transf, int mapf) +{ + if (casef) + src = docase(dst, dlen, src); + if (transf) + src = dotrans(dst, dlen, src); + if (mapf) + src = domap(dst, dlen, src); + return src; +} + /* * Send multiple files. */ @@ -422,7 +441,7 @@ mput(int argc, char *argv[]) int i; sigfunc oldintr; int ointer; - char *tp; + const char *tp; if (argc == 0 || (argc == 1 && !another(&argc, &argv, "local-files"))) { fprintf(ttyout, "usage: %s local-files\n", argv[0]); @@ -443,13 +462,9 @@ mput(int argc, char *argv[]) continue; } if (mflag && confirm(argv[0], cp)) { - tp = cp; - if (mcase) - tp = docase(tp); - if (ntflag) - tp = dotrans(tp); - if (mapflag) - tp = domap(tp); + char buf[MAXPATHLEN]; + tp = doprocess(buf, sizeof(buf), cp, + mcase, ntflag, mapflag); sendrequest((sunique) ? "STOU" : "STOR", cp, tp, cp != tp || !interactive); if (!mflag && fromatty) { @@ -471,8 +486,9 @@ mput(int argc, char *argv[]) if (!doglob) { if (mflag && confirm(argv[0], argv[i])) { - tp = (ntflag) ? dotrans(argv[i]) : argv[i]; - tp = (mapflag) ? domap(tp) : tp; + char buf[MAXPATHLEN]; + tp = doprocess(buf, sizeof(buf), argv[i], + 0, ntflag, mapflag); sendrequest((sunique) ? "STOU" : "STOR", argv[i], tp, tp != argv[i] || !interactive); if (!mflag && fromatty) { @@ -497,8 +513,10 @@ mput(int argc, char *argv[]) for (cpp = gl.gl_pathv; cpp && *cpp != NULL && connected; cpp++) { if (mflag && confirm(argv[0], *cpp)) { - tp = (ntflag) ? dotrans(*cpp) : *cpp; - tp = (mapflag) ? domap(tp) : tp; + char buf[MAXPATHLEN]; + tp = *cpp; + tp = doprocess(buf, sizeof(buf), *cpp, + 0, ntflag, mapflag); sendrequest((sunique) ? "STOU" : "STOR", *cpp, tp, *cpp != tp || !interactive); if (!mflag && fromatty) { @@ -540,8 +558,10 @@ get(int argc, char *argv[]) int getit(int argc, char *argv[], int restartit, const char *mode) { - int loc, rval; - char *remfile, *locfile, *olocfile; + int loc, rval; + char *remfile, *olocfile; + const char *locfile; + char buf[MAXPATHLEN]; loc = rval = 0; if (argc == 2) { @@ -563,13 +583,8 @@ getit(int argc, char *argv[], int restartit, const char *mode) code = -1; return (0); } - locfile = olocfile; - if (loc && mcase) - locfile = docase(locfile); - if (loc && ntflag) - locfile = dotrans(locfile); - if (loc && mapflag) - locfile = domap(locfile); + locfile = doprocess(buf, sizeof(buf), olocfile, + loc && mcase, loc && ntflag, loc && mapflag); if (restartit) { struct stat stbuf; int ret; @@ -649,7 +664,8 @@ mget(int argc, char *argv[]) { sigfunc oldintr; int ointer; - char *cp, *tp; + char *cp; + const char *tp; int restartit; if (argc == 0 || @@ -674,6 +690,7 @@ mget(int argc, char *argv[]) if (sigsetjmp(jabort, 1)) mabort(); while ((cp = remglob(argv, proxy, NULL)) != NULL) { + char buf[MAXPATHLEN]; if (*cp == '\0' || !connected) { mflag = 0; continue; @@ -687,13 +704,7 @@ mget(int argc, char *argv[]) } if (!confirm(argv[0], cp)) continue; - tp = cp; - if (mcase) - tp = docase(tp); - if (ntflag) - tp = dotrans(tp); - if (mapflag) - tp = domap(tp); + tp = doprocess(buf, sizeof(buf), cp, mcase, ntflag, mapflag); if (restartit) { struct stat stbuf; @@ -1376,7 +1387,7 @@ mls(int argc, char *argv[]) ointer = interactive; interactive = 1; if (confirm("Continue with", argv[0])) { - mflag ++; + mflag++; } interactive = ointer; } @@ -1666,7 +1677,7 @@ do_chmod(int argc, char *argv[]) (void)command("SITE CHMOD %s %s", argv[1], argv[2]); } -#define COMMAND_1ARG(argc, argv, cmd) \ +#define COMMAND_1ARG(argc, argv, cmd) \ if (argc == 1) \ command(cmd); \ else \ @@ -1868,26 +1879,25 @@ setcase(int argc, char *argv[]) * convert the given name to lower case if it's all upper case, into * a static buffer which is returned to the caller */ -char * -docase(char *name) +static const char * +docase(char *dst, size_t dlen, const char *src) { - static char new[MAXPATHLEN]; - int i, dochange; + size_t i; + int dochange = 1; - dochange = 1; - for (i = 0; name[i] != '\0' && i < sizeof(new) - 1; i++) { - new[i] = name[i]; - if (islower((unsigned char)new[i])) + for (i = 0; src[i] != '\0' && i < dlen - 1; i++) { + dst[i] = src[i]; + if (islower((unsigned char)dst[i])) dochange = 0; } - new[i] = '\0'; + dst[i] = '\0'; if (dochange) { - for (i = 0; new[i] != '\0'; i++) - if (isupper((unsigned char)new[i])) - new[i] = tolower((unsigned char)new[i]); + for (i = 0; dst[i] != '\0'; i++) + if (isupper((unsigned char)dst[i])) + dst[i] = tolower((unsigned char)dst[i]); } - return (new); + return dst; } void @@ -1922,22 +1932,24 @@ setntrans(int argc, char *argv[]) (void)strlcpy(ntout, argv[2], sizeof(ntout)); } -char * -dotrans(char *name) +static const char * +dotrans(char *dst, size_t dlen, const char *src) { - static char new[MAXPATHLEN]; - char *cp1, *cp2 = new; - int i, ostop, found; + const char *cp1; + char *cp2 = dst; + size_t i, ostop; for (ostop = 0; *(ntout + ostop) && ostop < 16; ostop++) continue; - for (cp1 = name; *cp1; cp1++) { - found = 0; + for (cp1 = src; *cp1; cp1++) { + int found = 0; for (i = 0; *(ntin + i) && i < 16; i++) { if (*cp1 == *(ntin + i)) { found++; if (i < ostop) { *cp2++ = *(ntout + i); + if (cp2 - dst >= dlen - 1) + goto out; } break; } @@ -1946,8 +1958,9 @@ dotrans(char *name) *cp2++ = *cp1; } } +out: *cp2 = '\0'; - return (new); + return dst; } void @@ -1983,12 +1996,12 @@ setnmap(int argc, char *argv[]) (void)strlcpy(mapout, cp, MAXPATHLEN); } -char * -domap(char *name) +static const char * +domap(char *dst, size_t dlen, const char *src) { - static char new[MAXPATHLEN]; - char *cp1 = name, *cp2 = mapin; - char *tp[9], *te[9]; + const char *cp1 = src; + char *cp2 = mapin; + const char *tp[9], *te[9]; int i, toks[9], toknum = 0, match = 1; for (i=0; i < 9; ++i) { @@ -2031,130 +2044,127 @@ domap(char *name) { toks[toknum] = 0; } - cp1 = new; - *cp1 = '\0'; - cp2 = mapout; - while (*cp2) { + cp2 = dst; + *cp2 = '\0'; + cp1 = mapout; + while (*cp1) { match = 0; - switch (*cp2) { + switch (*cp1) { case '\\': - if (*(cp2 + 1)) { - *cp1++ = *++cp2; + if (*(cp1 + 1)) { + *cp2++ = *++cp1; } break; case '[': LOOP: - if (*++cp2 == '$' && - isdigit((unsigned char)*(cp2+1))) { - if (*++cp2 == '0') { - char *cp3 = name; + if (*++cp1 == '$' && + isdigit((unsigned char)*(cp1+1))) { + if (*++cp1 == '0') { + const char *cp3 = src; while (*cp3) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } match = 1; } - else if (toks[toknum = *cp2 - '1']) { - char *cp3 = tp[toknum]; + else if (toks[toknum = *cp1 - '1']) { + const char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } match = 1; } } else { - while (*cp2 && *cp2 != ',' && - *cp2 != ']') { - if (*cp2 == '\\') { - cp2++; + while (*cp1 && *cp1 != ',' && + *cp1 != ']') { + if (*cp1 == '\\') { + cp1++; } - else if (*cp2 == '$' && - isdigit((unsigned char)*(cp2+1))) { - if (*++cp2 == '0') { - char *cp3 = name; + else if (*cp1 == '$' && + isdigit((unsigned char)*(cp1+1))) { + if (*++cp1 == '0') { + const char *cp3 = src; while (*cp3) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } } else if (toks[toknum = - *cp2 - '1']) { - char *cp3=tp[toknum]; + *cp1 - '1']) { + const char *cp3=tp[toknum]; while (cp3 != te[toknum]) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } } } - else if (*cp2) { - *cp1++ = *cp2++; + else if (*cp1) { + *cp2++ = *cp1++; } } - if (!*cp2) { + if (!*cp1) { fputs( "nmap: unbalanced brackets.\n", ttyout); - return (name); + return (src); } match = 1; - cp2--; + cp1--; } if (match) { - while (*++cp2 && *cp2 != ']') { - if (*cp2 == '\\' && *(cp2 + 1)) { - cp2++; + while (*++cp1 && *cp1 != ']') { + if (*cp1 == '\\' && *(cp1 + 1)) { + cp1++; } } - if (!*cp2) { + if (!*cp1) { fputs( "nmap: unbalanced brackets.\n", ttyout); - return (name); + return (src); } break; } - switch (*++cp2) { + switch (*++cp1) { case ',': goto LOOP; case ']': break; default: - cp2--; + cp1--; goto LOOP; } break; case '$': - if (isdigit((unsigned char)*(cp2 + 1))) { - if (*++cp2 == '0') { - char *cp3 = name; + if (isdigit((unsigned char)*(cp1 + 1))) { + if (*++cp1 == '0') { + const char *cp3 = src; while (*cp3) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } } - else if (toks[toknum = *cp2 - '1']) { - char *cp3 = tp[toknum]; + else if (toks[toknum = *cp1 - '1']) { + const char *cp3 = tp[toknum]; while (cp3 != te[toknum]) { - *cp1++ = *cp3++; + *cp2++ = *cp3++; } } break; } /* intentional drop through */ default: - *cp1++ = *cp2; + *cp2++ = *cp1; break; } - cp2++; - } - *cp1 = '\0'; - if (!*new) { - return (name); + cp1++; } - return (new); + *cp2 = '\0'; + return *dst ? dst : src; } void diff --git a/net/tnftp/files/src/cmdtab.c b/net/tnftp/files/src/cmdtab.c index 4b0aaa3ad93..9f52b0d012d 100644 --- a/net/tnftp/files/src/cmdtab.c +++ b/net/tnftp/files/src/cmdtab.c @@ -1,4 +1,5 @@ -/* $NetBSD: cmdtab.c,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: cmdtab.c,v 1.5 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1996-2000 The NetBSD Foundation, Inc. @@ -65,6 +66,17 @@ * SUCH DAMAGE. */ +#if 0 +#include <sys/cdefs.h> +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94"; +#else +__RCSID("NetBSD: cmdtab.c,v 1.5 2005/05/11 02:41:28 lukem Exp"); +#endif +#endif /* not lint */ +#endif + #include "tnftp.h" #include "ftp_var.h" @@ -180,7 +192,7 @@ HSTR empty[] = ""; #define CMPL0 #else /* !NO_EDITCOMPLETE */ #define CMPL(x) #x, -#define CMPL0 empty, +#define CMPL0 empty, #endif /* !NO_EDITCOMPLETE */ struct cmd cmdtab[] = { diff --git a/net/tnftp/files/src/domacro.c b/net/tnftp/files/src/domacro.c index b35156435d6..27c7657de89 100644 --- a/net/tnftp/files/src/domacro.c +++ b/net/tnftp/files/src/domacro.c @@ -1,4 +1,5 @@ -/* $NetBSD: domacro.c,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: domacro.c,v 1.4 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp */ /* * Copyright (c) 1985, 1993, 1994 @@ -29,6 +30,17 @@ * SUCH DAMAGE. */ +#if 0 +#include <sys/cdefs.h> +#ifndef lint +#if 0 +static char sccsid[] = "@(#)domacro.c 8.3 (Berkeley) 4/2/94"; +#else +__RCSID("NetBSD: domacro.c,v 1.4 2005/05/11 02:41:28 lukem Exp"); +#endif +#endif /* not lint */ +#endif + #include "tnftp.h" #include "ftp_var.h" diff --git a/net/tnftp/files/src/extern.h b/net/tnftp/files/src/extern.h index de9b36a0df7..2998cd68fbe 100644 --- a/net/tnftp/files/src/extern.h +++ b/net/tnftp/files/src/extern.h @@ -1,4 +1,5 @@ -/* $NetBSD: extern.h,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: extern.h,v 1.5 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: extern.h,v 1.66 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. @@ -70,7 +71,7 @@ /* * Copyright (C) 1997 and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -82,7 +83,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -129,11 +130,8 @@ void delete(int, char **); void disconnect(int, char **); void do_chmod(int, char **); void do_umask(int, char **); -char *docase(char *); void domacro(int, char **); -char *domap(char *); void doproxy(int, char **); -char *dotrans(char *); void feat(int, char **); void fget(int, char **); int fileindir(const char *, const char *); @@ -253,6 +251,7 @@ void usage(void); void user(int, char **); int xconnect(int, const struct sockaddr *, int); int xlisten(int, int); +int xpoll(struct pollfd *, int, int); void *xmalloc(size_t); StringList *xsl_init(void); void xsl_add(StringList *, char *); diff --git a/net/tnftp/files/src/fetch.c b/net/tnftp/files/src/fetch.c index 08cb08ca72d..b835808ca76 100644 --- a/net/tnftp/files/src/fetch.c +++ b/net/tnftp/files/src/fetch.c @@ -1,4 +1,5 @@ -/* $NetBSD: fetch.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: fetch.c,v 1.7 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: fetch.c,v 1.157 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -42,7 +43,7 @@ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: fetch.c,v 1.7 2005/05/11 02:41:28 lukem Exp"); #endif /* not lint */ #endif @@ -714,7 +715,6 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) /* success */ break; } - freeaddrinfo(res0); if (s < 0) { warn("Can't connect to %s", host); @@ -956,7 +956,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) || match_token(&cp, "WWW-Authenticate:")) { if (! (token = match_token(&cp, "Basic"))) { if (debug) - fprintf(ttyout, + fprintf(ttyout, "skipping unknown auth scheme `%s'\n", token); continue; @@ -1257,6 +1257,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth) close(s); if (closefunc != NULL && fout != NULL) (*closefunc)(fout); + if (res0) + freeaddrinfo(res0); FREEPTR(savefile); FREEPTR(user); FREEPTR(pass); @@ -1397,7 +1399,7 @@ fetch_ftp(const char *url) } else dir = NULL; if (urltype == FTP_URL_T && file != NULL) { - url_decode(file); + url_decode(file); /* but still don't url_decode(dir) */ } if (debug) @@ -1578,7 +1580,10 @@ fetch_ftp(const char *url) ointeractive = interactive; interactive = 0; - xargv[0] = "mget"; + if (restartautofetch) + xargv[0] = "mreget"; + else + xargv[0] = "mget"; mget(xargc, xargv); interactive = ointeractive; } else { @@ -1775,7 +1780,7 @@ auto_put(int argc, char **argv, const char *uploadserver) pathsep++; uargv[2] = xstrdup(pathsep); pathsep[0] = '/'; - } else + } else uargv[2] = xstrdup(pathsep + 1); pathsep[1] = '\0'; uargc++; @@ -1784,8 +1789,8 @@ auto_put(int argc, char **argv, const char *uploadserver) if (debug) fprintf(ttyout, "auto_put: URL `%s' argv[2] `%s'\n", path, uargv[2] ? uargv[2] : "<null>"); - - /* connect and cwd */ + + /* connect and cwd */ rval = auto_fetch(1, &path); free(path); if(rval >= 0) @@ -1799,7 +1804,7 @@ auto_put(int argc, char **argv, const char *uploadserver) } for(; argv[0] != NULL; argv++) { - uargv[1] = argv[0]; + uargv[1] = argv[0]; mput(uargc, uargv); } rval = 0; diff --git a/net/tnftp/files/src/ftp.1 b/net/tnftp/files/src/ftp.1 index 7e1b567253c..eda2f1d7015 100644 --- a/net/tnftp/files/src/ftp.1 +++ b/net/tnftp/files/src/ftp.1 @@ -1,6 +1,7 @@ -.\" $NetBSD: ftp.1,v 1.2 2005/01/04 23:44:24 lukem Exp $ +.\" NetBSD: ftp.1,v 1.7 2005/05/11 02:41:28 lukem Exp +.\" from NetBSD: ftp.1,v 1.109 2005/02/20 20:54:01 wiz Exp .\" -.\" Copyright (c) 1996-2003 The NetBSD Foundation, Inc. +.\" Copyright (c) 1996-2004 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation @@ -64,7 +65,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd October 7, 2004 +.Dd January 15, 2005 .Dt FTP 1 .Os .Sh NAME @@ -951,7 +952,9 @@ traffic. .Tn FTP servers are required to support the .Dv PASV -command by RFC 1123, some do not.) +command by +.Li RFC 1123 , +some do not.) .It Ic pdir Op Ar remote-path Perform .Ic dir @@ -1563,7 +1566,7 @@ ascii or binary (respectively). The default transfer type is binary. .Pp In order to be compliant with -.Cm RFC 1738 , +.Li RFC 1738 , .Nm interprets the .Ar path @@ -1614,7 +1617,10 @@ This is unlikely to be useful. .It Any .Sq Li \&% Ns Ar XX -codes within the path components are decoded, with +codes +(per +.Li RFC 1738 ) +within the path components are decoded, with .Ar XX representing a character code in hexadecimal. This decoding takes place after the @@ -2222,9 +2228,9 @@ URL requests .Tn FTP protocol). .Pp -.Em NOTE : -this is not used for interactive sessions, only for command-line -fetches. +See +.Ev http_proxy +for further notes about proxy use. .It Ev http_proxy URL of .Tn HTTP @@ -2235,6 +2241,18 @@ If proxy authentication is required and there is a username and password in this URL, they will automatically be used in the first attempt to authenticate to the proxy. .Pp +If +.Dq unsafe +URL characters are required in the username or password +(for example +.Sq @ +or +.Sq / ) , +encode them with +.Li RFC 1738 +.Sq Li \&% Ns Ar XX +encoding. +.Pp Note that the use of a username and password in .Ev ftp_proxy and @@ -2275,13 +2293,13 @@ for an example of how to make this automatic. .Sh STANDARDS .Nm attempts to be compliant with -.Cm RFC 959 , -.Cm RFC 1123 , -.Cm RFC 1738 , -.Cm RFC 2068 , -.Cm RFC 2389 , -.Cm RFC 2428 , -.Cm RFC 2732 , +.Li RFC 959 , +.Li RFC 1123 , +.Li RFC 1738 , +.Li RFC 2068 , +.Li RFC 2389 , +.Li RFC 2428 , +.Li RFC 2732 , and .Cm draft-ietf-ftpext-mlst-11 . .Sh HISTORY diff --git a/net/tnftp/files/src/ftp.c b/net/tnftp/files/src/ftp.c index f76cb2e3400..5481da0c31a 100644 --- a/net/tnftp/files/src/ftp.c +++ b/net/tnftp/files/src/ftp.c @@ -1,7 +1,8 @@ -/* $NetBSD: ftp.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: ftp.c,v 1.6 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: ftp.c,v 1.130 2005/05/11 02:29:12 lukem Exp */ /*- - * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -68,7 +69,7 @@ /* * Copyright (C) 1997 and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -80,7 +81,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -102,7 +103,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: ftp.c,v 1.6 2005/05/11 02:41:28 lukem Exp"); #endif #endif /* not lint */ #endif @@ -151,6 +152,7 @@ hookup(char *host, char *port) char hbuf[MAXHOSTNAMELEN]; static char hostnamebuf[MAXHOSTNAMELEN]; char *cause = "unknown"; + int on = 1; memset((char *)&hisctladdr, 0, sizeof (hisctladdr)); memset((char *)&myctladdr, 0, sizeof (myctladdr)); @@ -173,7 +175,7 @@ hookup(char *host, char *port) else (void)strlcpy(hostnamebuf, host, sizeof(hostnamebuf)); hostname = hostnamebuf; - + for (res = res0; res; res = res->ai_next) { /* * make sure that ai_addr is NOT an IPv4 mapped address. @@ -252,10 +254,12 @@ hookup(char *host, char *port) #ifdef IPTOS_LOWDELAY if (hisctladdr.su_family == AF_INET) { int tos = IPTOS_LOWDELAY; - if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, - sizeof(int)) < 0) + if (setsockopt(s, IPPROTO_IP, IP_TOS, + (void *)&tos, sizeof(int)) == -1) { if (debug) - warn("setsockopt TOS (ignored)"); + warn("setsockopt %s (ignored)", + "IPTOS_LOWDELAY"); + } } #endif cin = fdopen(s, "r"); @@ -279,13 +283,11 @@ hookup(char *host, char *port) code = -1; goto bad; } - { - int on = 1; - if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)) - < 0 && debug) { - warn("setsockopt"); - } + if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, + (void *)&on, sizeof(on)) == -1) { + if (debug) + warn("setsockopt %s (ignored)", "SO_OOBINLINE"); } return (hostname); @@ -519,39 +521,10 @@ getreply(int expecteof) static int empty(FILE *cin, FILE *din, int sec) { - int nr; - int nfd = 0; - -#ifdef USE_SELECT - struct timeval t; - fd_set rmask; - - FD_ZERO(&rmask); - if (cin) { - if (nfd < fileno(cin)) - nfd = fileno(cin); - FD_SET(fileno(cin), &rmask); - } - if (din) { - if (nfd < fileno(din)) - nfd = fileno(din); - FD_SET(fileno(din), &rmask); - } - - t.tv_sec = (long) sec; - t.tv_usec = 0; - if ((nr = select(nfd, &rmask, NULL, NULL, &t)) <= 0) - return nr; - - nr = 0; - if (cin) - nr |= FD_ISSET(fileno(cin), &rmask) ? 1 : 0; - if (din) - nr |= FD_ISSET(fileno(din), &rmask) ? 2 : 0; - -#else - struct pollfd pfd[2]; + int nr, nfd; + struct pollfd pfd[2]; + nfd = 0; if (cin) { pfd[nfd].fd = fileno(cin); pfd[nfd++].events = POLLIN; @@ -562,7 +535,7 @@ empty(FILE *cin, FILE *din, int sec) pfd[nfd++].events = POLLIN; } - if ((nr = poll(pfd, nfd, sec * 1000)) <= 0) + if ((nr = xpoll(pfd, nfd, sec * 1000)) <= 0) return nr; nr = 0; @@ -571,7 +544,6 @@ empty(FILE *cin, FILE *din, int sec) nr |= (pfd[nfd++].revents & POLLIN) ? 1 : 0; if (din) nr |= (pfd[nfd++].revents & POLLIN) ? 2 : 0; -#endif return nr; } @@ -1304,15 +1276,16 @@ initconn(void) return (1); } if ((options & SO_DEBUG) && - setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, - sizeof(on)) < 0) + setsockopt(data, SOL_SOCKET, SO_DEBUG, + (void *)&on, sizeof(on)) == -1) { if (debug) - warn("setsockopt (ignored)"); + warn("setsockopt %s (ignored)", "SO_DEBUG"); + } result = COMPLETE + 1; switch (data_addr.su_family) { case AF_INET: if (epsv4 && !epsv4bad) { - pasvcmd = "EPSV"; + pasvcmd = "EPSV"; result = command("EPSV"); if (!connected) return (1); @@ -1335,7 +1308,7 @@ initconn(void) } } if (result != COMPLETE) { - pasvcmd = "PASV"; + pasvcmd = "PASV"; result = command("PASV"); if (!connected) return (1); @@ -1343,7 +1316,7 @@ initconn(void) break; #ifdef INET6 case AF_INET6: - pasvcmd = "EPSV"; + pasvcmd = "EPSV"; result = command("EPSV"); if (!connected) return (1); @@ -1541,10 +1514,12 @@ initconn(void) #ifdef IPTOS_THROUGHPUT if (data_addr.su_family == AF_INET) { on = IPTOS_THROUGHPUT; - if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, - sizeof(int)) < 0) + if (setsockopt(data, IPPROTO_IP, IP_TOS, + (void *)&on, sizeof(int)) == -1) { if (debug) - warn("setsockopt TOS (ignored)"); + warn("setsockopt %s (ignored)", + "IPTOS_THROUGHPUT"); + } } #endif return (0); @@ -1564,9 +1539,9 @@ initconn(void) return (1); } if (!sendport) - if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, (char *)&on, - sizeof(on)) < 0) { - warn("setsockopt (reuse address)"); + if (setsockopt(data, SOL_SOCKET, SO_REUSEADDR, + (void *)&on, sizeof(on)) == -1) { + warn("setsockopt %s", "SO_REUSEADDR"); goto bad; } if (bind(data, (struct sockaddr *)&data_addr.si_su, @@ -1574,11 +1549,12 @@ initconn(void) warn("bind"); goto bad; } - if (options & SO_DEBUG && - setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, - sizeof(on)) < 0) + if ((options & SO_DEBUG) && + setsockopt(data, SOL_SOCKET, SO_DEBUG, + (void *)&on, sizeof(on)) == -1) { if (debug) - warn("setsockopt (ignored)"); + warn("setsockopt %s (ignored)", "SO_DEBUG"); + } len = sizeof(data_addr.si_su); memset((char *)&data_addr, 0, sizeof (data_addr)); if (getsockname(data, (struct sockaddr *)&data_addr.si_su, &len) < 0) { @@ -1663,7 +1639,7 @@ initconn(void) if (!connected) return (1); skip_port: - + if (result == ERROR && sendport == -1) { sendport = 0; tmpno = 1; @@ -1676,15 +1652,17 @@ initconn(void) #ifdef IPTOS_THROUGHPUT if (data_addr.su_family == AF_INET) { on = IPTOS_THROUGHPUT; - if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, - sizeof(int)) < 0) + if (setsockopt(data, IPPROTO_IP, IP_TOS, + (void *)&on, sizeof(int)) == -1) if (debug) - warn("setsockopt TOS (ignored)"); + warn("setsockopt %s (ignored)", + "IPTOS_THROUGHPUT"); } #endif return (0); bad: - (void)close(data), data = -1; + (void)close(data); + data = -1; if (tmpno) sendport = 1; return (1); @@ -1693,31 +1671,78 @@ initconn(void) FILE * dataconn(const char *lmode) { - struct sockinet from; - int s, fromlen = myctladdr.su_len; + struct sockinet from; + int s, fromlen, flags, rv, timeout; + struct timeval endtime, now, td; + struct pollfd pfd[1]; - if (passivemode) + if (passivemode) /* passive data connection */ return (fdopen(data, lmode)); - s = accept(data, (struct sockaddr *) &from.si_su, &fromlen); - if (s < 0) { + /* active mode data connection */ + + if ((flags = fcntl(data, F_GETFL, 0)) == -1) + goto dataconn_failed; /* get current socket flags */ + if (fcntl(data, F_SETFL, flags | O_NONBLOCK) == -1) + goto dataconn_failed; /* set non-blocking connect */ + + /* NOTE: we now must restore socket flags on successful exit */ + + /* limit time waiting on listening socket */ + pfd[0].fd = data; + pfd[0].events = POLLIN; + (void)gettimeofday(&endtime, NULL); /* determine end time */ + endtime.tv_sec += (quit_time > 0) ? quit_time: 60; + /* without -q, default to 60s */ + do { + (void)gettimeofday(&now, NULL); + timersub(&endtime, &now, &td); + timeout = td.tv_sec * 1000 + td.tv_usec/1000; + if (timeout < 0) + timeout = 0; + rv = xpoll(pfd, 1, timeout); + } while (rv == -1 && errno == EINTR); /* loop until poll ! EINTR */ + if (rv == -1) { + warn("poll waiting before accept"); + goto dataconn_failed; + } + if (rv == 0) { + warn("poll timeout waiting before accept"); + goto dataconn_failed; + } + + /* (non-blocking) accept the connection */ + fromlen = myctladdr.su_len; + do { + s = accept(data, (struct sockaddr *) &from.si_su, &fromlen); + } while (s == -1 && errno == EINTR); /* loop until accept ! EINTR */ + if (s == -1) { warn("accept"); - (void)close(data), data = -1; - return (NULL); + goto dataconn_failed; } + (void)close(data); data = s; + if (fcntl(data, F_SETFL, flags) == -1) /* restore socket flags */ + goto dataconn_failed; + #ifdef IPTOS_THROUGHPUT if (from.su_family == AF_INET) { int tos = IPTOS_THROUGHPUT; - if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, - sizeof(int)) < 0) { + if (setsockopt(s, IPPROTO_IP, IP_TOS, + (void *)&tos, sizeof(int)) == -1) { if (debug) - warn("setsockopt TOS (ignored)"); + warn("setsockopt %s (ignored)", + "IPTOS_THROUGHPUT"); } } #endif return (fdopen(data, lmode)); + + dataconn_failed: + (void)close(data); + data = -1; + return (NULL); } void @@ -2002,7 +2027,7 @@ gunique(const char *local) } len = strlcpy(new, local, sizeof(new)); cp = &new[len]; - *cp++ = '.'; + *cp++ = '.'; while (!d) { if (++count == 100) { fputs("runique: can't find unique file name.\n", diff --git a/net/tnftp/files/src/ftp.cat1 b/net/tnftp/files/src/ftp.cat1 index 702e7a8de00..ae1d6fb32df 100644 --- a/net/tnftp/files/src/ftp.cat1 +++ b/net/tnftp/files/src/ftp.cat1 @@ -770,7 +770,7 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS fer type will take place as ascii or binary (respectively). The default transfer type is binary. - In order to be compliant with RRFFCC 11773388, ffttpp interprets the _p_a_t_h + In order to be compliant with RFC 1738, ffttpp interprets the _p_a_t_h part of an ``ftp://'' auto-fetch URL as follows: ++oo The `/' immediately after the _h_o_s_t[:_p_o_r_t] is interpreted as a @@ -786,12 +786,12 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS the equivalent of a ccdd command without a directory name. This is unlikely to be useful. - ++oo Any `%_X_X' codes within the path components are decoded, with _X_X - representing a character code in hexadecimal. This decoding - takes place after the _p_a_t_h has been split into components, but - before each component is used in the equivalent of a ccdd or ggeett - command. Some often-used codes are `%2F' (which represents - `/') and `%7E' (which represents `~'). + ++oo Any `%_X_X' codes (per RFC 1738) within the path components are + decoded, with _X_X representing a character code in hexadecimal. + This decoding takes place after the _p_a_t_h has been split into + components, but before each component is used in the equivalent + of a ccdd or ggeett command. Some often-used codes are `%2F' (which + represents `/') and `%7E' (which represents `~'). The above interpretation has the following consequences: @@ -1066,14 +1066,17 @@ EENNVVIIRROONNMMEENNTT ftp_proxy URL of FTP proxy to use when making FTP URL requests (if not defined, use the standard FTP protocol). - _N_O_T_E: this is not used for interactive sessions, only for - command-line fetches. + See http_proxy for further notes about proxy use. http_proxy URL of HTTP proxy to use when making HTTP URL requests. If proxy authentication is required and there is a user- name and password in this URL, they will automatically be used in the first attempt to authenticate to the proxy. + If ``unsafe'' URL characters are required in the username + or password (for example `@' or `/'), encode them with RFC + 1738 `%_X_X' encoding. + Note that the use of a username and password in ftp_proxy and http_proxy may be incompatible with other programs that use it (such as lynx(1)). @@ -1101,8 +1104,8 @@ SSEEEE AALLSSOO getservbyname(3), editrc(5), services(5), ftpd(8) SSTTAANNDDAARRDDSS - ffttpp attempts to be compliant with RRFFCC 995599, RRFFCC 11112233, RRFFCC 11773388, RRFFCC 22006688, - RRFFCC 22338899, RRFFCC 22442288, RRFFCC 22773322, and ddrraafftt--iieettff--ffttppeexxtt--mmllsstt--1111. + ffttpp attempts to be compliant with RFC 959, RFC 1123, RFC 1738, RFC 2068, + RFC 2389, RFC 2428, RFC 2732, and ddrraafftt--iieettff--ffttppeexxtt--mmllsstt--1111. HHIISSTTOORRYY The ffttpp command appeared in 4.2BSD. @@ -1135,4 +1138,4 @@ BBUUGGSS uses a SIIT translator for IPv6-to-IPv4 translation, ffttpp is unable to support your configuration. -NetBSD 2.0 October 7, 2004 NetBSD 2.0 +NetBSD 3.0_BETA January 15, 2005 NetBSD 3.0_BETA diff --git a/net/tnftp/files/src/ftp_var.h b/net/tnftp/files/src/ftp_var.h index 3beb9046525..3fd33788013 100644 --- a/net/tnftp/files/src/ftp_var.h +++ b/net/tnftp/files/src/ftp_var.h @@ -1,4 +1,5 @@ -/* $NetBSD: ftp_var.h,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: ftp_var.h,v 1.5 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: ftp_var.h,v 1.71 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1996-2005 The NetBSD Foundation, Inc. @@ -70,7 +71,7 @@ /* * Copyright (C) 1997 and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -82,7 +83,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -120,9 +121,9 @@ struct cmd { char *c_name; /* name of command */ const char *c_help; /* help string */ - char c_bell; /* give bell when command completes */ - char c_conn; /* must be connected to use command */ - char c_proxy; /* proxy server may execute */ + char c_bell; /* give bell when command completes */ + char c_conn; /* must be connected to use command */ + char c_proxy; /* proxy server may execute */ #ifndef NO_EDITCOMPLETE const char *c_complete; /* context sensitive completion list */ #endif /* !NO_EDITCOMPLETE */ diff --git a/net/tnftp/files/src/main.c b/net/tnftp/files/src/main.c index 5812933d43a..a9bb48af604 100644 --- a/net/tnftp/files/src/main.c +++ b/net/tnftp/files/src/main.c @@ -1,4 +1,5 @@ -/* $NetBSD: main.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: main.c,v 1.7 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: main.c,v 1.93 2005/05/11 02:29:12 lukem Exp */ /*- * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. @@ -68,7 +69,7 @@ /* * Copyright (C) 1997 and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -80,7 +81,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -105,7 +106,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: main.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: main.c,v 1.7 2005/05/11 02:41:28 lukem Exp"); #endif #endif /* not lint */ #endif @@ -134,6 +135,7 @@ main(int argc, char *argv[]) struct passwd *pw; char *cp, *ep, *anonuser, *anonpass, *upload_path; int dumbterm, s, len, isupload; + socklen_t slen; #if 0 /* XXX */ setlocale(LC_ALL, ""); @@ -199,12 +201,12 @@ main(int argc, char *argv[]) if (s == -1) err(1, "can't create socket"); len = sizeof(rcvbuf_size); - if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *) &rcvbuf_size, &len) - < 0) + if (getsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *) &rcvbuf_size, + &slen) == -1) err(1, "unable to get default rcvbuf size"); len = sizeof(sndbuf_size); - if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *) &sndbuf_size, &len) - < 0) + if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *) &sndbuf_size, + &slen) == -1) err(1, "unable to get default sndbuf size"); (void)close(s); /* sanity check returned buffer sizes */ @@ -449,7 +451,7 @@ main(int argc, char *argv[]) } if (netrc[0] == '\0' && localhome != NULL) { if (strlcpy(netrc, localhome, sizeof(netrc)) >= sizeof(netrc) || - strlcat(netrc, "/.netrc", sizeof(netrc)) >= sizeof(netrc)) { + strlcat(netrc, "/.netrc", sizeof(netrc)) >= sizeof(netrc)) { warnx("%s/.netrc: %s", localhome, strerror(ENAMETOOLONG)); netrc[0] = '\0'; @@ -647,7 +649,8 @@ cmdscanner(void) break; line[num] = '\0'; } else if (num == sizeof(line) - 2) { - fputs("sorry, input line too long.\n", ttyout); + fputs("Sorry, input line is too long.\n", + ttyout); while ((num = getchar()) != '\n' && num != EOF) /* void */; break; @@ -658,20 +661,23 @@ cmdscanner(void) HistEvent ev; cursor_pos = NULL; - if ((buf = el_gets(el, &num)) == NULL || num == 0) { + buf = el_gets(el, &num); + if (buf == NULL || num == 0) { if (fromatty) putc('\n', ttyout); quit(0, NULL); } - if (buf[--num] == '\n') { - if (num == 0) - break; - } else if (num >= sizeof(line)) { - fputs("sorry, input line too long.\n", ttyout); + if (num >= sizeof(line)) { + fputs("Sorry, input line is too long.\n", + ttyout); break; } memcpy(line, buf, num); - line[num] = '\0'; + if (line[--num] == '\n') { + line[num] = '\0'; + if (num == 0) + break; + } history(hist, &ev, H_ENTER, buf); } #endif /* !NO_EDITCOMPLETE */ diff --git a/net/tnftp/files/src/progressbar.c b/net/tnftp/files/src/progressbar.c index 911f0b13c53..5d9d9f9d0d9 100644 --- a/net/tnftp/files/src/progressbar.c +++ b/net/tnftp/files/src/progressbar.c @@ -1,4 +1,6 @@ -/* $NetBSD: progressbar.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* pkgsrc $NetBSD $/ +/* NetBSD: progressbar.c,v 1.6 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: progressbar.c,v 1.7 2005/04/11 01:49:31 lukem Exp */ /*- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. @@ -39,7 +41,7 @@ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: progressbar.c,v 1.6 2005/05/11 02:41:28 lukem Exp"); #endif /* not lint */ #endif @@ -72,7 +74,6 @@ foregroundproc(void) #endif /* !defined(NO_PROGRESS) */ -#ifndef NO_PROGRESS static void updateprogressmeter(int); /* @@ -86,8 +87,6 @@ updateprogressmeter(int dummy) progressmeter(0); errno = oerrno; } -#endif /* NO_PROGRESS */ - /* * List of order of magnitude prefixes. @@ -120,7 +119,7 @@ progressmeter(int flag) struct timeval td; off_t abbrevsize, bytespersec; double elapsed; - int ratio, barlength, i, len, remaining; + int ratio, barlength, i, remaining; /* * Work variables for progress bar. @@ -130,7 +129,10 @@ progressmeter(int flag) * `static' portion of it), be sure to update * these appropriately. */ +#endif + int len; char buf[256]; /* workspace for progress bar */ +#ifndef NO_PROGRESS #define BAROVERHEAD 43 /* non `*' portion of progress bar */ /* * stars should contain at least @@ -207,11 +209,11 @@ progressmeter(int flag) /* * calculate the length of the `*' bar, ensuring that - * the number of stars won't exceed the buffer size + * the number of stars won't exceed the buffer size */ barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD; if (prefix) - barlength -= strlen(prefix); + barlength -= strlen(prefix); if (barlength > 0) { i = barlength * ratio / 100; len += snprintf(buf + len, BUFLEFT, diff --git a/net/tnftp/files/src/progressbar.h b/net/tnftp/files/src/progressbar.h index 6fa94e4ef80..a3f80d179e9 100644 --- a/net/tnftp/files/src/progressbar.h +++ b/net/tnftp/files/src/progressbar.h @@ -1,4 +1,5 @@ -/* $NetBSD: progressbar.h,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: progressbar.h,v 1.5 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: progressbar.h,v 1.5 2005/02/10 16:00:38 jmc Exp */ /*- * Copyright (c) 1996-2003 The NetBSD Foundation, Inc. @@ -82,7 +83,6 @@ void psummary(int); void ptransfer(int); #endif /* !STANDALONE_PROGRESS */ - #ifdef NO_LONG_LONG # define LLF "%ld" # define LLFP(x) "%" x "ld" diff --git a/net/tnftp/files/src/ruserpass.c b/net/tnftp/files/src/ruserpass.c index 07c3df9c737..616869837fd 100644 --- a/net/tnftp/files/src/ruserpass.c +++ b/net/tnftp/files/src/ruserpass.c @@ -1,4 +1,5 @@ -/* $NetBSD: ruserpass.c,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: ruserpass.c,v 1.4 2005/05/11 02:41:28 lukem Exp */ +/* from NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp */ /* * Copyright (c) 1985, 1993, 1994 @@ -29,6 +30,17 @@ * SUCH DAMAGE. */ +#if 0 +#include <sys/cdefs.h> +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; +#else +__RCSID("NetBSD: ruserpass.c,v 1.4 2005/05/11 02:41:28 lukem Exp"); +#endif +#endif /* not lint */ +#endif + #include "tnftp.h" #include "ftp_var.h" diff --git a/net/tnftp/files/src/util.c b/net/tnftp/files/src/util.c index ba66f4cd2aa..372934cb1d7 100644 --- a/net/tnftp/files/src/util.c +++ b/net/tnftp/files/src/util.c @@ -1,4 +1,5 @@ -/* $NetBSD: util.c,v 1.3 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: util.c,v 1.9 2005/05/11 03:57:57 lukem Exp */ +/* from NetBSD: util.c,v 1.121 2005/05/11 02:29:13 lukem Exp */ /*- * Copyright (c) 1997-2005 The NetBSD Foundation, Inc. @@ -72,7 +73,7 @@ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.3 2005/01/04 23:44:24 lukem Exp $"); +__RCSID("NetBSD: util.c,v 1.9 2005/05/11 03:57:57 lukem Exp"); #endif /* not lint */ #endif @@ -730,7 +731,7 @@ remotemodtime(const char *file, int noisy) timebuf.tm_hour = hour; timebuf.tm_mday = day; timebuf.tm_mon = mo - 1; - timebuf.tm_year = yy - TM_YEAR_BASE; + timebuf.tm_year = yy - TM_YEAR_BASE; timebuf.tm_isdst = -1; rtime = timegm(&timebuf); if (rtime == -1) { @@ -1010,12 +1011,12 @@ void setupsockbufsize(int sock) { - if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *) &sndbuf_size, - sizeof(rcvbuf_size)) < 0) + if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, + (void *)&sndbuf_size, sizeof(rcvbuf_size)) == -1) warn("unable to set sndbuf size %d", sndbuf_size); - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *) &rcvbuf_size, - sizeof(rcvbuf_size)) < 0) + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, + (void *)&rcvbuf_size, sizeof(rcvbuf_size)) == -1) warn("unable to set rcvbuf size %d", rcvbuf_size); } @@ -1225,28 +1226,83 @@ isipv6addr(const char *addr) /* * Internal version of connect(2); sets socket buffer sizes first and - * handles the syscall being interrupted. + * supports a connection timeout using a non-blocking connect(2) with + * a poll(2). + * Socket fcntl flags are temporarily updated to include O_NONBLOCK; + * these will not be reverted on connection failure. * Returns -1 upon failure (with errno set to the problem), or 0 on success. */ int xconnect(int sock, const struct sockaddr *name, int namelen) { - int rv; + int flags, rv, timeout, error; + socklen_t slen; + struct timeval endtime, now, td; + struct pollfd pfd[1]; setupsockbufsize(sock); - rv = connect(sock, name, namelen); - if (rv == -1 && errno == EINTR) { - fd_set connfd; - FD_ZERO(&connfd); - FD_SET(sock, &connfd); + if ((flags = fcntl(sock, F_GETFL, 0)) == -1) + return -1; /* get current socket flags */ + if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) + return -1; /* set non-blocking connect */ + + /* NOTE: we now must restore socket flags on successful exit */ + + pfd[0].fd = sock; + pfd[0].events = POLLIN|POLLOUT; + + if (quit_time > 0) { /* want a non default timeout */ + (void)gettimeofday(&endtime, NULL); + endtime.tv_sec += quit_time; /* determine end time */ + } + + rv = connect(sock, name, namelen); /* inititate the connection */ + if (rv == -1) { /* connection error */ + if (errno != EINPROGRESS) /* error isn't "please wait" */ + return -1; + + /* connect EINPROGRESS; wait */ do { - rv = select(sock + 1, NULL, &connfd, NULL, NULL); + if (quit_time > 0) { /* determine timeout */ + (void)gettimeofday(&now, NULL); + timersub(&endtime, &now, &td); + timeout = td.tv_sec * 1000 + td.tv_usec/1000; + if (timeout < 0) + timeout = 0; + } else { + timeout = INFTIM; + } + pfd[0].revents = 0; + rv = xpoll(pfd, 1, timeout); + /* loop until poll ! EINTR */ } while (rv == -1 && errno == EINTR); - if (rv > 0) - rv = 0; + + if (rv == 0) { /* poll (connect) timed out */ + errno = ETIMEDOUT; + return -1; + } + + if (rv == -1) { /* poll error */ + return -1; + } else if (pfd[0].revents & (POLLIN|POLLOUT)) { + rv = sizeof(error); /* ok, or pending error */ + if (getsockopt(sock, SOL_SOCKET, SO_ERROR, + &error, &slen) == -1) + return -1; /* Solaris pending error */ + if (error != 0) { + errno = error; /* BSD pending error */ + return -1; + } + } else { + errno = EBADF; /* this shouldn't happen ... */ + return -1; + } } - return (rv); + + if (fcntl(sock, F_SETFL, flags) == -1) /* restore socket flags */ + return -1; + return 0; } /* @@ -1261,6 +1317,65 @@ xlisten(int sock, int backlog) } /* + * Internal version of poll(2), to allow reimplementation by select(2) + * on platforms without the former. + */ +int +xpoll(struct pollfd *fds, int nfds, int timeout) +{ +#if HAVE_POLL + return poll(fds, nfds, timeout); + +#elif HAVE_SELECT /* implement poll(2) using select(2) */ + fd_set rset, wset; + struct timeval tv, *ptv; + int i, max, rv; + + FD_ZERO(&rset); /* build list of read & write events */ + FD_ZERO(&wset); + max = 0; + for (i = 0; i < nfds; i++) { + if (fds[i].fd > FD_SETSIZE) { + warnx("can't select fd %d", fds[i].fd); + errno = EINVAL; + return -1; + } else if (fds[i].fd > max) + max = fds[i].fd; + if (fds[i].events & POLLIN) + FD_SET(fds[i].fd, &rset); + if (fds[i].events & POLLOUT) + FD_SET(fds[i].fd, &wset); + } + + ptv = &tv; /* determine timeout */ + if (timeout == -1) { /* wait forever */ + ptv = NULL; + } else if (timeout == 0) { /* poll once */ + ptv->tv_sec = 0; + ptv->tv_usec = 0; + } + else if (timeout != 0) { /* wait timeout milliseconds */ + ptv->tv_sec = timeout / 1000; + ptv->tv_usec = (timeout % 1000) * 1000; + } + rv = select(max + 1, &rset, &wset, NULL, ptv); + if (rv <= 0) /* -1 == error, 0 == timeout */ + return rv; + + for (i = 0; i < nfds; i++) { /* determine results */ + if (FD_ISSET(fds[i].fd, &rset)) + fds[i].revents |= POLLIN; + if (FD_ISSET(fds[i].fd, &wset)) + fds[i].revents |= POLLOUT; + } + return rv; + +#else +# error no way to implement xpoll +#endif +} + +/* * malloc() with inbuilt error checking */ void * diff --git a/net/tnftp/files/src/version.h b/net/tnftp/files/src/version.h index c9f141db3f3..bb033553959 100644 --- a/net/tnftp/files/src/version.h +++ b/net/tnftp/files/src/version.h @@ -1,4 +1,5 @@ -/* $NetBSD: version.h,v 1.2 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: version.h,v 1.1.1.6 2005/05/11 02:33:48 lukem Exp */ +/* from NetBSD: version.h,v 1.48 2005/05/11 02:29:13 lukem Exp */ /*- * Copyright (c) 1999-2005 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,5 +41,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20050103" +#define FTP_VERSION "20050511" #endif diff --git a/net/tnftp/files/tnftp.h b/net/tnftp/files/tnftp.h index 6c5100644a8..e1462c4faba 100644 --- a/net/tnftp/files/tnftp.h +++ b/net/tnftp/files/tnftp.h @@ -1,7 +1,7 @@ -/* $Id: tnftp.h,v 1.4 2005/01/04 23:44:24 lukem Exp $ */ +/* NetBSD: tnftp.h,v 1.12 2005/05/11 04:21:53 lukem Exp */ #define FTP_PRODUCT "tnftp" -#define FTP_VERSION "20050103" +#define FTP_VERSION "20050511" #include "config.h" @@ -48,10 +48,26 @@ # include <sys/poll.h> # endif #elif HAVE_SELECT -# define USE_SELECT -#else +# ifndef POLLIN +# define POLLIN 1 +# endif +# ifndef POLLOUT +# define POLLOUT 4 +# endif +/* we use select */ +#else /* ! HAVE_POLL && ! HAVE_SELECT */ # error "no poll() or select() found" #endif +#ifndef INFTIM +# define INFTIM -1 +#endif +#if ! HAVE_STRUCT_POLLFD +struct pollfd { + int fd; + short events; + short revents; +}; +#endif #if HAVE_DIRENT_H # include <dirent.h> diff --git a/net/tnftp/files/todo b/net/tnftp/files/todo index 5de6fcf4d8b..71554edc087 100644 --- a/net/tnftp/files/todo +++ b/net/tnftp/files/todo @@ -1,4 +1,4 @@ -$Id: todo,v 1.2 2005/01/04 23:44:24 lukem Exp $ +NetBSD: todo,v 1.7 2005/05/11 03:03:42 lukem Exp Current Items ------------- @@ -6,12 +6,15 @@ Current Items autoconf test for HAVE_GETADDRINFO_D (declaration) if providing getaddrinfo() override. (required for UnixWare 7.1.1) +Interix may need hack to fix detection of getpgrp() void args. +(See pkgsrc/net/tnftp/files/src/progressbar.c 1.2) + Update: INSTALL NEWS README Old Items --------- -macosx install notes / configure fixes +macosx install notes at end of configure, show summary of options used and features found @@ -27,8 +30,6 @@ in configure, check for ansi c compiler and barf if it fails check if we need #defines for memcpy() et al -check for utimes() decls [which system?] - possibly install editline.3 and editrc.5 system specific tests (to remove need for manual intervention): |