Commit Graph

75 Commits

Author SHA1 Message Date
lukem 294b3e3a95 be more explicit that $ftp_proxy and $http_proxy are not supported for
interactive sessions
2000-11-27 10:19:12 +00:00
lukem ecd3d78091 - implement "mreget"; as per "mget" but uses "reget" instead of "get"
- add -N netrc and $NETRC, as methods to select an alternative .netrc file
- cache local user name and home directory for further use
- in mget(), use docase() instead of a local version to do the case
  conversion.
2000-11-15 00:10:59 +00:00
lukem ddc9ba4e19 clarify that $ftp_proxy only works for full URLs and can't be used for
interactive connections.
2000-09-28 12:26:19 +00:00
lukem ef0145331b rename "opts" to "remopts", so people used to "o host" don't get bitten... 2000-07-28 11:45:11 +00:00
lukem b2a6191c15 add rfc 2389, since that's now supported 2000-07-18 07:18:36 +00:00
lukem 7816d2586e 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().
2000-07-18 07:16:52 +00:00
lukem 71c4464e3e - fix ai_unmapped() to be a no-op in the !def INET6 case
- display `(-INET6)' at the end of the version string if !def INET6
- clarify in the man page that IPv6 support may not be present (for lukemftp :)
2000-06-05 09:22:52 +00:00
itojun b347bd9b87 updated comment on IPv4 mapped address. sync with kame. 2000-06-01 04:26:38 +00:00
lukem 413a4004df 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>
2000-05-31 14:23:57 +00:00
lukem 04b8305c9e Fix examples on using pipes in local filenames. AFAICT, ftp has always
required `dir . |more' not as `dir |more' treats `|more' as the remote
filename. Resolves [bin/9922] by Geoff Wing <mason@primenet.com.au>
2000-05-31 10:25:15 +00:00
itojun 6fc49112e9 document IPv4 mapped address twists.
- ftp(1): treats IPv4 mapped destination as IPv4 peer, not native IPv6 peer.
  this does not support network with SIIT translator.
- rshd(8)/rlogind(8): rejects accesses from IPv4 mapped peer, to avoid
  possible abuse of IPv4 mapped addr (rshd/rlogind use source address-based
  auth so it is important to check the condition).
2000-05-30 05:21:46 +00:00
lukem bd22f3362b Change `ls' to use the `LIST' and not `NLST' FTP protocol command.
Now that after many years on not caring we find certain popular
ftp servers are starting to obey RFC959 to the letter of the law
and will only return a list of filenames (not directories or
other filetypes) in the output of `NLST', then `LIST' is more useful
in this case. (Note that the aforementioned pedanticness means that
filename completion isn't as useful as it could be...)
Fixes [bin/8937] by David A. Gatwood <dgatwood@deepspace.mklinux.org>
2000-05-28 07:53:30 +00:00
lukem 2c9a4cf5d0 convert to ANSI KNF 2000-05-01 10:35:16 +00:00
lukem d16e624b57 * 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.
2000-05-01 09:44:53 +00:00
lukem 80b66e48af change references from draft-ietf-ipngwg-url-literal-01.txt to RFC 2732 1999-12-21 13:00:18 +00:00
lukem f25449279d * complete_remote(): use remglob("", ...) instead of remglob(".", ...),
for listings of the current working directory; some ftp servers don't
  like `NLST .'.
  [noted by Giles Lean <giles@nemeton.com.au>]
* recvrequest(): treat remote=="" as remote==NULL when calling command().
  (to support the above change)
* support `[user@]' in `[user@]host' and `[user@]host[:][path]'.
  [based on idea (and initial code) from David Maxwell <david@fundy.ca>]
* `idle' may be invoked without any args
* reformat some comments
* reformat usage string in program and man page
* call updateremotepwd() after successful login, not after successful connect
* always call setsockopt(, IPPROTO_IP, IP_TOS, ) (et al); using #if
  defined(IPPROTO_IP) doesn't work on certain foreign systems where
  enums instead of #defines are used...
  [noted by Matthias Pfaller <leo@dachau.marco.de>]
1999-11-26 21:41:55 +00:00
lukem ecb8a0755a - 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'
1999-11-12 02:50:38 +00:00
lukem 14fbd5079e - 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
1999-11-11 02:53:02 +00:00
lukem b2edff6b32 - implement restarting file:/// non-proxied http:// URLs (with -R).
- fix a semicolono which stopped file:/// from working
1999-11-10 07:34:41 +00:00
lukem 4f2d3550d0 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.
1999-10-24 12:31:36 +00:00
lukem 28f9cbb866 s/ARPANET/Internet/ ... 1999-10-12 08:11:59 +00:00
lukem da626f2307 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).
1999-10-12 06:04:59 +00:00
lukem 3f8b92b0b3 * factor out SIGINFO setting into a handler that is always active (but only
prints out info if bytes > 0). only set the handler if SIGINFO is defined
* hijack SIGQUIT to be the same as SIGINFO (foreign ports have this, and it's
  annoying to have SIGQUIT dump core on netbsd when it prints info on other
  systems)
* in {recv,send}request(), factor a lot of duplicated code out into a
  `cleanup' section at the end
* rework shell() a bit
1999-10-05 13:05:39 +00:00
lukem f45505380a add TNFi copyright to all files i've done more than a minor amount of work to... 1999-10-05 01:16:11 +00:00
lukem 4309cfaab3 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
1999-10-05 00:54:07 +00:00
lukem fcb1a22a1c If EPSV or EPRT fails, disable epsv4 for the rest of the current connection.
the disabled state can be overridden by toggling epsv4.

(I got sick of the errors about EPSV not being supported on almost
every server I connect to. This way we retain support for epsv4, but
it's not so whiny after the first failure...)
1999-10-01 08:01:12 +00:00
lukem 38100c05f4 * newer takes an optional second arg, so document this
* be a bit more explicit that the arguments to rate are in bytes
1999-10-01 05:08:31 +00:00
lukem 256fc138f1 * 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
1999-09-28 06:47:38 +00:00
lukem 700e3c1ec7 * 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.
1999-09-22 07:18:31 +00:00
lukem 375a0efb60 * 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
1999-07-12 13:20:34 +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
itojun 5536a65571 IPv6 support. 1999-07-02 07:59:56 +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
kleink 6d111978e7 Elaborate a bit on PAGER. 1999-06-13 20:00:03 +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 4494ebf448 parse http:// urls (and the $http_proxy variable) for [user:[pass]@]
elements, which are used for the initial authentication attempt (if
requested by the server).  in the case of $http_proxy, use the values
for proxy authentication.
1999-05-12 11:16:43 +00:00
lukem f3e5b2a6c6 clarify what uses gate-ftp mode. suggested by simonb 1999-05-04 14:16:15 +00:00
lukem f55d4712e3 * make parsing of ftp:// urls more RFC 1738 compliant;
- the path is split on `/', and each directory is CWD-ed into separately.
      (from [standards/7484] by Alan Barrett <apb@iafrica.com>)
    - support a trailing `;type=X' suffix, where X is a,i, or d.  (d isn't
      implemented, but it is recognised)
    - the only non-compliant behaviour is that empty directories sections
      (e.g `//') aren't run as `CWD ' - as a lot of ftpds don't like that.
      Instead, treat this as a no-op.
* don't support globbing for ftp urls, since that's technically not
  RFC compliant.
* fix a couple of man-page nits
1999-04-28 13:35:40 +00:00
lukem bed9aad370 * 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
1999-03-22 07:36:40 +00:00
garbled 5b40cb5777 First round of .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages.  Many more to
come.
1999-03-15 08:22:20 +00:00
lukem 5a1118c5f9 * add url_decode() - `in-place' decode %xx escapes in a given url component
* parse_url()
-   only look for user[:pass] for an ftp url (per rfc1738)
-   strip leading /'s in an ftp url. (almost per rfc 1738)
* fetch_url()
-   decode a copy of the path and use that to build local filenames
-   send port in http Host: header (suggested by cgd@netbsd.org)
* fetch_ftp()
-   url_decode() the user, pass and path
-   fix splitting of path into dir & file (partially from [bin/7073])
-   don't bother caching the last host; it can cause problems when
    using ftp:// transfers, or when the user changes between xfers
* improve documentation of auto-fetched url arguments (especially regarding
  escape sequences in ftp:// urls)
* some whitespace & copyright updates

this should fix [bin/7073] William O Ferry <woferry@warp.wofme.com>,
as well as the metaissues raised in that PR.
1999-03-08 04:36:12 +00:00
mycroft a1c657fe56 Clean up SYNOPSIS formatting. 1999-03-07 11:29:58 +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 0e87f1b53d support -f, which forces a cache flush for http xfers using either
`Pragma: no-cache' (http/1.0) or `Cache-Control: no-cache' (http/1.1)
1999-01-23 15:46:24 +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 64fa07c111 default anon password is user@ not user@host 1998-08-08 02:58:48 +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
perry 41b921e7d1 Style police: "uses" is better than "utilizes", which is a horrible nelogism. 1998-07-13 17:16:22 +00:00