CVS commit: src/usr.bin/ftp
Module Name:src Committed By: gutteridge Date: Wed Apr 17 02:46:03 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp.1: drop a sentence that's no longer accurate To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: gutteridge Date: Wed Apr 17 02:46:03 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp.1: drop a sentence that's no longer accurate To generate a diff of this commit: cvs rdiff -u -r1.153 -r1.154 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.153 src/usr.bin/ftp/ftp.1:1.154 --- src/usr.bin/ftp/ftp.1:1.153 Mon Feb 19 00:15:20 2024 +++ src/usr.bin/ftp/ftp.1 Wed Apr 17 02:46:03 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.153 2024/02/19 00:15:20 christos Exp $ +.\" $NetBSD: ftp.1,v 1.154 2024/04/17 02:46:03 gutteridge Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd February 18, 2024 +.Dd April 17, 2024 .Dt FTP 1 .Os .Sh NAME @@ -1905,7 +1905,6 @@ and (and optionally .Ar password\^ ) is in the URL, use them for the first attempt to authenticate. -There is currently no certificate validation and verification. .\" file:///path .It Li file:/// Ns Ar path A local URL, copied from
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Mon Feb 19 00:15:21 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: default is now 16K To generate a diff of this commit: cvs rdiff -u -r1.152 -r1.153 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.17 -r1.18 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.152 src/usr.bin/ftp/ftp.1:1.153 --- src/usr.bin/ftp/ftp.1:1.152 Sun Feb 18 17:29:56 2024 +++ src/usr.bin/ftp/ftp.1 Sun Feb 18 19:15:20 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.152 2024/02/18 22:29:56 christos Exp $ +.\" $NetBSD: ftp.1,v 1.153 2024/02/19 00:15:20 christos Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -205,6 +205,8 @@ to bypass normal login procedure, and us .It Fl b Ar bufsize Change the input buffer size to .Ar bufsize . +The default is +.Dv 16K . .It Fl d Enables debugging. .It Fl e Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.17 src/usr.bin/ftp/ssl.c:1.18 --- src/usr.bin/ftp/ssl.c:1.17 Sun Feb 18 17:29:56 2024 +++ src/usr.bin/ftp/ssl.c Sun Feb 18 19:15:20 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.17 2024/02/18 22:29:56 christos Exp $ */ +/* $NetBSD: ssl.c,v 1.18 2024/02/19 00:15:20 christos Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.17 2024/02/18 22:29:56 christos Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.18 2024/02/19 00:15:20 christos Exp $"); #endif #include @@ -579,7 +579,7 @@ fetch_getline(struct fetch_connect *conn break; } if (errormsg) - *errormsg = "Input line is too long (specify -b > 4K)"; + *errormsg = "Input line is too long (specify -b > 16K)"; fetch_clearerr(conn); return -3; }
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Mon Feb 19 00:15:21 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: default is now 16K To generate a diff of this commit: cvs rdiff -u -r1.152 -r1.153 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.17 -r1.18 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/ftp
In article <20240218223315.800aff...@cvs.netbsd.org>, Thomas Klausner wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: wiz >Date: Sun Feb 18 22:33:15 UTC 2024 > >Modified Files: > src/usr.bin/ftp: ftp_var.h > >Log Message: >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. This is used in two other places unrelated to fetch (one in getline on the stack and one static for completions). While it is ok to increase the default now because I've made it dynamically allocated in the fetch cases, we should probably use a different buffer constant for the other two... christos
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: wiz Date: Sun Feb 18 22:33:15 UTC 2024 Modified Files: src/usr.bin/ftp: ftp_var.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/ftp/ftp_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp_var.h diff -u src/usr.bin/ftp/ftp_var.h:1.87 src/usr.bin/ftp/ftp_var.h:1.88 --- src/usr.bin/ftp/ftp_var.h:1.87 Sun Feb 18 22:29:56 2024 +++ src/usr.bin/ftp/ftp_var.h Sun Feb 18 22:33:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp_var.h,v 1.87 2024/02/18 22:29:56 christos Exp $ */ +/* $NetBSD: ftp_var.h,v 1.88 2024/02/18 22:33:15 wiz Exp $ */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@ -169,7 +169,7 @@ enum { /* * Global defines */ -#define FTPBUFLEN (4 * MAXPATHLEN) +#define FTPBUFLEN (16 * 1024) #define MAX_IN_PORT_T 0xU #define HASHBYTES 1024 /* default mark for `hash' command */
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: wiz Date: Sun Feb 18 22:33:15 UTC 2024 Modified Files: src/usr.bin/ftp: ftp_var.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/usr.bin/ftp/ftp_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sun Feb 18 22:29:56 UTC 2024 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp.c ftp_var.h main.c ssl.c Log Message: Add -b to specify the buffer size. To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.151 -r1.152 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.175 -r1.176 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.86 -r1.87 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.129 -r1.130 src/usr.bin/ftp/main.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.238 src/usr.bin/ftp/fetch.c:1.239 --- src/usr.bin/ftp/fetch.c:1.238 Sat Aug 12 03:40:13 2023 +++ src/usr.bin/ftp/fetch.c Sun Feb 18 17:29:56 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.238 2023/08/12 07:40:13 mlelstv Exp $ */ +/* $NetBSD: fetch.c,v 1.239 2024/02/18 22:29:56 christos Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.238 2023/08/12 07:40:13 mlelstv Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.239 2024/02/18 22:29:56 christos Exp $"); #endif /* not lint */ /* @@ -1116,15 +1116,17 @@ negotiate_connection(FETCH *fin, const c char **auth, struct urlinfo *ui) { int len, hcode, rv; - char buf[FTPBUFLEN], *ep; + char *buf = NULL, *ep; const char *cp, *token; char *location, *message; *auth = message = location = NULL; + buf = ftp_malloc(ftp_buflen); + /* Read the response */ ep = buf; - switch (getresponse(fin, , sizeof(buf), )) { + switch (getresponse(fin, , ftp_buflen, )) { case C_CLEANUP: goto cleanup_fetch_url; case C_IMPROPER: @@ -1137,7 +1139,7 @@ negotiate_connection(FETCH *fin, const c /* Read the rest of the header. */ for (;;) { - if ((rv = getresponseline(fin, buf, sizeof(buf), )) != C_OK) + if ((rv = getresponseline(fin, buf, ftp_buflen, )) != C_OK) goto cleanup_fetch_url; if (len == 0) break; @@ -1265,6 +1267,7 @@ improper: rv = C_IMPROPER; goto out; out: + FREEPTR(buf); FREEPTR(message); FREEPTR(location); return rv; @@ -1279,7 +1282,7 @@ connectmethod(FETCH *fin, const char *ur void *ssl; int hcode, rv; const char *cp; - char buf[FTPBUFLEN], *ep; + char *buf = NULL, *ep; char *message = NULL; print_connect(fin, oui); @@ -1299,9 +1302,11 @@ connectmethod(FETCH *fin, const char *ur } alarmtimer(0); + buf = ftp_malloc(ftp_buflen); + /* Read the response */ ep = buf; - switch (getresponse(fin, , sizeof(buf), )) { + switch (getresponse(fin, , ftp_buflen, )) { case C_CLEANUP: goto cleanup_fetch_url; case C_IMPROPER: @@ -1313,7 +1318,7 @@ connectmethod(FETCH *fin, const char *ur for (;;) { int len; - if (getresponseline(fin, buf, sizeof(buf), ) != C_OK) + if (getresponseline(fin, buf, ftp_buflen, ) != C_OK) goto cleanup_fetch_url; if (len == 0) break; @@ -1364,6 +1369,7 @@ cleanup_fetch_url: rv = C_CLEANUP; goto out; out: + FREEPTR(buf); FREEPTR(message); return rv; } Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.151 src/usr.bin/ftp/ftp.1:1.152 --- src/usr.bin/ftp/ftp.1:1.151 Fri Dec 8 21:15:11 2023 +++ src/usr.bin/ftp/ftp.1 Sun Feb 18 17:29:56 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.151 2023/12/09 02:15:11 lukem Exp $ +.\" $NetBSD: ftp.1,v 1.152 2024/02/18 22:29:56 christos Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd December 9, 2023 +.Dd February 18, 2024 .Dt FTP 1 .Os .Sh NAME @@ -69,6 +69,7 @@ .Op Fl N Ar netrc .Op Fl o Ar output .Op Fl P Ar port +.Op Fl b Ar bufsize .Op Fl q Ar quittime .Op Fl r Ar retry .Op Fl s Ar srcaddr @@ -201,6 +202,9 @@ implement passive mode properly. Causes .Nm to bypass normal login procedure, and use an anonymous login instead. +.It Fl b Ar bufsize +Change the input buffer size to +.Ar bufsize . .It Fl d Enables debugging. .It Fl e Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.175 src/usr.bin/ftp/ftp.c:1.176 --- src/usr.bin/ftp/ftp.c:1.175 Fri May 5 11:46:06 2023 +++ src/usr.bin/ftp/ftp.c Sun Feb 18 17:29:56 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.175 2023/05/05 15:46:06 lukem Exp $ */ +/* $NetBSD: ftp.c,v 1.176 2024/02/18 22:29:56 christos Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.175 2023/05/05 15:46:06 lukem Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.176 2024/02/18 22:29:56 christos Exp $"); #endif #endif /* not lint */ @@ -130,6 +130,7 @@ sigjmp_buf ptabort; int ptabflg; int ptflag = 0; char pasv[BUFSIZ]; /* passive port for proxy data connection */
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sun Feb 18 22:29:56 UTC 2024 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp.c ftp_var.h main.c ssl.c Log Message: Add -b to specify the buffer size. To generate a diff of this commit: cvs rdiff -u -r1.238 -r1.239 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.151 -r1.152 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.175 -r1.176 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.86 -r1.87 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.129 -r1.130 src/usr.bin/ftp/main.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sat Dec 9 02:15:11 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: 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"). To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sat Dec 9 02:15:11 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: 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"). To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.150 src/usr.bin/ftp/ftp.1:1.151 --- src/usr.bin/ftp/ftp.1:1.150 Sat Feb 25 17:37:09 2023 +++ src/usr.bin/ftp/ftp.1 Sat Dec 9 02:15:11 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.150 2023/02/25 17:37:09 uwe Exp $ +.\" $NetBSD: ftp.1,v 1.151 2023/12/09 02:15:11 lukem Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd February 25, 2023 +.Dd December 9, 2023 .Dt FTP 1 .Os .Sh NAME @@ -65,7 +65,7 @@ .Nd Internet file transfer program .Sh SYNOPSIS .Nm -.Op Fl 46AadefginpRtVv? +.Op Fl 46AadefginpRtVv\&? .Op Fl N Ar netrc .Op Fl o Ar output .Op Fl P Ar port @@ -289,7 +289,7 @@ Uses as the local IP address for all connections. .It Fl t Enables packet tracing. -.It Fl T Ar direction Ns Cm \&, Ns Ar maximum\| Ns Oo Cm \&, Ns Ar increment Oc +.It Fl T Ar direction Ns Cm \&, Ns Ar maximum Ns Oo Cm \&, Ns Ar increment Oc Set the maximum transfer rate for .Ar direction to @@ -392,24 +392,20 @@ or .Ic nmap setting. File transfer uses the current settings for -.Ic type , -.Ic format , -.Ic mode , +.Ic type , +.Ic form , +.Ic mode , and -.Ic structure . +.Ic struct . .It Ic ascii -Set the file transfer -.Ic type -to network -.Tn ASCII . -This is the default type. +A synonym for +.Ic type Cm ascii . .It Ic bell Arrange that a bell be sounded after each file transfer command is completed. .It Ic binary -Set the file transfer -.Ic type -to support binary image transfer. +A synonym for +.Ic type Cm binary . .It Ic bye Terminate the .Tn FTP @@ -450,9 +446,12 @@ return to the command interpreter. Any defined macros are erased. .It Ic \ Toggle carriage return stripping during -ascii type file retrieval. +.Ic type Cm ascii +file retrieval. Records are denoted by a carriage return/linefeed sequence -during ascii type file transfer. +during +.Ic type Cm ascii +file transfer. When .Ic \ is on (the default), carriage returns are stripped from this @@ -463,7 +462,9 @@ delimiter. Records on .Pf non\- Ux remote systems may contain single linefeeds; -when an ascii type transfer is made, these linefeeds may be +when a +.Ic type Cm ascii +transfer is made, these linefeeds may be distinguished from a record delimiter only when .Ic \ is off. @@ -541,12 +542,11 @@ Retrieve the files listed in .Ar localfile , which has one line per filename. .It Ic form Ar format -Set the file transfer -.Ic form -to +Set the file transfer format control to .Ar format . The default (and only supported) -format is +.Ar format +is .Ql non-print . .It Ic ftp Ar host Op Ar port A synonym for @@ -579,27 +579,27 @@ If the local file name is not specified, it is given the same name it has on the remote machine, subject to alteration by the current -.Ic case , +.Ic case , .Ic ntrans , and .Ic nmap settings. The current settings for -.Ic type , +.Ic type , .Ic form , -.Ic mode , +.Ic mode , and -.Ic structure +.Ic struct are used while transferring the file. .It Ic glob Toggle filename expansion for -.Ic mdelete , +.Ic mdelete , .Ic mget , .Ic mput , and .Ic mreget . If globbing is turned off with -.Ic glob , +.Ic glob , the file name arguments are taken literally and not expanded. Globbing for @@ -630,7 +630,9 @@ entire directory subtrees of files. That can be done by transferring a .Xr tar 1 -archive of the subtree (in binary mode). +archive of the subtree (in +.Ic type Cm binary +mode). .It Ic hash Op Ar size Toggle hash-sign .Pq Ql # @@ -658,7 +660,7 @@ If is omitted, the current inactivity timer is printed. .It Ic image A synonym for -.Ic binary . +.Ic type Cm binary . .It Ic lcd Op Ar directory Change the working directory on the local machine. If @@ -682,7 +684,7 @@ A synonym for .It Ic macdef Ar macro-name Define a macro. Subsequent lines are stored as the macro -.Ar macro-name ; +.Ar macro-name ; a null line .Po consecutive newline characters in a file or carriage @@ -740,7 +742,7 @@ Delete the on the remote machine. .It Ic mdir Ar remote-files local-file Like -.Ic dir , +.Ic dir , except multiple remote files may be specified. If interactive prompting is on, .Nm @@ -759,7 +761,7 @@ See .Ic glob for details on the filename
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sat Aug 12 07:40:13 UTC 2023 Modified Files: src/usr.bin/ftp: fetch.c Log Message: Don't finish downloading an empty file with 'already done' before it is created locally. To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.237 src/usr.bin/ftp/fetch.c:1.238 --- src/usr.bin/ftp/fetch.c:1.237 Sun Jul 2 10:02:09 2023 +++ src/usr.bin/ftp/fetch.c Sat Aug 12 07:40:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.237 2023/07/02 10:02:09 mlelstv Exp $ */ +/* $NetBSD: fetch.c,v 1.238 2023/08/12 07:40:13 mlelstv Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.237 2023/07/02 10:02:09 mlelstv Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.238 2023/08/12 07:40:13 mlelstv Exp $"); #endif /* not lint */ /* @@ -1652,9 +1652,10 @@ fetch_url(const char *url, const char *p } } if (fout == NULL) { - if ((pi.rangeend != -1 && pi.rangeend <= restart_point) || + if (restart_point && ( + (pi.rangeend != -1 && pi.rangeend <= restart_point) || (pi.rangestart == -1 && - filesize != -1 && filesize <= restart_point)) { + filesize != -1 && filesize <= restart_point))) { /* already done */ if (verbose) fprintf(ttyout, "already done\n");
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sat Aug 12 07:40:13 UTC 2023 Modified Files: src/usr.bin/ftp: fetch.c Log Message: Don't finish downloading an empty file with 'already done' before it is created locally. To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sun Jul 2 10:02:09 UTC 2023 Modified Files: src/usr.bin/ftp: fetch.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.236 src/usr.bin/ftp/fetch.c:1.237 --- src/usr.bin/ftp/fetch.c:1.236 Sat Feb 25 12:07:25 2023 +++ src/usr.bin/ftp/fetch.c Sun Jul 2 10:02:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.236 2023/02/25 12:07:25 mlelstv Exp $ */ +/* $NetBSD: fetch.c,v 1.237 2023/07/02 10:02:09 mlelstv Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.236 2023/02/25 12:07:25 mlelstv Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.237 2023/07/02 10:02:09 mlelstv Exp $"); #endif /* not lint */ /* @@ -801,7 +801,12 @@ handle_proxy(const char *url, const char } FREEPTR(pui.path); - pui.path = ftp_strdup(url); +#ifdef WITH_SSL + if (ui->utype == HTTPS_URL_T) + pui.path = ftp_strdup(ui->path); + else +#endif + pui.path = ftp_strdup(url); freeurlinfo(ui); *ui = pui;
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sun Jul 2 10:02:09 UTC 2023 Modified Files: src/usr.bin/ftp: fetch.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.236 -r1.237 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Tue May 16 22:00:23 UTC 2023 Modified Files: src/usr.bin/ftp: version.h Log Message: ftp 20230516 for openssl 3.0 compat SSL_OP_IGNORE_UNEXPECTED_EOF To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/version.h diff -u src/usr.bin/ftp/version.h:1.97 src/usr.bin/ftp/version.h:1.98 --- src/usr.bin/ftp/version.h:1.97 Fri May 5 15:46:06 2023 +++ src/usr.bin/ftp/version.h Tue May 16 22:00:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.97 2023/05/05 15:46:06 lukem Exp $ */ +/* $NetBSD: version.h,v 1.98 2023/05/16 22:00:23 lukem Exp $ */ /*- * Copyright (c) 1999-2023 The NetBSD Foundation, Inc. @@ -34,5 +34,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20230505" +#define FTP_VERSION "20230516" #endif
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Tue May 16 22:00:23 UTC 2023 Modified Files: src/usr.bin/ftp: version.h Log Message: ftp 20230516 for openssl 3.0 compat SSL_OP_IGNORE_UNEXPECTED_EOF To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Tue May 16 18:52:09 UTC 2023 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Ignore EOF from remote. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.15 src/usr.bin/ftp/ssl.c:1.16 --- src/usr.bin/ftp/ssl.c:1.15 Fri May 5 11:46:06 2023 +++ src/usr.bin/ftp/ssl.c Tue May 16 14:52:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.15 2023/05/05 15:46:06 lukem Exp $ */ +/* $NetBSD: ssl.c,v 1.16 2023/05/16 18:52:09 christos Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.15 2023/05/05 15:46:06 lukem Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.16 2023/05/16 18:52:09 christos Exp $"); #endif #include @@ -639,6 +639,9 @@ fetch_start_ssl(int sock, const char *se /* Enable peer verification, (using the default callback) */ SSL_set_verify(ssl, SSL_VERIFY_PEER, NULL); } +#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF + SSL_set_options(ssl, SSL_OP_IGNORE_UNEXPECTED_EOF); +#endif /* save current socket flags */ if ((flags = fcntl(sock, F_GETFL, 0)) == -1) {
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Tue May 16 18:52:09 UTC 2023 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Ignore EOF from remote. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri May 5 15:46:06 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.c ssl.c util.c version.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.166 -r1.167 src/usr.bin/ftp/util.c cvs rdiff -u -r1.96 -r1.97 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.174 src/usr.bin/ftp/ftp.c:1.175 --- src/usr.bin/ftp/ftp.c:1.174 Thu Aug 26 06:23:24 2021 +++ src/usr.bin/ftp/ftp.c Fri May 5 15:46:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $ */ +/* $NetBSD: ftp.c,v 1.175 2023/05/05 15:46:06 lukem Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.175 2023/05/05 15:46:06 lukem Exp $"); #endif #endif /* not lint */ @@ -1733,7 +1733,8 @@ dataconn(const char *lmode) if (timeout < 0) timeout = 0; rv = ftp_poll(pfd, 1, timeout); - } while (rv == -1 && errno == EINTR); /* loop until poll ! EINTR */ + /* loop until poll !EINTR && !EAGAIN */ + } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); if (rv == -1) { warn("Can't poll waiting before accept"); goto dataconn_failed; @@ -1747,7 +1748,8 @@ dataconn(const char *lmode) fromlen = myctladdr.su_len; do { s = accept(data, (struct sockaddr *) _su, ); - } while (s == -1 && errno == EINTR); /* loop until accept ! EINTR */ + /* loop until accept !EINTR && !EAGAIN */ + } while (s == -1 && (errno == EINTR || errno == EAGAIN)); if (s == -1) { warn("Can't accept data connection"); goto dataconn_failed; Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.14 src/usr.bin/ftp/ssl.c:1.15 --- src/usr.bin/ftp/ssl.c:1.14 Sun Apr 9 06:10:03 2023 +++ src/usr.bin/ftp/ssl.c Fri May 5 15:46:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.14 2023/04/09 06:10:03 lukem Exp $ */ +/* $NetBSD: ssl.c,v 1.15 2023/05/05 15:46:06 lukem Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -35,9 +35,10 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.14 2023/04/09 06:10:03 lukem Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.15 2023/05/05 15:46:06 lukem Exp $"); #endif +#include #include #include #include @@ -48,7 +49,6 @@ __RCSID("$NetBSD: ssl.c,v 1.14 2023/04/0 #include #include -#include #include #include @@ -96,38 +96,33 @@ struct fetch_connect { static ssize_t fetch_writev(struct fetch_connect *conn, struct iovec *iov, int iovcnt) { - struct timeval now, timeout, delta; - fd_set writefds; + struct timeval timeout, now, delta; ssize_t len, total; int fd = conn->sd; - int r; + int rv, timeout_secs; + struct pollfd pfd[1]; - if (quit_time > 0) { - FD_ZERO(); - gettimeofday(, NULL); - timeout.tv_sec += quit_time; - } + pfd[0].fd = fd; + pfd[0].events = POLLOUT; + gettimeofday(, NULL); + timeout.tv_sec += quit_time; total = 0; while (iovcnt > 0) { - while (quit_time > 0 && !FD_ISSET(fd, )) { - FD_SET(fd, ); - gettimeofday(, NULL); - delta.tv_sec = timeout.tv_sec - now.tv_sec; - delta.tv_usec = timeout.tv_usec - now.tv_usec; - if (delta.tv_usec < 0) { -delta.tv_usec += 100; -delta.tv_sec--; - } - if (delta.tv_sec < 0) { -errno = ETIMEDOUT; + if (quit_time > 0) { /* enforce timeout */ + do { +(void)gettimeofday(, NULL); +timersub(, , ); +timeout_secs = delta.tv_sec * 1000 + delta.tv_usec/1000; +if (timeout_secs < 0) + timeout_secs = 0; +rv = ftp_poll(pfd, 1, timeout_secs); + /* loop until poll !EINTR && !EAGAIN */ + } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); + if (rv == -1) return -1; - } - errno = 0; - r = select(fd + 1, NULL, , NULL, ); - if (r == -1) { -if (errno == EINTR) - continue; + if (rv == 0) { +errno = ETIMEDOUT; return -1; } } @@ -330,7 +325,7 @@ fetch_nonssl_read(int sd, void *buf, siz rlen = read(sd, buf, len); if (rlen == -1) { - if (errno == EAGAIN
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri May 5 15:46:06 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.c ssl.c util.c version.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.166 -r1.167 src/usr.bin/ftp/util.c cvs rdiff -u -r1.96 -r1.97 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sun Apr 9 06:10:03 UTC 2023 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Simplify includes Include "ftp_var.h" instead of various system headers and "extern.h". To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.13 src/usr.bin/ftp/ssl.c:1.14 --- src/usr.bin/ftp/ssl.c:1.13 Sat Feb 25 12:07:25 2023 +++ src/usr.bin/ftp/ssl.c Sun Apr 9 06:10:03 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.13 2023/02/25 12:07:25 mlelstv Exp $ */ +/* $NetBSD: ssl.c,v 1.14 2023/04/09 06:10:03 lukem Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.13 2023/02/25 12:07:25 mlelstv Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.14 2023/04/09 06:10:03 lukem Exp $"); #endif #include @@ -63,11 +63,7 @@ __RCSID("$NetBSD: ssl.c,v 1.13 2023/02/2 #endif #include "ssl.h" - -#include -#include -#include -#include "extern.h" +#include "ftp_var.h" extern int quit_time, verbose, ftp_debug; extern FILE *ttyout;
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sun Apr 9 06:10:03 UTC 2023 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Simplify includes Include "ftp_var.h" instead of various system headers and "extern.h". To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: uwe Date: Sat Feb 25 17:37:09 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp(1): better mark up for url vs cd example To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: uwe Date: Sat Feb 25 17:37:09 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp(1): better mark up for url vs cd example To generate a diff of this commit: cvs rdiff -u -r1.149 -r1.150 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.149 src/usr.bin/ftp/ftp.1:1.150 --- src/usr.bin/ftp/ftp.1:1.149 Sat Feb 25 13:51:48 2023 +++ src/usr.bin/ftp/ftp.1 Sat Feb 25 17:37:09 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.149 2023/02/25 13:51:48 uwe Exp $ +.\" $NetBSD: ftp.1,v 1.150 2023/02/25 17:37:09 uwe Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -1792,24 +1792,38 @@ and where to use For example, the following URLs correspond to the equivalents of the indicated commands: .Bl -tag -width "ftp://host/%2Fdir1%2Fdir2%2Ffile; -.It ftp://host/dir1/dir2/file -.Dq "cd dir1" , -.Dq "cd dir2" , -.Dq "get file" . -.It ftp://host/%2Fdir1/dir2/file -.Dq "cd /dir1" , -.Dq "cd dir2" , -.Dq "get file" . -.It ftp://host/dir1%2Fdir2/file -.Dq "cd dir1/dir2" , -.Dq "get file" . -.It ftp://host/%2Fdir1%2Fdir2/file -.Dq "cd /dir1/dir2" , -.Dq "get file" . -.It ftp://host/dir1%2Fdir2%2Ffile -.Dq "get dir1/dir2/file" . -.It ftp://host/%2Fdir1%2Fdir2%2Ffile -.Dq "get /dir1/dir2/file" . +.It Xo \" ftp://host/dir1/dir2/file +.Sm off +.Ic ftp:// Ar host +.Ic / Ar dir1 +.Ic / Ar dir2 +.Ic / Ar file +.Sm on +.Xc +.Ic cd Ar dir1 , +.Ic cd Ar dir2 , +.Ic get Ar file . +.It Xo \" ftp://host/%2Fdir1/dir2/file +.Sm off +.Ic ftp:// Ar host +.Ic /%2F Ar dir1 +.Ic / Ar dir2 +.Ic / Ar file +.Sm on +.Xc +.Ic cd / Ns Ar dir1 , +.Ic cd Ar dir2 , +.Ic get Ar file . +.It Xo \" ftp://host/dir1%2Fdir2/file +.Sm off +.Ic ftp:// Ar host +.Ic / Ar dir1 +.Ic %2F Ar dir2 +.Ic / Ar file +.Sm on +.Xc +.Ic cd Ar dir1 Ns Ic / Ns Ar dir2 , +.Ic get Ar file . .El .It You must have appropriate access permission for each of the
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: uwe Date: Sat Feb 25 13:51:48 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.148 -r1.149 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.148 src/usr.bin/ftp/ftp.1:1.149 --- src/usr.bin/ftp/ftp.1:1.148 Sat Feb 25 12:07:25 2023 +++ src/usr.bin/ftp/ftp.1 Sat Feb 25 13:51:48 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.148 2023/02/25 12:07:25 mlelstv Exp $ +.\" $NetBSD: ftp.1,v 1.149 2023/02/25 13:51:48 uwe Exp $ .\" .\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -77,9 +77,9 @@ .Oo .Fl T Xo .Sm off -.Ar dir , +.Ar dir Cm \&, .Ar max -.Op , Ar inc +.Op Cm \&, Ar inc .Sm on .Xc .Oc @@ -239,11 +239,14 @@ will check the an account on the remote machine. If no entry exists, .Nm -will prompt for the remote machine login name (default is the user -identity on the local machine), and, if necessary, prompt for a password +will prompt for the remote machine login name +.Pq default is the user identity on the local machine , +and, if necessary, prompt for a password and an account with which to login. To override the auto-login for auto-fetch transfers, specify the -username (and optionally, password) as appropriate. +username +.Pq and optionally, password +as appropriate. .It Fl o Ar output When auto-fetching files, save the contents in .Ar output . @@ -254,9 +257,9 @@ below. If .Ar output is not -.Sq - +.Sq Fl or doesn't start with -.Sq \&| , +.Sq Cm \&| , then only the first file specified will be retrieved into .Ar output ; all other files will be retrieved into the basename of their @@ -286,7 +289,7 @@ Uses as the local IP address for all connections. .It Fl t Enables packet tracing. -.It Fl T Ar direction Ns , Ns Ar maximum Ns Oo , Ns Ar increment Oc +.It Fl T Ar direction Ns Cm \&, Ns Ar maximum\| Ns Oo Cm \&, Ns Ar increment Oc Set the maximum transfer rate for .Ar direction to @@ -304,9 +307,10 @@ Upload files on the command line to where .Ar url is one of the -.Sq Li ftp:// +.Ql ftp:// URL types as supported by auto-fetch -(with an optional target filename for single file uploads), and +.Pq with an optional target filename for single file uploads , +and .Ar file is one or more local files to be uploaded. .It Fl V @@ -320,10 +324,13 @@ Enable .Ic verbose and .Ic progress . -This is the default if output is to a terminal (and in the case of +This is the default if output is to a terminal +.Po +and in the case of .Ic progress , .Nm -is the foreground process). +is the foreground process +.Pc . Forces .Nm to show all responses from the remote server, as well @@ -334,7 +341,7 @@ Set the size of the socket send and rece Refer to .Ic xferbuf for more information. -.It Fl ? +.It Fl \&? Display help to stdout, and exit. .El .Pp @@ -356,7 +363,7 @@ is awaiting commands from the user the p is provided to the user. The following commands are recognized by -.Nm ftp : +.Nm : .Bl -tag -width Ic .It Ic \&! Op Ar command Op Ar args Invoke an interactive shell on the local machine. @@ -454,7 +461,7 @@ sequence to conform with the single linefeed record delimiter. Records on -.Pf non\- Ns Ux +.Pf non\- Ux remote systems may contain single linefeeds; when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when @@ -527,9 +534,8 @@ is executed again. A synonym for .Ic bye . .It Ic features -Display what features the remote server supports (using the -.Dv FEAT -command). +Display what features the remote server supports +.Pq using the Dv FEAT No command . .It Ic fget Ar localfile Retrieve the files listed in .Ar localfile , @@ -541,7 +547,7 @@ to .Ar format . The default (and only supported) format is -.Dq non-print . +.Ql non-print . .It Ic ftp Ar host Op Ar port A synonym for .Ic open . @@ -551,9 +557,11 @@ TIS FWTK and Gauntlet .Tn FTP proxies. This will not be permitted if the gate-ftp server hasn't been set -(either explicitly by the user, or from the +.Po +either explicitly by the user, or from the .Ev FTPSERVER -environment variable). +environment variable +.Pc . If .Ar host is given, @@ -625,7 +633,7 @@ transferring a archive of the subtree (in binary mode). .It Ic hash Op Ar size Toggle hash-sign -.Pq Sq # +.Pq Ql # printing for each data block transferred. The size of a data block defaults to 1024 bytes. This can be changed by specifying @@ -675,16 +683,24 @@ A synonym for Define a macro. Subsequent lines are stored as the macro .Ar macro-name ; -a null line
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: uwe Date: Sat Feb 25 13:51:48 UTC 2023 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.148 -r1.149 src/usr.bin/ftp/ftp.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sat Feb 25 12:07:25 UTC 2023 Modified Files: src/usr.bin/ftp: cmdtab.c extern.h fetch.c ftp.1 main.c ssl.c util.c version.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/ftp/cmdtab.c cvs rdiff -u -r1.82 -r1.83 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.235 -r1.236 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.147 -r1.148 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.128 -r1.129 src/usr.bin/ftp/main.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.165 -r1.166 src/usr.bin/ftp/util.c cvs rdiff -u -r1.95 -r1.96 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: mlelstv Date: Sat Feb 25 12:07:25 UTC 2023 Modified Files: src/usr.bin/ftp: cmdtab.c extern.h fetch.c ftp.1 main.c ssl.c util.c version.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/ftp/cmdtab.c cvs rdiff -u -r1.82 -r1.83 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.235 -r1.236 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.147 -r1.148 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.128 -r1.129 src/usr.bin/ftp/main.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.165 -r1.166 src/usr.bin/ftp/util.c cvs rdiff -u -r1.95 -r1.96 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/cmdtab.c diff -u src/usr.bin/ftp/cmdtab.c:1.52 src/usr.bin/ftp/cmdtab.c:1.53 --- src/usr.bin/ftp/cmdtab.c:1.52 Sat Dec 22 16:57:09 2012 +++ src/usr.bin/ftp/cmdtab.c Sat Feb 25 12:07:25 2023 @@ -1,7 +1,7 @@ -/* $NetBSD: cmdtab.c,v 1.52 2012/12/22 16:57:09 christos Exp $ */ +/* $NetBSD: cmdtab.c,v 1.53 2023/02/25 12:07:25 mlelstv Exp $ */ /*- - * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2023 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmdtab.c,v 1.52 2012/12/22 16:57:09 christos Exp $"); +__RCSID("$NetBSD: cmdtab.c,v 1.53 2023/02/25 12:07:25 mlelstv Exp $"); #endif #endif /* not lint */ @@ -295,13 +295,14 @@ struct cmd cmdtab[] = { }; struct option optiontab[] = { - { "anonpass", NULL }, - { "ftp_proxy", NULL }, - { "http_proxy", NULL }, - { "https_proxy",NULL }, - { "no_proxy", NULL }, - { "pager", NULL }, - { "prompt", NULL }, - { "rprompt", NULL }, - { NULL, NULL }, + { "anonpass", NULL }, + { "ftp_proxy", NULL }, + { "http_proxy", NULL }, + { "https_proxy", NULL }, + { "no_proxy", NULL }, + { "pager", NULL }, + { "prompt", NULL }, + { "rprompt", NULL }, + { "sslnoverify" ,NULL }, + { NULL, NULL }, }; Index: src/usr.bin/ftp/extern.h diff -u src/usr.bin/ftp/extern.h:1.82 src/usr.bin/ftp/extern.h:1.83 --- src/usr.bin/ftp/extern.h:1.82 Sat Jun 22 23:40:53 2019 +++ src/usr.bin/ftp/extern.h Sat Feb 25 12:07:25 2023 @@ -1,7 +1,7 @@ -/* $NetBSD: extern.h,v 1.82 2019/06/22 23:40:53 christos Exp $ */ +/* $NetBSD: extern.h,v 1.83 2023/02/25 12:07:25 mlelstv Exp $ */ /*- - * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2023 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -243,6 +243,7 @@ void user(int, char **); int ftp_connect(int, const struct sockaddr *, socklen_t, int); int ftp_listen(int, int); int ftp_poll(struct pollfd *, int, int); +int ftp_truthy(const char *, const char *, int); #ifndef SMALL void *ftp_malloc(size_t); StringList *ftp_sl_init(void); Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.235 src/usr.bin/ftp/fetch.c:1.236 --- src/usr.bin/ftp/fetch.c:1.235 Sun Sep 11 20:49:27 2022 +++ src/usr.bin/ftp/fetch.c Sat Feb 25 12:07:25 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.235 2022/09/11 20:49:27 christos Exp $ */ +/* $NetBSD: fetch.c,v 1.236 2023/02/25 12:07:25 mlelstv Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.235 2022/09/11 20:49:27 christos Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.236 2023/02/25 12:07:25 mlelstv Exp $"); #endif /* not lint */ /* @@ -617,13 +617,15 @@ parse_url(const char *url, const char *d sigjmp_buf httpabort; static int -ftp_socket(const struct urlinfo *ui, void **ssl) +ftp_socket(const struct urlinfo *ui, void **ssl, struct authinfo *auth) { struct addrinfo hints, *res, *res0 = NULL; int error; int s; const char *host = ui->host; const char *port = ui->port; + char *fuser = NULL, *pass = NULL, *facct = NULL; + int n; if (ui->utype != HTTPS_URL_T) ssl = NULL; @@ -688,6 +690,28 @@ ftp_socket(const struct urlinfo *ui, voi continue; } + if (ruserpass("", , , ) < 0) { + close(s); + s = -1; + continue; + } + + if (autologin) { + if (fuser != NULL && auth->user == NULL) +auth->user = ftp_strdup(fuser); + if (pass != NULL && auth->pass ==
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: andvar Date: Fri Jan 20 22:08:49 UTC 2023 Modified Files: src/usr.bin/ftp: util.c Log Message: s/bninary/binary/ in comment. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: andvar Date: Fri Jan 20 22:08:49 UTC 2023 Modified Files: src/usr.bin/ftp: util.c Log Message: s/bninary/binary/ in comment. To generate a diff of this commit: cvs rdiff -u -r1.164 -r1.165 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/util.c diff -u src/usr.bin/ftp/util.c:1.164 src/usr.bin/ftp/util.c:1.165 --- src/usr.bin/ftp/util.c:1.164 Sat Aug 6 18:26:43 2022 +++ src/usr.bin/ftp/util.c Fri Jan 20 22:08:48 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.164 2022/08/06 18:26:43 andvar Exp $ */ +/* $NetBSD: util.c,v 1.165 2023/01/20 22:08:48 andvar Exp $ */ /*- * Copyright (c) 1997-2020 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.164 2022/08/06 18:26:43 andvar Exp $"); +__RCSID("$NetBSD: util.c,v 1.165 2023/01/20 22:08:48 andvar Exp $"); #endif /* not lint */ /* @@ -209,7 +209,7 @@ getremoteinfo(void) os_len, reply_string + 4); } /* - * Decide whether we should default to bninary. + * Decide whether we should default to binary. * Traditionally checked for "215 UNIX Type: L8", but * some printers report "Linux" ! so be more forgiving. * In reality we probably almost never want text any more.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Sep 22 03:31:04 UTC 2022 Modified Files: src/usr.bin/ftp: version.h Log Message: update ftp version to 20220911 PR/57003: Handle relative URLs (patch by kim@) To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/version.h diff -u src/usr.bin/ftp/version.h:1.94 src/usr.bin/ftp/version.h:1.95 --- src/usr.bin/ftp/version.h:1.94 Thu Aug 26 06:25:59 2021 +++ src/usr.bin/ftp/version.h Thu Sep 22 03:31:04 2022 @@ -1,7 +1,7 @@ -/* $NetBSD: version.h,v 1.94 2021/08/26 06:25:59 lukem Exp $ */ +/* $NetBSD: version.h,v 1.95 2022/09/22 03:31:04 lukem Exp $ */ /*- - * Copyright (c) 1999-2021 The NetBSD Foundation, Inc. + * Copyright (c) 1999-2022 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -34,5 +34,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20210826" +#define FTP_VERSION "20220911" #endif
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Sep 22 03:31:04 UTC 2022 Modified Files: src/usr.bin/ftp: version.h Log Message: update ftp version to 20220911 PR/57003: Handle relative URLs (patch by kim@) To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Mon Sep 12 15:10:31 UTC 2022 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Disable verification for now until we implement installation of trust anchors. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.11 src/usr.bin/ftp/ssl.c:1.12 --- src/usr.bin/ftp/ssl.c:1.11 Tue Aug 30 04:51:28 2022 +++ src/usr.bin/ftp/ssl.c Mon Sep 12 11:10:31 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.11 2022/08/30 08:51:28 christos Exp $ */ +/* $NetBSD: ssl.c,v 1.12 2022/09/12 15:10:31 christos Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -34,7 +34,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.11 2022/08/30 08:51:28 christos Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.12 2022/09/12 15:10:31 christos Exp $"); #endif #include @@ -589,7 +589,7 @@ fetch_start_ssl(int sock, const char *se SSL_CTX *ctx; X509_VERIFY_PARAM *param; int ret, ssl_err; - int verify = getenv("NO_CERT_VERIFY") == NULL; + int verify = 0; // getenv("NO_CERT_VERIFY") == NULL; /* Init the SSL library and context */ if (!SSL_library_init()){
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Mon Sep 12 15:10:31 UTC 2022 Modified Files: src/usr.bin/ftp: ssl.c Log Message: Disable verification for now until we implement installation of trust anchors. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sun Sep 11 20:49:27 UTC 2022 Modified Files: src/usr.bin/ftp: fetch.c Log Message: PR/57003: Handle relative URLs (patch by kim@) To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.234 src/usr.bin/ftp/fetch.c:1.235 --- src/usr.bin/ftp/fetch.c:1.234 Sun Aug 1 11:29:30 2021 +++ src/usr.bin/ftp/fetch.c Sun Sep 11 16:49:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.234 2021/08/01 15:29:30 andvar Exp $ */ +/* $NetBSD: fetch.c,v 1.235 2022/09/11 20:49:27 christos Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.234 2021/08/01 15:29:30 andvar Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.235 2022/09/11 20:49:27 christos Exp $"); #endif /* not lint */ /* @@ -106,12 +106,13 @@ __dead static void timeouthttp(int); static int auth_url(const char *, char **, const struct authinfo *); static void base64_encode(const unsigned char *, size_t, unsigned char *); #endif -static int go_fetch(const char *); +static int go_fetch(const char *, struct urlinfo *); static int fetch_ftp(const char *); -static int fetch_url(const char *, const char *, char *, char *); +static int fetch_url(const char *, const char *, char *, char *, +struct urlinfo *); static const char *match_token(const char **, const char *); static int parse_url(const char *, const char *, struct urlinfo *, -struct authinfo *); +struct authinfo *, struct urlinfo *); static void url_decode(char *); static void freeauthinfo(struct authinfo *); static void freeurlinfo(struct urlinfo *); @@ -274,7 +275,7 @@ auth_url(const char *challenge, char **r scheme = "Basic"; /* only support Basic authentication */ gotpass = NULL; - DPRINTF("auth_url: challenge `%s'\n", challenge); + DPRINTF("%s: challenge `%s'\n", __func__, challenge); if (! match_token(, scheme)) { warnx("Unsupported authentication challenge `%s'", @@ -336,7 +337,7 @@ auth_url(const char *challenge, char **r *response = ftp_malloc(rlen); (void)strlcpy(*response, scheme, rlen); len = strlcat(*response, " ", rlen); - /* use `clen - 1' to not encode the trailing NUL */ + /* use `clen - 1' to not encode the trailing NUL */ base64_encode((unsigned char *)clear, clen - 1, (unsigned char *)*response + len); memset(clear, 0, clen); @@ -367,7 +368,7 @@ base64_encode(const unsigned char *clear | ((clear[i + 1] >> 4) & 0x0f)]; *(cp++) = enc[((clear[i + 1] << 2) & 0x3c) | ((clear[i + 2] >> 6) & 0x03)]; - *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; + *(cp++) = enc[((clear[i + 2] ) & 0x3f)]; } *cp = '\0'; while (i-- > len) @@ -400,6 +401,42 @@ url_decode(char *url) *q = '\0'; } +static const char * +get_port(const struct urlinfo *ui) +{ + + switch(ui->utype) { + case HTTP_URL_T: + return httpport; + case FTP_URL_T: + return ftpport; + case FILE_URL_T: + return ""; +#ifdef WITH_SSL + case HTTPS_URL_T: + return httpsport; +#endif + default: + return NULL; + } +} + +static int +use_relative(const struct urlinfo *ui) +{ + if (ui == NULL) + return 0; + switch (ui->utype) { + case HTTP_URL_T: + case FILE_URL_T: +#ifdef WITH_SSL + case HTTPS_URL_T: +#endif + return 1; + default: + return 0; + } +} /* * Parse URL of form (per RFC 3986): @@ -435,7 +472,7 @@ url_decode(char *url) static int parse_url(const char *url, const char *desc, struct urlinfo *ui, -struct authinfo *auth) +struct authinfo *auth, struct urlinfo *rui) { const char *origurl, *tport; char *cp, *ep, *thost; @@ -446,29 +483,26 @@ parse_url(const char *url, const char *d DPRINTF("parse_url: %s `%s'\n", desc, url); origurl = url; - tport = NULL; if (STRNEQUAL(url, HTTP_URL)) { url += sizeof(HTTP_URL) - 1; ui->utype = HTTP_URL_T; ui->portnum = HTTP_PORT; - tport = httpport; } else if (STRNEQUAL(url, FTP_URL)) { url += sizeof(FTP_URL) - 1; ui->utype = FTP_URL_T; ui->portnum = FTP_PORT; - tport = ftpport; } else if (STRNEQUAL(url, FILE_URL)) { url += sizeof(FILE_URL) - 1; ui->utype = FILE_URL_T; - tport = ""; #ifdef WITH_SSL } else if (STRNEQUAL(url, HTTPS_URL)) { url += sizeof(HTTPS_URL) - 1; ui->utype = HTTPS_URL_T; ui->portnum = HTTPS_PORT; - tport = httpsport; #endif + } else if (rui != NULL) { + copyurlinfo(ui, rui); } else { warnx("Invalid %s `%s'", desc, url); cleanup_parse_url: @@ -477,6 +511,7 @@ parse_url(const char *url, const char *d return (-1); } + if (*url == '\0') return (0); @@ -541,7 +576,8 @@ parse_url(const char *url, const char *d #endif /* INET6 */ if ((cp = strchr(thost, ':')) != NULL) *cp++ = '\0'; - ui->host = thost; + if (*thost != '\0') +
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sun Sep 11 20:49:27 UTC 2022 Modified Files: src/usr.bin/ftp: fetch.c Log Message: PR/57003: Handle relative URLs (patch by kim@) To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/usr.bin/ftp/fetch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Tue Aug 30 08:51:28 UTC 2022 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: Add cert verification, together with an environment variable "NO_CERT_VERIFY", to turn it off. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.10 -r1.11 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.146 src/usr.bin/ftp/ftp.1:1.147 --- src/usr.bin/ftp/ftp.1:1.146 Sun Apr 25 05:09:55 2021 +++ src/usr.bin/ftp/ftp.1 Tue Aug 30 04:51:28 2022 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.146 2021/04/25 09:09:55 lukem Exp $ +.\" $NetBSD: ftp.1,v 1.147 2022/08/30 08:51:28 christos Exp $ .\" .\" Copyright (c) 1996-2021 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd April 25, 2021 +.Dd August 29, 2022 .Dt FTP 1 .Os .Sh NAME @@ -2320,6 +2320,8 @@ file, if one exists. An alternate location of the .Pa .netrc file. +.It Ev NO_CERT_VERIFY +Don't verify SSL certificates. .It Ev PAGER Used by various commands to display files. Defaults to Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.10 src/usr.bin/ftp/ssl.c:1.11 --- src/usr.bin/ftp/ssl.c:1.10 Thu Jun 3 06:23:33 2021 +++ src/usr.bin/ftp/ssl.c Tue Aug 30 04:51:28 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.10 2021/06/03 10:23:33 lukem Exp $ */ +/* $NetBSD: ssl.c,v 1.11 2022/08/30 08:51:28 christos Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav @@ -34,7 +34,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ssl.c,v 1.10 2021/06/03 10:23:33 lukem Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.11 2022/08/30 08:51:28 christos Exp $"); #endif #include @@ -587,7 +587,9 @@ fetch_start_ssl(int sock, const char *se { SSL *ssl; SSL_CTX *ctx; + X509_VERIFY_PARAM *param; int ret, ssl_err; + int verify = getenv("NO_CERT_VERIFY") == NULL; /* Init the SSL library and context */ if (!SSL_library_init()){ @@ -599,6 +601,10 @@ fetch_start_ssl(int sock, const char *se ctx = SSL_CTX_new(SSLv23_client_method()); SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY); + if (verify) { + SSL_CTX_set_default_verify_paths(ctx); + SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); + } ssl = SSL_new(ctx); if (ssl == NULL){ @@ -606,6 +612,19 @@ fetch_start_ssl(int sock, const char *se SSL_CTX_free(ctx); return NULL; } + + if (verify) { + param = SSL_get0_param(ssl); + if (!X509_VERIFY_PARAM_set1_host(param, servername, + strlen(servername))) { + fprintf(ttyout, "SSL verification setup failed\n"); + return NULL; + } + + /* Enable peer verification, (using the default callback) */ + SSL_set_verify(ssl, SSL_VERIFY_PEER, NULL); + } + SSL_set_fd(ssl, sock); if (!SSL_set_tlsext_host_name(ssl, __UNCONST(servername))) { fprintf(ttyout, "SSL hostname setting failed\n");
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Tue Aug 30 08:51:28 UTC 2022 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: Add cert verification, together with an environment variable "NO_CERT_VERIFY", to turn it off. To generate a diff of this commit: cvs rdiff -u -r1.146 -r1.147 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.10 -r1.11 src/usr.bin/ftp/ssl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sat Oct 9 09:07:21 UTC 2021 Modified Files: src/usr.bin/ftp: main.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/ftp/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/main.c diff -u src/usr.bin/ftp/main.c:1.127 src/usr.bin/ftp/main.c:1.128 --- src/usr.bin/ftp/main.c:1.127 Sat Jul 18 03:00:37 2020 +++ src/usr.bin/ftp/main.c Sat Oct 9 09:07:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $ */ +/* $NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $ */ /*- * Copyright (c) 1996-2015 The NetBSD Foundation, Inc. @@ -98,7 +98,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19 #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $"); +__RCSID("$NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $"); #endif #endif /* not lint */ @@ -267,7 +267,7 @@ main(int volatile argc, char **volatile } } - while ((ch = getopt(argc, argv, "?46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) { + while ((ch = getopt(argc, argv, ":46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) { switch (ch) { case '4': family = AF_INET; @@ -420,6 +420,11 @@ main(int volatile argc, char **volatile if (optopt == '?') { return usage_help(); } + warnx("-%c: unknown option", optopt); + return usage(); + + case ':': + warnx("-%c: missing argument", optopt); return usage(); default:
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Sat Oct 9 09:07:21 UTC 2021 Modified Files: src/usr.bin/ftp: main.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/usr.bin/ftp/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: rillig Date: Fri Aug 27 17:35:03 UTC 2021 Modified Files: src/usr.bin/ftp: util.c Log Message: ftp: fix undefined behavior when parsing FEAT lint says: warning: argument to 'function from ' must be cast to 'unsigned char', not to 'int' [342] To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: rillig Date: Fri Aug 27 17:35:03 UTC 2021 Modified Files: src/usr.bin/ftp: util.c Log Message: ftp: fix undefined behavior when parsing FEAT lint says: warning: argument to 'function from ' must be cast to 'unsigned char', not to 'int' [342] To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/util.c diff -u src/usr.bin/ftp/util.c:1.162 src/usr.bin/ftp/util.c:1.163 --- src/usr.bin/ftp/util.c:1.162 Sun Apr 25 08:26:35 2021 +++ src/usr.bin/ftp/util.c Fri Aug 27 17:35:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.162 2021/04/25 08:26:35 lukem Exp $ */ +/* $NetBSD: util.c,v 1.163 2021/08/27 17:35:03 rillig Exp $ */ /*- * Copyright (c) 1997-2020 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.162 2021/04/25 08:26:35 lukem Exp $"); +__RCSID("$NetBSD: util.c,v 1.163 2021/08/27 17:35:03 rillig Exp $"); #endif /* not lint */ /* @@ -171,7 +171,7 @@ parse_feat(const char *fline) * work-around broken ProFTPd servers that can't * even obey RFC 2389. */ - while (*fline && isspace((int)*fline)) + while (*fline && isspace((unsigned char)*fline)) fline++; if (strcasecmp(fline, "MDTM") == 0)
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:25:59 UTC 2021 Modified Files: src/usr.bin/ftp: version.h Log Message: update ftp version to 20210826 Version bump for PASV/LPSV address validation To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/version.h diff -u src/usr.bin/ftp/version.h:1.93 src/usr.bin/ftp/version.h:1.94 --- src/usr.bin/ftp/version.h:1.93 Thu Jun 3 10:23:33 2021 +++ src/usr.bin/ftp/version.h Thu Aug 26 06:25:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.93 2021/06/03 10:23:33 lukem Exp $ */ +/* $NetBSD: version.h,v 1.94 2021/08/26 06:25:59 lukem Exp $ */ /*- * Copyright (c) 1999-2021 The NetBSD Foundation, Inc. @@ -34,5 +34,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20210603" +#define FTP_VERSION "20210826" #endif
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:25:59 UTC 2021 Modified Files: src/usr.bin/ftp: version.h Log Message: update ftp version to 20210826 Version bump for PASV/LPSV address validation To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:23:24 UTC 2021 Modified Files: src/usr.bin/ftp: ftp.c Log Message: 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.) To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.173 src/usr.bin/ftp/ftp.c:1.174 --- src/usr.bin/ftp/ftp.c:1.173 Thu Aug 26 06:16:29 2021 +++ src/usr.bin/ftp/ftp.c Thu Aug 26 06:23:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $ */ +/* $NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.174 2021/08/26 06:23:24 lukem Exp $"); #endif #endif /* not lint */ @@ -1381,13 +1381,11 @@ initconn(void) if (data_addr.su_family != AF_INET) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); -error = 1; goto bad; } if (code / 10 == 22 && code != 227) { fputs("wrong server: return code must be 227\n", ttyout); -error = 1; goto bad; } error = sscanf(pasv, "%u,%u,%u,%u,%u,%u", @@ -1396,10 +1394,8 @@ initconn(void) if (error != 6) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); -error = 1; goto bad; } - error = 0; memset(_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET; data_addr.su_len = sizeof(struct sockaddr_in); @@ -1416,7 +1412,6 @@ initconn(void) if (code / 10 == 22 && code != 228) { fputs("wrong server: return code must be 228\n", ttyout); -error = 1; goto bad; } switch (data_addr.su_family) { @@ -1429,17 +1424,14 @@ initconn(void) if (error != 9) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } if (af != 4 || hal != 4 || pal != 2) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } -error = 0; memset(_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET; data_addr.su_len = sizeof(struct sockaddr_in); @@ -1467,17 +1459,14 @@ initconn(void) if (error != 21) { fputs( "Passive mode address scan failure. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } if (af != 6 || hal != 16 || pal != 2) { fputs( "Passive mode AF mismatch. Shouldn't happen!\n", ttyout); - error = 1; goto bad; } -error = 0; memset(_addr, 0, sizeof(data_addr)); data_addr.su_family = AF_INET6; data_addr.su_len = sizeof(struct sockaddr_in6); @@ -1500,7 +1489,8 @@ initconn(void) break; #endif default: -error = 1; +fputs("Unknown passive mode AF.\n", ttyout); +goto bad; } } else if (strcmp(pasvcmd, "EPSV") == 0) { char delim[4]; @@ -1509,20 +1499,17 @@ initconn(void) if (code / 10 == 22 && code != 229) { fputs("wrong server: return code must be 229\n", ttyout); -error = 1; goto bad; } if (sscanf(pasv, "%c%c%c%d%c", [0], [1], [2], [1], [3]) != 5) { fputs("parse error!\n", ttyout); -error = 1; goto bad; } if (delim[0] != delim[1] || delim[0] != delim[2] || delim[0] != delim[3]) { fputs("parse error!\n", ttyout); -error = 1; goto bad; } data_addr = hisctladdr;
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:23:24 UTC 2021 Modified Files: src/usr.bin/ftp: ftp.c Log Message: 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.) To generate a diff of this commit: cvs rdiff -u -r1.173 -r1.174 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:16:29 UTC 2021 Modified Files: src/usr.bin/ftp: ftp.c Log Message: 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/msg2.html To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Aug 26 06:16:29 UTC 2021 Modified Files: src/usr.bin/ftp: ftp.c Log Message: 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/msg2.html To generate a diff of this commit: cvs rdiff -u -r1.172 -r1.173 src/usr.bin/ftp/ftp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.172 src/usr.bin/ftp/ftp.c:1.173 --- src/usr.bin/ftp/ftp.c:1.172 Thu Jun 3 10:11:00 2021 +++ src/usr.bin/ftp/ftp.c Thu Aug 26 06:16:29 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.172 2021/06/03 10:11:00 lukem Exp $ */ +/* $NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -92,7 +92,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.172 2021/06/03 10:11:00 lukem Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.173 2021/08/26 06:16:29 lukem Exp $"); #endif #endif /* not lint */ @@ -1406,6 +1406,12 @@ initconn(void) data_addr.si_su.su_sin.sin_addr.s_addr = htonl(pack4(addr, 0)); data_addr.su_port = htons(pack2(port, 0)); + if (data_addr.si_su.su_sin.sin_addr.s_addr != + hisctladdr.si_su.su_sin.sin_addr.s_addr) { +fputs("Passive mode address mismatch.\n", +ttyout); +goto bad; + } } else if (strcmp(pasvcmd, "LPSV") == 0) { if (code / 10 == 22 && code != 228) { fputs("wrong server: return code must be 228\n", @@ -1440,6 +1446,12 @@ initconn(void) data_addr.si_su.su_sin.sin_addr.s_addr = htonl(pack4(addr, 0)); data_addr.su_port = htons(pack2(port, 0)); +if (data_addr.si_su.su_sin.sin_addr.s_addr != +hisctladdr.si_su.su_sin.sin_addr.s_addr) { + fputs("Passive mode address mismatch.\n", + ttyout); + goto bad; +} break; #ifdef INET6 case AF_INET6: @@ -1477,6 +1489,14 @@ initconn(void) } } data_addr.su_port = htons(pack2(port, 0)); +if (memcmp( +_addr.si_su.su_sin6.sin6_addr, +_su.su_sin6.sin6_addr, +sizeof(data_addr.si_su.su_sin6.sin6_addr))) { + fputs("Passive mode address mismatch.\n", + ttyout); + goto bad; +} break; #endif default:
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sat Jun 22 23:40:53 UTC 2019 Modified Files: src/usr.bin/ftp: extern.h util.c Log Message: trim down error checking if we are small. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.159 -r1.160 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sat Jun 22 23:40:33 UTC 2019 Modified Files: src/usr.bin/ftp: progressbar.c Log Message: make this compile again with -DNO_PROGRESS To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/ftp/progressbar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sat Jun 22 23:40:33 UTC 2019 Modified Files: src/usr.bin/ftp: progressbar.c Log Message: make this compile again with -DNO_PROGRESS To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/ftp/progressbar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/progressbar.c diff -u src/usr.bin/ftp/progressbar.c:1.22 src/usr.bin/ftp/progressbar.c:1.23 --- src/usr.bin/ftp/progressbar.c:1.22 Wed Jun 27 18:07:36 2012 +++ src/usr.bin/ftp/progressbar.c Sat Jun 22 19:40:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.22 2012/06/27 22:07:36 riastradh Exp $ */ +/* $NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.22 2012/06/27 22:07:36 riastradh Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.23 2019/06/22 23:40:33 christos Exp $"); #endif /* not lint */ /* @@ -87,6 +87,7 @@ updateprogressmeter(int dummy) /* * List of order of magnitude suffixes, per IEC 60027-2. */ +#if !defined(NO_PROGRESS) || !defined(STANDALONE_PROGRESS) static const char * const suffixes[] = { "", /* 2^0 (byte) */ "KiB", /* 2^10 Kibibyte */ @@ -102,6 +103,7 @@ static const char * const suffixes[] = { #endif }; #define NSUFFIXES (int)(sizeof(suffixes) / sizeof(suffixes[0])) +#endif /* * Display a transfer progress bar if progress is non-zero. @@ -139,8 +141,10 @@ progressmeter(int flag) * these appropriately. */ #endif +#if !defined(NO_PROGRESS) || !defined(STANDALONE_PROGRESS) size_t len; char buf[256]; /* workspace for progress bar */ +#endif #ifndef NO_PROGRESS #define BAROVERHEAD 45 /* non `*' portion of progress bar */ /*
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Sat Jun 22 23:40:53 UTC 2019 Modified Files: src/usr.bin/ftp: extern.h util.c Log Message: trim down error checking if we are small. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.159 -r1.160 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/extern.h diff -u src/usr.bin/ftp/extern.h:1.81 src/usr.bin/ftp/extern.h:1.82 --- src/usr.bin/ftp/extern.h:1.81 Sun Feb 3 23:09:13 2019 +++ src/usr.bin/ftp/extern.h Sat Jun 22 19:40:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.81 2019/02/04 04:09:13 mrg Exp $ */ +/* $NetBSD: extern.h,v 1.82 2019/06/22 23:40:53 christos Exp $ */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@ -243,7 +243,14 @@ void user(int, char **); int ftp_connect(int, const struct sockaddr *, socklen_t, int); int ftp_listen(int, int); int ftp_poll(struct pollfd *, int, int); +#ifndef SMALL void *ftp_malloc(size_t); StringList *ftp_sl_init(void); void ftp_sl_add(StringList *, char *); char *ftp_strdup(const char *); +#else +#define ftp_malloc(a) malloc(a); +#define ftp_sl_init() sl_init() +#define ftp_sl_add(a, b) sl_add((a), (b)) +#define ftp_strdup(a) strdup(a) +#endif Index: src/usr.bin/ftp/util.c diff -u src/usr.bin/ftp/util.c:1.159 src/usr.bin/ftp/util.c:1.160 --- src/usr.bin/ftp/util.c:1.159 Mon Nov 20 16:11:36 2017 +++ src/usr.bin/ftp/util.c Sat Jun 22 19:40:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.159 2017/11/20 21:11:36 kre Exp $ */ +/* $NetBSD: util.c,v 1.160 2019/06/22 23:40:53 christos Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ #include #ifndef lint -__RCSID("$NetBSD: util.c,v 1.159 2017/11/20 21:11:36 kre Exp $"); +__RCSID("$NetBSD: util.c,v 1.160 2019/06/22 23:40:53 christos Exp $"); #endif /* not lint */ /* @@ -1491,6 +1491,7 @@ ftp_poll(struct pollfd *fds, int nfds, i return poll(fds, nfds, timeout); } +#ifndef SMALL /* * malloc() with inbuilt error checking */ @@ -1545,3 +1546,4 @@ ftp_strdup(const char *str) err(1, "Unable to allocate memory for string copy"); return (s); } +#endif
Re: CVS commit: src/usr.bin/ftp
On Sat, Sep 12, 2015 at 07:38:42PM +, Thomas Klausner wrote: > Module Name: src > Committed By: wiz > Date: Sat Sep 12 19:38:42 UTC 2015 > > Modified Files: > src/usr.bin/ftp: fetch.c ssl.c ssl.h > > Log Message: > Add Server Name Indication (SNI) support for https. host can't be NULL at this point, so the check is redundant. Joerg
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Mar 4 21:40:53 UTC 2010 Modified Files: src/usr.bin/ftp: extern.h fetch.c util.c Log Message: Parse HTTP 'Date' entries in the `C' locale rather than the user's. Fix from [bin/42917] (with minor changes), from KAMADA Ken'ichi. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.191 -r1.192 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.152 -r1.153 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/extern.h diff -u src/usr.bin/ftp/extern.h:1.77 src/usr.bin/ftp/extern.h:1.78 --- src/usr.bin/ftp/extern.h:1.77 Mon Jul 13 19:05:41 2009 +++ src/usr.bin/ftp/extern.h Thu Mar 4 21:40:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.77 2009/07/13 19:05:41 roy Exp $ */ +/* $NetBSD: extern.h,v 1.78 2010/03/04 21:40:53 lukem Exp $ */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@ -166,6 +166,7 @@ void opts(int, char **); void newer(int, char **); void page(int, char **); +const char *parse_rfc2616time(struct tm *, const char *); int parserate(int, char **, int); char *prompt(void); void proxabort(int); Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.191 src/usr.bin/ftp/fetch.c:1.192 --- src/usr.bin/ftp/fetch.c:1.191 Mon Aug 17 09:08:16 2009 +++ src/usr.bin/ftp/fetch.c Thu Mar 4 21:40:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.191 2009/08/17 09:08:16 christos Exp $ */ +/* $NetBSD: fetch.c,v 1.192 2010/03/04 21:40:53 lukem Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fetch.c,v 1.191 2009/08/17 09:08:16 christos Exp $); +__RCSID($NetBSD: fetch.c,v 1.192 2010/03/04 21:40:53 lukem Exp $); #endif /* not lint */ /* @@ -934,28 +934,18 @@ } else if (match_token(cp, Last-Modified:)) { struct tm parsed; -char *t; +const char *t; memset(parsed, 0, sizeof(parsed)); - /* RFC1123 */ -if ((t = strptime(cp, - %a, %d %b %Y %H:%M:%S GMT, - parsed)) - /* RFC0850 */ -|| (t = strptime(cp, - %a, %d-%b-%y %H:%M:%S GMT, - parsed)) - /* asctime */ -|| (t = strptime(cp, - %a, %b %d %H:%M:%S %Y, - parsed))) { +t = parse_rfc2616time(parsed, cp); +if (t != NULL) { parsed.tm_isdst = -1; if (*t == '\0') mtime = timegm(parsed); #ifndef NO_DEBUG if (ftp_debug mtime != -1) { fprintf(ttyout, - parsed date as: %s, + parsed time as: %s, rfc2822time(localtime(mtime))); } #endif Index: src/usr.bin/ftp/util.c diff -u src/usr.bin/ftp/util.c:1.152 src/usr.bin/ftp/util.c:1.153 --- src/usr.bin/ftp/util.c:1.152 Mon Jul 13 19:05:41 2009 +++ src/usr.bin/ftp/util.c Thu Mar 4 21:40:53 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.152 2009/07/13 19:05:41 roy Exp $ */ +/* $NetBSD: util.c,v 1.153 2010/03/04 21:40:53 lukem Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -64,7 +64,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: util.c,v 1.152 2009/07/13 19:05:41 roy Exp $); +__RCSID($NetBSD: util.c,v 1.153 2010/03/04 21:40:53 lukem Exp $); #endif /* not lint */ /* @@ -85,6 +85,7 @@ #include signal.h #include libgen.h #include limits.h +#include locale.h #include netdb.h #include stdio.h #include stdlib.h @@ -756,7 +757,7 @@ else goto cleanup_parse_time; } else { - DPRINTF(remotemodtime: parsed date `%s' as LLF + DPRINTF(remotemodtime: parsed time `%s' as LLF , %s, timestr, (LLT)rtime, rfc2822time(localtime(rtime))); @@ -792,6 +793,32 @@ } /* + * Parse HTTP-date as per RFC 2616. + * Return a pointer to the next character of the consumed date string, + * or NULL if failed. + */ +const char * +parse_rfc2616time(struct tm *parsed, const char *httpdate) +{ + const char *t; + const char *curlocale; + + /* The representation of %a depends on the current locale. */ + curlocale = setlocale(LC_TIME, NULL); + (void)setlocale(LC_TIME, C); +/* RFC1123 */ + if ((t = strptime(httpdate, %a, %d %b %Y %H:%M:%S GMT, parsed)) || +/* RFC0850 */ + (t = strptime(httpdate, %a, %d-%b-%y %H:%M:%S GMT, parsed)) || +/* asctime */ + (t = strptime(httpdate, %a, %b %d %H:%M:%S %Y, parsed))) { + ; /* do nothing */ + } + (void)setlocale(LC_TIME, curlocale); + return t; +} + +/* * Update global `localcwd', which contains the state of the local cwd */ void
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Thu Mar 4 21:40:53 UTC 2010 Modified Files: src/usr.bin/ftp: extern.h fetch.c util.c Log Message: Parse HTTP 'Date' entries in the `C' locale rather than the user's. Fix from [bin/42917] (with minor changes), from KAMADA Ken'ichi. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.191 -r1.192 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.152 -r1.153 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri Mar 5 07:41:10 UTC 2010 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp.c util.c Log Message: Back to using 'RFC ' instead of 'RFC' To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.159 -r1.160 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.153 -r1.154 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri Mar 5 07:41:10 UTC 2010 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp.c util.c Log Message: Back to using 'RFC ' instead of 'RFC' To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.159 -r1.160 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.153 -r1.154 src/usr.bin/ftp/util.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.192 src/usr.bin/ftp/fetch.c:1.193 --- src/usr.bin/ftp/fetch.c:1.192 Thu Mar 4 21:40:53 2010 +++ src/usr.bin/ftp/fetch.c Fri Mar 5 07:41:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.192 2010/03/04 21:40:53 lukem Exp $ */ +/* $NetBSD: fetch.c,v 1.193 2010/03/05 07:41:10 lukem Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: fetch.c,v 1.192 2010/03/04 21:40:53 lukem Exp $); +__RCSID($NetBSD: fetch.c,v 1.193 2010/03/05 07:41:10 lukem Exp $); #endif /* not lint */ /* @@ -281,7 +281,7 @@ /* - * Parse URL of form (per RFC3986): + * Parse URL of form (per RFC 3986): * type://[user[:password]...@]host[:port][/path] * Returns -1 if a parse error occurred, otherwise 0. * It's the caller's responsibility to url_decode() the returned @@ -291,7 +291,7 @@ * malloc(3)ed strings of the relevant section, and port to * the number given, or ftpport if ftp://, or httpport if http://. * - * XXX: this is not totally RFC3986 compliant; path will have the + * XXX: this is not totally RFC 3986 compliant; path will have the * leading `/' unless it's an ftp:// URL, as this makes things easier * for file:// and http:// URLs. ftp:// URLs have the `/' between the * host and the URL-path removed, but any additional leading slashes @@ -394,7 +394,7 @@ #ifdef INET6 /* * Check if thost is an encoded IPv6 address, as per - * RFC3986: + * RFC 3986: * `[' ipv6-address ']' */ if (*thost == '[') { @@ -1520,12 +1520,12 @@ * directories in one step. * * If we are dealing with an `ftp://host/path' URL - * (urltype is FTP_URL_T), then RFC3986 says we need to + * (urltype is FTP_URL_T), then RFC 3986 says we need to * send a separate CWD command for each unescaped / * in the path, and we have to interpret %hex escaping * *after* we find the slashes. It's possible to get * empty components here, (from multiple adjacent - * slashes in the path) and RFC3986 says that we should + * slashes in the path) and RFC 3986 says that we should * still do `CWD ' (with a null argument) in such cases. * * Many ftp servers don't support `CWD ', so if there's an @@ -1597,8 +1597,8 @@ fprintf(stderr, \n ftp: The `CWD ' command (without a directory), which is required by\n - RFC3986 to support the empty directory in the URL pathname (`//'),\n - conflicts with the server's conformance to RFC0959.\n + RFC 3986 to support the empty directory in the URL pathname (`//'),\n + conflicts with the server's conformance to RFC 959.\n Try the same URL without the `//' in the URL pathname.\n \n); goto cleanup_fetch_ftp; Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.130 src/usr.bin/ftp/ftp.1:1.131 --- src/usr.bin/ftp/ftp.1:1.130 Sat Jul 11 18:35:48 2009 +++ src/usr.bin/ftp/ftp.1 Fri Mar 5 07:41:10 2010 @@ -1,6 +1,6 @@ -.\ $NetBSD: ftp.1,v 1.130 2009/07/11 18:35:48 joerg Exp $ +.\ $NetBSD: ftp.1,v 1.131 2010/03/05 07:41:10 lukem Exp $ .\ -.\ Copyright (c) 1996-2008 The NetBSD Foundation, Inc. +.\ Copyright (c) 1996-2010 The NetBSD Foundation, Inc. .\ All rights reserved. .\ .\ This code is derived from software contributed to The NetBSD Foundation @@ -57,7 +57,7 @@ .\ .\ @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\ -.Dd May 10, 2008 +.Dd March 5, 2010 .Dt FTP 1 .Os .Sh NAME @@ -777,7 +777,7 @@ .Dq stream . .It Ic modtime Ar remote-file Show the last modification time of the file on the remote machine, in -.Li RFC2822 +.Li RFC 2822 format. .It Ic more Ar file A synonym for @@ -998,7 +998,7 @@ servers are required to support the .Dv PASV command by -.Li RFC1123 , +.Li RFC 1123 , some do not.) .It Ic pdir Op Ar remote-path Perform @@ -1591,7 +1591,7 @@ The default transfer type is binary. .Pp In order to be compliant with -.Li RFC3986 , +.Li RFC 3986 , .Nm interprets the .Ar path @@ -1644,7 +1644,7 @@ .Sq Li \% Ns Ar XX codes (per -.Li RFC3986 ) +.Li RFC 3986 ) within the path components are decoded, with .Ar XX representing a character code in hexadecimal. @@ -2285,7 +2285,7 @@ or .Sq / ) , encode them with -.Li RFC3986 +.Li RFC 3986 .Sq Li \% Ns Ar XX encoding. .Pp @@ -2330,23 +2330,23 @@ .Nm attempts to be compliant with: .Bl -tag -offset indent
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri Mar 5 07:45:41 UTC 2010 Modified Files: src/usr.bin/ftp: version.h Log Message: ftp 20100305: fix http date parsing To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/usr.bin/ftp/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/ftp/version.h diff -u src/usr.bin/ftp/version.h:1.80 src/usr.bin/ftp/version.h:1.81 --- src/usr.bin/ftp/version.h:1.80 Sun Nov 15 10:03:16 2009 +++ src/usr.bin/ftp/version.h Fri Mar 5 07:45:40 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.80 2009/11/15 10:03:16 lukem Exp $ */ +/* $NetBSD: version.h,v 1.81 2010/03/05 07:45:40 lukem Exp $ */ /*- * Copyright (c) 1999-2009 The NetBSD Foundation, Inc. @@ -34,5 +34,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION 20090915 +#define FTP_VERSION 20100305 #endif
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Tue Jan 12 06:50:05 UTC 2010 Modified Files: src/usr.bin/ftp: cmds.c Log Message: rename argument from bool to val To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/usr.bin/ftp/cmds.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.