CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Fri Oct 4 18:06:53 UTC 2024 Modified Files: src/usr.bin/ftp: extern.h ftp.c Log Message: remove const when string gets overwritten. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.177 -r1.178 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/extern.h diff -u src/usr.bin/ftp/extern.h:1.83 src/usr.bin/ftp/extern.h:1.84 --- src/usr.bin/ftp/extern.h:1.83 Sat Feb 25 07:07:25 2023 +++ src/usr.bin/ftp/extern.h Fri Oct 4 14:06:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.83 2023/02/25 12:07:25 mlelstv Exp $ */ +/* $NetBSD: extern.h,v 1.84 2024/10/04 18:06:53 christos Exp $ */ /*- * Copyright (c) 1996-2023 The NetBSD Foundation, Inc. @@ -137,7 +137,7 @@ char *getoptionvalue(const char *); void getremoteinfo(void); int getreply(int); char *globulize(const char *); -char *gunique(const char *); +char *gunique(char *); void help(int, char **); char *hookup(const char *, const char *); void idlecmd(int, char **); @@ -176,7 +176,7 @@ void quit(int, char **); void justquit(void) __dead; void quote(int, char **); void quote1(const char *, int, char **); -void recvrequest(const char *, const char *, const char *, +void recvrequest(const char *, char *, const char *, const char *, int, int); void reget(int, char **); char *remglob(char **, int, const char **); Index: src/usr.bin/ftp/ftp.c diff -u src/usr.bin/ftp/ftp.c:1.177 src/usr.bin/ftp/ftp.c:1.178 --- src/usr.bin/ftp/ftp.c:1.177 Wed Sep 25 12:53:58 2024 +++ src/usr.bin/ftp/ftp.c Fri Oct 4 14:06:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.177 2024/09/25 16:53:58 christos Exp $ */ +/* $NetBSD: ftp.c,v 1.178 2024/10/04 18:06:53 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.177 2024/09/25 16:53:58 christos Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.178 2024/10/04 18:06:53 christos Exp $"); #endif #endif /* not lint */ @@ -925,7 +925,7 @@ sendrequest(const char *cmd, const char } void -recvrequest(const char *cmd, const char *volatile local, const char *remote, +recvrequest(const char *cmd, char *volatile local, const char *remote, const char *lmode, int printnames, int ignorespecial) { FILE *volatile fout; @@ -2037,7 +2037,7 @@ reset(int argc, char *argv[]) } char * -gunique(const char *local) +gunique(char *local) { static char new[MAXPATHLEN]; char *cp = strrchr(local, '/');
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Fri Oct 4 18:06:53 UTC 2024 Modified Files: src/usr.bin/ftp: extern.h ftp.c Log Message: remove const when string gets overwritten. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/ftp/extern.h cvs rdiff -u -r1.177 -r1.178 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: christos Date: Fri Oct 4 18:06:19 UTC 2024 Modified Files: src/usr.bin/ftp: progressbar.c Log Message: use unsigned when doing shifts. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 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.26 src/usr.bin/ftp/progressbar.c:1.27 --- src/usr.bin/ftp/progressbar.c:1.26 Wed Sep 25 12:53:58 2024 +++ src/usr.bin/ftp/progressbar.c Fri Oct 4 14:06:19 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.26 2024/09/25 16:53:58 christos Exp $ */ +/* $NetBSD: progressbar.c,v 1.27 2024/10/04 18:06:19 christos Exp $ */ /*- * Copyright (c) 1997-2024 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.26 2024/09/25 16:53:58 christos Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.27 2024/10/04 18:06:19 christos Exp $"); #endif /* not lint */ /* @@ -123,12 +123,12 @@ static struct timeval lastupdate; void progressmeter(int flag) { - static off_t lastsize; - off_t cursize; + static uint64_t lastsize; + uint64_t cursize; struct timeval now, wait; #ifndef NO_PROGRESS struct timeval td; - off_t abbrevsize, bytespersec; + uint64_t abbrevsize, bytespersec; double elapsed; int ratio, i, remaining, barlength; @@ -261,7 +261,7 @@ progressmeter(int flag) suffixes[i]); if (filesize > 0) { - if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) { + if (bytes <= 0 || elapsed <= 0.0 || cursize > (uint64_t)filesize) { len += snprintf(buf + len, BUFLEFT, " --:-- ETA"); } else if (wait.tv_sec >= STALLTIME) { len += snprintf(buf + len, BUFLEFT, " - stalled -");
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Fri Oct 4 18:06:19 UTC 2024 Modified Files: src/usr.bin/ftp: progressbar.c Log Message: use unsigned when doing shifts. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 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: Fri Oct 4 18:05:44 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c Log Message: Check bounds when copying to destination. Remove const where the const string ended up being overwritten. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 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.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Fri Oct 4 18:05:44 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c Log Message: Check bounds when copying to destination. Remove const where the const string ended up being overwritten. To generate a diff of this commit: cvs rdiff -u -r1.143 -r1.144 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. Modified files: Index: src/usr.bin/ftp/cmds.c diff -u src/usr.bin/ftp/cmds.c:1.143 src/usr.bin/ftp/cmds.c:1.144 --- src/usr.bin/ftp/cmds.c:1.143 Wed Sep 25 12:53:58 2024 +++ src/usr.bin/ftp/cmds.c Fri Oct 4 14:05:43 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.143 2024/09/25 16:53:58 christos Exp $ */ +/* $NetBSD: cmds.c,v 1.144 2024/10/04 18:05:43 christos Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.143 2024/09/25 16:53:58 christos Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.144 2024/10/04 18:05:43 christos Exp $"); #endif #endif /* not lint */ @@ -147,10 +147,10 @@ __dead static void mintr(int); static void mabort(const char *); static void set_type(const char *); -static const char *doprocess(char *, size_t, const char *, int, int, int); -static const char *domap(char *, size_t, const char *); -static const char *docase(char *, size_t, const char *); -static const char *dotrans(char *, size_t, const char *); +static char *doprocess(char *, size_t, char *, int, int, int); +static char *domap(char *, size_t, const char *); +static char *docase(char *, size_t, const char *); +static char *dotrans(char *, size_t, const char *); /* * Confirm if "cmd" is to be performed upon "file". @@ -407,7 +407,7 @@ put(int argc, char *argv[]) const char *cmd; int loc = 0; char *locfile; - const char *remfile; + char *remfile; if (argc == 2) { argc++; @@ -437,8 +437,8 @@ put(int argc, char *argv[]) free(locfile); } -static const char * -doprocess(char *dst, size_t dlen, const char *src, +static char * +doprocess(char *dst, size_t dlen, char *src, int casef, int transf, int mapf) { if (casef) @@ -576,8 +576,7 @@ int getit(int argc, char *argv[], int restartit, const char *gmode) { int loc, rval; - char *remfile, *olocfile; - const char *locfile; + char *remfile, *olocfile, *locfile; char buf[MAXPATHLEN]; loc = rval = 0; @@ -684,8 +683,7 @@ mget(int argc, char *argv[]) { sigfunc oldintr; int ointer; - char *cp; - const char *tp; + char *cp, *tp; int volatile restartit; if (argc == 0 || @@ -1290,13 +1288,11 @@ void ls(int argc, char *argv[]) { const char *cmd; - char *remdir, *locbuf; - const char *locfile; + char *remdir, *locbuf, *locfile; int pagecmd, mlsdcmd; remdir = NULL; locbuf = NULL; - locfile = "-"; pagecmd = mlsdcmd = 0; /* * the only commands that start with `p' are @@ -1326,6 +1322,8 @@ ls(int argc, char *argv[]) remdir = argv[1]; if (argc > 2) locfile = argv[2]; + else + locfile = locbuf = ftp_strdup("-"); if (argc > 3 || ((pagecmd | mlsdcmd) && argc > 2)) { usage: if (pagecmd || mlsdcmd) @@ -1345,11 +1343,12 @@ ls(int argc, char *argv[]) if (EMPTYSTRING(p)) p = DEFAULTPAGER; len = strlen(p) + 2; + free(locbuf); locbuf = ftp_malloc(len); locbuf[0] = '|'; (void)strlcpy(locbuf + 1, p, len - 1); locfile = locbuf; - } else if ((strcmp(locfile, "-") != 0) && *locfile != '|') { + } else if (locfile != locbuf) { if ((locbuf = globulize(locfile)) == NULL || !confirm("output to local-file:", locbuf)) { code = -1; @@ -1920,7 +1919,7 @@ setcase(int argc, char *argv[]) * convert the given name to lower case if it's all upper case, into * a static buffer which is returned to the caller */ -static const char * +static char * docase(char *dst, size_t dlen, const char *src) { size_t i; @@ -1973,7 +1972,14 @@ setntrans(int argc, char *argv[]) (void)strlcpy(ntout, argv[2], sizeof(ntout)); } -static const char * +#define ADDC(x) \ + do { \ + *cp2++ = x; \ + if (cp2 - dst >= (ptrdiff_t)(dlen - 1)) \ + goto out; \ + } while (0) + +static char * dotrans(char *dst, size_t dlen, const char *src) { const char *cp1; @@ -1988,15 +1994,13 @@ dotrans(char *dst, size_t dlen, const ch if (*cp1 == ntin[i]) { found++; if (i < ostop) { - *cp2++ = ntout[i]; - if (cp2 - dst >= (ptrdiff_t)(dlen - 1)) - goto out; + ADDC(ntout[i]); } break; } } if (!found) { - *cp2++ = *cp1; + ADDC(*cp1); } } out: @@ -2037,8 +2041,8 @@ setnmap(int argc, char *argv[]) (void)strlcpy(mapout, cp, MAXPATHLEN); } -static const char * -domap(char *dst, size_t dlen __unused, const char *src) +static char * +domap(char *dst, size_t dlen, const char *src) { const char *cp1 = src; char *cp2 = mapin; @@ -2093,7 +2097,7 @@ domap(char *dst,
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Fri Oct 4 18:04:06 UTC 2024 Modified Files: src/usr.bin/ftp: ruserpass.c Log Message: extract duplicate code into a function. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.bin/ftp/ruserpass.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: Fri Oct 4 18:04:06 UTC 2024 Modified Files: src/usr.bin/ftp: ruserpass.c Log Message: extract duplicate code into a function. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/usr.bin/ftp/ruserpass.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/ruserpass.c diff -u src/usr.bin/ftp/ruserpass.c:1.34 src/usr.bin/ftp/ruserpass.c:1.35 --- src/usr.bin/ftp/ruserpass.c:1.34 Thu Jul 18 23:53:13 2024 +++ src/usr.bin/ftp/ruserpass.c Fri Oct 4 14:04:06 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ruserpass.c,v 1.34 2024/07/19 03:53:13 lukem Exp $ */ +/* $NetBSD: ruserpass.c,v 1.35 2024/10/04 18:04:06 christos Exp $ */ /* * Copyright (c) 1985, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: ruserpass.c,v 1.34 2024/07/19 03:53:13 lukem Exp $"); +__RCSID("$NetBSD: ruserpass.c,v 1.35 2024/10/04 18:04:06 christos Exp $"); #endif #endif /* not lint */ @@ -79,6 +79,20 @@ static struct toktab { { NULL, 0 } }; +static int +match_host_domain(const char *host, const char *domain, const char *tokv) +{ + const char *tmp; + + if (strcasecmp(host, tokval) == 0) + return 1; + + return (tmp = strchr(host, '.')) != NULL && + strcasecmp(tmp, domain) == 0 && + strncasecmp(host, tokv, tmp - host) == 0 && + tokv[tmp - host] == '\0'; +} + int ruserpass(const char *host, char **aname, char **apass, char **aacct) { @@ -119,19 +133,9 @@ ruserpass(const char *host, char **aname * or official hostname. Also allow match of * incompletely-specified host in local domain. */ - if (strcasecmp(host, tokval) == 0) -goto match; - if (strcasecmp(hostname, tokval) == 0) -goto match; - if ((tmp = strchr(hostname, '.')) != NULL && - strcasecmp(tmp, mydomain) == 0 && - strncasecmp(hostname, tokval, tmp-hostname) == 0 && - tokval[tmp - hostname] == '\0') + if (match_host_domain(hostname, mydomain, tokval)) goto match; - if ((tmp = strchr(host, '.')) != NULL && - strcasecmp(tmp, mydomain) == 0 && - strncasecmp(host, tokval, tmp - host) == 0 && - tokval[tmp - host] == '\0') + if (match_host_domain(host, mydomain, tokval)) goto match; continue; }
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: kre Date: Mon Sep 30 19:23:31 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: Don't forget the dot, use the intended macro name (I think), and improve the wording a little.(All related to the -H option.) To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 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.158 src/usr.bin/ftp/ftp.1:1.159 --- src/usr.bin/ftp/ftp.1:1.158 Mon Sep 30 13:03:36 2024 +++ src/usr.bin/ftp/ftp.1 Mon Sep 30 19:23:31 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.158 2024/09/30 13:03:36 christos Exp $ +.\" $NetBSD: ftp.1,v 1.159 2024/09/30 19:23:31 kre Exp $ .\" .\" Copyright (c) 1996-2024 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -224,17 +224,17 @@ or proxies. .It Fl g Disables file name globbing. -It Fl H Ar header +.It Fl H Ar header Include the provided .Ar header string as a custom .Tn HTTP header for an -.Th HTTP +.Tn HTTP request. -You can specify multiple headers by repeating the +The .Fl H -option. +option can be repeated to add additional headers. .It Fl i Turns off interactive prompting during multiple file transfers.
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: kre Date: Mon Sep 30 19:23:31 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: Don't forget the dot, use the intended macro name (I think), and improve the wording a little.(All related to the -H option.) To generate a diff of this commit: cvs rdiff -u -r1.158 -r1.159 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: christos Date: Mon Sep 30 13:03:37 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 main.c Log Message: fix markup (h -> H), explain about multiple headers, fix usage (from RVP) To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.132 -r1.133 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: christos Date: Mon Sep 30 13:03:37 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 main.c Log Message: fix markup (h -> H), explain about multiple headers, fix usage (from RVP) To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.132 -r1.133 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/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.157 src/usr.bin/ftp/ftp.1:1.158 --- src/usr.bin/ftp/ftp.1:1.157 Fri Sep 27 12:31:36 2024 +++ src/usr.bin/ftp/ftp.1 Mon Sep 30 09:03:36 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.157 2024/09/27 16:31:36 riastradh Exp $ +.\" $NetBSD: ftp.1,v 1.158 2024/09/30 13:03:36 christos Exp $ .\" .\" Copyright (c) 1996-2024 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd September 25, 2024 +.Dd September 30, 2024 .Dt FTP 1 .Os .Sh NAME @@ -67,7 +67,7 @@ .Nm .Op Fl 46AadefginpRtVv\&? .Op Fl b Ar bufsize -.Op Fl h Ar header +.Op Fl H Ar header .Op Fl N Ar netrc .Op Fl o Ar output .Op Fl P Ar port @@ -232,6 +232,9 @@ string as a custom header for an .Th HTTP request. +You can specify multiple headers by repeating the +.Fl H +option. .It Fl i Turns off interactive prompting during multiple file transfers. Index: src/usr.bin/ftp/main.c diff -u src/usr.bin/ftp/main.c:1.132 src/usr.bin/ftp/main.c:1.133 --- src/usr.bin/ftp/main.c:1.132 Wed Sep 25 12:55:39 2024 +++ src/usr.bin/ftp/main.c Mon Sep 30 09:03:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.132 2024/09/25 16:55:39 christos Exp $ */ +/* $NetBSD: main.c,v 1.133 2024/09/30 13:03:37 christos Exp $ */ /*- * Copyright (c) 1996-2023 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.132 2024/09/25 16:55:39 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.133 2024/09/30 13:03:37 christos Exp $"); #endif #endif /* not lint */ @@ -1080,8 +1080,9 @@ synopsis(FILE * stream) const char * progname = getprogname(); fprintf(stream, -"usage: %s [-46AadefginpRtVv] [-N NETRC] [-o OUTPUT] [-P PORT] [-q QUITTIME]\n" -" [-r RETRY] [-s SRCADDR] [-T DIR,MAX[,INC]] [-x XFERSIZE]\n" +"usage: %s [-46AadefginpRtVv] [-H HEADER] [-N NETRC] [-o OUTPUT] [-P PORT]\n" +" [-q QUITTIME] [-r RETRY] [-s SRCADDR] [-T DIR,MAX[,INC]]\n" +" [-x XFERSIZE]\n" " [[USER@]HOST [PORT]]\n" " [[USER@]HOST:[PATH][/]]\n" " [file:///PATH]\n"
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: riastradh Date: Fri Sep 27 16:31:36 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp(1): Nix trailing whitespace in man page. No functional change intended. PR bin/58581: ftp(1) should allow specifying header fields in http requests To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 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: riastradh Date: Fri Sep 27 16:31:36 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 Log Message: ftp(1): Nix trailing whitespace in man page. No functional change intended. PR bin/58581: ftp(1) should allow specifying header fields in http requests To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 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.156 src/usr.bin/ftp/ftp.1:1.157 --- src/usr.bin/ftp/ftp.1:1.156 Wed Sep 25 16:55:39 2024 +++ src/usr.bin/ftp/ftp.1 Fri Sep 27 16:31:36 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.156 2024/09/25 16:55:39 christos Exp $ +.\" $NetBSD: ftp.1,v 1.157 2024/09/27 16:31:36 riastradh Exp $ .\" .\" Copyright (c) 1996-2024 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -227,7 +227,7 @@ Disables file name globbing. It Fl H Ar header Include the provided .Ar header -string as a custom +string as a custom .Tn HTTP header for an .Th HTTP
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Wed Sep 25 16:55:40 UTC 2024 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp_var.h main.c Log Message: PR/58581: Sunil Nimmagadda: Add flag to allow specifying extra http header fields. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.155 -r1.156 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.88 -r1.89 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.131 -r1.132 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/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.240 src/usr.bin/ftp/fetch.c:1.241 --- src/usr.bin/ftp/fetch.c:1.240 Wed Sep 25 12:53:58 2024 +++ src/usr.bin/ftp/fetch.c Wed Sep 25 12:55:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.240 2024/09/25 16:53:58 christos Exp $ */ +/* $NetBSD: fetch.c,v 1.241 2024/09/25 16:55:39 christos Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.240 2024/09/25 16:53:58 christos Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.241 2024/09/25 16:55:39 christos Exp $"); #endif /* not lint */ /* @@ -865,6 +865,7 @@ print_get(FETCH *fin, int hasleading, in const struct urlinfo *ui) { const char *leading = hasleading ? ", " : " ("; + struct entry *np; if (isproxy) { if (verbose) { @@ -882,6 +883,10 @@ print_get(FETCH *fin, int hasleading, in print_host(fin, ui); fetch_printf(fin, "Accept: */*\r\n"); fetch_printf(fin, "Connection: close\r\n"); + SLIST_FOREACH(np, &custom_headers, entries) { + fetch_printf(fin, "%s\r\n", np->header); + } + if (restart_point) { fputs(leading, ttyout); fetch_printf(fin, "Range: bytes=" LLF "-\r\n", Index: src/usr.bin/ftp/ftp.1 diff -u src/usr.bin/ftp/ftp.1:1.155 src/usr.bin/ftp/ftp.1:1.156 --- src/usr.bin/ftp/ftp.1:1.155 Thu Jul 18 23:51:21 2024 +++ src/usr.bin/ftp/ftp.1 Wed Sep 25 12:55:39 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.155 2024/07/19 03:51:21 lukem Exp $ +.\" $NetBSD: ftp.1,v 1.156 2024/09/25 16:55:39 christos Exp $ .\" .\" Copyright (c) 1996-2024 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -57,7 +57,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd July 19, 2024 +.Dd September 25, 2024 .Dt FTP 1 .Os .Sh NAME @@ -67,6 +67,7 @@ .Nm .Op Fl 46AadefginpRtVv\&? .Op Fl b Ar bufsize +.Op Fl h Ar header .Op Fl N Ar netrc .Op Fl o Ar output .Op Fl P Ar port @@ -223,6 +224,14 @@ or proxies. .It Fl g Disables file name globbing. +It Fl H Ar header +Include the provided +.Ar header +string as a custom +.Tn HTTP +header for an +.Th HTTP +request. .It Fl i Turns off interactive prompting during multiple file transfers. Index: src/usr.bin/ftp/ftp_var.h diff -u src/usr.bin/ftp/ftp_var.h:1.88 src/usr.bin/ftp/ftp_var.h:1.89 --- src/usr.bin/ftp/ftp_var.h:1.88 Sun Feb 18 17:33:15 2024 +++ src/usr.bin/ftp/ftp_var.h Wed Sep 25 12:55:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ftp_var.h,v 1.88 2024/02/18 22:33:15 wiz Exp $ */ +/* $NetBSD: ftp_var.h,v 1.89 2024/09/25 16:55:39 christos Exp $ */ /*- * Copyright (c) 1996-2009 The NetBSD Foundation, Inc. @@ -101,6 +101,7 @@ #endif #include +#include #include #include @@ -165,6 +166,14 @@ enum { FEAT_max }; +/* + * Custom HTTP headers + */ +struct entry { + SLIST_ENTRY(entry) entries; + const char *header; +}; +SLIST_HEAD(http_headers, entry); /* * Global defines @@ -320,8 +329,9 @@ GLOBAL FILE *cin; GLOBAL FILE *cout; GLOBAL int data; -extern struct cmd cmdtab[]; -extern struct option optiontab[]; +extern struct cmd cmdtab[]; +extern struct option optiontab[]; +extern struct http_headers custom_headers; extern size_t ftp_buflen; Index: src/usr.bin/ftp/main.c diff -u src/usr.bin/ftp/main.c:1.131 src/usr.bin/ftp/main.c:1.132 --- src/usr.bin/ftp/main.c:1.131 Wed Sep 25 12:53:58 2024 +++ src/usr.bin/ftp/main.c Wed Sep 25 12:55:39 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.131 2024/09/25 16:53:58 christos Exp $ */ +/* $NetBSD: main.c,v 1.132 2024/09/25 16:55:39 christos Exp $ */ /*- * Copyright (c) 1996-2023 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.131 2024/09/25 16:53:58 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.132 2024/09/25 16:55:39 christos Exp $"); #endif #endif /* not lint */ @@ -134,11 +134,14 @@ static int usage(void); static int usage_help(void); static void setupoption(const char *, const char *, const char *); +struct http_headers custom_headers; + int main(int volatile argc, char **volatile argv) { int ch, rval; struct passwd *pw; + struct entry *p; char *cp, *ep, *anonpass, *upload_path, *src_addr; const char *anonuser; int dumbterm, isupload; @@ -267,7 +270,8 @@ main(int volatile
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Wed Sep 25 16:55:40 UTC 2024 Modified Files: src/usr.bin/ftp: fetch.c ftp.1 ftp_var.h main.c Log Message: PR/58581: Sunil Nimmagadda: Add flag to allow specifying extra http header fields. To generate a diff of this commit: cvs rdiff -u -r1.240 -r1.241 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.155 -r1.156 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.88 -r1.89 src/usr.bin/ftp/ftp_var.h cvs rdiff -u -r1.131 -r1.132 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: christos Date: Wed Sep 25 16:53:58 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c complete.c fetch.c ftp.c main.c progressbar.c ssl.c util.c Log Message: pass some lint. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.47 -r1.48 src/usr.bin/ftp/complete.c cvs rdiff -u -r1.239 -r1.240 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/ftp/main.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.167 -r1.168 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/cmds.c diff -u src/usr.bin/ftp/cmds.c:1.142 src/usr.bin/ftp/cmds.c:1.143 --- src/usr.bin/ftp/cmds.c:1.142 Thu Jul 18 23:53:13 2024 +++ src/usr.bin/ftp/cmds.c Wed Sep 25 12:53:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.142 2024/07/19 03:53:13 lukem Exp $ */ +/* $NetBSD: cmds.c,v 1.143 2024/09/25 16:53:58 christos Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.142 2024/07/19 03:53:13 lukem Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.143 2024/09/25 16:53:58 christos Exp $"); #endif #endif /* not lint */ @@ -172,7 +172,7 @@ confirm(const char *cmd, const char *fil promptleft = cmd; promptright = file; } - while (1) { + for (;;) { fprintf(ttyout, "%s %s [anpqy?]? ", promptleft, promptright); (void)fflush(ttyout); if (get_line(stdin, cline, sizeof(cline), &errormsg) < 0) { @@ -1830,10 +1830,10 @@ account(int argc, char *argv[]) memset(ap, 0, strlen(ap)); } -sigjmp_buf abortprox; +static sigjmp_buf abortprox; void -proxabort(int notused) +proxabort(int notused __unused) { sigint_raised = 1; @@ -1855,7 +1855,7 @@ void doproxy(int argc, char *argv[]) { struct cmd *c; - int cmdpos; + size_t cmdpos; sigfunc oldintr; char cmdbuf[MAX_C_NAME]; @@ -2038,7 +2038,7 @@ setnmap(int argc, char *argv[]) } static const char * -domap(char *dst, size_t dlen, const char *src) +domap(char *dst, size_t dlen __unused, const char *src) { const char *cp1 = src; char *cp2 = mapin; @@ -2483,7 +2483,7 @@ macdef(int argc, char *argv[]) } tmp++; } - while (1) { + for (;;) { while ((c = getchar()) != '\n' && c != EOF) /* LOOP */; if (c == EOF || getchar() == '\n') { @@ -2605,7 +2605,8 @@ lpage(int argc, char *argv[]) void page(int argc, char *argv[]) { - int ohash, orestart_point, overbose; + int ohash, overbose; + off_t orestart_point; size_t len; const char *p; char *pager; @@ -2627,7 +2628,8 @@ page(int argc, char *argv[]) ohash = hash; orestart_point = restart_point; overbose = verbose; - hash = restart_point = verbose = 0; + hash = verbose = 0; + restart_point = 0; recvrequest("RETR", pager, argv[1], "r+", 1, 0); hash = ohash; restart_point = orestart_point; Index: src/usr.bin/ftp/complete.c diff -u src/usr.bin/ftp/complete.c:1.47 src/usr.bin/ftp/complete.c:1.48 --- src/usr.bin/ftp/complete.c:1.47 Mon Jan 28 07:04:16 2019 +++ src/usr.bin/ftp/complete.c Wed Sep 25 12:53:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: complete.c,v 1.47 2019/01/28 12:04:16 christos Exp $ */ +/* $NetBSD: complete.c,v 1.48 2024/09/25 16:53:58 christos Exp $ */ /*- * Copyright (c) 1997-2009 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: complete.c,v 1.47 2019/01/28 12:04:16 christos Exp $"); +__RCSID("$NetBSD: complete.c,v 1.48 2024/09/25 16:53:58 christos Exp $"); #endif /* not lint */ /* @@ -349,7 +349,7 @@ complete_remote(char *word, int list) * Generic complete routine */ unsigned char -complete(EditLine *cel, int ch) +complete(EditLine *cel, int ch __unused) { static char word[FTPBUFLEN]; static size_t lastc_argc, lastc_argo; Index: src/usr.bin/ftp/fetch.c diff -u src/usr.bin/ftp/fetch.c:1.239 src/usr.bin/ftp/fetch.c:1.240 --- src/usr.bin/ftp/fetch.c:1.239 Sun Feb 18 17:29:56 2024 +++ src/usr.bin/ftp/fetch.c Wed Sep 25 12:53:58 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.239 2024/02/18 22:29:56 christos Exp $ */ +/* $NetBSD: fetch.c,v 1.240 2024/09/25 16:53:58 christos Exp $ */ /*- * Copyright (c) 1997-2015 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.239 2024/02/18 22:29:56 christos Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.240 2024/09/25 16:53:58 christos Exp $"); #endif /* not lint */ /* @@ -261,8 +261,8 @@ freeurlinfo(struct urlinfo *ui) static int auth_url(const char *challenge, char **response, const struct authinfo *auth) { - const char *cp, *scheme, *errormsg; - char *ep, *clear, *realm; + const char *cp, *ep, *scheme, *errormsg; + char *clear, *realm;
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: christos Date: Wed Sep 25 16:53:58 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c complete.c fetch.c ftp.c main.c progressbar.c ssl.c util.c Log Message: pass some lint. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.47 -r1.48 src/usr.bin/ftp/complete.c cvs rdiff -u -r1.239 -r1.240 src/usr.bin/ftp/fetch.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/ftp/ftp.c cvs rdiff -u -r1.130 -r1.131 src/usr.bin/ftp/main.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/ftp/ssl.c cvs rdiff -u -r1.167 -r1.168 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 Jul 19 03:53:13 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c progressbar.c ruserpass.c Log Message: ftp: improve units used in comments and errors Use "KiB" instead of "K" in errors. Clarify related comments. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.33 -r1.34 src/usr.bin/ftp/ruserpass.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/cmds.c diff -u src/usr.bin/ftp/cmds.c:1.141 src/usr.bin/ftp/cmds.c:1.142 --- src/usr.bin/ftp/cmds.c:1.141 Wed Jan 6 09:15:59 2021 +++ src/usr.bin/ftp/cmds.c Fri Jul 19 03:53:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cmds.c,v 1.141 2021/01/06 09:15:59 lukem Exp $ */ +/* $NetBSD: cmds.c,v 1.142 2024/07/19 03:53:13 lukem Exp $ */ /*- * Copyright (c) 1996-2021 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.141 2021/01/06 09:15:59 lukem Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.142 2024/07/19 03:53:13 lukem Exp $"); #endif #endif /* not lint */ @@ -2487,7 +2487,7 @@ macdef(int argc, char *argv[]) while ((c = getchar()) != '\n' && c != EOF) /* LOOP */; if (c == EOF || getchar() == '\n') { - fputs("Macro not defined - 4K buffer exceeded.\n", + fputs("Macro not defined - 4 KiB buffer exceeded.\n", ttyout); code = -1; return; Index: src/usr.bin/ftp/progressbar.c diff -u src/usr.bin/ftp/progressbar.c:1.24 src/usr.bin/ftp/progressbar.c:1.25 --- src/usr.bin/ftp/progressbar.c:1.24 Wed Jan 6 04:43:14 2021 +++ src/usr.bin/ftp/progressbar.c Fri Jul 19 03:53:13 2024 @@ -1,7 +1,7 @@ -/* $NetBSD: progressbar.c,v 1.24 2021/01/06 04:43:14 lukem Exp $ */ +/* $NetBSD: progressbar.c,v 1.25 2024/07/19 03:53:13 lukem Exp $ */ /*- - * Copyright (c) 1997-2021 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2024 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.24 2021/01/06 04:43:14 lukem Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.25 2024/07/19 03:53:13 lukem Exp $"); #endif /* not lint */ /* @@ -89,17 +89,17 @@ updateprogressmeter(int dummy) */ #if !defined(NO_PROGRESS) || !defined(STANDALONE_PROGRESS) static const char * const suffixes[] = { - "", /* 2^0 (byte) */ - "KiB", /* 2^10 Kibibyte */ - "MiB", /* 2^20 Mebibyte */ - "GiB", /* 2^30 Gibibyte */ - "TiB", /* 2^40 Tebibyte */ - "PiB", /* 2^50 Pebibyte */ - "EiB", /* 2^60 Exbibyte */ + "", /* 2^0, (byte) */ + "KiB", /* 2^10, Kibibyte */ + "MiB", /* 2^20, Mebibyte */ + "GiB", /* 2^30, Gibibyte */ + "TiB", /* 2^40, Tebibyte */ + "PiB", /* 2^50, Pebibyte */ + "EiB", /* 2^60, Exbibyte */ #if 0 /* The following are not necessary for signed 64-bit off_t */ - "ZiB", /* 2^70 Zebibyte */ - "YiB", /* 2^80 Yobibyte */ + "ZiB", /* 2^70, Zebibyte */ + "YiB", /* 2^80, Yobibyte */ #endif }; #define NSUFFIXES (int)(sizeof(suffixes) / sizeof(suffixes[0])) Index: src/usr.bin/ftp/ruserpass.c diff -u src/usr.bin/ftp/ruserpass.c:1.33 src/usr.bin/ftp/ruserpass.c:1.34 --- src/usr.bin/ftp/ruserpass.c:1.33 Tue Apr 17 05:52:04 2007 +++ src/usr.bin/ftp/ruserpass.c Fri Jul 19 03:53:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ruserpass.c,v 1.33 2007/04/17 05:52:04 lukem Exp $ */ +/* $NetBSD: ruserpass.c,v 1.34 2024/07/19 03:53:13 lukem Exp $ */ /* * Copyright (c) 1985, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: ruserpass.c,v 1.33 2007/04/17 05:52:04 lukem Exp $"); +__RCSID("$NetBSD: ruserpass.c,v 1.34 2024/07/19 03:53:13 lukem Exp $"); #endif #endif /* not lint */ @@ -247,7 +247,7 @@ ruserpass(const char *host, char **aname tmp++; } if (tmp == macbuf + 4096) { -fputs("4K macro buffer exceeded.\n", +fputs("4 KiB macro buffer exceeded.\n", ttyout); goto bad; }
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri Jul 19 03:53:13 UTC 2024 Modified Files: src/usr.bin/ftp: cmds.c progressbar.c ruserpass.c Log Message: ftp: improve units used in comments and errors Use "KiB" instead of "K" in errors. Clarify related comments. To generate a diff of this commit: cvs rdiff -u -r1.141 -r1.142 src/usr.bin/ftp/cmds.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/ftp/progressbar.c cvs rdiff -u -r1.33 -r1.34 src/usr.bin/ftp/ruserpass.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 Jul 19 03:51:21 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: ftp: improve -b documentation Order -b bufsize in the synopsis. Document the actual default value. To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.18 -r1.19 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.154 src/usr.bin/ftp/ftp.1:1.155 --- src/usr.bin/ftp/ftp.1:1.154 Wed Apr 17 02:46:03 2024 +++ src/usr.bin/ftp/ftp.1 Fri Jul 19 03:51:21 2024 @@ -1,6 +1,6 @@ -.\" $NetBSD: ftp.1,v 1.154 2024/04/17 02:46:03 gutteridge Exp $ +.\" $NetBSD: ftp.1,v 1.155 2024/07/19 03:51:21 lukem Exp $ .\" -.\" Copyright (c) 1996-2023 The NetBSD Foundation, Inc. +.\" Copyright (c) 1996-2024 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 April 17, 2024 +.Dd July 19, 2024 .Dt FTP 1 .Os .Sh NAME @@ -66,10 +66,10 @@ .Sh SYNOPSIS .Nm .Op Fl 46AadefginpRtVv\&? +.Op Fl b Ar bufsize .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 @@ -205,8 +205,11 @@ 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 . +The default +.Ar bufsize +is +.Dv 16384 +(16 KiB). .It Fl d Enables debugging. .It Fl e Index: src/usr.bin/ftp/ssl.c diff -u src/usr.bin/ftp/ssl.c:1.18 src/usr.bin/ftp/ssl.c:1.19 --- src/usr.bin/ftp/ssl.c:1.18 Mon Feb 19 00:15:20 2024 +++ src/usr.bin/ftp/ssl.c Fri Jul 19 03:51:21 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl.c,v 1.18 2024/02/19 00:15:20 christos Exp $ */ +/* $NetBSD: ssl.c,v 1.19 2024/07/19 03:51:21 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.18 2024/02/19 00:15:20 christos Exp $"); +__RCSID("$NetBSD: ssl.c,v 1.19 2024/07/19 03:51:21 lukem Exp $"); #endif #include @@ -579,7 +579,7 @@ fetch_getline(struct fetch_connect *conn break; } if (errormsg) - *errormsg = "Input line is too long (specify -b > 16K)"; + *errormsg = "Input line is too long (specify -b > 16384)"; fetch_clearerr(conn); return -3; }
CVS commit: src/usr.bin/ftp
Module Name:src Committed By: lukem Date: Fri Jul 19 03:51:21 UTC 2024 Modified Files: src/usr.bin/ftp: ftp.1 ssl.c Log Message: ftp: improve -b documentation Order -b bufsize in the synopsis. Document the actual default value. To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/usr.bin/ftp/ftp.1 cvs rdiff -u -r1.18 -r1.19 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: 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, &ep, sizeof(buf), &hcode)) { + switch (getresponse(fin, &ep, ftp_buflen, &hcode)) { 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), &len)) != C_OK) + if ((rv = getresponseline(fin, buf, ftp_buflen, &len)) != 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, &ep, sizeof(buf), &hcode)) { + switch (getresponse(fin, &ep, ftp_buflen, &hcode)) { 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), &len) != C_OK) + if (getresponseline(fin, buf, ftp_buflen, &len) != 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[BUFSI
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 \&cr 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 \&cr 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 \&cr 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
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 *) &from.si_su, &fromlen); - } 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(&writefds); - gettimeofday(&timeout, NULL); - timeout.tv_sec += quit_time; - } + pfd[0].fd = fd; + pfd[0].events = POLLOUT; + gettimeofday(&timeout, NULL); + timeout.tv_sec += quit_time; total = 0; while (iovcnt > 0) { - while (quit_time > 0 && !FD_ISSET(fd, &writefds)) { - FD_SET(fd, &writefds); - gettimeofday(&now, 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(&now, NULL); +timersub(&timeout, &now, &delta); +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, &writefds, NULL, &delta); - if (r == -1) { -if (errno == EINTR) - continue; + if (rv == 0) { +errno = ETIMEDOUT; return -1; } } @@ -330,7 +325,7 @@ fetch_nonssl_re
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 (conse
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("", &fuser, &pass, &facct) < 0) { + close(s); + s = -1; + continue; + } + + if (autologin) { + if (fuser != NULL && auth->user == NULL) +auth->user = ftp_strdup(fuser); + if (pass != NULL && a
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(&cp, 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(&data_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(&data_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(&data_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", &delim[0], &delim[1], &delim[2], &port[1], &delim[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( +&data_addr.si_su.su_sin6.sin6_addr, +&hisctladdr.si_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
In article <20151217043656.44657f...@cvs.netbsd.org>, NONAKA Kimihiro wrote: >-=-=-=-=-=- > >Module Name: src >Committed By: nonaka >Date: Thu Dec 17 04:36:56 UTC 2015 > >Modified Files: > src/usr.bin/ftp: fetch.c > >Log Message: >- Fix to connect https via proxy. >- Fix ttyout message. > Thanks! christos
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: 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: 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.
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 #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): * ://[[:]...@][:][/] * 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; will have the + * XXX: this is not totally RFC 3986 compliant; 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 -width 8n -.It
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: 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: 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 #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 #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 #include #include +#include #include #include #include @@ -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: 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.
Re: CVS commit: src/usr.bin/ftp
On Sat, Aug 15, 2009 at 10:49:24PM -0400, Christos Zoulas wrote: | Module Name:src | Committed By: christos | Date: Sun Aug 16 02:49:23 UTC 2009 | | Modified Files: | src/usr.bin/ftp: fetch.c | | Log Message: | use strrchr to find the last @ because we might want the username to contain | u...@domain. This isn't correct; '@' is a reserved URI char per RFC 3986. If you want to encode '@domain' in the "username" section of the URI, use "%40domain". Please back this out. thanks, Luke. pgpJ8HrCFXMdF.pgp Description: PGP signature
Re: CVS commit: src/usr.bin/ftp
On Fri, Apr 24, 2009 at 02:07:56PM +1000, Geoff Wing wrote: | On Sunday 2009-04-12 10:18 +, Luke Mewburn output: | :Module Name: src | :Committed By: lukem | :Date: Sun Apr 12 10:18:52 UTC 2009 | : | :Modified Files: | : src/usr.bin/ftp: cmds.c cmdtab.c complete.c domacro.c extern.h fetch.c | : ftp.c ftp_var.h main.c progressbar.c progressbar.h util.c version.h | : | :Log Message: | :Fix numerous WARNS=4 issues (-Wcast-qual -Wsign-compare). | :cvs rdiff -u -r1.114 -r1.115 src/usr.bin/ftp/main.c | | | @@ -570,7 +574,7 @@ | anonftp = 0; | autologin = 0; | } | - setpeer(argc+1, xargv); | + setpeer(3, xargv); | autologin = oautologin; | if (connected == 1 && uuser != NULL) | (void)ftp_login(host, uuser, NULL); | | | This is a functional change, not a WARNS=4 issue. And it's wrong. | | Try "ftp ", e.g. | % ftp ftp.netbsd.org. Fixed. thanks, Luke. pgp9OHLko5jmP.pgp Description: PGP signature
Re: CVS commit: src/usr.bin/ftp
On Sunday 2009-04-12 10:18 +, Luke Mewburn output: :Module Name: src :Committed By: lukem :Date: Sun Apr 12 10:18:52 UTC 2009 : :Modified Files: : src/usr.bin/ftp: cmds.c cmdtab.c complete.c domacro.c extern.h fetch.c : ftp.c ftp_var.h main.c progressbar.c progressbar.h util.c version.h : :Log Message: :Fix numerous WARNS=4 issues (-Wcast-qual -Wsign-compare). :cvs rdiff -u -r1.114 -r1.115 src/usr.bin/ftp/main.c @@ -570,7 +574,7 @@ anonftp = 0; autologin = 0; } - setpeer(argc+1, xargv); + setpeer(3, xargv); autologin = oautologin; if (connected == 1 && uuser != NULL) (void)ftp_login(host, uuser, NULL); This is a functional change, not a WARNS=4 issue. And it's wrong. Try "ftp ", e.g. % ftp ftp.netbsd.org. Regards, Geoff
Re: CVS commit: src/usr.bin/ftp
Jed Davis wrote: > Module Name: src > Committed By: jld > Date: Wed Apr 15 04:19:39 UTC 2009 > > Modified Files: > > src/usr.bin/ftp: util.c > > Log Message: > > Another empty-body warning/error, another set of curly braces. This, and > the last one, appear to affect only the NO_DEBUG (e.g., SMALLPROG) build. Jumping in a bit late here, but might it have been better to do the "do { ... } while (0)" thing in ftp_var.h instead? Cheers, Simon.