Commit Graph

56 Commits

Author SHA1 Message Date
lukem 20a4d96576 reword EPSV status line 1999-09-21 13:10:16 +00:00
itojun 940276557f 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.
1999-07-11 20:37:39 +00:00
itojun d1a8e792f7 add dual-stack (IPv4/v6) support. hope I broke no other part... 1999-07-02 08:07:40 +00:00
lukem d8df707b58 s/xfer/transfer/ 1999-06-29 12:41:22 +00:00
lukem e25749a582 [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.
1999-06-29 10:43:16 +00:00
cgd d78b6bd31e 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.
1999-06-20 22:07:28 +00:00
lukem 9bfd0a7cb6 use default pager if $PAGER="" 1999-06-11 14:12:19 +00:00
lukem f7540e6f75 * fix gate mode to login as `user@realhost' rather than using PASSERVE;
the latter only seemed to work for TIS Gauntlet and not TIS fwtk.
  thanks to simonb@netbsd.org for testing this. fixes [bin/5556].
* if EOF (e.g, ^D) is entered at a username/password/account prompt which
  happens to use fgets(), exit the login rather than treating EOF as CR.
* don't use the comma operator where separate statements are valid
* always use snprintf to copy stuff into malloced buffers, just in case
  typos creep in and mean that the buffer ends up being overflowed
1999-06-02 02:03:57 +00:00
lukem 566466ff97 update copyright 1999-05-12 11:06:00 +00:00
lukem babd00aa2c whitespace & copyright fixes 1999-03-08 03:09:08 +00:00
lukem 0bd80459cb * -v enables verbose & progress, -V disables both
* set setvbuf(ttyout, NULL, _IOLBF, 0) and remove a bunch of fflush(ttyout).
* use fwrite() instead of write() for progressmeter (don't intermix stdio
  with non stdio ops)
1999-01-24 02:39:29 +00:00
lukem 5051fd95cb flush ttyout in togglevar() 1999-01-24 00:51:08 +00:00
lukem da0a823fb0 * hash & progress are mutually exclusive. [noted by mrg@netbsd.org]
* in autofetch mode, don't attempt to 'cd /' on first xfer (only on
  subsequent xfers), as some ftp daemons don't permit that.
  [noted by dbj@netbsd.org].
  XXX: code could be smarter (but a lot more complicated to boot); this
  works for now.
1998-10-08 14:45:26 +00:00
lukem 00c10429b7 replace command(buf) with command("%s", buf) in quote1(), thus preventing
'quote' commands that contain % formats from being mis-intepreted.
noted by Lundman <lundman@argonaut.com> on current-users@netbsd.org
1998-09-01 14:25:52 +00:00
lukem efa34be454 use <limits.h> for INT_MAX (more portable) 1998-08-08 02:51:49 +00:00
lukem 4a8ec5494d 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'
1998-08-03 01:49:25 +00:00
lukem b521b370b5 * spell `retrieved' correctly!
* parse Last-Modified: HTTP headers for date, and change time of
  retrieved file if parsing succeeded
* support file:/// and file://localhost/ URLs
* in url_get(), re-write byte moving code to consistently use fread()
  and fwrite(), and check errors at end with ferror()
* add about:* easter-egg (#ifndef SMALL :-)
1998-07-26 12:58:16 +00:00
thorpej 7a12770f94 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.
1998-07-10 04:39:03 +00:00
kleink fc5d36f8e4 GLOB_QUOTE is dead; per POSIX, backslash quoting of special characters being
enabled is the default behaviour.
1998-06-19 22:58:04 +00:00
lukem 9a6e9b2ce7 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.
1998-06-04 08:28:35 +00:00
christos acb3ba5670 - add <signal.h> since we are using signals.
- cast arg to is*() to unsigned char.
- don't require quad_t to exist to compile.
1998-05-20 00:52:29 +00:00
kleink 650b9ca681 Need <time.h> for asctime() and localtime() prototypes. 1998-04-01 21:07:03 +00:00
lukem 6ab4bdf006 define MAX_IN_PORT_T and use instead of USHRT_MAX. suggested by cgd@netbsd.org 1998-01-18 22:09:39 +00:00
lukem 7ee412ebee * 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.
1998-01-18 14:23:33 +00:00
lukem 699c57c48b correctly detect good vs bad hash mark values. (found by <enami@netbsd.org>) 1997-11-02 00:18:46 +00:00
lukem d067f3bbd2 * 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'
1997-11-01 14:36:49 +00:00
lukem a09466a728 add a space to restart message. from geoff wing in [bin/4161] 1997-09-26 15:22:46 +00:00
lukem 8732be2e09 More cleanups from Todd Miller <Todd.Miller@courtesan.com>:
* Use an int, not "union wait".
* Move the "parsed_url" label so that the next statement is not an "else" --
  some ansi C compilers don't like it the old way (SGI's for example).
* Deal with the possibility of getlogin(2) failing.
* Don't error out if the remote server doesn't support the "MDTM" command.
1997-09-21 01:06:30 +00:00
lukem 87453d32bd Fixes from Todd Miller <Todd.Miller@courtesan.com>:
* use size_t instead of int in places
* use symbolic constants when using access()
1997-09-13 09:05:52 +00:00
lukem 2fec2a28f5 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]]'
1997-08-18 10:20:13 +00:00
lukem 609496986e fix compile on alpha:
* cast all %qd printfs to (long long) [inspired by billc@warped.net]
* replace sscanf %qd with strtoq() et al
1997-07-21 14:03:48 +00:00
lukem b9d5554d5d * 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
1997-07-20 09:45:35 +00:00
pk f6d87734a6 NULL => 0 (Arne Juul; PR#3629) 1997-05-17 19:40:47 +00:00
lukem a9a78ba448 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>
1997-04-14 09:09:15 +00:00
lukem d473547d56 * 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>
1997-04-05 03:27:32 +00:00
lukem ae07641250 Fixes from <Todd.Miller@cs.colorado.edu>, with some cleanup and reworks by me:
* only echo "Passive mode" in verbose mode; scripts that use ftp
  may get unwanted output otherwise
* disable progress bar and modification time preservation when
  retreiving to a non-regular files. fixes progress bar getting in
  way of "get file /dev/tty"
* setup el_init() et al if editing is set, not if fromatty.
  TODO: migrate this to a function, and call if editing is turned on later
	in the session. also implement edit_cleanup if editing is turned off
* call el_set() after setting SIGWINCH handler. This fixes the problem
  when suspending in a non-cbreak shell (e.g, csh) would trash your tty mode.
* reset interactive mode correctly in auto_fetch() mget mode
1997-03-16 14:24:14 +00:00
christos 067f3f2db4 SMALLFTP->SMALL; remove SMALL from Makefile 1997-03-14 01:39:31 +00:00
lukem 3b5054739d 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.
1997-03-13 06:23:11 +00:00
lukem 3a50014d60 [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...
1997-02-01 10:44:54 +00:00
veego 13c790f77f Add missing ; 1997-01-19 20:17:37 +00:00
lukem 7a7fa80740 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.
1997-01-19 14:19:02 +00:00
tls 9d225a1783 RCS ID police 1997-01-09 20:18:21 +00:00
lukem 53b51b68ea doproxy(): remove leading "proxy " from input buffer so if another() is called
and line[] is reparsed to build margc/margv, commands don't get confused.
1997-01-03 02:55:59 +00:00
lukem e699917c51 * 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
1996-12-29 04:05:29 +00:00
christos 942194d9f4 - Don't print the '500 command not understood' reply for the SIZE and
MDTM commands which are not supported by all ftp servers, unless we
  are in debugging mode.
1996-12-25 16:00:38 +00:00
lukem b6df1b3d2d 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
1996-12-06 02:06:46 +00:00
lukem 8ef5f80460 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)
1996-11-28 03:12:28 +00:00
lukem 36d3d1fd0f 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)
1996-11-25 05:13:18 +00:00
tls 917ef72d79 Sync with 4.4lite2 1995-09-08 01:05:59 +00:00
jtc f9ffa0ef02 Null terminate case-mapped filenames (PR #640). 1994-12-15 08:58:44 +00:00