Commit Graph

643 Commits

Author SHA1 Message Date
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
christos e35c1a2b0b redo the connection waiting handling to make it more clear. 2019-04-07 00:44:54 +00:00
christos a5b9754eb4 Make fetch_read() return size_t like fread() does. It is bogus to
have one backing implementation that returns different values and
types than the other.  Handle error setting properly; i.e. bail
out if the internal read returned an error. Now we get a proper
error message when the the server resets our connection instead of
a warning that the right failed with an invalid argument.

The server used for testing was:
	http://capeweather.dyndns.org:8080/graphs/3474.png
Which seems to be unreliable :-)
2019-04-04 00:36:09 +00:00
martin c3c1b1c5e7 Try to avoid a (bogus) fatal warning from clang. 2019-02-06 07:56:42 +00:00
mrg a6590737cd - add justquit() that always exits. use it to avoid unreachable code. 2019-02-04 04:09:13 +00:00
mrg fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
christos 44671790a5 PR/53916: Rob Gill: remove redundant assignment to matchlen. 2019-01-28 12:04:16 +00:00
dholland 7f4ac6d6b0 Don't use the local username as the default anonftp password.
once upon a time doing this was part of the social glue that held the
community together, but that was a long time ago, and now it's just an
information leak.

proposed on tech-userlevel in 2008, then apparently forgotten :-|
2018-03-04 19:57:41 +00:00
christos a58fb25d66 more volatile to appease gcc. 2018-02-11 02:51:58 +00:00
christos 59b2928637 explicitly include <string.h> since OpenSSL-1.1 does not do it for us. 2018-02-06 19:26:02 +00:00
christos a8dccd7b32 Make outfile always allocated, free it to set it to NULL, and don't move it
around.
2017-11-25 15:39:17 +00:00
kre 23014bc41f Issue PWD commands to the server only when we actually
need the results, not speculatively, just in case we might.

Allows operation with some broken servers that get confused
by PWD commands in some situations, and saves server round
trips in the (modern) common case of
	ftp ftp://path/name
where we never need to know the results from PWD.
2017-11-20 21:11:36 +00:00
wiz 01869ca4d2 Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
riastradh ef315f7931 Remove MKCRYPTO option.
Originally, MKCRYPTO was introduced because the United States
classified cryptography as a munition and restricted its export.  The
export controls were substantially relaxed fifteen years ago, and are
essentially irrelevant for software with published source code.

In the intervening time, nobody bothered to remove the option after
its motivation -- the US export restriction -- was eliminated.  I'm
not aware of any other operating system that has a similar option; I
expect it is mainly out of apathy for churn that we still have it.
Today, cryptography is an essential part of modern computing -- you
can't use the internet responsibly without cryptography.

The position of the TNF board of directors is that TNF makes no
representation that MKCRYPTO=no satisfies any country's cryptography
regulations.

My personal position is that the availability of cryptography is a
basic human right; that any local laws restricting it to a privileged
few are fundamentally immoral; and that it is wrong for developers to
spend effort crippling cryptography to work around such laws.

As proposed on tech-crypto, tech-security, and tech-userlevel to no
objections:

https://mail-index.netbsd.org/tech-crypto/2017/05/06/msg000719.html
https://mail-index.netbsd.org/tech-security/2017/05/06/msg000928.html
https://mail-index.netbsd.org/tech-userlevel/2017/05/06/msg010547.html

P.S.  Reviewing all the uses of MKCRYPTO in src revealed a lot of
*bad* crypto that was conditional on it, e.g. DES in telnet...  That
should probably be removed too, but on the grounds that it is bad,
not on the grounds that it is (nominally) crypto.
2017-05-21 15:28:36 +00:00
nonaka 165ef89073 ftp(1): split the auth processing function. 2017-02-15 11:52:11 +00:00
christos 10c59ee542 Use the first name we requested the http/https URL for, not any name we ended
up with after random redirects.
2017-01-31 21:05:35 +00:00
nonaka a69e0947f2 handle proxy authentication correctly. 2016-12-15 04:49:15 +00:00
christos 8481accb85 PR/51558: ast@: ftp dumps core after usage message when IPv6 URL lacks a slash.
Initialize variable so that we don't get random behavior on cleanup.
2016-10-17 00:52:53 +00:00
joerg 740128222b When using data outside the signed char range, it is better to
consistently use an unsigned char buffer.
2016-10-04 15:06:31 +00:00
maya 519ca6e803 Do globbing for FTP URLs of the form ftp://... too
ok christos
2016-08-03 12:33:56 +00:00
christos b1bf748a07 PR/51043: Yorick Hardy: ftp(1) should use the port number for CONNECT 2016-04-04 23:59:41 +00:00
christos f3a6400cd0 sprinkle more volatile (distribution build with gcc-5.3) 2016-03-18 18:42:25 +00:00
christos 64f5cd70a3 CID 1354295: Array overrun. 2016-02-27 16:31:31 +00:00
christos 54835745af use sizeof() and array notation. 2016-02-06 21:23:09 +00:00
nonaka a3255ab05b Initialize the token match pointer. 2016-02-05 03:41:05 +00:00
wiz 30e99be8f8 Fix downloads of local files using file:// URLs
Previously it would error out in copyurlinfo() when copying a NULL port.
2016-01-05 11:41:00 +00:00
christos 1f7a09da7b mark function as only needed with ssl. 2015-12-17 20:36:36 +00:00
christos 01e355354c Split the position/size parsing into a separate function. 2015-12-17 17:26:45 +00:00
christos 33fd699b86 Simplify and factor out connect message 2015-12-17 17:08:45 +00:00
nonaka ac27abcc55 - Fix to connect https via proxy.
- Fix ttyout message.
2015-12-17 04:36:56 +00:00
christos 7a83389f23 make DPRINTF/DWARN always statements. 2015-12-16 23:00:39 +00:00
christos 17562cefd2 PR/50438: NONAKA Kimihiro: ftp(1): CONNECT method support
Please test!
2015-12-16 21:11:47 +00:00
christos 941a869c25 more refactoring:
- introduce authinfo and urlinfo structures
	- split negotiation code out.
2015-12-16 19:17:16 +00:00
nonaka f6c8c6eefb Fix compile failure without WITH_SSL.
>    /tmp/bracket/build/2015.12.15.21.01.27-i386/src/usr.bin/ftp/fetch.c: In function 'fetch_url':
>    /tmp/bracket/build/2015.12.15.21.01.27-i386/src/usr.bin/ftp/fetch.c:823:18: error: 'HTTPS_URL_T' undeclared (first use in this function)
>           urltype == HTTPS_URL_T ? &ssl : NULL);
2015-12-16 01:20:05 +00:00
christos 82dbb89087 Factor the proxy handling code out. 2015-12-15 21:45:21 +00:00