Up to [cvs.NetBSD.org] / src / usr.bin / ftp
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
Pull up following revision(s) (requested by lukem in ticket #1021): usr.bin/ftp/ftp.c: revision 1.178 usr.bin/ftp/version.h: revision 1.99 usr.bin/ftp/ruserpass.c: revision 1.35 usr.bin/ftp/main.c: revision 1.134 usr.bin/ftp/main.c: revision 1.135 usr.bin/ftp/progressbar.c: revision 1.27 usr.bin/ftp/util.c: revision 1.165 usr.bin/ftp/cmds.c: revision 1.144 usr.bin/ftp/extern.h: revision 1.84 usr.bin/ftp/fetch.c: revision 1.242 usr.bin/ftp/ftp.1: revision 1.160 s/bninary/binary/ in comment. extract duplicate code into a function. Check bounds when copying to destination. Remove const where the const string ended up being overwritten. use unsigned when doing shifts. remove const when string gets overwritten. ftp: exit non-zero if short http transfer when filesize is known If a http file size is known and the fetch finishes with less bytes transferred, exit non-zero. Bump version to 20241129. PR bin/54713 PR bin/58281 ftp: help improvements Document -? as a separate mode. Document -H HEADER in the usage. Clarify units for -b and -x. Consistent argument names between ftp -? and ftp(1). ftp: order getopt Upper before lower Consistently order options in getopt and the switch with the upper case option before the lower case option. This makes it easier to cross-reference with -? and ftp(1). No functional change.
remove const when string gets overwritten.
Pull up following revision(s) (requested by lukem in ticket #170): usr.bin/ftp/ssl.c: revision 1.13 usr.bin/ftp/fetch.c: revision 1.236 usr.bin/ftp/util.c: revision 1.166 usr.bin/ftp/main.c: revision 1.129 usr.bin/ftp/extern.h: revision 1.83 usr.bin/ftp/ftp.1: revision 1.148 usr.bin/ftp/cmdtab.c: revision 1.53 usr.bin/ftp/version.h: revision 1.96 Add option sslnoverify to control validation of SSL certificates. Add netrc processing to fetch-mode (URL on command line) to enable options and autologin via netrc. Fix SSL cleanup in some error paths. Certificate validation is now enabled by default. Set FTPSSLNOVERIFY=1 in environment or configure a corresponding init macro via netrc to not validate certs (required if you haven't installed a required CA certificate for OpenSSL). Discussed with lukem@ on icb.
Add option sslnoverify to control validation of SSL certificates. Add netrc processing to fetch-mode (URL on command line) to enable options and autologin via netrc. Fix SSL cleanup in some error paths. Certificate validation is now enabled by default. Set FTPSSLNOVERIFY=1 in environment or configure a corresponding init macro via netrc to not validate certs (required if you haven't installed a required CA certificate for OpenSSL). Discussed with lukem@ on icb.
Catch up to current, requested by christos in ticket #1763: usr.bin/ftp/Makefile up to 1.39 usr.bin/ftp/cmds.c up to 1.141 usr.bin/ftp/complete.c up to 1.47 usr.bin/ftp/domacro.c up to 1.23 usr.bin/ftp/extern.h up to 1.82 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp.c up to 1.174 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/progressbar.c up to 1.24 usr.bin/ftp/progressbar.h up to 1.9 usr.bin/ftp/ssl.c up to 1.12 usr.bin/ftp/ssl.h up to 1.5 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 ftp(1): validate address from PASV and LPSV response. ftp(1): use raw write(2) instead of fwrite(3) to avoid stream corruption because of the progress bar interrupts. Fixes for PR 56219 and PR 55857. PR 57003: Support relative redirects.
Backout ticket #1763 for now - trust anchors are not solved.
Catch up to current, requested by christos in ticket #1763: usr.bin/ftp/Makefile up to 1.39 usr.bin/ftp/cmds.c up to 1.141 usr.bin/ftp/complete.c up to 1.47 usr.bin/ftp/domacro.c up to 1.23 usr.bin/ftp/extern.h up to 1.82 usr.bin/ftp/fetch.c up to 1.235 usr.bin/ftp/ftp.1 up to 1.147 usr.bin/ftp/ftp.c up to 1.174 usr.bin/ftp/ftp_var.h up to 1.86 usr.bin/ftp/main.c up to 1.128 usr.bin/ftp/progressbar.c up to 1.24 usr.bin/ftp/progressbar.h up to 1.9 usr.bin/ftp/ssl.c up to 1.11 usr.bin/ftp/ssl.h up to 1.5 usr.bin/ftp/util.c up to 1.164 usr.bin/ftp/version.h up to 1.94 ftp(1): validate address from PASV and LPSV response. ftp(1): use raw write(2) instead of fwrite(3) to avoid stream corruption because of the progress bar interrupts. Fixes for PR 56219 and PR 55857. PR 57003: Support relative redirects.
Mostly merge changes from HEAD upto 20200411
trim down error checking if we are small.
Sync with HEAD
- add justquit() that always exits. use it to avoid unreachable code.
Apply patch, requested by tron in ticket #997: usr.bin/ftp/Makefile patch usr.bin/ftp/cmds.c patch usr.bin/ftp/cmdtab.c patch usr.bin/ftp/extern.h patch usr.bin/ftp/fetch.c patch usr.bin/ftp/ftp.1 patch usr.bin/ftp/ftp.c patch usr.bin/ftp/ftp_var.h patch usr.bin/ftp/main.c patch usr.bin/ftp/progressbar.c patch usr.bin/ftp/ssl.c patch usr.bin/ftp/ssl.h patch usr.bin/ftp/util.c patch usr.bin/ftp/version.h patch Add HTTPS support to ftp(1).
sync with head
As discussed on tech-net@: Don't display expected EHOSTUNREACH for all but the last connect attempts in terse mode.
Use __dead
Pull up following revision(s) (requested by lukem in ticket #1370): usr.bin/ftp/extern.h: revision 1.78 usr.bin/ftp/fetch.c: revision 1.192 usr.bin/ftp/util.c: revision 1.153 Parse HTTP 'Date' entries in the `C' locale rather than the user's. Fix from [bin/42917] (with minor changes), from KAMADA Ken'ichi.
Parse HTTP 'Date' entries in the `C' locale rather than the user's. Fix from [bin/42917] (with minor changes), from KAMADA Ken'ichi.
Rename internal getline() function to get_line() so it does conflict with the soon to be added getline(3) libc function.
Sync with HEAD. Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
Fix numerous WARNS=4 issues (-Wcast-qual -Wsign-compare).
Sync w/ -current. 34 merge conflicts to follow.
sync with head.
Add epsv6 and epsv to disable extended passive mode for ipv6 or both ipv4 and ipv6 respectively. This hack is due to our friends a Juniper Networks who break epsv in ipv6. Should be fixed in ScreenOS 6.2.X.
Remove clause 3 and 4 from TNF licenses
Use the service name to getaddrinfo() (along with the host name), so that features such as DNS Service Discovery have a better chance of working. Suggested by David Young <dyoung>. Display the service name in various status & error messages. Don't getservbyname() the :port component of a URL; RFC 3986 says it's just an unsigned number, not a service name.
Display times in RFC2822 form rather than using ctime(3), since the former is more explicit about the timezone offset.
Clean up use of confirm() and mbort() so that the current operation is always passed in (instead of depending upon the 'mname' global). For confirm(), if the second argument is NULL print the "Continue with <cmd>" prompt. This fixes up the the display of interrupted prompts.
Rename xfoo() to ftp_foo() to avoid collisions with libssh. Don't ask.
Pull up revision 1.69 (requested by lukem in ticket #606): Implement: int getline(FILE *stream, char *buf, size_t buflen, const char **errormsg) Read a line from the FILE stream into buf/buflen using fgets(), so up to buflen-1 chars will be read and the result will be NUL terminated. If the line has a trailing newline it will be removed. If the line is too long, excess characters will be read until newline/EOF/error. Various -ve return values indicate different errors, and errormsg will be changed to an error description if it's not NULL. Convert to use getline() instead of fgets() whenever reading user input to ensure that an overly long input line doesn't leave excess characters for the next input operation to accidentally use as input. Zero out the password & account after we've finished with it. Consistently use getpass(3) (i.e, character echo suppressed) when reading the account data. For some reason, historically the "login" code suppressed echo for Account: yet the "user" command did not! Display the hostname in the "getaddrinfo failed" warning. Appease some -Wcast-qual warnings. Fixing all of these requires significant code refactoring. (mmm, legacy code).
Pull up revision 1.68 (requested by lukem in ticket #606): Some const cleanups.
Pull up revision 1.67 (requested by lukem in ticket #606): Fix some cast issues highlighted by Scott Reynolds using gcc 4 on OSX.4
Implement: int getline(FILE *stream, char *buf, size_t buflen, const char **errormsg) Read a line from the FILE stream into buf/buflen using fgets(), so up to buflen-1 chars will be read and the result will be NUL terminated. If the line has a trailing newline it will be removed. If the line is too long, excess characters will be read until newline/EOF/error. Various -ve return values indicate different errors, and errormsg will be changed to an error description if it's not NULL. Convert to use getline() instead of fgets() whenever reading user input to ensure that an overly long input line doesn't leave excess characters for the next input operation to accidentally use as input. Zero out the password & account after we've finished with it. Consistently use getpass(3) (i.e, character echo suppressed) when reading the account data. For some reason, historically the "login" code suppressed echo for Account: yet the "user" command did not! Display the hostname in the "getaddrinfo failed" warning. Appease some -Wcast-qual warnings. Fixing all of these requires significant code refactoring. (mmm, legacy code).
Some const cleanups.
Fix some cast issues highlighted by Scott Reynolds using gcc 4 on OSX.4
Pull up revision 1.66 (requested by lukem in ticket #266): gratuitous whitespace cleanup (before someone else jumps the gun...)
Pull up revision 1.65 (requested by lukem in ticket #265): 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).
gratuitous whitespace cleanup (before someone else jumps the gun...)
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).
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 for me to tackle right now. I will leave it to the author; hi luke!
Forbid filenames returned from mget that aren't in (or below) the current directory. The previous behaviour (of trusting the remote server's response when retrieving the list of files to mget with prompting disabled) has been in ftp ~forever, and has been a "known issue" for a long time. Recently an advisory was published by D.J. Bernstein on behalf of Yosef Klein warning of the problems with the previous behaviour, so to alleviate concern I've fixed this with a sledgehammer. Remember the local cwd after any operation which may change it. Use "remotecwd" instead of "remotepwd".
Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22365, verified by myself.
Pullup rev 1.61 (requested by grant in ticket #1115) Separate progress reporting into a utility set of routines. Use these to provide a standalone progress binary and integrate support for this into sysinst.
Abstract out progress bar support into progressbar.[ch], for inclusion in external programs (conditionalized on -DSTANDALONE_PROGRESS). The following moved from util.c to progressbar.c: alarmtimer(), progressmeter(), psummary(), ptransfer(), xsignal(), xsignal_restart() The following moved from extern.h and ftp_var.h to progressbar.h: STALLTIME, verbose, fromatty, progress, quit_time, ttywidth
Pull up revision 1.60 (via patch, requested by he): Format string cleanup.
Pullup usr.bin string format fixes [is]. See "cvs log" for explicit revision numbers per file, from sommerfeld.
More format string cleanup by sommerfeld.
* implement parseport(), which takes a string and attempts to convert it to a numeric port number * use parseport() in parse_url() and hookup() * don't try and lookup the port number using getaddrinfo(), as it's too hard to separate a failed host name lookup from a failed service name lookup. this was causing lossage on systems that don't have `http' in services(5) (such as solaris), but only crept in when we started using getaddrinfo() unconditionally.
add support for FEAT and OPTS commands with `features' and `opts'. (from RFC 2389). add support for MLST & MLSD (machine parseble listings) with 'mlst', 'mlsd' and 'pmlsd' (mlsd |$PAGER) commands. (from draft-ietf-ftpext-mlst-11) rename remotesyst() to getremoteinfo(), and modify to parse the result from FEAT (if supported), and take into account the support for the various extensions such as MDTM, SIZE, REST (STREAM), MLSD, and FEAT/OPTS. put each feature into one of the following categories: - known to work (explicit FEAT) - unknown but assume works until explicit failure, when it's then tagged as `known not to work'. - known not to work (FEAT succeeded but didn't return anything, or was unknown and then explicit failure) assign results into features[] matrix. add support to getreply() so that an optional callback will be called for each line received from the server except for the first and last. this is used in FEAT (and MLST) parsing. modify various commands to check if REST (STREAM), MDTM and SIZE are explicitly or implicitly supported before using. fix `syst' when verbose is off. minor knf (indent goto labels by one space, etc). simply various command usage handlers by assuming that argv != NULL except for quit() and disconnect().
Sync w/ netbsd-1-5-base.
* migrate the SYST parsing from setpeer() into a separate remotesyst(). call remotesyst() only when login has been successful some servers don't let you run SYST until you've successfully logged in. * in fetch_ftp(), always call setpeer() with autologin disabled, and use the following ftp_login() to DTRT. this prevents ftp from trying to login a second time if the first autologin fails when connecting to a remote site anonymously using autofetch. * reset unix_proxy and unix_server in cleanuppeer() * missed a function conversion in the KNF sweep...
Add support for 'ftp -u url file ...', to upload a list of files to given url. Mostly based on [bin/10019] by Scott Aaron Bamford <sab@ansic.net>
convert IPv4 mapped address (::ffff:10.1.1.1) into real IPv4 address before touching it. IPv4 mapped address complicates too many things in FTP protocol handling.
convert to ANSI KNF
* Add support for `fget localfile', which reads a list of filenames to retrieve from localfile. Based on work by Darren Reed. * Crank version. * Update copyright dates.
define private type `sigfunc' as typedef void (*sigfunc) __P((int)); and replace use of sig_t and void (*)(int). certain other OSes define sig_t differently to that (they add extra arguments), and it causes problems due to function mismatches, etc...
Pull up to last week's -current.
* implement xsl_init() and xsl_add(); error checking forms of sl_{init,add}() * fix bug where the second press of <TAB> on an empty word (i.e, list all options) may have resulted in an strncmp() against NULL. (detected by _DIAGASSERT())
- implement `set rprompt'; right side version of `set prompt'. depends on EL_RPROMPT support i added to editline(3). - allow $FTPPROMPT and $FTPRPROMPT to override defaults for the relevant prompts - move `%' formatting code from prompt() to expandbuf(). - implement `%.' and `%c', similar to the same % codes in tcsh(1) (functionality I added to tcsh nearly 6 years ago), except that `%.' always does `...trailing' and `%c' always does `/<x>trailing'. - unknown `%foo' codes get printed as `%foo'
- implement updateremotepwd(); update the global variable `remotepwd' to contain the remote working directory. - add `set prompt', a user configurable prompt. (defaults to `ftp> '). the following escape characters a la tcsh(1) are supported: %/, %m, %M, and %n. - add global var `username'; used by prompt code - fix a couple of minor memory leaks - bump version
new features: - add `usage'; displays the usage of a command. implemented by calling the c_handler() with argc = 0, argv = "funcname". - add `passive auto'; does the same as $FTPMODE=auto. - add `set [option value]'; display all options, or set an option to a value. - add `unset option'; unset an option. - add getoptionvalue() to retrieve an option's value, and replace a few global variables with calls to this. - implement cleanuppeer(), which resets various bits of state back to `disconnected'. call in disconnect() and lostpeer(). - support completing on `options'. - improve recovery after a SIGINT may have closed the connection. XXX: there's still a couple to fix other stuff: - various consistency fixes in the man page. - ensure that the command usage strings in the code and man page match reality. - mput/mget: check that the connection still exists before each xfer. - minor cosmetic changes in confirm(). - set code correctly in sizecmd() and modtime() - don't need \n in err() strings. - change lostpeer to take an argument (rather than casting (sig_t)lostpeer in signal handlers) - knf and whitespace police.
* fix up confirm() (broke `a' and `p' in last commit) * simplify main loop (don't need `top' variable any more) * use a struct sockaddr_in6.sin6_addr for the result from inet_pton(), rather than u_char buf[16] * add a few more comments
a few user interface and cosmetic tweaks: * confirm(): move from util.c to cmds.c. display mnemonic string in its prompt. add support for `q' (terminate current xfer), `?' (show help list) * in various signal handlers, output a linefeed only if fromatty. * if fgets(stdin) returned NULL (i.e, EOF), clearerr(stdin) because you don't want future fgets to fail. this is not done for the fgets() in the main command loop, since ftp will quit at that point. * unless ftp is invoked with -a, don't retain the anonftp setting between hosts (`ftp somehost:' sets anonftp, but you don't want that to `stick' if you close that connection and open a new one).
allow a second SIGINT during the "xfer aborted. waiting for remote to finish abort." stage. if this occurs, just call lostpeer() to close the connection. whilst this might be considered brutal, it's also extremely handy if you're impatient or there's lossage at the remote end.
* use sigsetjmp()/siglongjump() instead of setjmp()/longjmp(); the latter don't save the signal mask on some foreign systems. * ensure signal handlers don't use stdio and do reset errno if they don't exit with siglongjmp() * use a common SIGINT handler for {send,recv}request()
add TNFi copyright to all files i've done more than a minor amount of work to...
enhancments from Marc Horowitz <marc@mit.edu> to improve connection timeouts: * implement xsignal_restart(), which only sets the SA_RESTART flag if specifically requested * xsignal() is now a wrapper to xsignal_restart(). INFO, USR1, USR2 and WINCH are restartable, ALRM, INT, PIPE and QUIT are not. * improve getreply()'s timeout code to take advantage of the above. other changes: * improve wording of how globbing works for `classic' URLs (host:path). suggested by John Refling <johnr@imageworks.com> in relation to PRs [bin/8519] and [bin/8520] * always compile in the `edit' command even if NO_EDITCOMPLETE defined. it's just a no-op in the latter case, which is more consistent to the users. * always compile in about: support (i.e, remove NO_ABOUT). i'm entitled to some vanity in this program... * clean up some whitespace
prefix the global variables in ftp_var.h with GLOBAL, which defaults to "extern" if it's not set. define GLOBAL to (empty) in main.c. this effectively moves all the globals into main.c whilst retaining namespace access to them in other source files. (global vars in header files confuse foreign linkers)
* In the !NI_NUMERICHOST case (i.e, getaddrinfo() challenged systems), portnum should be in host order. found/fixed by Matthias Pfaller <leo@dachau.marco.de> * parse_url(): improve checking of portnum, and add an extra argument to pass back the parsed portnum to the caller (reduces a bit of code duplication) * Move the KAME/WIDE copyrights after the BSD/TNFi ones. Since there was significantly less code added under the former, it's only fair on the latter.
* fix initialisation of home[] * fetch_url(): if path would be NULL, return strdup("")
* add new commands: lpage page local files pdir as dir, but through your $PAGER pls as ls, but through your $PAGER * implement docase() (a la dotrans() et al) and use appropriately, rototilling some duplicated code * globulize(): modify to return a pointer to the strdup()ed result in all cases, and hack the code that calls it to take this into account * replace strcpy() and strncpy() with strlcpy() * put(), getit(): use some aptly named local vars instead of argv[...] * delint
* idle(): rename to idlecmd(). certain linux distributions have an incompatible prototype for idle() in <unistd.h> (which i thought was against namespace and sensibility guidelines, but...) * consistently use xsignal() instead of signal(). we get known behaviour in all cases (SA_RESTART), which is good for some borken foreign systems. * remove signal.h from most files; it's unnecessary now * fetch_url(): use `long chunksize' instead of ssize_t; it's more portable, and we're setting chunksize with strtol() anyway * xsignal(): only use SA_RESTART if it exists. SunOS 4.x doesn't have it but has the inverse (SA_INTERRUPT). the original function i was inspired from had this support (lib/signal.c, W. Richard Stevens' `UNP 2nd ed Vol 1'). * remove <termios.h> from util.c; it should be unnecessary now
* replace ifdefs against __SVR4 and __linux__ with DIRENT_MISSING_D_NAMLEN; it's more portable and more obvious * remove the mkgmtime() && HAVE_TIMEGM stuff: a) why should netbsd have to define HAVE_TIMEGM to compile cleanly? b) foreign compiles of ftp should just be linked with working timegm function a more portable version of this ftp client will be released as a 3rdparty product; no use polluting our code with half-baked attempts...
* add support for `xferbuf', which sets both `sndbuf' and `rcvbuf' * document the above three commands * rototill the way the sndbuf and rcvbuf work. remove resetsockbufsize() * use the appropriate socket buffer size as the size of the buffer that the read()/write() loops use. speeds up things in some cases.
* change fetch_ftp() to be fully rfc 1738 compliant; if the URL contains the an empty directory (e.g, between `some' and `path' in `ftp://host/some//path'), then execute `CWD ' (without a path). This command will probably fail on rfc 959 compliant servers, so issue a warning in this case and bail. [noted by cgd]. (i wonder if the people who wrote rfc 1738 actually realised that this requirement appears to contravene the spec for `cwd' in rfc 959 ?) * replace isurl() with isipv6addr(), and use appropriately. fixes auto-login with `classic ftp URLs' (e.g, `ftp somehost:') * cleanup and rework some of the ipv6 stuff in parse_url() * prevent potential coredump in fetch_ftp() when parsing `;type=X' * KNF a few lines * fix a couple of comments * cleanup the man page a bit
add epsv4 command, which enable/disable the use of EPSV/EPRT. this is mainly for (hypothetical) ftp server which disconnect clients that use EPSV/EPRT. I've never seen any ftp server like this, but epsv4 command may be of use when such an ftp server is found.
add dual-stack (IPv4/v6) support. hope I broke no other part...
[fear this; more ftp hacking from lukem :-] features: --------- * transfer rate throttling with the new `rate' command. syntax: rate direction [max [incr]] where direction is `all', `get' or `put'. if max is not supplied, the current settings are displayed. if max is supplied, then transfers in the given direction will be throttled to this value. if incr is supplied, the increment for the `on-the-fly' scaling will be set to that, otherwise `1024' is used. currently implemented for binary get, binary put, and url fetches. not yet supported for ascii get or put, or local file copies. * on-the-fly scaling of the throttle based on signals: - SIGUSR1 raises the throttle rate by the increment for that direction - SIGUSR2 lowers the throttle rate by the increment for that direction * -T dir,max[,incr] option to set rate from the command line * `k', `m', `g' suffix support for bytecounts in the `hash', `rate', `rcvbuf' and `sndbuf' commands) bug fixes and code mods: ------------------------ * fix up ftp_login() so that ruserpass() is always called, even for command-line url fetches. * implement strsuftoi(), which parses a given number into a int with suffix support. replaces getsockbufsize() * implement parserate(), which does the argv parsing for -T and rate * save and restore errno in signal handlers (may not be necessary, but it doesn't hurt) notes: ------ the rate command has had reasonable testing, but I'd like feedback if it doesn't do the right thing, especially from people on slower (i.e, modem) links. I haven't tested the rate throttle against a http server which does `transfer-encoding: chunked' because I couldn't find a server to test against.
pull up rev 1.29 from trunk. (cgd)
remove declaration for empty; it is only used in one file and hide it's implementation.
split the "SMALL" #ifdefs into ones for NO_ABOUT, NO_EDITCOMPLETE, and NO_PROGRESS. -DSMALL still implies all of those. progress meter support isn't necessary for the smallest possible ftp client, but it adds very little space and makes users' lives much better. Therefore, it should be enabled for installation media if at all possible.
* implement -R; restart non-proxied command-line FTP xfers * fix fetch_ftp() so that hcode parsing is not done for file:// urls (a } in the wrong place, and code at the wrong indent level...) * change outfile to being a global (so it gets correctly reset) * change parse_url to not remove leading '/' for non ftp urls. whilst this is not totally rfc1738 compliant, other code kinda assumes this is the case, and it doesn't hurt
changes to fix [bin/6951] by Peter Simons <simons@cys.de>: * implement ftpvis(), which \ quotes the following in the given string: SP, TAB, \, CR, " * use ftpvis() in complete_ambiguous(), to escape characters in a word which would confuse makeargv()/slurpstring().
pull up rev 1.26 from trunk (itohy)
Temporary fix of UTC -> time_t conversion: 1. changed to use timegm(3) on NetBSD and 2. supply alternative code for other Unix-like OSs (NetBSD ftp shall be portable for some reasons :-). This fix closes PR #6448. NOTE: This should be fixed again if a portable UTC to time_t conversion method is specified in some standards.
pull up rev(s) 1.19-1.25 from trunk. (feyrer)
* implement xsignal(); same semantics as signal() but uses sigaction with an explicit SA_RESTART. (needed for portability) * use xsignal() for SIGALRM and SIGINFO handlers
features: * support $no_proxy, which is a comma or space separated list of host[:port] elements for which proxying is to be disabled. (asked for by cgd in [bin/5027]) * if $FTPANONPASS is defined, use that as the anon ftp password (instead of "`whoami`@") * allow http URL's without a filename as long as an output file is specified. other stuff: * implement parse_url(), which breaks up a URL into its bits, and use. * simplify url_get() and auto_fetch() to use parse_url() and to not modify the supplied URL or a copy of it. * implement xmalloc() and xstrdup(); error-checked malloc()/strdup() * add more consistency to messages, quoting strings in output as `%s'
const poisoning.
* send 'Connection: close' in HTTP/1.1 headers, preventing the remove server from using a persistent connection, which speeds up such requests. * support http 301 and 302 redirects * rewrite guts of url_get() to use fparseln() et al instead of read(s,&p,1)... enables each in the header to be parsed as necessary * rename login to ftp_login, to remove conflict with util.h::login * cleanup verbose messages during http proxy requests
Add "sndbuf" and "rcvbuf" commands for setting the socket buffer sizes, which in turn can allow the use of larger TCP windows. This is a work in progress; there is not yet support for specifying global defaults or user prefrences on a host/network basis.
some fixes & enhancements from openbsd's ftp, with extra fixes by me: * default to passive with active fallback. $FTPMODE modifies this behaviour. -A forces active connection. * support '-o outfile' for auto-fetched files. outfile can be a file, `-' (for stdout), or '|command' (to output each file through command). * support '-r waittime', which retries the connection after waittime seconds if it fails. * fix 'page file' when restart is non-zero. * try all ip-addresses of a host in a http fetch (as the normal ftp fetch does). XXX: a ``broken pipe'' error sometimes occurs with -o '|command'; i haven't tracked this down yet.
* ensure buffer for username is initialised, so ^D on username prompt doesn't use garbage for the username. from "Soren S. Jorvang" <soren@t.dk> in [bin/4559] * use in_port_t for ports, and USHRT_MAX instead of 0xffff (from millert@openbsd.org) * use `NULL' instead of `(.... *)0' where appropriate.
Pull rev 1.18 up from trunk (lukem)
* in recvrequest(), ignore restart_point unless "RETR"ieving. fixes problems where a remote completion or `mget' would confuse the client a `restart' had been issued beforehand. now, `restart' is remembered until an operation that can actually use it is invoked. * in sendrequest(), don't reset restart_point upon entry. fixes `restart' for `put' operations. * if `restart' is invoked with no arguments, print current setting instead of displaying a usage * consistently use printf("%qd", (long long)restart_point) when displaying restart_point * use strto[lq]() instead of atol() when parsing `mark' and `restart' values * remove unnecessary strlen()s when result of previous snprintf() will do * replace a few malloc()/strcpy()s with strdup()s * use SECSPERHOUR instead of '3600'
bugs fixed: * don't interpret '-' or '|' when a local filename is determined from the remote name (i.e, in mget, and in get with only one argument). This is implemented using an extra argument to recvrequest(). Fixes a major security hole. * clean up memory leak when using globulize() * clean up a couple of comments * fix wording in TNF copyright features added: * support for TIS fwtk gate-ftp servers: * read defaults from $FTPSERVER && $FTPSERVERPORT * start in gate-ftp mode if invoked as 'gate-ftp' * toggle or set with 'gate [host [port]]'
* use RCSID() && COPYRIGHT() macros * cleanup for WARNS=1 (including some ugly '(void)&var' bits wrapped in #ifdef __GNUC__ to shut up gcc warnings WRT setjmp/longjmp) * use strtol() instead of atoi(), and more extensively check result of conversion * use u_int16_t instead of short or int for TCP port addresses
More enhancements/bugfixes (when will it end?) * differentiate between being connected, and being logged in * cleanup some text messages * support username & password ftp URLs (ftp://user:pass@host/) in non-proxy situations; assume proxy supports it for proxy situations. * cd to / before performing any autofetch transfers * use strncasecmp in URL parsing. fix from <Todd.Miller@courtesan.com>
* support $ftp_proxy for ftp:// transfers [bin/3245] * add "more" & "less" as synonyms for "page" * move editline setup code into controlediting(), and call appropriately. only setup setup terminal if going into interactive mode. inspired by Todd Miller <todd.miller@courtesan.com>
SMALLFTP->SMALL; remove SMALL from Makefile
Features: * support remglobbing of auto_fetch arguments * new flag - '-e'; disable editing * "page file" == "get file |${PAGER-less}" Bugfixes/cleanup: * consistently use a trailing '.' on messages * code cleanup, including buffer overrun fixes, use puts and putchar in places, etc (inspired by OpenBSD mods) * disable progress bar when local-file is a pipe or '-' * skip \r in http headers * fix remote ftpd slash bug more elegantly (so it works with ////) * abort_remote(): check if cout==NULL before using it. should fix [bin/3273] * fixed up cosmetic problems when complete_remote() generated errors from the remote server (such as "no files found", "login with user and pass", ...) done by adding extra argument to remglob(), which is a pointer to an error buffer to put messages in rather than printing to stdout.
[Yet Another Huge Ftp Commit - hopefully the last for a while, barring any more little things people want added ...] New features: * progressmeter is now asynchronous, so "stalled" transfers can be detected. "- stalled -" is displayed instead of the ETA in this case. When the xfer resumes, the time that the xfer was stalled for is factored out of the ETA. It is debatable whether this is better than not factoring it out, but I like it this way (I.e, if it stalls for 8 seconds and the ETA was 30 seconds, when it resumes the ETA will still be 30 seconds). * verbosity can be disabled on the command line (-V), so that in auto-fetch mode the only lines displayed will be a description of the file, and the progress bar (if possible) * if the screen is resized (and detected via the SIGWINCH signal), the progress bar will rescale automatically. Bugs fixed: * progress bar will not use the last character on the line, as this can cause problems on some terminals * screen dimensions (via ioctl(TIOCWINSZ)) should use stdout not stdin * progressmeter() used some vars before initialising them * ^D will quit now. [fixes bin/3162] * use hstrerror() to generate error message for host name lookup failure. * use getcwd instead of getwd (it should have been OK, but why tempt fate?) * auto-fetch transfers will always return a positive exit value upon failure or interruption, relative to the file's position in argv[]. * remote completion of / will work, without putting a leading "///". This is actually a bug in ftpd(1), where "NLST /" prefixes all names with "//", but fixing every ftpd(1) is not an option...
New features: * Command line editing via editline(3) library. * Context sensitive command and file completion, including remote files. Enhancements to auto-fetch feature: * Support for http:// URLs using the http protocol, including proxy HTTP support via $htty_proxy if it's defined. * The connection is kept open between successive files on the same host. (obviously, this does not count for http requests.) * Return value of ftp is 0 on no error, or the offset in argv[] of the file which failed (i.e., argv[x] failed, ftp returns x). * If the path in an ftp URL or classic format line has a trailing '/', cd to the path and enter interactive mode. Fixes [bin/3011], albiet requiring the user to help ftp in determining the operation. Other changes: * '-P port' works for normal ftp, and is the default for all classic style auto-fetch transfers and for ftp URLs that don't specify the port. (previously it would just work for the first xfer.) * Some code moved into separated files along logical divisions. * Editing and completion can be compiled out with -DSMALLFTP.
RCS ID police
* preserve modtime if size is 0 [bin/3040, Enami Tsugutomo] * in autofetch mode, don't retry a file if the connection failed - skip it and move to the next file. [bin/3051, Matt Green] * only print error messages from SIZE or MDTM if the user used 'size' or 'modt' (respectively). prevents extraneous warnings during normal transfers when connected to a site which doesn't support these (behaviour prior to last commit), but still allows error feedback to specific user requests for this info (which the last commit broke). * 'account': only accept one optional argument * if invoked as pftp, default to passive mode on (from FreeBSD) * remove leading '0 ' in progress bar - looked ugly * use warn instead of perror * use strncpy when src isn't known to have safe length * remglob(): use mkstemp() to prevent symlink games, and don't override _PATH_TMP, use it as the prefix to the temp file
functionality mods: * implement 'progress bar/meter' (inspired by ncftp). use 'progress' to toggle on. it will display current file size to 5 digits, automatically determining suffix (up to 16384 P (petabytes) == 2^64). * 'ls' now uses NLST (unadorned listing), a la older ftp clients. 'dir' still does LIST (long listing). idea from John Nemeth <jnemeth@cue.bc.ca> bug fixes: * return first line of reply in reply_string[] from getreply(), instead of last line. This fixes [bin/741] (parsing of SYST), and also means that SIZE and MDTM messages will be parsed correctly if they're longer than 1 line. * parse URL-style auto-ftps that have no filename correctly (e.g, ftp://host, ftp://host/, ftp://host/dir/). pointed out by Jaromir Dolecek <dolecek@saruman.ics.muni.cz> * pass the correct size array in 2nd arg of utimes() when setting the modification time
More features, some of which were inspired by changes that friedman@gnu.ai.mit.edu (Noah Friedman) made to his modified ftp: - implement "lpwd" - local pwd - implement "preserve" - toggle preserving of file modification times on retrieved files - allow for explicit "on" or "off" arg to toggle commands - "exit" synonym for "quit", "msend" synonym for "mput" - in confirmation mode, allow 'a' (yes to rest of current command), and 'p' (turn off prompt mode, as if 'prompt off' was done, effective immediately) - "modtime" returns time formatted as localtime, not GMT Bug fixes: - check for extraneous args on commands - cleanup const usage, line formatting - create 0 length temporary file in remglob() to prevent symlink games (from OpenBSD) - check length of filename of ~/.netrc (from OpenBSD)
cleanups/bugfixes: - don't echo 'ACCT' parameter when debugging (a la 'PASS') - Fix checking of directory access for "/foo", the parent directory is "/", not "" (from FreeBSD) - remove trailing whitespace on lines - add any missing NetBSD tags - cleanups to man page, includinging sorting options description feature additions: - variable sized hash marks (from [bin/683], but done in the hash command as an optional arg) - more user-friendly transfer time printing (from FreeBSD, with mods) - '-p' command line option to jump into PASV mode (closes [bin/2857], but with an option rather than checking argv[0]) - SIGINFO support for printing xfer stats when sending/receiving requests - '-P port' for changing the port to connect to (from thorpej@netbsd.org) - '-a': bypass normal login, and try anonymous login (from OpenBSD via thorpej) - autofetch files via url (ftp://...) or "classic" (host:/file) (from OpenBSD via thorpej) - 'ftp' synonymous with 'open' (from FreeBSD)
Sync with 4.4lite2
imported from 44lite2
Add RCS ids.
file extern.h was added on branch netbsd-1-0 on 1994-08-29 03:09:11 +0000
Add RCS ids.
passive mode support, from David Carrel <carrel@cisco.com>, and cleaned up for the new ftp sources by me.
import from 4.4-Lite
Initial revision