Commit Graph

677 Commits

Author SHA1 Message Date
gutteridge f9cbc07bc5 ftp.1: drop a sentence that's no longer accurate 2024-04-17 02:46:03 +00:00
christos 710028cc1b default is now 16K 2024-02-19 00:15:20 +00:00
wiz 8c5ffc0fbb ftp: bump FTPBUFLEN from 4kB to 16kB
sourceforge.net returns a 5kB content-security-policy.
Analyzed by mlelstv@ who reports usual limits are between 4kB and 48kB.
2024-02-18 22:33:15 +00:00
christos b5f76c451f Add -b <buflen> to specify the buffer size. 2024-02-18 22:29:56 +00:00
lukem 87c2a4af33 ftp(1): wording and formatting improvements
Fix grammar issue with "Support values" reported in private mail.
Document all file transfer types in "type" and cross-reference that.
Consistency fixes in describing file transfer parameters and types.
Fix some mandoc -Tlint issues (except "useless macro: Tn").
2023-12-09 02:15:11 +00:00
mlelstv 76da897ffe Don't finish downloading an empty file with 'already done' before it is
created locally.
2023-08-12 07:40:13 +00:00
mlelstv cee41877f8 Fix HTTPS through Proxy.
While a regular HTTP Proxy, requires the absolute URL with protocol
and host part, yyou must only send the relative URL through a
CONNECT tunnel (you are talking to the target server).
2023-07-02 10:02:09 +00:00
lukem c4b7a9e794 bsd.own.mk: rename GCC_NO_* to CC_WNO_*
Rename compiler-warning-disable variables from
	GCC_NO_warning
to
	CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
2023-06-03 09:09:01 +00:00
lukem b8a22b4ebe ftp 20230516 for openssl 3.0 compat SSL_OP_IGNORE_UNEXPECTED_EOF 2023-05-16 22:00:23 +00:00
christos 3778483fd3 Ignore EOF from remote. 2023-05-16 18:52:09 +00:00
lukem 55c16b26b6 add timeout for ssl connect
Implement a timeout for SSL connection setup, using -q QUITTIME,
defaulting to 60 seconds.
SSL_connect(3) (unlike connect(2)) doesn't timeout by default.

Adapt ssl error messages destination: if unexpected error
from local API, use warn()/warnx() to stderr;
if expected error from a network operation (e.g., timeouts),
use fprintf to ttyout (which might be stdout).

Consistently use ftp_poll() instead of select();
ssl.c (using select()) was added 7 years after the
previous uses of select() were converted to poll().

Check EAGAIN as well as existing EINTR error from ftp_poll(),
for portability.
2023-05-05 15:46:06 +00:00
lukem 6db0a1447b Simplify includes
Include "ftp_var.h" instead of various system headers and "extern.h".
2023-04-09 06:10:03 +00:00
uwe ea045e23c8 ftp(1): better mark up for url vs cd example 2023-02-25 17:37:09 +00:00
uwe e07284c9b0 ftp(1): minor markup tweaks
Use .Ql instead of .Sq Li, add some missing ones.  Use .Pq instead of
explicit () for longer phrases - these are easier to read in the
postscript output b/c of extra spacing.
2023-02-25 13:51:48 +00:00
mlelstv ddcd952b6c 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.
2023-02-25 12:07:25 +00:00
andvar 1899cf5c74 s/bninary/binary/ in comment. 2023-01-20 22:08:48 +00:00
lukem 549e7721e4 update ftp version to 20220911
PR/57003: Handle relative URLs (patch by kim@)
2022-09-22 03:31:04 +00:00
christos b014ae325d Disable verification for now until we implement installation of trust anchors. 2022-09-12 15:10:31 +00:00
christos 4cd84277f2 PR/57003: Handle relative URLs (patch by kim@) 2022-09-11 20:49:27 +00:00
christos 42e6ad3ad9 Add cert verification, together with an environment variable "NO_CERT_VERIFY",
to turn it off.
2022-08-30 08:51:28 +00:00
andvar 6478b40555 s/blity/bility/ in various words, mainly in comments. 2022-08-06 18:26:41 +00:00
lukem 8c92a88f00 ftp: fix -? more portably
Start the optstring with ":" (which implicitly disables opterr),
and handle '?' with optopt=='?' separately to ':'.
Fixes -? display of full usage on other platforms.
2021-10-09 09:07:20 +00:00
rillig 133e932a29 usr.bin: remove unnecessary lint comment CONSTCOND
Since 2021-01-31, lint no longer warns about 'do ... while (0)'.

No functional change.
2021-09-10 21:52:17 +00:00
rillig ac83d301f8 ftp: fix undefined behavior when parsing FEAT
lint says: warning: argument to 'function from <ctype.h>' must be cast
to 'unsigned char', not to 'int' [342]
2021-08-27 17:35:03 +00:00
lukem fe59185633 update ftp version to 20210826
Version bump for PASV/LPSV address validation
2021-08-26 06:25:59 +00:00
lukem e6d740a8e7 ftp: remove unnecessary variable assignments
Remove assignment to error in initconn(); it's not tested anywhere after the
initial use, so no need to set it before goto bad.

(Looks like copypasta from the initial addition of the code in rev 1.48.)
2021-08-26 06:23:24 +00:00
lukem 819e578d6a ftp: validate address from PASV and LPSV response
Fail if the server's response to PASV or LPSV contains an IP address
that doesn't match that of the control connection.
(EPSV already only uses the port portion of the server's response,
per RFC 2428).

Previously a hostile server could cause ftp to open a data connection elsewhere.

Many other ftp implementations have had a similar change for many years,
including those in popular browsers (before they deprecated FTP ...)

Thanks to Simon Josefsson notifying me about
  https://lists.gnu.org/archive/html/bug-inetutils/2021-06/msg00002.html
2021-08-26 06:16:29 +00:00
andvar 4b2769fe52 fix typos in word "otherwise". 2021-08-01 15:29:29 +00:00
christos ee9a791b28 Use raw write(2) instead of fwrite(3) to avoid stream corruption because
of the progress bar interrupts. From RVP.
2021-07-06 09:26:47 +00:00
lukem b6f942120f use fetch_*() for I/O with SMALLPROG / !WITH_SSL builds
Adapt the SMALLPROG / -UWITH_SSL build to also use the fetch_*()
methods from ssl.c, instead of using stdio, as stdio isn't robust
when using interruptable signals.

Disable ssl-specific support in the fetch_*() methods if WITH_SSL
isn't defined, so SMALLPROG still doesn't have ssl support (as expected).

The resulting SMALLPROG binary is slightly larger than before
(e.g., 157KiB vs 153KiB on amd64).

Set version to 20210603 for this fix and the SO_KEEPALIVE fix for PR 56129.

PR install/56219
2021-06-03 10:23:33 +00:00
lukem 689eea59e5 set SO_KEEPALIVE on control connection
Attempt to prevent timeouts of the control connection by setting SO_KEEPALIVE.
This matches the equivalent behaviour in ftpd.

Note: This is a much simpler change than adding a background polling event
to invoke "STAT" (or "NOOP") on the control connection during a transfer.
(It's unclear from RFC 959 whether "NOOP" is even permitted during a transfer).

PR bin/56129
2021-06-03 10:11:00 +00:00
lukem 9f8e2c9192 ftp(1): consistently use FTP for protocol use. 2021-04-25 09:09:55 +00:00
lukem 094f09734d ftp(1): consistent Ic (not Nm) for commands 2021-04-25 08:46:19 +00:00
lukem 4f096ae03f better XXX comment for buggy ftp server 2021-04-25 08:26:35 +00:00
lukem 5a12b29797 ftp(1): more $https_proxy documentation
Document $https_proxy in ENVIRONMENT.
(It was already documented elsewhere).

Fixes PR bin/51883
2021-01-31 08:59:40 +00:00
lukem 5650392b38 ftp(1): fix description of "debug"
"debug" command and documentation got accidentally renamed
to "ftp_debug" 13 years ago, and was only partially fixed.
2021-01-06 09:15:59 +00:00
lukem 920389c199 ftp: don't use restartable signals
Refactor to not rely upon restartable signals (SA_RESTART),
possibly fixing intermittent failures with -q QUITTIME.

ftp transfers: handle EINTR/EAGAIN in copy_bytes(),
instead of relying upon restartable signals.

http/https transfers: Explicitly print an error similar to
progressmeter() when timing-out for -Q QUITTIME in fetch_wait(),
and set errno to ETIMEDOUT so that the warn() in fetch_url()
prints a more accurate error message.

PR/55857
2021-01-06 04:43:14 +00:00
mrg cb93b81028 add support for new GCC 9 warnings that may be too much to fix
right now.  new address-of-packed-member and format-overflow
warnings have new GCC_NO_ADDR_OF_PACKED_MEMBER amd
GCC_NO_FORMAT_OVERFLOW variables to remove these warnings.

apply to a bunch of the tree.  mostly, these are real bugs that
should be fixed, but in many cases, only by removing the 'packed'
attribute from some structure that doesn't really need it.  (i
looked at many different ones, and while perhaps 60-80% were
already properly aligned, it wasn't clear to me that the uses
were always coming from sane data vs network alignment, so it
doesn't seem safe to remove packed without careful research for
each affect struct.)  clang already warned (and was not erroring)
for many of these cases, but gcc picked up dozens more.
2020-09-06 07:20:26 +00:00
lukem 6ded57f3ab ftp: add -? for help. improve synopsis
Add -? to display usage synopsis and help to stdout.
This allows for "ftp -? | less", which is more user friendly.
Errors still show usage to stderr.
Consistency improvements in some usage text.
2020-07-18 03:00:37 +00:00
uwe 7bb9dbe9f7 Try to improve markup for better PostScript output. 2020-07-15 19:23:44 +00:00
uwe 7eb2a579d9 Do not use "[...]", just "..." is enough.
Conventionally the ellipsis already expresses optional repetition,
e.g. .Ar without arguments produces "file ...".
2020-07-15 17:36:38 +00:00
pgoyette 0c228d5c9c Remove now-extraneous Op since we already have Oo and Oc to enclose
the Ar port.
2020-07-15 16:41:16 +00:00
lukem 960cec782f ftp.1: don't wrap "[[user@]host [port]]" 2020-07-15 08:56:05 +00:00
lukem 5a6e9afc87 ftp(1): consistency tweaks 2020-07-13 11:17:14 +00:00
lukem 123e840f8b ftp.c: improve signal handler restoration
Only invoke the old signal handler if it's a real signal handler
and not SIG_IGN, SIG_DFL, SIG_HOLD, or SIG_ERR, using new static
function issighandler().
Avoids an intermittent race condition with a null pointer
dereference via (*SIG_DFL)().
Bug class reported by Joyu Liao from Juniper Networks.

Use SIG_ERR instead of NULL as the indicator that a signal handler
hasn't been changed, so that SIG_DFL (equivalent to NULL)
will be restored.
2020-07-11 02:19:31 +00:00
lukem 0eaa71357e fetch_url: improve signal handler restoration
Use SIG_ERR not NULL as the indicator that a signal handler
hasn't been changed, so that SIG_DFL (equivalent to NULL)
will be restored.

Fix restoration of SIGQUIT; use the old handler not SIGPIPE's.
2020-07-11 00:29:38 +00:00
lukem 31aae2d731 ftp: exit if lostpeer invoked by a signal
lostpeer() calls too many async-unsafe functions (both directly
and indirectly) to close and cleanup the remote connections,
so just exit after the cleanup if invoked by a signal.

Reported in private mail by Qi Hou.
May also resolve a crash reported by Thomas Klausner.
2020-06-08 01:33:27 +00:00
lukem b310c98c56 update ftp version to 20190622 2020-02-26 05:55:27 +00:00
christos 4a69030bcd trim down error checking if we are small. 2019-06-22 23:40:53 +00:00
christos 9bedb72e28 make this compile again with -DNO_PROGRESS 2019-06-22 23:40:33 +00:00