summaryrefslogtreecommitdiff
path: root/usr.bin/ftp
AgeCommit message (Collapse)Author
2023-12-15No interactive shell if -o is givenKlemens Nanni
After r1.140 and r1.144 fixed -o '' and clenaed up option handling, respectively, avoid the "ftp> " shell if any output file was specified. OK millert
2023-12-12Make -o less special, drop -o '' support, always use last valueKlemens Nanni
ftp(1) says -o is about a single file/URL, but option handling takes the empty string as "reset previous -o value", which makes little sense, is undocumented and counter-intuitively works as if no -o was specified. OK millert
2023-11-30Single file to stdout without "fattr"Klemens Nanni
Regardless of SMALL and other command flags, 'ftp -o - URL [file|URL ...]' only processes the first URL and exists. Only standard output is written to and modifying 'struct stat' properties as per pledge(2) "fattr" don't apply. OK millert
2023-11-30Fold identical pledge cases, '#ifndef SMALL \n if (!resume)' equals 'else'Klemens Nanni
OK millert
2023-11-22Piping single file to standard out needs no "proc exec"Klemens Nanni
'-o -' now means no "ftp> " shell, so no "|some cmd" files, "!some cmd" or "page" commands. OK millert
2023-11-22Do not drop into "ftp> " shell when piping to stdandard outputKlemens Nanni
'-o -' is orthogonal to an interactive prompt, yet some (malformed) URLs such as ftp://host/ would still end up there; exit after processing the first file/URL to prevent this. sthen deraadt agree OK millert
2023-11-09-C/resume without "proc exec"Klemens Nanni
ftp(1) has "proc exec" to run sh(1) on interactive ! commands and filenames starting with "|"; this is orthogonal to continuing transfers using the existing file size as offsets. There seems to be no case where a) the argument is an URL, i.e. we pledge, and b) a shell is spawned somehow, so avoid these promises when resuming. bsd.port.mk(5) FETCH_CMD uses -C by default. OK millert
2023-06-28revert makefile change included by mistake in previousOmar Polo
2023-06-28drop needless strcspn in the header parsingOmar Polo
since fetch.c revision 1.211, ftp removes trailingwhitespaces early so there's no need to re-do that when parsing a header. while here, remove an unused variable too. ok tb, millert
2023-06-28fix parsing of the Last-Modified headerOmar Polo
Was overlooked in r1.209. diff from 'a dog' (OpenBSD [at] anthropomorphic [dot] dog) ok tb, sthen
2023-03-08Delete obsolete /* ARGSUSED */ lint comments.Philip Guenther
ok miod@ millert@
2022-12-26spelling fixes; from paul tagliamonteJason McIntyre
amendments to his diff are noted on tech
2022-11-09Before printing the redirect URI pass it through stravis since it isClaudio Jeker
untrusted input. OK tb@ kn@ millert@
2022-11-09Strip spaces at end of header lines and in chunked encoding headers.Claudio Jeker
HTTP standard allows for spaces in too many places OK millert@ tb@
2022-09-19Remove now-unused connect_wait() function.Todd C. Miller
2022-09-15Use non-blocking connect() with ppoll() and timeout instead of alarm().Todd C. Miller
For hosts with multiple IP addrs this makes it possible to fall over from an unresponsive IP to another. This also replaces the other connect(2) + connect_wait() calls with timed_connect() so the -w option now works for more that just http. OK sthen@ deraadt@
2022-09-08Adjust HTTP header parsing to follow RFC more closely.Claudio Jeker
RFC9112 allows any amount of space/tabs between the ':' and the value. Until now this code required exactly one space which works most of the time but is not RFC compliant. OK djm@
2022-03-27ftp.1: remove a sentence fragment left over from a previous editChristian Weisgerber
ok deraadt@ jmc@ miod@
2021-11-10Revert previousKlemens Nanni
I overlooked the autoinstall case where "Requesting ..." is used, but those messages that got fixed where omitted in ftp's SMALL version. Noticed the hard way by anton
2021-11-09Print actually requested URLsKlemens Nanni
Encoding URL paths changes the requested URL and therefore may yield different responses (opposed to an unencoded URL), solely depending on how the server implements de/encoding. Always print the encoded URL which actually gets requested in output like "Requesting ..." and erors likes "Error retrieving ....: 404 Not Found" and don't use the original URL provided on the command line. This matches exactly what is seen on the wire, e.g. with tshark(1) and helps debugging URL de/encoding related (server) issues. Feedback OK sthen
2021-11-06Stop URL encoding the tilde characterKlemens Nanni
RFC 1738 Uniform Resource Locators (URL) lists tilde as unsafe character. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax updates it to The tilde "~" character was added to those in the "unreserved" set, since it is extensively used on the Internet in spite of the difficulty to transcribe it with some keyboards. In theory, this shouldn't make a difference, but some servers do not decode "%7e" and thus erroneously serve a 404. RFC 2396 2.4.2. When to Escape and Unescape says: In some cases, data that could be represented by an unreserved character may appear escaped; for example, some of the unreserved "mark" characters are automatically escaped by some systems. If the given URI scheme defines a canonicalization algorithm, then unreserved characters may be unescaped according to that algorithm. For example, "%7e" is sometimes used instead of "~" in an http URL path, but the two are equivalent for an http URL. Update ftp(1) to RFC 2396 by no longer treating "~" as unsafe character. This is effectively a one-character diff; update comments accordingly as well as the order of characters to ease code-to-standard comparison. This matches curl(1) and wget(1) behaviour wrt. encoding of "~". OK sthen
2021-08-31Spacing. OK tb@Claudio Jeker
2021-07-14Remove unneeded calls to tls_init(3)kn
As per the manual and lib/libtls/tls.c revision 1.79 from 2018 "Automatically handle library initialisation for libtls." initialisation is handled automatically by other tls_*(3) functions. Remove explicit tls_init() calls from base to not give the impression of it being needed. Feedback tb OK Tests mestre
2021-03-29in unsafe_char(), handle %NN with array-index inspection rather than weirdTheo de Raadt
ptr++ ok claudio
2021-03-13only try to set timestamps on files; avoids error with ftp -o /dev/nullStuart Henderson
ok jca robert
2021-02-25ftp: prevent double free() in error pathChristian Weisgerber
Reported by bentley@; ok bentley@ jca@
2021-02-16make use of getline(3) in ftp(1)Christian Weisgerber
Replace fparseln(3) with getline(3). This removes the only use of libutil.a(fparseln.o) from the ramdisk. Replace a complicated fgetln(3) idiom with the much simpler getline(3). ok jca@
2021-02-02add -Tu to usage();Jason McIntyre
2021-02-02introduce support for sending the If-Modified-Since header whileRobert Nagy
fetching over http(s) and use the timestamps from the remote server's Last-Modified header if available when saving local files this makes it possible to mirror files better with ftp(1) the new timestamp behaviour can be disabled with the new '-u' flag ok sthen@, input from sthen@ and gnezdo@
2021-01-27update comment, SMALL was split into SMALL and NOSSLStuart Henderson
2021-01-01Handle Permanent Redirect (RFC 7538)Christopher Zimmermann
ok jca@, kn@
2020-10-18Accommodate POSIX basename(3) that takes a non-const parameter andChristian Weisgerber
may modify the string buffer. improved and ok jca@
2020-09-06On tls_config_set_protocols() failure, include the output ofTheo Buehler
tls_config_error() in the errx() message. discussed with jsing
2020-09-06Wording tweak from jsingTheo Buehler
2020-09-06Use an int for the verification depth and drop a cast.Theo Buehler
from jca
2020-09-06Document -S protocols in ftp(1)Theo Buehler
ok jca
2020-09-06Allow specifying supported TLS protocols in ftp(1)Theo Buehler
This adds the possibility of specifying the TLS protocols for ftp(1) to use via -S "protocols=tlsv1.2:tlsv1.1" or -S "protocols=all" or simlar options. This works the same way as nc(1)'s -T protocols option using tls_config_{parse,set}_protocols(3) internally. ok jca
2020-09-01Fix build with -fno-common (default in clang 11)Jeremie Courreges-Anglas
Input and ok mortimer@
2020-07-06in 2014 I added this annotation: /* XXX floating point printf in signal ↵Theo de Raadt
handler */ our snprintf is reentrant safe except for floating point. Break the double apart into integer.integer notation, to avoid that. ok kettenis millert
2020-07-04Avoid malloc(3) calls in signal handlerkn
Fetch aborts through SIGINT (^C) print a message with fputs(3), but this calls malloc() on its own, which is not supported from interrupt handler context. Fix it by using write(2) which avoids further memory allocations. While here, merge abortfile() into the identical aborthttp() with a more generic "fetch aborted." message for simplicity. Spotted with vm.malloc_conf=SU and ^C on a port's "make fetch" causing ftp(49660) in malloc(): recursive call Abort trap (core dumped) OK jca (who came up with using write(2) independently)
2020-07-04Fix a double free in error pathsJeremie Courreges-Anglas
Consistently disarm the SIGINT handler on error, else a SIGINT can lead to taking twice the cleanup path. Initial report by naddy@, ok tb@
2020-06-20Avoid one uninitialized warning in file_get()Jeremie Courreges-Anglas
2020-02-22Avoid duplication in the code that sends headersJeremie Courreges-Anglas
ok yasuoka@
2020-02-22Respect userinfo even when built with NOSSL (floppy ramdisks)Jeremie Courreges-Anglas
Not handling it is incorrect and can lead to credentials leaks in DNS requests. The resulting growth is reasonable (about 300 bytes on amd64). ok yasuoka@
2020-02-20Backout revision 1.190 partially. That part was an unintended change whichYASUOKA Masahiko
is work in progress.
2020-02-19Fix http (not https) auth combined with proxy auth.Jeremie Courreges-Anglas
First look for userinfo, and overwrite it to make sure it doesn't reappears again later. Then reset the path to fix the fragile mechanism that produces the full request URI for the proxied connection case. ok yazuoka@
2020-02-19Don't put the userinfo in request URI. This also makes accessing aYASUOKA Masahiko
https server with user/password through "http_proxy" environment variable work properly. ok jca
2020-02-13Two longjmp(3) vs volatile fixes and improvementsJeremie Courreges-Anglas
- allocate read buffer before setjmp(3) so that its value is properly defined when longjmp(3) returns - only mark as volatile variables modified after setjmp(3) and used again after a possible return from longjmp(3)
2020-02-13Fixes and tweaks for read/write loop in url_get()Jeremie Courreges-Anglas
Changes already present in file_get() - no need to special case write(2) returning 0 - clearer loop condition - fix read error detection and properly save errno
2020-02-11Simplify and unify wording for the -I sourceaddr option in various places.Theo de Raadt
This is somewhat related to the "-b bind_addr" option some programs have, which should get some cleanup also... input florian claudio jmc