summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlukem <lukem@pkgsrc.org>2005-01-03 09:50:10 +0000
committerlukem <lukem@pkgsrc.org>2005-01-03 09:50:10 +0000
commita6bec2b30fb19dddd7fca1be45d1d6f6527d2d87 (patch)
treed78d5cf2215ef44e06ca8169af9a7c213f3877fd
parent95aee2c9bbbeef17874a286f0b6a2cdea9ceebd1 (diff)
downloadpkgsrc-a6bec2b30fb19dddd7fca1be45d1d6f6527d2d87.tar.gz
Import tnftp 20050103.
Various changes, including: * forbid mget of filenames that aren't in or below the local cwd. * improve auto-fetch transfers * improve www/proxy authentication support * improve http response header parsing * change UCB-licensed code from 4-clause to 3-clause
-rw-r--r--net/tnftp/files/COPYING4
-rw-r--r--net/tnftp/files/ChangeLog79
-rw-r--r--net/tnftp/files/src/cmds.c97
-rw-r--r--net/tnftp/files/src/cmdtab.c394
-rw-r--r--net/tnftp/files/src/domacro.c8
-rw-r--r--net/tnftp/files/src/extern.h14
-rw-r--r--net/tnftp/files/src/fetch.c240
-rw-r--r--net/tnftp/files/src/ftp.124
-rw-r--r--net/tnftp/files/src/ftp.c55
-rw-r--r--net/tnftp/files/src/ftp.cat1274
-rw-r--r--net/tnftp/files/src/ftp_var.h28
-rw-r--r--net/tnftp/files/src/main.c38
-rw-r--r--net/tnftp/files/src/progressbar.c8
-rw-r--r--net/tnftp/files/src/progressbar.h3
-rw-r--r--net/tnftp/files/src/ruserpass.c8
-rw-r--r--net/tnftp/files/src/util.c100
-rw-r--r--net/tnftp/files/src/version.h6
-rw-r--r--net/tnftp/files/tnftp.h4
18 files changed, 788 insertions, 596 deletions
diff --git a/net/tnftp/files/COPYING b/net/tnftp/files/COPYING
index a604bf591b8..20097f572ea 100644
--- a/net/tnftp/files/COPYING
+++ b/net/tnftp/files/COPYING
@@ -1,6 +1,6 @@
-$Id: COPYING,v 1.1.1.1 2003/02/28 10:54:42 lukem Exp $
+$Id: COPYING,v 1.1.1.2 2005/01/03 10:30:34 lukem Exp $
-Copyright (c) 2001-2003 The NetBSD Foundation, Inc.
+Copyright (c) 2001-2005 The NetBSD Foundation, Inc.
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
diff --git a/net/tnftp/files/ChangeLog b/net/tnftp/files/ChangeLog
index f5395ab2ace..afb6939099b 100644
--- a/net/tnftp/files/ChangeLog
+++ b/net/tnftp/files/ChangeLog
@@ -1,4 +1,81 @@
-$Id: ChangeLog,v 1.1.1.1 2003/08/25 11:52:55 lukem Exp $
+$Id: ChangeLog,v 1.1.1.2 2005/01/03 10:23:21 lukem Exp $
+
+Mon Jan 3 10:21:57 UTC 2005 lukem
+
+ * Release "tnftp 20050103"
+
+ * Merge NetBSD-ftp 20050103:
+ - Forbid filenames returned from mget that aren't in (or below)
+ the current directory. The previous behaviour (of trusting
+ the remote server's response when retrieving the list of
+ files to mget with prompting disabled) has been in ftp
+ ~forever, and has been a "known issue" for a long time.
+ Recently an advisory was published by D.J. Bernstein on
+ behalf of Yosef Klein warning of the problems with the
+ previous behaviour, so to alleviate concern I've fixed
+ this with a sledgehammer.
+ - Remember the local cwd after any operation which may
+ change it.
+ - Use "remotecwd" instead of "remotepwd".
+ - Add (unsigned char) cast to ctype functions
+ - Ensure that "mname" is set in ls() and mls() so that an
+ aborted confirm() prints the correct name.
+ Problem highlighted & suggested fix from PR [bin/17766]
+ by Steve McClellan.
+ - If an ftp auto-fetch transfer is interrupted by SIGINT
+ (usually ^C), exit with 130 instead of 1 (or rarely, 0).
+ This allows an ftp auto-fetch in a shell loop to correctly
+ terminate the loop.
+ Should fix PR [pkg/26351], and possibly others.
+ - Save approximately 8K by not including http authentication,
+ extended status messages and help strings when the
+ appropriate options are set.
+ - Move UCB-licensed code from 4-clause to 3-clause licence.
+ Patches provided by Joel Baker in PR 22365, verified by
+ Alistair Crooks.
+ - Always decode %xx in a url's user & pass components.
+ - Only remember {WWW,Proxy}-Authenticate "Basic" challenges; no
+ point in tracking any others since ftp doesn't support them.
+ - Improve the parsing of HTTP responses.
+ - Don't base64 encode the trailing NUL in the HTTP basic auth
+ response. Problem noted by Eric Haszlakiewicz.
+ - Improve parsing of HTTP response headers to be more RFC2616
+ compliant, and skip LWS (linear white space; CR, LF, space,
+ tab) and the end of lines and between the field name and
+ the field value. This still isn't 100% compliant, since we
+ don't support "multi line" responses at this time.
+ This should fix PR [bin/22611] from TAMURA Kent (although I
+ can't easily find a http server to reproduce the problem
+ against.)
+ - Fix a minor memory leak when parsing HTTP response headers.
+ - Don't unnecessarily display a 401/407 error when running
+ with -V. Fix from PR [bin/18535] by Jeremy Reed.
+ - Don't warn about "ignored setsockopt" failures unless
+ debugging is enabled. Suggested by Todd Vierling.
+ - Allow empty passwords in ftp://user:@host/file auto-fetch
+ URLs, per RFC 1738. Requested by Simon Poole.
+ - correct URL syntax in comment
+ - Note potentially surprising file-saving behaviour in case
+ of HTTP redirects
+ - -n is ignored for auto-fetch transfers
+ - If connect(2) in xconnect() fails with EINTR, call select(2)
+ on the socket until it's writable or it fails with something
+ other than EINTR. This matches the behaviour in SUSv3, and
+ prevents the problem when pressing ^T (SIGINFO, which is
+ marked as restartable) during connection setup would cause
+ ftp to fail with EADDRINUSE or EALREADY when the second
+ connect(2) was attempted on the same socket. Problem found
+ and solution provided by Maxime Henrion <mux@freebsd.org>.
+ - Add -q to usage. From Kouichirou Hiratsuka in PR 26199.
+ - PR/25566: Anders Magnusson: ftp(1) do not like large TCP
+ windows. Limit it to 8M.
+
+Mon Oct 6 01:23:03 UTC 2003 lukem
+
+ * configure.in improvements:
+ - When testing for IN6ADDRSZ in <arpa/nameser.h>, pull in
+ <sys/types.h> first. From Stoned Elipot <seb @ NetBSD>
+ - Whitespace cleanup
Mon Aug 25 11:45:45 UTC 2003 lukem
diff --git a/net/tnftp/files/src/cmds.c b/net/tnftp/files/src/cmds.c
index 5bc10ea6ac2..4ba717a65f4 100644
--- a/net/tnftp/files/src/cmds.c
+++ b/net/tnftp/files/src/cmds.c
@@ -1,7 +1,7 @@
-/* $NetBSD: cmds.c,v 1.1.1.1 2003/07/31 07:18:23 lukem Exp $ */
+/* $NetBSD: cmds.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -52,11 +52,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -108,7 +104,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmds.c,v 1.1.1.1 2003/07/31 07:18:23 lukem Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif
#endif /* not lint */
#endif
@@ -137,7 +133,7 @@ struct types {
};
sigjmp_buf jabort;
-char *mname;
+const char *mname;
static int confirm(const char *, const char *);
@@ -157,7 +153,7 @@ confirm(const char *cmd, const char *file)
clearerr(stdin);
return (0);
}
- switch (tolower(*line)) {
+ switch (tolower((unsigned char)*line)) {
case 'a':
confirmrest = 1;
fprintf(ttyout,
@@ -682,7 +678,14 @@ mget(int argc, char *argv[])
mflag = 0;
continue;
}
- if (! mflag || !confirm(argv[0], cp))
+ if (! mflag)
+ continue;
+ if (! fileindir(cp, localcwd)) {
+ fprintf(ttyout, "Skipping non-relative filename `%s'\n",
+ cp);
+ continue;
+ }
+ if (!confirm(argv[0], cp))
continue;
tp = cp;
if (mcase)
@@ -764,13 +767,13 @@ onoff(int bool)
void
status(int argc, char *argv[])
{
- int i;
if (argc == 0) {
fprintf(ttyout, "usage: %s\n", argv[0]);
code = -1;
return;
}
+#ifndef NO_STATUS
if (connected)
fprintf(ttyout, "Connected %sto %s.\n",
connected == -1 ? "and logged in" : "", hostname);
@@ -834,13 +837,16 @@ status(int argc, char *argv[])
onoff(editing)
#endif /* !def NO_EDITCOMPLETE */
);
- fprintf(ttyout, "Version: %s %s\n", FTP_PRODUCT, FTP_VERSION);
if (macnum > 0) {
+ int i;
+
fputs("Macros:\n", ttyout);
for (i=0; i<macnum; i++) {
fprintf(ttyout, "\t%s\n", macros[i].mac_name);
}
}
+#endif /* !def NO_STATUS */
+ fprintf(ttyout, "Version: %s %s\n", FTP_PRODUCT, FTP_VERSION);
code = 0;
}
@@ -1121,7 +1127,7 @@ cd(int argc, char *argv[])
}
if (r == COMPLETE) {
dirchange = 1;
- updateremotepwd();
+ updateremotecwd();
}
}
@@ -1131,7 +1137,6 @@ cd(int argc, char *argv[])
void
lcd(int argc, char *argv[])
{
- char buf[MAXPATHLEN];
char *locdir;
code = -1;
@@ -1145,14 +1150,16 @@ lcd(int argc, char *argv[])
}
if ((locdir = globulize(argv[1])) == NULL)
return;
- if (chdir(locdir) < 0)
- warn("local: %s", locdir);
+ if (chdir(locdir) == -1)
+ warn("lcd %s", locdir);
else {
- if (getcwd(buf, sizeof(buf)) != NULL) {
- fprintf(ttyout, "Local directory now %s\n", buf);
+ updatelocalcwd();
+ if (localcwd[0]) {
+ fprintf(ttyout, "Local directory now: %s\n", localcwd);
code = 0;
- } else
- warn("getcwd: %s", locdir);
+ } else {
+ fprintf(ttyout, "Unable to determine local directory\n");
+ }
}
(void)free(locdir);
}
@@ -1164,7 +1171,6 @@ void
delete(int argc, char *argv[])
{
-
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "remote-file"))) {
fprintf(ttyout, "usage: %s remote-file\n", argv[0]);
@@ -1313,6 +1319,7 @@ ls(int argc, char *argv[])
(void)strlcpy(locfile + 1, p, len - 1);
freelocfile = 1;
} else if ((strcmp(locfile, "-") != 0) && *locfile != '|') {
+ mname = argv[0];
if ((locfile = globulize(locfile)) == NULL ||
!confirm("output to local-file:", locfile)) {
code = -1;
@@ -1349,6 +1356,7 @@ mls(int argc, char *argv[])
}
odest = dest = argv[argc - 1];
argv[argc - 1] = NULL;
+ mname = argv[0];
if (strcmp(dest, "-") && *dest != '|')
if (((dest = globulize(dest)) == NULL) ||
!confirm("output to local-file:", dest)) {
@@ -1356,7 +1364,6 @@ mls(int argc, char *argv[])
return;
}
dolist = strcmp(argv[0], "mls");
- mname = argv[0];
mflag = 1;
oldintr = xsignal(SIGINT, mintr);
if (sigsetjmp(jabort, 1))
@@ -1388,7 +1395,7 @@ void
shell(int argc, char *argv[])
{
pid_t pid;
- sigfunc old1;
+ sigfunc oldintr;
char shellnam[MAXPATHLEN], *shell, *namep;
int wait_status;
@@ -1397,7 +1404,7 @@ shell(int argc, char *argv[])
code = -1;
return;
}
- old1 = xsignal(SIGINT, SIG_IGN);
+ oldintr = xsignal(SIGINT, SIG_IGN);
if ((pid = fork()) == 0) {
for (pid = 3; pid < 20; pid++)
(void)close(pid);
@@ -1428,7 +1435,7 @@ shell(int argc, char *argv[])
if (pid > 0)
while (wait(&wait_status) != pid)
;
- (void)xsignal(SIGINT, old1);
+ (void)xsignal(SIGINT, oldintr);
if (pid == -1) {
warn("Try again later");
code = -1;
@@ -1499,19 +1506,20 @@ user(int argc, char *argv[])
void
pwd(int argc, char *argv[])
{
- int oldverbose = verbose;
- if (argc == 0) {
+ code = -1;
+ if (argc != 1) {
fprintf(ttyout, "usage: %s\n", argv[0]);
- code = -1;
return;
}
- verbose = 1; /* If we aren't verbose, this doesn't do anything! */
- if (command("PWD") == ERROR && code == 500) {
- fputs("PWD command not recognized, trying XPWD.\n", ttyout);
- (void)command("XPWD");
+ if (! remotecwd[0])
+ updateremotecwd();
+ if (! remotecwd[0])
+ fprintf(ttyout, "Unable to determine remote directory\n");
+ else {
+ fprintf(ttyout, "Remote directory: %s\n", remotecwd);
+ code = 0;
}
- verbose = oldverbose;
}
/*
@@ -1520,19 +1528,19 @@ pwd(int argc, char *argv[])
void
lpwd(int argc, char *argv[])
{
- char buf[MAXPATHLEN];
- if (argc == 0) {
+ code = -1;
+ if (argc != 1) {
fprintf(ttyout, "usage: %s\n", argv[0]);
- code = -1;
return;
}
- if (getcwd(buf, sizeof(buf)) != NULL) {
- fprintf(ttyout, "Local directory %s\n", buf);
+ if (! localcwd[0])
+ updatelocalcwd();
+ if (! localcwd[0])
+ fprintf(ttyout, "Unable to determine local directory\n");
+ else {
+ fprintf(ttyout, "Local directory: %s\n", localcwd);
code = 0;
- } else {
- warn("getcwd");
- code = -1;
}
}
@@ -1778,6 +1786,7 @@ void
proxabort(int notused)
{
+ sigint_raised = 1;
alarmtimer(0);
if (!proxy) {
pswitch(1);
@@ -1876,7 +1885,7 @@ docase(char *name)
if (dochange) {
for (i = 0; new[i] != '\0'; i++)
if (isupper((unsigned char)new[i]))
- new[i] = tolower(new[i]);
+ new[i] = tolower((unsigned char)new[i]);
}
return (new);
}
@@ -2297,7 +2306,7 @@ cdup(int argc, char *argv[])
}
if (r == COMPLETE) {
dirchange = 1;
- updateremotepwd();
+ updateremotecwd();
}
}
diff --git a/net/tnftp/files/src/cmdtab.c b/net/tnftp/files/src/cmdtab.c
index 32d2b6df690..b072ee3b36a 100644
--- a/net/tnftp/files/src/cmdtab.c
+++ b/net/tnftp/files/src/cmdtab.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cmdtab.c,v 1.1.1.1 2003/02/28 10:44:52 lukem Exp $ */
+/* $NetBSD: cmdtab.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -48,11 +48,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -77,207 +73,219 @@
* User FTP -- Command Tables.
*/
-char accounthelp[] = "send account command to remote server";
-char appendhelp[] = "append to a file";
-char asciihelp[] = "set ascii transfer type";
-char beephelp[] = "beep when command completed";
-char binaryhelp[] = "set binary transfer type";
-char casehelp[] = "toggle mget upper/lower case id mapping";
-char cdhelp[] = "change remote working directory";
-char cduphelp[] = "change remote working directory to parent directory";
-char chmodhelp[] = "change file permissions of remote file";
-char connecthelp[] = "connect to remote ftp server";
-char crhelp[] = "toggle carriage return stripping on ascii gets";
-char debughelp[] = "toggle/set debugging mode";
-char deletehelp[] = "delete remote file";
-char disconhelp[] = "terminate ftp session";
-char domachelp[] = "execute macro";
-char edithelp[] = "toggle command line editing";
-char epsv4help[] = "toggle use of EPSV/EPRT on IPv4 ftp";
-char feathelp[] = "show FEATures supported by remote system";
-char formhelp[] = "set file transfer format";
-char gatehelp[] = "toggle gate-ftp; specify host[:port] to change proxy";
-char globhelp[] = "toggle metacharacter expansion of local file names";
-char hashhelp[] = "toggle printing `#' marks; specify number to set size";
-char helphelp[] = "print local help information";
-char idlehelp[] = "get (set) idle timer on remote side";
-char lcdhelp[] = "change local working directory";
-char lpagehelp[] = "view a local file through your pager";
-char lpwdhelp[] = "print local working directory";
-char lshelp[] = "list contents of remote path";
-char macdefhelp[] = "define a macro";
-char mdeletehelp[] = "delete multiple files";
-char mgethelp[] = "get multiple files";
-char mregethelp[] = "get multiple files restarting at end of local file";
-char fgethelp[] = "get files using a localfile as a source of names";
-char mkdirhelp[] = "make directory on the remote machine";
-char mlshelp[] = "list contents of multiple remote directories";
-char mlsdhelp[] = "list contents of remote directory in a machine "
+#define HSTR static const char
+
+#ifndef NO_HELP
+HSTR accounthelp[] = "send account command to remote server";
+HSTR appendhelp[] = "append to a file";
+HSTR asciihelp[] = "set ascii transfer type";
+HSTR beephelp[] = "beep when command completed";
+HSTR binaryhelp[] = "set binary transfer type";
+HSTR casehelp[] = "toggle mget upper/lower case id mapping";
+HSTR cdhelp[] = "change remote working directory";
+HSTR cduphelp[] = "change remote working directory to parent directory";
+HSTR chmodhelp[] = "change file permissions of remote file";
+HSTR connecthelp[] = "connect to remote ftp server";
+HSTR crhelp[] = "toggle carriage return stripping on ascii gets";
+HSTR debughelp[] = "toggle/set debugging mode";
+HSTR deletehelp[] = "delete remote file";
+HSTR disconhelp[] = "terminate ftp session";
+HSTR domachelp[] = "execute macro";
+HSTR edithelp[] = "toggle command line editing";
+HSTR epsv4help[] = "toggle use of EPSV/EPRT on IPv4 ftp";
+HSTR feathelp[] = "show FEATures supported by remote system";
+HSTR formhelp[] = "set file transfer format";
+HSTR gatehelp[] = "toggle gate-ftp; specify host[:port] to change proxy";
+HSTR globhelp[] = "toggle metacharacter expansion of local file names";
+HSTR hashhelp[] = "toggle printing `#' marks; specify number to set size";
+HSTR helphelp[] = "print local help information";
+HSTR idlehelp[] = "get (set) idle timer on remote side";
+HSTR lcdhelp[] = "change local working directory";
+HSTR lpagehelp[] = "view a local file through your pager";
+HSTR lpwdhelp[] = "print local working directory";
+HSTR lshelp[] = "list contents of remote path";
+HSTR macdefhelp[] = "define a macro";
+HSTR mdeletehelp[] = "delete multiple files";
+HSTR mgethelp[] = "get multiple files";
+HSTR mregethelp[] = "get multiple files restarting at end of local file";
+HSTR fgethelp[] = "get files using a localfile as a source of names";
+HSTR mkdirhelp[] = "make directory on the remote machine";
+HSTR mlshelp[] = "list contents of multiple remote directories";
+HSTR mlsdhelp[] = "list contents of remote directory in a machine "
"parsable form";
-char mlsthelp[] = "list remote path in a machine parsable form";
-char modehelp[] = "set file transfer mode";
-char modtimehelp[] = "show last modification time of remote file";
-char mputhelp[] = "send multiple files";
-char newerhelp[] = "get file if remote file is newer than local file ";
-char nmaphelp[] = "set templates for default file name mapping";
-char ntranshelp[] = "set translation table for default file name mapping";
-char optshelp[] = "show or set options for remote commands";
-char pagehelp[] = "view a remote file through your pager";
-char passivehelp[] = "toggle use of passive transfer mode";
-char plshelp[] = "list contents of remote path through your pager";
-char pmlsdhelp[] = "list contents of remote directory in a machine "
+HSTR mlsthelp[] = "list remote path in a machine parsable form";
+HSTR modehelp[] = "set file transfer mode";
+HSTR modtimehelp[] = "show last modification time of remote file";
+HSTR mputhelp[] = "send multiple files";
+HSTR newerhelp[] = "get file if remote file is newer than local file ";
+HSTR nmaphelp[] = "set templates for default file name mapping";
+HSTR ntranshelp[] = "set translation table for default file name mapping";
+HSTR optshelp[] = "show or set options for remote commands";
+HSTR pagehelp[] = "view a remote file through your pager";
+HSTR passivehelp[] = "toggle use of passive transfer mode";
+HSTR plshelp[] = "list contents of remote path through your pager";
+HSTR pmlsdhelp[] = "list contents of remote directory in a machine "
"parsable form through your pager";
-char porthelp[] = "toggle use of PORT/LPRT cmd for each data connection";
-char preservehelp[] ="toggle preservation of modification time of "
+HSTR porthelp[] = "toggle use of PORT/LPRT cmd for each data connection";
+HSTR preservehelp[] ="toggle preservation of modification time of "
"retrieved files";
-char progresshelp[] ="toggle transfer progress meter";
-char prompthelp[] = "force interactive prompting on multiple commands";
-char proxyhelp[] = "issue command on alternate connection";
-char pwdhelp[] = "print working directory on remote machine";
-char quithelp[] = "terminate ftp session and exit";
-char quotehelp[] = "send arbitrary ftp command";
-char ratehelp[] = "set transfer rate limit (in bytes/second)";
-char receivehelp[] = "receive file";
-char regethelp[] = "get file restarting at end of local file";
-char remotehelp[] = "get help from remote server";
-char renamehelp[] = "rename file";
-char resethelp[] = "clear queued command replies";
-char restarthelp[]= "restart file transfer at bytecount";
-char rmdirhelp[] = "remove directory on the remote machine";
-char rmtstatushelp[]="show status of remote machine";
-char runiquehelp[] = "toggle store unique for local files";
-char sendhelp[] = "send one file";
-char sethelp[] = "set or display options";
-char shellhelp[] = "escape to the shell";
-char sitehelp[] = "send site specific command to remote server\n"
+HSTR progresshelp[] ="toggle transfer progress meter";
+HSTR prompthelp[] = "force interactive prompting on multiple commands";
+HSTR proxyhelp[] = "issue command on alternate connection";
+HSTR pwdhelp[] = "print working directory on remote machine";
+HSTR quithelp[] = "terminate ftp session and exit";
+HSTR quotehelp[] = "send arbitrary ftp command";
+HSTR ratehelp[] = "set transfer rate limit (in bytes/second)";
+HSTR receivehelp[] = "receive file";
+HSTR regethelp[] = "get file restarting at end of local file";
+HSTR remotehelp[] = "get help from remote server";
+HSTR renamehelp[] = "rename file";
+HSTR resethelp[] = "clear queued command replies";
+HSTR restarthelp[]= "restart file transfer at bytecount";
+HSTR rmdirhelp[] = "remove directory on the remote machine";
+HSTR rmtstatushelp[]="show status of remote machine";
+HSTR runiquehelp[] = "toggle store unique for local files";
+HSTR sendhelp[] = "send one file";
+HSTR sethelp[] = "set or display options";
+HSTR shellhelp[] = "escape to the shell";
+HSTR sitehelp[] = "send site specific command to remote server\n"
"\t\tTry \"rhelp site\" or \"site help\" "
"for more information";
-char sizecmdhelp[] = "show size of remote file";
-char statushelp[] = "show current status";
-char structhelp[] = "set file transfer structure";
-char suniquehelp[] = "toggle store unique on remote machine";
-char systemhelp[] = "show remote system type";
-char tenexhelp[] = "set tenex file transfer type";
-char tracehelp[] = "toggle packet tracing";
-char typehelp[] = "set file transfer type";
-char umaskhelp[] = "get (set) umask on remote side";
-char unsethelp[] = "unset an option";
-char usagehelp[] = "show command usage";
-char userhelp[] = "send new user information";
-char verbosehelp[] = "toggle verbose mode";
-char xferbufhelp[] = "set socket send/receive buffer size";
+HSTR sizecmdhelp[] = "show size of remote file";
+HSTR statushelp[] = "show current status";
+HSTR structhelp[] = "set file transfer structure";
+HSTR suniquehelp[] = "toggle store unique on remote machine";
+HSTR systemhelp[] = "show remote system type";
+HSTR tenexhelp[] = "set tenex file transfer type";
+HSTR tracehelp[] = "toggle packet tracing";
+HSTR typehelp[] = "set file transfer type";
+HSTR umaskhelp[] = "get (set) umask on remote side";
+HSTR unsethelp[] = "unset an option";
+HSTR usagehelp[] = "show command usage";
+HSTR userhelp[] = "send new user information";
+HSTR verbosehelp[] = "toggle verbose mode";
+HSTR xferbufhelp[] = "set socket send/receive buffer size";
+#endif
+
+HSTR empty[] = "";
+
+#ifdef NO_HELP
+#define H(x) empty
+#else
+#define H(x) x
+#endif
#ifdef NO_EDITCOMPLETE
#define CMPL(x)
#define CMPL0
#else /* !NO_EDITCOMPLETE */
#define CMPL(x) #x,
-#define CMPL0 "",
+#define CMPL0 empty,
#endif /* !NO_EDITCOMPLETE */
struct cmd cmdtab[] = {
- { "!", shellhelp, 0, 0, 0, CMPL0 shell },
- { "$", domachelp, 1, 0, 0, CMPL0 domacro },
- { "account", accounthelp, 0, 1, 1, CMPL0 account},
- { "append", appendhelp, 1, 1, 1, CMPL(lr) put },
- { "ascii", asciihelp, 0, 1, 1, CMPL0 setascii },
- { "bell", beephelp, 0, 0, 0, CMPL0 setbell },
- { "binary", binaryhelp, 0, 1, 1, CMPL0 setbinary },
- { "bye", quithelp, 0, 0, 0, CMPL0 quit },
- { "case", casehelp, 0, 0, 1, CMPL0 setcase },
- { "cd", cdhelp, 0, 1, 1, CMPL(r) cd },
- { "cdup", cduphelp, 0, 1, 1, CMPL0 cdup },
- { "chmod", chmodhelp, 0, 1, 1, CMPL(nr) do_chmod },
- { "close", disconhelp, 0, 1, 1, CMPL0 disconnect },
- { "cr", crhelp, 0, 0, 0, CMPL0 setcr },
- { "debug", debughelp, 0, 0, 0, CMPL0 setdebug },
- { "delete", deletehelp, 0, 1, 1, CMPL(r) delete },
- { "dir", lshelp, 1, 1, 1, CMPL(rl) ls },
- { "disconnect", disconhelp, 0, 1, 1, CMPL0 disconnect },
- { "edit", edithelp, 0, 0, 0, CMPL0 setedit },
- { "epsv4", epsv4help, 0, 0, 0, CMPL0 setepsv4 },
- { "exit", quithelp, 0, 0, 0, CMPL0 quit },
- { "features", feathelp, 0, 1, 1, CMPL0 feat },
- { "fget", fgethelp, 1, 1, 1, CMPL(l) fget },
- { "form", formhelp, 0, 1, 1, CMPL0 setform },
- { "ftp", connecthelp, 0, 0, 1, CMPL0 setpeer },
- { "gate", gatehelp, 0, 0, 0, CMPL0 setgate },
- { "get", receivehelp, 1, 1, 1, CMPL(rl) get },
- { "glob", globhelp, 0, 0, 0, CMPL0 setglob },
- { "hash", hashhelp, 0, 0, 0, CMPL0 sethash },
- { "help", helphelp, 0, 0, 1, CMPL(C) help },
- { "idle", idlehelp, 0, 1, 1, CMPL0 idlecmd },
- { "image", binaryhelp, 0, 1, 1, CMPL0 setbinary },
- { "lcd", lcdhelp, 0, 0, 0, CMPL(l) lcd },
- { "less", pagehelp, 1, 1, 1, CMPL(r) page },
- { "lpage", lpagehelp, 0, 0, 0, CMPL(l) lpage },
- { "lpwd", lpwdhelp, 0, 0, 0, CMPL0 lpwd },
- { "ls", lshelp, 1, 1, 1, CMPL(rl) ls },
- { "macdef", macdefhelp, 0, 0, 0, CMPL0 macdef },
- { "mdelete", mdeletehelp, 1, 1, 1, CMPL(R) mdelete },
- { "mdir", mlshelp, 1, 1, 1, CMPL(R) mls },
- { "mget", mgethelp, 1, 1, 1, CMPL(R) mget },
- { "mkdir", mkdirhelp, 0, 1, 1, CMPL(r) makedir },
- { "mls", mlshelp, 1, 1, 1, CMPL(R) mls },
- { "mlsd", mlsdhelp, 1, 1, 1, CMPL(r) ls },
- { "mlst", mlsthelp, 1, 1, 1, CMPL(r) mlst },
- { "mode", modehelp, 0, 1, 1, CMPL0 setftmode },
- { "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime },
- { "more", pagehelp, 1, 1, 1, CMPL(r) page },
- { "mput", mputhelp, 1, 1, 1, CMPL(L) mput },
- { "mreget", mregethelp, 1, 1, 1, CMPL(R) mget },
- { "msend", mputhelp, 1, 1, 1, CMPL(L) mput },
- { "newer", newerhelp, 1, 1, 1, CMPL(r) newer },
- { "nlist", lshelp, 1, 1, 1, CMPL(rl) ls },
- { "nmap", nmaphelp, 0, 0, 1, CMPL0 setnmap },
- { "ntrans", ntranshelp, 0, 0, 1, CMPL0 setntrans },
- { "open", connecthelp, 0, 0, 1, CMPL0 setpeer },
- { "page", pagehelp, 1, 1, 1, CMPL(r) page },
- { "passive", passivehelp, 0, 0, 0, CMPL0 setpassive },
- { "pdir", plshelp, 1, 1, 1, CMPL(r) ls },
- { "pls", plshelp, 1, 1, 1, CMPL(r) ls },
- { "pmlsd", pmlsdhelp, 1, 1, 1, CMPL(r) ls },
- { "preserve", preservehelp, 0, 0, 0, CMPL0 setpreserve },
- { "progress", progresshelp, 0, 0, 0, CMPL0 setprogress },
- { "prompt", prompthelp, 0, 0, 0, CMPL0 setprompt },
- { "proxy", proxyhelp, 0, 0, 1, CMPL(c) doproxy },
- { "put", sendhelp, 1, 1, 1, CMPL(lr) put },
- { "pwd", pwdhelp, 0, 1, 1, CMPL0 pwd },
- { "quit", quithelp, 0, 0, 0, CMPL0 quit },
- { "quote", quotehelp, 1, 1, 1, CMPL0 quote },
- { "rate", ratehelp, 0, 0, 0, CMPL0 setrate },
- { "rcvbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
- { "recv", receivehelp, 1, 1, 1, CMPL(rl) get },
- { "reget", regethelp, 1, 1, 1, CMPL(rl) reget },
- { "remopts", optshelp, 0, 1, 1, CMPL0 opts },
- { "rename", renamehelp, 0, 1, 1, CMPL(rr) renamefile },
- { "reset", resethelp, 0, 1, 1, CMPL0 reset },
- { "restart", restarthelp, 1, 1, 1, CMPL0 restart },
- { "rhelp", remotehelp, 0, 1, 1, CMPL0 rmthelp },
- { "rmdir", rmdirhelp, 0, 1, 1, CMPL(r) removedir },
- { "rstatus", rmtstatushelp, 0, 1, 1, CMPL(r) rmtstatus },
- { "runique", runiquehelp, 0, 0, 1, CMPL0 setrunique },
- { "send", sendhelp, 1, 1, 1, CMPL(lr) put },
- { "sendport", porthelp, 0, 0, 0, CMPL0 setport },
- { "set", sethelp, 0, 0, 0, CMPL(o) setoption },
- { "site", sitehelp, 0, 1, 1, CMPL0 site },
- { "size", sizecmdhelp, 1, 1, 1, CMPL(r) sizecmd },
- { "sndbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
- { "status", statushelp, 0, 0, 1, CMPL0 status },
- { "struct", structhelp, 0, 1, 1, CMPL0 setstruct },
- { "sunique", suniquehelp, 0, 0, 1, CMPL0 setsunique },
- { "system", systemhelp, 0, 1, 1, CMPL0 syst },
- { "tenex", tenexhelp, 0, 1, 1, CMPL0 settenex },
- { "throttle", ratehelp, 0, 0, 0, CMPL0 setrate },
- { "trace", tracehelp, 0, 0, 0, CMPL0 settrace },
- { "type", typehelp, 0, 1, 1, CMPL0 settype },
- { "umask", umaskhelp, 0, 1, 1, CMPL0 do_umask },
- { "unset", unsethelp, 0, 0, 0, CMPL(o) unsetoption },
- { "usage", usagehelp, 0, 0, 1, CMPL(C) help },
- { "user", userhelp, 0, 1, 1, CMPL0 user },
- { "verbose", verbosehelp, 0, 0, 0, CMPL0 setverbose },
- { "xferbuf", xferbufhelp, 0, 0, 0, CMPL0 setxferbuf },
- { "?", helphelp, 0, 0, 1, CMPL(C) help },
+ { "!", H(shellhelp), 0, 0, 0, CMPL0 shell },
+ { "$", H(domachelp), 1, 0, 0, CMPL0 domacro },
+ { "account", H(accounthelp), 0, 1, 1, CMPL0 account},
+ { "append", H(appendhelp), 1, 1, 1, CMPL(lr) put },
+ { "ascii", H(asciihelp), 0, 1, 1, CMPL0 setascii },
+ { "bell", H(beephelp), 0, 0, 0, CMPL0 setbell },
+ { "binary", H(binaryhelp), 0, 1, 1, CMPL0 setbinary },
+ { "bye", H(quithelp), 0, 0, 0, CMPL0 quit },
+ { "case", H(casehelp), 0, 0, 1, CMPL0 setcase },
+ { "cd", H(cdhelp), 0, 1, 1, CMPL(r) cd },
+ { "cdup", H(cduphelp), 0, 1, 1, CMPL0 cdup },
+ { "chmod", H(chmodhelp), 0, 1, 1, CMPL(nr) do_chmod },
+ { "close", H(disconhelp), 0, 1, 1, CMPL0 disconnect },
+ { "cr", H(crhelp), 0, 0, 0, CMPL0 setcr },
+ { "debug", H(debughelp), 0, 0, 0, CMPL0 setdebug },
+ { "delete", H(deletehelp), 0, 1, 1, CMPL(r) delete },
+ { "dir", H(lshelp), 1, 1, 1, CMPL(rl) ls },
+ { "disconnect", H(disconhelp), 0, 1, 1, CMPL0 disconnect },
+ { "edit", H(edithelp), 0, 0, 0, CMPL0 setedit },
+ { "epsv4", H(epsv4help), 0, 0, 0, CMPL0 setepsv4 },
+ { "exit", H(quithelp), 0, 0, 0, CMPL0 quit },
+ { "features", H(feathelp), 0, 1, 1, CMPL0 feat },
+ { "fget", H(fgethelp), 1, 1, 1, CMPL(l) fget },
+ { "form", H(formhelp), 0, 1, 1, CMPL0 setform },
+ { "ftp", H(connecthelp), 0, 0, 1, CMPL0 setpeer },
+ { "gate", H(gatehelp), 0, 0, 0, CMPL0 setgate },
+ { "get", H(receivehelp), 1, 1, 1, CMPL(rl) get },
+ { "glob", H(globhelp), 0, 0, 0, CMPL0 setglob },
+ { "hash", H(hashhelp), 0, 0, 0, CMPL0 sethash },
+ { "help", H(helphelp), 0, 0, 1, CMPL(C) help },
+ { "idle", H(idlehelp), 0, 1, 1, CMPL0 idlecmd },
+ { "image", H(binaryhelp), 0, 1, 1, CMPL0 setbinary },
+ { "lcd", H(lcdhelp), 0, 0, 0, CMPL(l) lcd },
+ { "less", H(pagehelp), 1, 1, 1, CMPL(r) page },
+ { "lpage", H(lpagehelp), 0, 0, 0, CMPL(l) lpage },
+ { "lpwd", H(lpwdhelp), 0, 0, 0, CMPL0 lpwd },
+ { "ls", H(lshelp), 1, 1, 1, CMPL(rl) ls },
+ { "macdef", H(macdefhelp), 0, 0, 0, CMPL0 macdef },
+ { "mdelete", H(mdeletehelp), 1, 1, 1, CMPL(R) mdelete },
+ { "mdir", H(mlshelp), 1, 1, 1, CMPL(R) mls },
+ { "mget", H(mgethelp), 1, 1, 1, CMPL(R) mget },
+ { "mkdir", H(mkdirhelp), 0, 1, 1, CMPL(r) makedir },
+ { "mls", H(mlshelp), 1, 1, 1, CMPL(R) mls },
+ { "mlsd", H(mlsdhelp), 1, 1, 1, CMPL(r) ls },
+ { "mlst", H(mlsthelp), 1, 1, 1, CMPL(r) mlst },
+ { "mode", H(modehelp), 0, 1, 1, CMPL0 setftmode },
+ { "modtime", H(modtimehelp), 0, 1, 1, CMPL(r) modtime },
+ { "more", H(pagehelp), 1, 1, 1, CMPL(r) page },
+ { "mput", H(mputhelp), 1, 1, 1, CMPL(L) mput },
+ { "mreget", H(mregethelp), 1, 1, 1, CMPL(R) mget },
+ { "msend", H(mputhelp), 1, 1, 1, CMPL(L) mput },
+ { "newer", H(newerhelp), 1, 1, 1, CMPL(r) newer },
+ { "nlist", H(lshelp), 1, 1, 1, CMPL(rl) ls },
+ { "nmap", H(nmaphelp), 0, 0, 1, CMPL0 setnmap },
+ { "ntrans", H(ntranshelp), 0, 0, 1, CMPL0 setntrans },
+ { "open", H(connecthelp), 0, 0, 1, CMPL0 setpeer },
+ { "page", H(pagehelp), 1, 1, 1, CMPL(r) page },
+ { "passive", H(passivehelp), 0, 0, 0, CMPL0 setpassive },
+ { "pdir", H(plshelp), 1, 1, 1, CMPL(r) ls },
+ { "pls", H(plshelp), 1, 1, 1, CMPL(r) ls },
+ { "pmlsd", H(pmlsdhelp), 1, 1, 1, CMPL(r) ls },
+ { "preserve", H(preservehelp),0, 0, 0, CMPL0 setpreserve },
+ { "progress", H(progresshelp),0, 0, 0, CMPL0 setprogress },
+ { "prompt", H(prompthelp), 0, 0, 0, CMPL0 setprompt },
+ { "proxy", H(proxyhelp), 0, 0, 1, CMPL(c) doproxy },
+ { "put", H(sendhelp), 1, 1, 1, CMPL(lr) put },
+ { "pwd", H(pwdhelp), 0, 1, 1, CMPL0 pwd },
+ { "quit", H(quithelp), 0, 0, 0, CMPL0 quit },
+ { "quote", H(quotehelp), 1, 1, 1, CMPL0 quote },
+ { "rate", H(ratehelp), 0, 0, 0, CMPL0 setrate },
+ { "rcvbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
+ { "recv", H(receivehelp), 1, 1, 1, CMPL(rl) get },
+ { "reget", H(regethelp), 1, 1, 1, CMPL(rl) reget },
+ { "remopts", H(optshelp), 0, 1, 1, CMPL0 opts },
+ { "rename", H(renamehelp), 0, 1, 1, CMPL(rr) renamefile },
+ { "reset", H(resethelp), 0, 1, 1, CMPL0 reset },
+ { "restart", H(restarthelp), 1, 1, 1, CMPL0 restart },
+ { "rhelp", H(remotehelp), 0, 1, 1, CMPL0 rmthelp },
+ { "rmdir", H(rmdirhelp), 0, 1, 1, CMPL(r) removedir },
+ { "rstatus", H(rmtstatushelp),0, 1, 1, CMPL(r) rmtstatus },
+ { "runique", H(runiquehelp), 0, 0, 1, CMPL0 setrunique },
+ { "send", H(sendhelp), 1, 1, 1, CMPL(lr) put },
+ { "sendport", H(porthelp), 0, 0, 0, CMPL0 setport },
+ { "set", H(sethelp), 0, 0, 0, CMPL(o) setoption },
+ { "site", H(sitehelp), 0, 1, 1, CMPL0 site },
+ { "size", H(sizecmdhelp), 1, 1, 1, CMPL(r) sizecmd },
+ { "sndbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
+ { "status", H(statushelp), 0, 0, 1, CMPL0 status },
+ { "struct", H(structhelp), 0, 1, 1, CMPL0 setstruct },
+ { "sunique", H(suniquehelp), 0, 0, 1, CMPL0 setsunique },
+ { "system", H(systemhelp), 0, 1, 1, CMPL0 syst },
+ { "tenex", H(tenexhelp), 0, 1, 1, CMPL0 settenex },
+ { "throttle", H(ratehelp), 0, 0, 0, CMPL0 setrate },
+ { "trace", H(tracehelp), 0, 0, 0, CMPL0 settrace },
+ { "type", H(typehelp), 0, 1, 1, CMPL0 settype },
+ { "umask", H(umaskhelp), 0, 1, 1, CMPL0 do_umask },
+ { "unset", H(unsethelp), 0, 0, 0, CMPL(o) unsetoption },
+ { "usage", H(usagehelp), 0, 0, 1, CMPL(C) help },
+ { "user", H(userhelp), 0, 1, 1, CMPL0 user },
+ { "verbose", H(verbosehelp), 0, 0, 0, CMPL0 setverbose },
+ { "xferbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
+ { "?", H(helphelp), 0, 0, 1, CMPL(C) help },
{ 0 },
};
diff --git a/net/tnftp/files/src/domacro.c b/net/tnftp/files/src/domacro.c
index ad6956cd0f8..1fc8f25a33e 100644
--- a/net/tnftp/files/src/domacro.c
+++ b/net/tnftp/files/src/domacro.c
@@ -1,4 +1,4 @@
-/* $NetBSD: domacro.c,v 1.1.1.1 2003/02/28 10:44:53 lukem Exp $ */
+/* $NetBSD: domacro.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/net/tnftp/files/src/extern.h b/net/tnftp/files/src/extern.h
index 3a85055990d..7f47a0b38d9 100644
--- a/net/tnftp/files/src/extern.h
+++ b/net/tnftp/files/src/extern.h
@@ -1,7 +1,7 @@
-/* $NetBSD: extern.h,v 1.1.1.1 2003/02/28 10:44:53 lukem Exp $ */
+/* $NetBSD: extern.h,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -48,11 +48,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -140,6 +136,7 @@ void doproxy(int, char **);
char *dotrans(char *);
void feat(int, char **);
void fget(int, char **);
+int fileindir(const char *, const char *);
int foregroundproc(void);
void formatbuf(char *, size_t, const char *);
void ftpvis(char *, size_t, const char *, size_t);
@@ -250,7 +247,8 @@ int strsuftoi(const char *);
void syst(int, char **);
int togglevar(int, char **, int *, const char *);
void unsetoption(int, char **);
-void updateremotepwd(void);
+void updatelocalcwd(void);
+void updateremotecwd(void);
void usage(void);
void user(int, char **);
int xconnect(int, const struct sockaddr *, int);
diff --git a/net/tnftp/files/src/fetch.c b/net/tnftp/files/src/fetch.c
index 845bd189631..bf81acffd66 100644
--- a/net/tnftp/files/src/fetch.c
+++ b/net/tnftp/files/src/fetch.c
@@ -1,7 +1,7 @@
-/* $NetBSD: fetch.c,v 1.1.1.1 2003/07/31 06:18:43 lukem Exp $ */
+/* $NetBSD: fetch.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -42,7 +42,7 @@
#if 0
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.1.1.1 2003/07/31 06:18:43 lukem Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif /* not lint */
#endif
@@ -64,11 +64,14 @@ typedef enum {
} url_t;
void aborthttp(int);
+#ifndef NO_AUTH
static int auth_url(const char *, char **, const char *, const char *);
-static void base64_encode(const u_char *, size_t, u_char *);
+static void base64_encode(const unsigned char *, size_t, unsigned char *);
+#endif
static int go_fetch(const char *);
static int fetch_ftp(const char *);
static int fetch_url(const char *, const char *, char *, char *);
+static const char *match_token(const char **, const char *);
static int parse_url(const char *, const char *, url_t *, char **,
char **, char **, char **, in_port_t *, char **);
static void url_decode(char *);
@@ -76,6 +79,11 @@ static void url_decode(char *);
static int redirect_loop;
+#define STRNEQUAL(a,b) (strncasecmp((a), (b), sizeof((b))-1) == 0)
+#define ISLWS(x) ((x)=='\r' || (x)=='\n' || (x)==' ' || (x)=='\t')
+#define SKIPLWS(x) do { while (ISLWS((*x))) x++; } while (0)
+
+
#define ABOUT_URL "about:" /* propaganda */
#define FILE_URL "file://" /* file URL prefix */
#define FTP_URL "ftp://" /* ftp URL prefix */
@@ -83,6 +91,35 @@ static int redirect_loop;
/*
+ * Determine if token is the next word in buf (case insensitive).
+ * If so, advance buf past the token and any trailing LWS, and
+ * return a pointer to the token (in buf). Otherwise, return NULL.
+ * token may be preceeded by LWS.
+ * token must be followed by LWS or NUL. (I.e, don't partial match).
+ */
+static const char *
+match_token(const char **buf, const char *token)
+{
+ const char *p, *orig;
+ size_t tlen;
+
+ tlen = strlen(token);
+ p = *buf;
+ SKIPLWS(p);
+ orig = p;
+ if (strncasecmp(p, token, tlen) != 0)
+ return NULL;
+ p += tlen;
+ if (*p != '\0' && !ISLWS(*p))
+ return NULL;
+ SKIPLWS(p);
+ orig = *buf;
+ *buf = p;
+ return orig;
+}
+
+#ifndef NO_AUTH
+/*
* Generate authorization response based on given authentication challenge.
* Returns -1 if an error occurred, otherwise 0.
* Sets response to a malloc(3)ed string; caller should free.
@@ -91,52 +128,52 @@ static int
auth_url(const char *challenge, char **response, const char *guser,
const char *gpass)
{
- char *cp, *ep, *clear, *line, *realm, *scheme;
+ const char *cp, *scheme;
+ char *ep, *clear, *realm;
char user[BUFSIZ], *pass;
int rval;
size_t len, clen, rlen;
*response = NULL;
- clear = realm = scheme = NULL;
+ clear = realm = NULL;
rval = -1;
- line = xstrdup(challenge);
- cp = line;
+ cp = challenge;
+ scheme = "Basic"; /* only support Basic authentication */
if (debug)
fprintf(ttyout, "auth_url: challenge `%s'\n", challenge);
- scheme = strsep(&cp, " ");
-#define SCHEME_BASIC "Basic"
- if (strncasecmp(scheme, SCHEME_BASIC, sizeof(SCHEME_BASIC) - 1) != 0) {
- warnx("Unsupported WWW Authentication challenge - `%s'",
+ if (! match_token(&cp, scheme)) {
+ warnx("Unsupported authentication challenge - `%s'",
challenge);
goto cleanup_auth_url;
}
- cp += strspn(cp, " ");
#define REALM "realm=\""
- if (strncasecmp(cp, REALM, sizeof(REALM) - 1) == 0)
+ if (STRNEQUAL(cp, REALM))
cp += sizeof(REALM) - 1;
else {
- warnx("Unsupported WWW Authentication challenge - `%s'",
+ warnx("Unsupported authentication challenge - `%s'",
challenge);
goto cleanup_auth_url;
}
+/* XXX: need to improve quoted-string parsing to support \ quoting, etc. */
if ((ep = strchr(cp, '\"')) != NULL) {
size_t len = ep - cp;
realm = (char *)xmalloc(len + 1);
(void)strlcpy(realm, cp, len + 1);
} else {
- warnx("Unsupported WWW Authentication challenge - `%s'",
+ warnx("Unsupported authentication challenge - `%s'",
challenge);
goto cleanup_auth_url;
}
- if (guser != NULL)
+ fprintf(ttyout, "Username for `%s': ", realm);
+ if (guser != NULL) {
(void)strlcpy(user, guser, sizeof(user));
- else {
- fprintf(ttyout, "Username for `%s': ", realm);
+ fprintf(ttyout, "%s\n", user);
+ } else {
(void)fflush(ttyout);
if (fgets(user, sizeof(user) - 1, stdin) == NULL) {
clearerr(stdin);
@@ -162,13 +199,13 @@ auth_url(const char *challenge, char **response, const char *guser,
*response = (char *)xmalloc(rlen);
(void)strlcpy(*response, scheme, rlen);
len = strlcat(*response, " ", rlen);
- base64_encode(clear, clen, (u_char *)*response + len);
+ /* use `clen - 1' to not encode the trailing NUL */
+ base64_encode(clear, clen - 1, (unsigned char *)*response + len);
memset(clear, 0, clen);
rval = 0;
cleanup_auth_url:
FREEPTR(clear);
- FREEPTR(line);
FREEPTR(realm);
return (rval);
}
@@ -178,11 +215,11 @@ auth_url(const char *challenge, char **response, const char *guser,
* which should be at least ((len + 2) * 4 / 3 + 1) in size.
*/
static void
-base64_encode(const u_char *clear, size_t len, u_char *encoded)
+base64_encode(const unsigned char *clear, size_t len, unsigned char *encoded)
{
- static const u_char enc[] =
+ static const unsigned char enc[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- u_char *cp;
+ unsigned char *cp;
int i;
cp = encoded;
@@ -198,6 +235,7 @@ base64_encode(const u_char *clear, size_t len, u_char *encoded)
while (i-- > len)
*(--cp) = '=';
}
+#endif
/*
* Decode %xx escapes in given string, `in-place'.
@@ -227,7 +265,7 @@ url_decode(char *url)
/*
* Parse URL of form:
- * <type>://[<user>[:<password>@]]<host>[:<port>][/<path>]
+ * <type>://[<user>[:<password>]@]<host>[:<port>][/<path>]
* Returns -1 if a parse error occurred, otherwise 0.
* It's the caller's responsibility to url_decode() the returned
* user, pass and path.
@@ -276,17 +314,17 @@ parse_url(const char *url, const char *desc, url_t *type,
*portnum = 0;
tport = NULL;
- if (strncasecmp(url, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
+ if (STRNEQUAL(url, HTTP_URL)) {
url += sizeof(HTTP_URL) - 1;
*type = HTTP_URL_T;
*portnum = HTTP_PORT;
tport = httpport;
- } else if (strncasecmp(url, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
+ } else if (STRNEQUAL(url, FTP_URL)) {
url += sizeof(FTP_URL) - 1;
*type = FTP_URL_T;
*portnum = FTP_PORT;
tport = ftpport;
- } else if (strncasecmp(url, FILE_URL, sizeof(FILE_URL) - 1) == 0) {
+ } else if (STRNEQUAL(url, FILE_URL)) {
url += sizeof(FILE_URL) - 1;
*type = FILE_URL_T;
} else {
@@ -328,6 +366,9 @@ parse_url(const char *url, const char *desc, url_t *type,
*cp = '\0';
*pass = xstrdup(cp + 1);
}
+ url_decode(*user);
+ if (*pass)
+ url_decode(*pass);
}
#ifdef INET6
@@ -416,7 +457,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
size_t len;
static size_t bufsize;
static char *xferbuf;
- char *cp, *ep, *buf, *savefile;
+ const char *cp, *token;
+ char *ep, *buf, *savefile;
char *auth, *location, *message;
char *user, *pass, *host, *port, *path, *decodedpath;
char *puser, *ppass, *useragent;
@@ -496,7 +538,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
goto cleanup_fetch_url;
} else {
if (debug)
- fprintf(ttyout, "got savefile as `%s'\n", savefile);
+ fprintf(ttyout, "savefile `%s'\n", savefile);
}
restart_point = 0;
@@ -769,7 +811,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
warn("Receiving HTTP reply");
goto cleanup_fetch_url;
}
- while (len > 0 && (buf[len-1] == '\r' || buf[len-1] == '\n'))
+ while (len > 0 && (ISLWS(buf[len-1])))
buf[--len] = '\0';
if (debug)
fprintf(ttyout, "received `%s'\n", buf);
@@ -786,28 +828,27 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
message = xstrdup(cp);
/* Read the rest of the header. */
- FREEPTR(buf);
while (1) {
+ FREEPTR(buf);
if ((buf = fparseln(fin, &len, NULL, "\0\0\0", 0))
== NULL) {
warn("Receiving HTTP reply");
goto cleanup_fetch_url;
}
- while (len > 0 &&
- (buf[len-1] == '\r' || buf[len-1] == '\n'))
+ while (len > 0 && (ISLWS(buf[len-1])))
buf[--len] = '\0';
if (len == 0)
break;
if (debug)
fprintf(ttyout, "received `%s'\n", buf);
- /* Look for some headers */
+ /*
+ * Look for some headers
+ */
+
cp = buf;
-#define CONTENTLEN "Content-Length: "
- if (strncasecmp(cp, CONTENTLEN,
- sizeof(CONTENTLEN) - 1) == 0) {
- cp += sizeof(CONTENTLEN) - 1;
+ if (match_token(&cp, "Content-Length:")) {
filesize = STRTOLL(cp, &ep, 10);
if (filesize < 0 || *ep != '\0')
goto improper;
@@ -816,13 +857,12 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
"parsed len as: " LLF "\n",
(LLT)filesize);
-#define CONTENTRANGE "Content-Range: bytes "
- } else if (strncasecmp(cp, CONTENTRANGE,
- sizeof(CONTENTRANGE) - 1) == 0) {
- cp += sizeof(CONTENTRANGE) - 1;
- if (*cp == '*') {
- ep = cp + 1;
- }
+ } else if (match_token(&cp, "Content-Range:")) {
+ if (! match_token(&cp, "bytes"))
+ goto improper;
+
+ if (*cp == '*')
+ cp++;
else {
rangestart = STRTOLL(cp, &ep, 10);
if (rangestart < 0 || *ep != '-')
@@ -831,19 +871,20 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
rangeend = STRTOLL(cp, &ep, 10);
if (rangeend < 0 || rangeend < rangestart)
goto improper;
+ cp = ep;
}
- if (*ep != '/')
+ if (*cp != '/')
goto improper;
- cp = ep + 1;
- if (*cp == '*') {
- ep = cp + 1;
- }
+ cp++;
+ if (*cp == '*')
+ cp++;
else {
entitylen = STRTOLL(cp, &ep, 10);
if (entitylen < 0)
goto improper;
+ cp = ep;
}
- if (*ep != '\0')
+ if (*cp != '\0')
goto improper;
if (debug) {
@@ -862,13 +903,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
goto cleanup_fetch_url;
}
-#define LASTMOD "Last-Modified: "
- } else if (strncasecmp(cp, LASTMOD,
- sizeof(LASTMOD) - 1) == 0) {
+ } else if (match_token(&cp, "Last-Modified:")) {
struct tm parsed;
char *t;
- cp += sizeof(LASTMOD) - 1;
/* RFC 1123 */
if ((t = strptime(cp,
"%a, %d %b %Y %H:%M:%S GMT",
@@ -891,29 +929,22 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
}
}
-#define LOCATION "Location: "
- } else if (strncasecmp(cp, LOCATION,
- sizeof(LOCATION) - 1) == 0) {
- cp += sizeof(LOCATION) - 1;
+ } else if (match_token(&cp, "Location:")) {
location = xstrdup(cp);
if (debug)
fprintf(ttyout,
- "parsed location as: %s\n", cp);
+ "parsed location as `%s'\n", cp);
-#define TRANSENC "Transfer-Encoding: "
- } else if (strncasecmp(cp, TRANSENC,
- sizeof(TRANSENC) - 1) == 0) {
- cp += sizeof(TRANSENC) - 1;
- if (strcasecmp(cp, "binary") == 0) {
+ } else if (match_token(&cp, "Transfer-Encoding:")) {
+ if (match_token(&cp, "binary")) {
warnx(
- "Bogus transfer encoding - `%s' (fetching anyway)",
- cp);
+ "Bogus transfer encoding - `binary' (fetching anyway)");
continue;
}
- if (strcasecmp(cp, "chunked") != 0) {
+ if (! (token = match_token(&cp, "chunked"))) {
warnx(
"Unsupported transfer encoding - `%s'",
- cp);
+ token);
goto cleanup_fetch_url;
}
ischunked++;
@@ -921,26 +952,20 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
fprintf(ttyout,
"using chunked encoding\n");
-#define PROXYAUTH "Proxy-Authenticate: "
- } else if (strncasecmp(cp, PROXYAUTH,
- sizeof(PROXYAUTH) - 1) == 0) {
- cp += sizeof(PROXYAUTH) - 1;
- FREEPTR(auth);
- auth = xstrdup(cp);
- if (debug)
- fprintf(ttyout,
- "parsed proxy-auth as: %s\n", cp);
-
-#define WWWAUTH "WWW-Authenticate: "
- } else if (strncasecmp(cp, WWWAUTH,
- sizeof(WWWAUTH) - 1) == 0) {
- cp += sizeof(WWWAUTH) - 1;
+ } else if (match_token(&cp, "Proxy-Authenticate:")
+ || match_token(&cp, "WWW-Authenticate:")) {
+ if (! (token = match_token(&cp, "Basic"))) {
+ if (debug)
+ fprintf(ttyout,
+ "skipping unknown auth scheme `%s'\n",
+ token);
+ continue;
+ }
FREEPTR(auth);
- auth = xstrdup(cp);
+ auth = xstrdup(token);
if (debug)
fprintf(ttyout,
- "parsed www-auth as: %s\n", cp);
-
+ "parsed auth as `%s'\n", cp);
}
}
@@ -983,18 +1008,13 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
rval = go_fetch(location);
}
goto cleanup_fetch_url;
+#ifndef NO_AUTH
case 401:
case 407:
{
char **authp;
char *auser, *apass;
- fprintf(ttyout, "%s\n", message);
- if (EMPTYSTRING(auth)) {
- warnx(
- "No authentication challenge provided by server");
- goto cleanup_fetch_url;
- }
if (hcode == 401) {
authp = &wwwauth;
auser = user;
@@ -1004,6 +1024,14 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
auser = puser;
apass = ppass;
}
+ if (verbose || *authp == NULL ||
+ auser == NULL || apass == NULL)
+ fprintf(ttyout, "%s\n", message);
+ if (EMPTYSTRING(auth)) {
+ warnx(
+ "No authentication challenge provided by server");
+ goto cleanup_fetch_url;
+ }
if (*authp != NULL) {
char reply[10];
@@ -1013,10 +1041,9 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
== NULL) {
clearerr(stdin);
goto cleanup_fetch_url;
- } else {
- if (tolower(reply[0]) != 'y')
- goto cleanup_fetch_url;
}
+ if (tolower((unsigned char)reply[0]) != 'y')
+ goto cleanup_fetch_url;
auser = NULL;
apass = NULL;
}
@@ -1028,6 +1055,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
}
goto cleanup_fetch_url;
}
+#endif
default:
if (message)
warnx("Error retrieving file - `%s'", message);
@@ -1254,6 +1282,7 @@ aborthttp(int notused)
char msgbuf[100];
int len;
+ sigint_raised = 1;
alarmtimer(0);
len = strlcpy(msgbuf, "\nHTTP fetch aborted.\n", sizeof(msgbuf));
write(fileno(ttyout), msgbuf, len);
@@ -1280,17 +1309,14 @@ fetch_ftp(const char *url)
rval = 1;
type = TYPE_I;
- if (strncasecmp(url, FTP_URL, sizeof(FTP_URL) - 1) == 0) {
+ if (STRNEQUAL(url, FTP_URL)) {
if ((parse_url(url, "URL", &urltype, &user, &pass,
&host, &port, &portnum, &path) == -1) ||
(user != NULL && *user == '\0') ||
- (pass != NULL && *pass == '\0') ||
EMPTYSTRING(host)) {
warnx("Invalid URL `%s'", url);
goto cleanup_fetch_ftp;
}
- url_decode(user);
- url_decode(pass);
/*
* Note: Don't url_decode(path) here. We need to keep the
* distinction between "/" and "%2F" until later.
@@ -1600,10 +1626,11 @@ go_fetch(const char *url)
{
char *proxy;
+#ifndef NO_ABOUT
/*
* Check for about:*
*/
- if (strncasecmp(url, ABOUT_URL, sizeof(ABOUT_URL) - 1) == 0) {
+ if (STRNEQUAL(url, ABOUT_URL)) {
url += sizeof(ABOUT_URL) -1;
if (strcasecmp(url, "ftp") == 0 ||
strcasecmp(url, "tnftp") == 0) {
@@ -1633,12 +1660,12 @@ go_fetch(const char *url)
fputs("\n", ttyout);
return (0);
}
+#endif
/*
* Check for file:// and http:// URLs.
*/
- if (strncasecmp(url, HTTP_URL, sizeof(HTTP_URL) - 1) == 0 ||
- strncasecmp(url, FILE_URL, sizeof(FILE_URL) - 1) == 0)
+ if (STRNEQUAL(url, HTTP_URL) || STRNEQUAL(url, FILE_URL))
return (fetch_url(url, NULL, NULL, NULL));
/*
@@ -1647,8 +1674,7 @@ go_fetch(const char *url)
* Othewise, use fetch_ftp().
*/
proxy = getoptionvalue("ftp_proxy");
- if (!EMPTYSTRING(proxy) &&
- strncasecmp(url, FTP_URL, sizeof(FTP_URL) - 1) == 0)
+ if (!EMPTYSTRING(proxy) && STRNEQUAL(url, FTP_URL))
return (fetch_url(url, NULL, NULL, NULL));
return (fetch_ftp(url));
@@ -1677,7 +1703,9 @@ auto_fetch(int argc, char *argv[])
if (sigsetjmp(toplevel, 1)) {
if (connected)
disconnect(0, NULL);
- return (argpos + 1);
+ if (rval > 0)
+ rval = argpos + 1;
+ return (rval);
}
(void)xsignal(SIGINT, intr);
(void)xsignal(SIGPIPE, lostpeer);
diff --git a/net/tnftp/files/src/ftp.1 b/net/tnftp/files/src/ftp.1
index 11bed2d9eb2..bfb1cc97ee4 100644
--- a/net/tnftp/files/src/ftp.1
+++ b/net/tnftp/files/src/ftp.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: ftp.1,v 1.1.1.1 2003/07/31 06:18:44 lukem Exp $
+.\" $NetBSD: ftp.1,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $
.\"
.\" Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -46,11 +46,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
@@ -68,7 +64,7 @@
.\"
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\"
-.Dd July 31, 2003
+.Dd October 7, 2004
.Dt FTP 1
.Os
.Sh NAME
@@ -228,7 +224,7 @@ Restrains
.Nm
from attempting
.Dq auto-login
-upon initial connection.
+upon initial connection for non auto-fetch transfers.
If auto-login is enabled,
.Nm
will check the
@@ -240,6 +236,8 @@ If no entry exists,
will prompt for the remote machine login name (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.
.It Fl N Ar netrc
Use
.Ar netrc
@@ -1123,7 +1121,7 @@ Outgoing transfers.
.El
.Pp
.Ar maximum
-can by modified on the fly by
+can be modified on the fly by
.Ar increment
bytes (default: 1024) each time a given signal is received:
.B
@@ -1748,6 +1746,14 @@ is not given, the file is stored in the current directory as the
.Xr basename 1
of
.Ar path .
+Note that if a
+.Tn HTTP
+redirect is received, the fetch is retried using the new target URL
+supplied by the server, with a corresponding new
+.Ar path .
+Using an explicit
+.Fl o Ar output
+is recommended, to avoid writing to unexpected file names.
.Pp
If a classic format or an
.Tn FTP
diff --git a/net/tnftp/files/src/ftp.c b/net/tnftp/files/src/ftp.c
index 12f58f92d56..4b56f42d6d7 100644
--- a/net/tnftp/files/src/ftp.c
+++ b/net/tnftp/files/src/ftp.c
@@ -1,7 +1,7 @@
-/* $NetBSD: ftp.c,v 1.1.1.1 2003/07/31 07:18:24 lukem Exp $ */
+/* $NetBSD: ftp.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -48,11 +48,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -106,7 +102,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
-__RCSID("$NetBSD: ftp.c,v 1.1.1.1 2003/07/31 07:18:24 lukem Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif
#endif /* not lint */
#endif
@@ -115,8 +111,9 @@ __RCSID("$NetBSD: ftp.c,v 1.1.1.1 2003/07/31 07:18:24 lukem Exp $");
#include "ftp_var.h"
-volatile int abrtflag = 0;
-volatile int timeoutflag = 0;
+volatile sig_atomic_t abrtflag;
+volatile sig_atomic_t timeoutflag;
+
sigjmp_buf ptabort;
int ptabflg;
int ptflag = 0;
@@ -214,10 +211,7 @@ hookup(char *host, char *port)
cause = "socket";
continue;
}
- while ((error = xconnect(s, res->ai_addr, res->ai_addrlen)) < 0
- && errno == EINTR) {
- ;
- }
+ error = xconnect(s, res->ai_addr, res->ai_addrlen);
if (error) {
/* this "if" clause is to prevent print warning twice */
if (res->ai_next) {
@@ -260,7 +254,8 @@ hookup(char *host, char *port)
int tos = IPTOS_LOWDELAY;
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos,
sizeof(int)) < 0)
- warn("setsockopt TOS (ignored)");
+ if (debug)
+ warn("setsockopt TOS (ignored)");
}
#endif
cin = fdopen(s, "r");
@@ -304,6 +299,7 @@ cmdabort(int notused)
{
int oerrno = errno;
+ sigint_raised = 1;
alarmtimer(0);
if (fromatty)
write(fileno(ttyout), "\n", 1);
@@ -557,13 +553,13 @@ empty(FILE *cin, FILE *din, int sec)
struct pollfd pfd[2];
if (cin) {
- pfd[nfd].fd = fileno(cin);
- pfd[nfd++].events = POLLIN;
+ pfd[nfd].fd = fileno(cin);
+ pfd[nfd++].events = POLLIN;
}
if (din) {
- pfd[nfd].fd = fileno(din);
- pfd[nfd++].events = POLLIN;
+ pfd[nfd].fd = fileno(din);
+ pfd[nfd++].events = POLLIN;
}
if ((nr = poll(pfd, nfd, sec * 1000)) <= 0)
@@ -587,6 +583,7 @@ abortxfer(int notused)
char msgbuf[100];
int len;
+ sigint_raised = 1;
alarmtimer(0);
mflag = 0;
abrtflag = 0;
@@ -1309,7 +1306,8 @@ initconn(void)
if ((options & SO_DEBUG) &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on)) < 0)
- warn("setsockopt (ignored)");
+ if (debug)
+ warn("setsockopt (ignored)");
result = COMPLETE + 1;
switch (data_addr.su_family) {
case AF_INET:
@@ -1528,8 +1526,6 @@ initconn(void)
while (xconnect(data, (struct sockaddr *)&data_addr.si_su,
data_addr.su_len) < 0) {
- if (errno == EINTR)
- continue;
if (activefallback) {
(void)close(data);
data = -1;
@@ -1547,7 +1543,8 @@ initconn(void)
on = IPTOS_THROUGHPUT;
if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,
sizeof(int)) < 0)
- warn("setsockopt TOS (ignored)");
+ if (debug)
+ warn("setsockopt TOS (ignored)");
}
#endif
return (0);
@@ -1580,7 +1577,8 @@ initconn(void)
if (options & SO_DEBUG &&
setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on)) < 0)
- warn("setsockopt (ignored)");
+ if (debug)
+ warn("setsockopt (ignored)");
len = sizeof(data_addr.si_su);
memset((char *)&data_addr, 0, sizeof (data_addr));
if (getsockname(data, (struct sockaddr *)&data_addr.si_su, &len) < 0) {
@@ -1680,7 +1678,8 @@ initconn(void)
on = IPTOS_THROUGHPUT;
if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on,
sizeof(int)) < 0)
- warn("setsockopt TOS (ignored)");
+ if (debug)
+ warn("setsockopt TOS (ignored)");
}
#endif
return (0);
@@ -1713,7 +1712,8 @@ dataconn(const char *lmode)
int tos = IPTOS_THROUGHPUT;
if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos,
sizeof(int)) < 0) {
- warn("setsockopt TOS (ignored)");
+ if (debug)
+ warn("setsockopt TOS (ignored)");
}
}
#endif
@@ -1725,6 +1725,7 @@ psabort(int notused)
{
int oerrno = errno;
+ sigint_raised = 1;
alarmtimer(0);
abrtflag++;
errno = oerrno;
@@ -1821,6 +1822,7 @@ void
abortpt(int notused)
{
+ sigint_raised = 1;
alarmtimer(0);
if (fromatty)
write(fileno(ttyout), "\n", 1);
@@ -2039,6 +2041,7 @@ abort_squared(int dummy)
char msgbuf[100];
int len;
+ sigint_raised = 1;
alarmtimer(0);
len = strlcpy(msgbuf, "\nremote abort aborted; closing connection.\n",
sizeof(msgbuf));
diff --git a/net/tnftp/files/src/ftp.cat1 b/net/tnftp/files/src/ftp.cat1
index c63bf421608..702e7a8de00 100644
--- a/net/tnftp/files/src/ftp.cat1
+++ b/net/tnftp/files/src/ftp.cat1
@@ -1,7 +1,7 @@
FTP(1) NetBSD General Commands Manual FTP(1)
NNAAMMEE
- ffttpp - Internet file transfer program
+ ffttpp -- Internet file transfer program
SSYYNNOOPPSSIISS
ffttpp [--4466AAaaddeeffggiinnppRRttvvVV] [--NN _n_e_t_r_c] [--oo _o_u_t_p_u_t] [--PP _p_o_r_t] [--qq _q_u_i_t_t_i_m_e]
@@ -28,9 +28,9 @@ DDEESSCCRRIIPPTTIIOONN
--66 Forces ffttpp to only use IPv6 addresses.
--AA Force active mode ftp. By default, ffttpp will try to use passive
- mode ftp and fall back to active mode if passive is not support-
- ed by the server. This option causes ffttpp to always use an ac-
- tive connection. It is only useful for connecting to very old
+ mode ftp and fall back to active mode if passive is not sup-
+ ported by the server. This option causes ffttpp to always use an
+ active connection. It is only useful for connecting to very old
servers that do not implement passive mode properly.
--aa Causes ffttpp to bypass normal login procedure, and use an anony-
@@ -49,12 +49,15 @@ DDEESSCCRRIIPPTTIIOONN
--ii Turns off interactive prompting during multiple file transfers.
--nn Restrains ffttpp from attempting ``auto-login'' upon initial con-
- nection. If auto-login is enabled, ffttpp will check the _._n_e_t_r_c
- (see below) file in the user's home directory for an entry de-
- scribing an account on the remote machine. If no entry exists,
- ffttpp will prompt for the remote machine login name (default is
- the user identity on the local machine), and, if necessary,
- prompt for a password and an account with which to login.
+ nection for non auto-fetch transfers. If auto-login is enabled,
+ ffttpp will check the _._n_e_t_r_c (see below) file in the user's home
+ directory for an entry describing an account on the remote
+ machine. If no entry exists, ffttpp will prompt for the remote
+ machine login name (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.
--NN _n_e_t_r_c
Use _n_e_t_r_c instead of _~_/_._n_e_t_r_c. Refer to _T_H_E _._n_e_t_r_c _F_I_L_E for
@@ -97,8 +100,8 @@ DDEESSCCRRIIPPTTIIOONN
--vv Enable vveerrbboossee and pprrooggrreessss. This is the default if output is
to a terminal (and in the case of pprrooggrreessss, ffttpp is the fore-
- ground process). Forces ffttpp to show all responses from the re-
- mote server, as well as report on data transfer statistics.
+ ground process). Forces ffttpp to show all responses from the
+ remote server, as well as report on data transfer statistics.
--VV Disable vveerrbboossee and pprrooggrreessss, overriding the default of enabled
when output is to a terminal.
@@ -107,8 +110,8 @@ DDEESSCCRRIIPPTTIIOONN
command line. If this is done, ffttpp will immediately attempt to establish
a connection to an FTP server on that host; otherwise, ffttpp will enter its
command interpreter and await instructions from the user. When ffttpp is
- awaiting commands from the user the prompt `ftp>' is provided to the us-
- er. The following commands are recognized by ffttpp:
+ awaiting commands from the user the prompt `ftp>' is provided to the
+ user. The following commands are recognized by ffttpp:
!! [_c_o_m_m_a_n_d [_a_r_g_s]]
Invoke an interactive shell on the local machine. If there
@@ -132,8 +135,8 @@ DDEESSCCRRIIPPTTIIOONN
or nnmmaapp setting. File transfer uses the current settings for
ttyyppee, ffoorrmmaatt, mmooddee, and ssttrruuccttuurree.
- aasscciiii Set the file transfer ttyyppee to network ASCII. This is the de-
- fault type.
+ aasscciiii Set the file transfer ttyyppee to network ASCII. This is the
+ default type.
bbeellll Arrange that a bell be sounded after each file transfer com-
mand is completed.
@@ -141,8 +144,8 @@ DDEESSCCRRIIPPTTIIOONN
bbiinnaarryy Set the file transfer ttyyppee to support binary image transfer.
bbyyee Terminate the FTP session with the remote server and exit
- ffttpp. An end of file will also terminate the session and ex-
- it.
+ ffttpp. An end of file will also terminate the session and
+ exit.
ccaassee Toggle remote computer file name case mapping during ggeett,
mmggeett and mmppuutt commands. When ccaassee is on (default is off),
@@ -164,8 +167,8 @@ DDEESSCCRRIIPPTTIIOONN
cclloossee Terminate the FTP session with the remote server, and return
to the command interpreter. Any defined macros are erased.
- ccrr Toggle carriage return stripping during ascii type file re-
- trieval. Records are denoted by a carriage return/linefeed
+ ccrr Toggle carriage return stripping during ascii type file
+ retrieval. Records are denoted by a carriage return/linefeed
sequence during ascii type file transfer. When ccrr is on (the
default), carriage returns are stripped from this sequence to
conform with the UNIX single linefeed record delimiter.
@@ -188,8 +191,8 @@ DDEESSCCRRIIPPTTIIOONN
machine. The listing includes any system-dependent informa-
tion that the server chooses to include; for example, most
UNIX systems will produce output from the command `ls -l'.
- If _r_e_m_o_t_e_-_p_a_t_h is left unspecified, the current working di-
- rectory is used. If interactive prompting is on, ffttpp will
+ If _r_e_m_o_t_e_-_p_a_t_h is left unspecified, the current working
+ directory is used. If interactive prompting is on, ffttpp will
prompt the user to verify that the last argument is indeed
the target local file for receiving ddiirr output. If no local
file is specified, or if _l_o_c_a_l_-_f_i_l_e is `--', the output is
@@ -231,8 +234,8 @@ DDEESSCCRRIIPPTTIIOONN
user, or from the FTPSERVER environment variable). If _h_o_s_t
is given, then gate-ftp mode will be enabled, and the gate-
ftp server will be set to _h_o_s_t. If _p_o_r_t is also given, that
- will be used as the port to connect to on the gate-ftp serv-
- er.
+ will be used as the port to connect to on the gate-ftp
+ server.
ggeett _r_e_m_o_t_e_-_f_i_l_e [_l_o_c_a_l_-_f_i_l_e]
Retrieve the _r_e_m_o_t_e_-_f_i_l_e and store it on the local machine.
@@ -294,17 +297,18 @@ DDEESSCCRRIIPPTTIIOONN
_m_a_c_r_o_-_n_a_m_e; a null line (consecutive newline characters in a
file or carriage returns from the terminal) terminates macro
input mode. There is a limit of 16 macros and 4096 total
- characters in all defined macros. Macros remain defined un-
- til a cclloossee command is executed. The macro processor inter-
- prets `$' and `\' as special characters. A `$' followed by a
- number (or numbers) is replaced by the corresponding argument
- on the macro invocation command line. A `$' followed by an
- `i' signals that macro processor that the executing macro is
- to be looped. On the first pass `$i' is replaced by the
- first argument on the macro invocation command line, on the
- second pass it is replaced by the second argument, and so on.
- A `\' followed by any character is replaced by that charac-
- ter. Use the `\' to prevent special treatment of the `$'.
+ characters in all defined macros. Macros remain defined
+ until a cclloossee command is executed. The macro processor
+ interprets `$' and `\' as special characters. A `$' followed
+ by a number (or numbers) is replaced by the corresponding
+ argument on the macro invocation command line. A `$' fol-
+ lowed by an `i' signals that macro processor that the execut-
+ ing macro is to be looped. On the first pass `$i' is
+ replaced by the first argument on the macro invocation com-
+ mand line, on the second pass it is replaced by the second
+ argument, and so on. A `\' followed by any character is
+ replaced by that character. Use the `\' to prevent special
+ treatment of the `$'.
mmddeelleettee [_r_e_m_o_t_e_-_f_i_l_e_s]
Delete the _r_e_m_o_t_e_-_f_i_l_e_s on the remote machine.
@@ -351,8 +355,8 @@ DDEESSCCRRIIPPTTIIOONN
only supported) mode is ``stream''.
mmooddttiimmee _r_e_m_o_t_e_-_f_i_l_e
- Show the last modification time of the file on the remote ma-
- chine.
+ Show the last modification time of the file on the remote
+ machine.
mmoorree _f_i_l_e A synonym for ppaaggee.
@@ -382,8 +386,8 @@ DDEESSCCRRIIPPTTIIOONN
Set or unset the filename mapping mechanism. If no arguments
are specified, the filename mapping mechanism is unset. If
arguments are specified, remote filenames are mapped during
- mmppuutt commands and ppuutt commands issued without a specified re-
- mote target filename. If arguments are specified, local
+ mmppuutt commands and ppuutt commands issued without a specified
+ remote target filename. If arguments are specified, local
filenames are mapped during mmggeett commands and ggeett commands
issued without a specified local target filename. This com-
mand is useful when connecting to a non-UNIX remote computer
@@ -394,24 +398,24 @@ DDEESSCCRRIIPPTTIIOONN
settings). Variable templating is accomplished by including
the sequences `$1', `$2', ..., `$9' in _i_n_p_a_t_t_e_r_n. Use `\' to
prevent this special treatment of the `$' character. All
- other characters are treated literally, and are used to de-
- termine the nnmmaapp [_i_n_p_a_t_t_e_r_n] variable values. For example,
+ other characters are treated literally, and are used to
+ determine the nnmmaapp [_i_n_p_a_t_t_e_r_n] variable values. For example,
given _i_n_p_a_t_t_e_r_n $1.$2 and the remote file name "mydata.data",
$1 would have the value "mydata", and $2 would have the value
"data". The _o_u_t_p_a_t_t_e_r_n determines the resulting mapped file-
name. The sequences `$1', `$2', ...., `$9' are replaced by
- any value resulting from the _i_n_p_a_t_t_e_r_n template. The se-
- quence `$0' is replace by the original filename. Additional-
- ly, the sequence `[_s_e_q_1, _s_e_q_2]' is replaced by [_s_e_q_1] if _s_e_q_1
- is not a null string; otherwise it is replaced by _s_e_q_2. For
- example, the command
+ any value resulting from the _i_n_p_a_t_t_e_r_n template. The
+ sequence `$0' is replace by the original filename. Addition-
+ ally, the sequence `[_s_e_q_1, _s_e_q_2]' is replaced by [_s_e_q_1] if
+ _s_e_q_1 is not a null string; otherwise it is replaced by _s_e_q_2.
+ For example, the command
nmap $1.$2.$3 [$1,$2].[$2,file]
would yield the output filename "myfile.data" for input file-
names "myfile.data" and "myfile.data.old", "myfile.file" for
- the input filename "myfile", and "myfile.myfile" for the in-
- put filename ".myfile". Spaces may be included in
+ the input filename "myfile", and "myfile.myfile" for the
+ input filename ".myfile". Spaces may be included in
_o_u_t_p_a_t_t_e_r_n, as in the example: `nmap $1 sed "s/ *$//" > $1'
. Use the `\' character to prevent special treatment of the
`$','[',']', and `,' characters.
@@ -422,8 +426,8 @@ DDEESSCCRRIIPPTTIIOONN
lation mechanism is unset. If arguments are specified, char-
acters in remote filenames are translated during mmppuutt com-
mands and ppuutt commands issued without a specified remote tar-
- get filename. If arguments are specified, characters in lo-
- cal filenames are translated during mmggeett commands and ggeett
+ get filename. If arguments are specified, characters in
+ local filenames are translated during mmggeett commands and ggeett
commands issued without a specified local target filename.
This command is useful when connecting to a non-UNIX remote
computer with different file naming conventions or practices.
@@ -454,8 +458,9 @@ DDEESSCCRRIIPPTTIIOONN
tens on a port and sends that address to the remote server,
who connects back to it. Passive mode is useful when using
ffttpp through a gateway router or host that controls the direc-
- tionality of traffic. (Note that though FTP servers are re-
- quired to support the PASV command by RFC 1123, some do not.)
+ tionality of traffic. (Note that though FTP servers are
+ required to support the PASV command by RFC 1123, some do
+ not.)
ppddiirr [_r_e_m_o_t_e_-_p_a_t_h]
Perform ddiirr [_r_e_m_o_t_e_-_p_a_t_h], and display the result with the
@@ -511,15 +516,15 @@ DDEESSCCRRIIPPTTIIOONN
ondary control connection. Enter the command "proxy ?" to
see other FTP commands executable on the secondary connec-
tion. The following commands behave differently when pref-
- aced by pprrooxxyy: ooppeenn will not define new macros during the au-
- to-login process, cclloossee will not erase existing macro defini-
- tions, ggeett and mmggeett transfer files from the host on the pri-
- mary control connection to the host on the secondary control
- connection, and ppuutt, mmppuutt, and aappppeenndd transfer files from the
- host on the secondary control connection to the host on the
- primary control connection. Third party file transfers de-
- pend upon support of the FTP protocol PASV command by the
- server on the secondary control connection.
+ aced by pprrooxxyy: ooppeenn will not define new macros during the
+ auto-login process, cclloossee will not erase existing macro defi-
+ nitions, ggeett and mmggeett transfer files from the host on the
+ primary control connection to the host on the secondary con-
+ trol connection, and ppuutt, mmppuutt, and aappppeenndd transfer files
+ from the host on the secondary control connection to the host
+ on the primary control connection. Third party file trans-
+ fers depend upon support of the FTP protocol PASV command by
+ the server on the secondary control connection.
ppuutt _l_o_c_a_l_-_f_i_l_e [_r_e_m_o_t_e_-_f_i_l_e]
Store a local file on the remote machine. If _r_e_m_o_t_e_-_f_i_l_e is
@@ -546,13 +551,13 @@ DDEESSCCRRIIPPTTIIOONN
ggeett Incoming transfers.
ppuutt Outgoing transfers.
- _m_a_x_i_m_u_m can by modified on the fly by _i_n_c_r_e_m_e_n_t bytes (de-
- fault: 1024) each time a given signal is received:
+ _m_a_x_i_m_u_m can be modified on the fly by _i_n_c_r_e_m_e_n_t bytes
+ (default: 1024) each time a given signal is received:
SIGUSR1 Increment _m_a_x_i_m_u_m by _i_n_c_r_e_m_e_n_t bytes.
- SIGUSR2 Decrement _m_a_x_i_m_u_m by _i_n_c_r_e_m_e_n_t bytes. The re-
- sult must be a positive number.
+ SIGUSR2 Decrement _m_a_x_i_m_u_m by _i_n_c_r_e_m_e_n_t bytes. The
+ result must be a positive number.
If _m_a_x_i_m_u_m is not supplied, the current throttle rates are
displayed.
@@ -582,15 +587,15 @@ DDEESSCCRRIIPPTTIIOONN
rreennaammee [_f_r_o_m [_t_o]]
Rename the file _f_r_o_m on the remote machine, to the file _t_o.
- rreesseett Clear reply queue. This command re-synchronizes command/re-
- ply sequencing with the remote FTP server. Resynchronization
- may be necessary following a violation of the FTP protocol by
- the remote server.
+ rreesseett Clear reply queue. This command re-synchronizes com-
+ mand/reply sequencing with the remote FTP server. Resynchro-
+ nization may be necessary following a violation of the FTP
+ protocol by the remote server.
rreessttaarrtt _m_a_r_k_e_r
Restart the immediately following ggeett or ppuutt at the indicated
- _m_a_r_k_e_r. On UNIX systems, marker is usually a byte offset in-
- to the file.
+ _m_a_r_k_e_r. On UNIX systems, marker is usually a byte offset
+ into the file.
rrhheellpp [_c_o_m_m_a_n_d_-_n_a_m_e]
Request help from the remote FTP server. If a _c_o_m_m_a_n_d_-_n_a_m_e
@@ -601,8 +606,8 @@ DDEESSCCRRIIPPTTIIOONN
rrssttaattuuss [_r_e_m_o_t_e_-_f_i_l_e]
With no arguments, show status of remote machine. If
- _r_e_m_o_t_e_-_f_i_l_e is specified, show status of _r_e_m_o_t_e_-_f_i_l_e on re-
- mote machine.
+ _r_e_m_o_t_e_-_f_i_l_e is specified, show status of _r_e_m_o_t_e_-_f_i_l_e on
+ remote machine.
rruunniiqquuee Toggle storing of files on the local system with unique file-
names. If a file already exists with a name equal to the
@@ -612,14 +617,14 @@ DDEESSCCRRIIPPTTIIOONN
this process continues up to ".99", an error message is
printed, and the transfer does not take place. The generated
unique filename will be reported. Note that rruunniiqquuee will not
- affect local files generated from a shell command (see be-
- low). The default value is off.
+ affect local files generated from a shell command (see
+ below). The default value is off.
sseenndd _l_o_c_a_l_-_f_i_l_e [_r_e_m_o_t_e_-_f_i_l_e]
A synonym for ppuutt.
- sseennddppoorrtt Toggle the use of PORT commands. By default, ffttpp will at-
- tempt to use a PORT command when establishing a connection
+ sseennddppoorrtt Toggle the use of PORT commands. By default, ffttpp will
+ attempt to use a PORT command when establishing a connection
for each data transfer. The use of PORT commands can prevent
delays when performing multiple file transfers. If the PORT
command fails, ffttpp will use the default data port. When the
@@ -668,8 +673,8 @@ DDEESSCCRRIIPPTTIIOONN
command for successful completion. The remote server will
report unique name. Default value is off.
- ssyysstteemm Show the type of operating system running on the remote ma-
- chine.
+ ssyysstteemm Show the type of operating system running on the remote
+ machine.
tteenneexx Set the file transfer type to that needed to talk to TENEX
machines.
@@ -707,9 +712,9 @@ DDEESSCCRRIIPPTTIIOONN
vveerrbboossee Toggle verbose mode. In verbose mode, all responses from the
FTP server are displayed to the user. In addition, if ver-
- bose is on, when a file transfer completes, statistics re-
- garding the efficiency of the transfer are reported. By de-
- fault, verbose is on.
+ bose is on, when a file transfer completes, statistics
+ regarding the efficiency of the transfer are reported. By
+ default, verbose is on.
xxffeerrbbuuff _s_i_z_e
Set the size of the socket send and receive buffers to _s_i_z_e.
@@ -724,8 +729,8 @@ DDEESSCCRRIIPPTTIIOONN
force the setting appropriately.
Commands which take a byte count as an argument (e.g., hhaasshh, rraattee, and
- xxffeerrbbuuff) support an optional suffix on the argument which changes the in-
- terpretation of the argument. Supported suffixes are:
+ xxffeerrbbuuff) support an optional suffix on the argument which changes the
+ interpretation of the argument. Supported suffixes are:
b Causes no modification. (Optional)
k Kilo; multiply the argument by 1024
m Mega; multiply the argument by 1048576
@@ -756,10 +761,10 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS
ftp://[_u_s_e_r[:_p_a_s_s_w_o_r_d]@]_h_o_s_t[:_p_o_r_t]/_p_a_t_h[/][;type=_X]
An FTP URL, retrieved using the FTP protocol if sseett ffttpp__pprrooxxyy isn't
- defined. Otherwise, transfer the URL using HTTP via the proxy de-
- fined in sseett ffttpp__pprrooxxyy. If sseett ffttpp__pprrooxxyy isn't defined and _u_s_e_r is
- given, login as _u_s_e_r. In this case, use _p_a_s_s_w_o_r_d if supplied, oth-
- erwise prompt the user for one.
+ defined. Otherwise, transfer the URL using HTTP via the proxy
+ defined in sseett ffttpp__pprrooxxyy. If sseett ffttpp__pprrooxxyy isn't defined and _u_s_e_r
+ is given, login as _u_s_e_r. In this case, use _p_a_s_s_w_o_r_d if supplied,
+ otherwise prompt the user for one.
If a suffix of `;type=A' or `;type=I' is supplied, then the trans-
fer type will take place as ascii or binary (respectively). The
@@ -791,12 +796,12 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS
The above interpretation has the following consequences:
++oo The path is interpreted relative to the default login directory
- of the specified user or of the `anonymous' user. If the _/ di-
- rectory is required, use a leading path of ``%2F''. If a us-
- er's home directory is required (and the remote server supports
- the syntax), use a leading path of ``%7Euser/''. For example,
- to retrieve _/_e_t_c_/_m_o_t_d from `localhost' as the user `myname'
- with the password `mypass', use
+ of the specified user or of the `anonymous' user. If the _/
+ directory is required, use a leading path of ``%2F''. If a
+ user's home directory is required (and the remote server sup-
+ ports the syntax), use a leading path of ``%7Euser/''. For
+ example, to retrieve _/_e_t_c_/_m_o_t_d from `localhost' as the user
+ `myname' with the password `mypass', use
``ftp://myname:mypass@localhost/%2fetc/motd''
++oo The exact ccdd and ggeett commands can be controlled by careful
@@ -820,8 +825,8 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS
ftp://host/%2Fdir1%2Fdir2%2Ffile ``get /dir1/dir2/file''.
- ++oo You must have appropriate access permission for each of the in-
- termediate directories that is used in the equivalent of a ccdd
+ ++oo You must have appropriate access permission for each of the
+ intermediate directories that is used in the equivalent of a ccdd
command.
http://[_u_s_e_r[:_p_a_s_s_w_o_r_d]@]_h_o_s_t[:_p_o_r_t]/_p_a_t_h
@@ -835,7 +840,11 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS
A local URL, copied from _/_p_a_t_h on the local host.
Unless noted otherwise above, and --oo _o_u_t_p_u_t is not given, the file is
- stored in the current directory as the basename(1) of _p_a_t_h.
+ stored in the current directory as the basename(1) of _p_a_t_h. Note that if
+ a HTTP redirect is received, the fetch is retried using the new target
+ URL supplied by the server, with a corresponding new _p_a_t_h. Using an
+ explicit --oo _o_u_t_p_u_t is recommended, to avoid writing to unexpected file
+ names.
If a classic format or an FTP URL format has a trailing `/' or an empty
_p_a_t_h component, then ffttpp will connect to the site and ccdd to the directory
@@ -846,9 +855,9 @@ AAUUTTOO--FFEETTCCHHIINNGG FFIILLEESS
HTTP 1.0.
If --RR is given, all auto-fetches that don't go via the FTP or HTTP prox-
- ies will be restarted. For FTP, this is implemented by using rreeggeett in-
- stead of ggeett. For HTTP, this is implemented by using the `Range: bytes='
- HTTP/1.1 directive.
+ ies will be restarted. For FTP, this is implemented by using rreeggeett
+ instead of ggeett. For HTTP, this is implemented by using the `Range:
+ bytes=' HTTP/1.1 directive.
If WWW or proxy WWW authentication is required, you will be prompted to
enter a username and password to authenticate with.
@@ -891,18 +900,18 @@ FFIILLEE NNAAMMIINNGG CCOONNVVEENNTTIIOONNSS
3. Failing the above checks, if ``globbing'' is enabled, local file
names are expanded according to the rules used in the csh(1); c.f.
the gglloobb command. If the ffttpp command expects a single local file
- (e.g. ppuutt), only the first filename generated by the "globbing" op-
- eration is used.
+ (e.g. ppuutt), only the first filename generated by the "globbing"
+ operation is used.
4. For mmggeett commands and ggeett commands with unspecified local file
- names, the local filename is the remote filename, which may be al-
- tered by a ccaassee, nnttrraannss, or nnmmaapp setting. The resulting filename
+ names, the local filename is the remote filename, which may be
+ altered by a ccaassee, nnttrraannss, or nnmmaapp setting. The resulting filename
may then be altered if rruunniiqquuee is on.
5. For mmppuutt commands and ppuutt commands with unspecified remote file
- names, the remote filename is the local filename, which may be al-
- tered by a nnttrraannss or nnmmaapp setting. The resulting filename may then
- be altered by the remote server if ssuunniiqquuee is on.
+ names, the remote filename is the local filename, which may be
+ altered by a nnttrraannss or nnmmaapp setting. The resulting filename may
+ then be altered by the remote server if ssuunniiqquuee is on.
FFIILLEE TTRRAANNSSFFEERR PPAARRAAMMEETTEERRSS
The FTP specification specifies many parameters which may affect a file
@@ -911,23 +920,23 @@ FFIILLEE TTRRAANNSSFFEERR PPAARRAAMMEETTEERRSS
ffttpp supports the ascii and image types of file transfer, plus local byte
size 8 for tteenneexx mode transfers.
- ffttpp supports only the default values for the remaining file transfer pa-
- rameters: mmooddee, ffoorrmm, and ssttrruucctt.
+ ffttpp supports only the default values for the remaining file transfer
+ parameters: mmooddee, ffoorrmm, and ssttrruucctt.
TTHHEE ..nneettrrcc FFIILLEE
The _._n_e_t_r_c file contains login and initialization information used by the
auto-login process. It resides in the user's home directory, unless
overridden with the --NN _n_e_t_r_c option, or specified in the NETRC environ-
- ment variable. The following tokens are recognized; they may be separat-
- ed by spaces, tabs, or new-lines:
+ ment variable. The following tokens are recognized; they may be sepa-
+ rated by spaces, tabs, or new-lines:
mmaacchhiinnee _n_a_m_e
- Identify a remote machine _n_a_m_e. The auto-login process search-
- es the _._n_e_t_r_c file for a mmaacchhiinnee token that matches the remote
- machine specified on the ffttpp command line or as an ooppeenn command
- argument. Once a match is made, the subsequent _._n_e_t_r_c tokens
- are processed, stopping when the end of file is reached or an-
- other mmaacchhiinnee or a ddeeffaauulltt token is encountered.
+ Identify a remote machine _n_a_m_e. The auto-login process
+ searches the _._n_e_t_r_c file for a mmaacchhiinnee token that matches the
+ remote machine specified on the ffttpp command line or as an ooppeenn
+ command argument. Once a match is made, the subsequent _._n_e_t_r_c
+ tokens are processed, stopping when the end of file is reached
+ or another mmaacchhiinnee or a ddeeffaauulltt token is encountered.
ddeeffaauulltt This is the same as mmaacchhiinnee _n_a_m_e except that ddeeffaauulltt matches
any name. There can be only one ddeeffaauulltt token, and it must be
@@ -935,9 +944,9 @@ TTHHEE ..nneettrrcc FFIILLEE
default login anonymous password user@site
- thereby giving the user an automatic anonymous FTP login to ma-
- chines not specified in _._n_e_t_r_c. This can be overridden by us-
- ing the --nn flag to disable auto-login.
+ thereby giving the user an automatic anonymous FTP login to
+ machines not specified in _._n_e_t_r_c. This can be overridden by
+ using the --nn flag to disable auto-login.
llooggiinn _n_a_m_e
Identify a user on the remote machine. If this token is
@@ -974,18 +983,19 @@ TTHHEE ..nneettrrcc FFIILLEE
followed by a blank line.
CCOOMMMMAANNDD LLIINNEE EEDDIITTIINNGG
- ffttpp supports interactive command line editing, via the editline(3) li-
- brary. It is enabled with the eeddiitt command, and is enabled by default if
- input is from a tty. Previous lines can be recalled and edited with the
- arrow keys, and other GNU Emacs-style editing keys may be used as well.
+ ffttpp supports interactive command line editing, via the editline(3)
+ library. It is enabled with the eeddiitt command, and is enabled by default
+ if input is from a tty. Previous lines can be recalled and edited with
+ the arrow keys, and other GNU Emacs-style editing keys may be used as
+ well.
The editline(3) library is configured with a _._e_d_i_t_r_c file - refer to
editrc(5) for more information.
An extra key binding is available to ffttpp to provide context sensitive
command and filename completion (including remote file completion). To
- use this, bind a key to the editline(3) command ffttpp--ccoommpplleettee. By de-
- fault, this is bound to the TAB key.
+ use this, bind a key to the editline(3) command ffttpp--ccoommpplleettee. By
+ default, this is bound to the TAB key.
CCOOMMMMAANNDD LLIINNEE PPRROOMMPPTT
By default, ffttpp displays a command line prompt of ``ftp> '' to the user.
@@ -999,9 +1009,9 @@ CCOOMMMMAANNDD LLIINNEE PPRROOMMPPTT
%/ The current remote working directory.
%c[[0]_n],%.[[0]_n]
- The trailing component of the current remote working directo-
- ry, or _n trailing components if a digit _n is given. If _n be-
- gins with `0', the number of skipped components precede the
+ The trailing component of the current remote working direc-
+ tory, or _n trailing components if a digit _n is given. If _n
+ begins with `0', the number of skipped components precede the
trailing component(s) in the format ``/<_n_u_m_b_e_r>_t_r_a_i_l_i_n_g'' (for
`%c') or ``..._t_r_a_i_l_i_n_g'' (for `%.').
@@ -1084,8 +1094,8 @@ EEXXTTEENNDDEEDD PPAASSSSIIVVEE MMOODDEE AANNDD FFIIRRE
229 Entering Extended Passive Mode (|||58551|)
then you will need to disable extended passive mode with eeppssvv44 ooffff. See
- the above section _T_h_e _._n_e_t_r_c _F_i_l_e for an example of how to make this au-
- tomatic.
+ the above section _T_h_e _._n_e_t_r_c _F_i_l_e for an example of how to make this
+ automatic.
SSEEEE AALLSSOO
getservbyname(3), editrc(5), services(5), ftpd(8)
@@ -1125,4 +1135,4 @@ BBUUGGSS
uses a SIIT translator for IPv6-to-IPv4 translation, ffttpp is unable to
support your configuration.
-NetBSD 1.6 July 31, 2003 NetBSD 1.6
+NetBSD 2.0 October 7, 2004 NetBSD 2.0
diff --git a/net/tnftp/files/src/ftp_var.h b/net/tnftp/files/src/ftp_var.h
index a99c9728b87..bd1ced52738 100644
--- a/net/tnftp/files/src/ftp_var.h
+++ b/net/tnftp/files/src/ftp_var.h
@@ -1,7 +1,7 @@
-/* $NetBSD: ftp_var.h,v 1.1.1.1 2003/02/28 10:44:54 lukem Exp $ */
+/* $NetBSD: ftp_var.h,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -48,11 +48,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -122,15 +118,15 @@
* Format of command table.
*/
struct cmd {
- char *c_name; /* name of command */
- char *c_help; /* help string */
- char c_bell; /* give bell when command completes */
- char c_conn; /* must be connected to use command */
- char c_proxy; /* proxy server may execute */
+ char *c_name; /* name of command */
+ const char *c_help; /* help string */
+ char c_bell; /* give bell when command completes */
+ char c_conn; /* must be connected to use command */
+ char c_proxy; /* proxy server may execute */
#ifndef NO_EDITCOMPLETE
- char *c_complete; /* context sensitive completion list */
+ const char *c_complete; /* context sensitive completion list */
#endif /* !NO_EDITCOMPLETE */
- void (*c_handler)(int, char **); /* function to call */
+ void (*c_handler)(int, char **); /* function to call */
};
/*
@@ -265,7 +261,8 @@ GLOBAL char *direction; /* direction transfer is occurring */
GLOBAL char *hostname; /* name of host connected to */
GLOBAL int unix_server; /* server is unix, can use binary for ascii */
GLOBAL int unix_proxy; /* proxy is unix, can use binary for ascii */
-GLOBAL char remotepwd[MAXPATHLEN]; /* remote dir */
+GLOBAL char localcwd[MAXPATHLEN]; /* local dir */
+GLOBAL char remotecwd[MAXPATHLEN]; /* remote dir */
GLOBAL char *username; /* name of user logged in as. (dynamic) */
GLOBAL sa_family_t family; /* address family to use for connections */
@@ -306,6 +303,7 @@ GLOBAL void (*reply_callback)(const char *);
* first (`xxx-') and last (`xxx ')
*/
+GLOBAL volatile sig_atomic_t sigint_raised;
GLOBAL FILE *cin;
GLOBAL FILE *cout;
diff --git a/net/tnftp/files/src/main.c b/net/tnftp/files/src/main.c
index 5823130dc4b..a8cb503a001 100644
--- a/net/tnftp/files/src/main.c
+++ b/net/tnftp/files/src/main.c
@@ -1,7 +1,7 @@
-/* $NetBSD: main.c,v 1.1.1.1 2003/07/31 06:18:44 lukem Exp $ */
+/* $NetBSD: main.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
+ * Copyright (c) 1996-2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -48,11 +48,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -109,7 +105,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: main.c,v 1.1.1.1 2003/07/31 06:18:44 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif
#endif /* not lint */
#endif
@@ -144,6 +140,8 @@ main(int argc, char *argv[])
#endif
setprogname(argv[0]);
+ sigint_raised = 0;
+
ftpport = "ftp";
httpport = "http";
gateport = NULL;
@@ -211,9 +209,14 @@ main(int argc, char *argv[])
(void)close(s);
/* sanity check returned buffer sizes */
if (rcvbuf_size <= 0)
- rcvbuf_size = 8192;
+ rcvbuf_size = 8 * 1024;
if (sndbuf_size <= 0)
- sndbuf_size = 8192;
+ sndbuf_size = 8 * 1024;
+
+ if (sndbuf_size > 8 * 1024 * 1024)
+ sndbuf_size = 8 * 1024 * 1024;
+ if (rcvbuf_size > 8 * 1024 * 1024)
+ rcvbuf_size = 8 * 1024 * 1024;
marg_sl = xsl_init();
if ((tmpdir = getenv("TMPDIR")) == NULL)
@@ -498,17 +501,22 @@ main(int argc, char *argv[])
if (argc > 0) {
if (isupload) {
rval = auto_put(argc, argv, upload_path);
+ sigint_or_rval_exit:
+ if (sigint_raised) {
+ (void)xsignal(SIGINT, SIG_DFL);
+ raise(SIGINT);
+ }
exit(rval);
} else if (strchr(argv[0], ':') != NULL
&& ! isipv6addr(argv[0])) {
rval = auto_fetch(argc, argv);
if (rval >= 0) /* -1 == connected and cd-ed */
- exit(rval);
+ goto sigint_or_rval_exit;
} else {
char *xargv[4], *user, *host;
- if (sigsetjmp(toplevel, 1))
- exit(0);
+ if ((rval = sigsetjmp(toplevel, 1)))
+ goto sigint_or_rval_exit;
(void)xsignal(SIGINT, intr);
(void)xsignal(SIGPIPE, lostpeer);
user = NULL;
@@ -1021,8 +1029,8 @@ usage(void)
const char *progname = getprogname();
(void)fprintf(stderr,
-"usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-r retry]\n"
-" [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n"
+"usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-q quittime]\n"
+" [-r retry] [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n"
" [file:///file] [ftp://[user[:pass]@]host[:port]/path[/]]\n"
" [http://[user[:pass]@]host[:port]/path] [...]\n"
" %s -u URL file [...]\n", progname, progname);
diff --git a/net/tnftp/files/src/progressbar.c b/net/tnftp/files/src/progressbar.c
index 980ab6f6514..538a7b8e447 100644
--- a/net/tnftp/files/src/progressbar.c
+++ b/net/tnftp/files/src/progressbar.c
@@ -1,4 +1,4 @@
-/* $NetBSD: progressbar.c,v 1.1.1.1 2003/07/31 06:18:44 lukem Exp $ */
+/* $NetBSD: progressbar.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
#if 0
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: progressbar.c,v 1.1.1.1 2003/07/31 06:18:44 lukem Exp $");
+__RCSID("$NetBSD: progressbar.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif /* not lint */
#endif
@@ -197,6 +197,8 @@ progressmeter(int flag)
return;
len += snprintf(buf + len, BUFLEFT, "\r");
+ if (prefix)
+ len += snprintf(buf + len, BUFLEFT, "%s", prefix);
if (filesize > 0) {
ratio = (int)((double)cursize * 100.0 / (double)filesize);
ratio = MAX(ratio, 0);
@@ -208,6 +210,8 @@ progressmeter(int flag)
* the number of stars won't exceed the buffer size
*/
barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD;
+ if (prefix)
+ barlength -= strlen(prefix);
if (barlength > 0) {
i = barlength * ratio / 100;
len += snprintf(buf + len, BUFLEFT,
diff --git a/net/tnftp/files/src/progressbar.h b/net/tnftp/files/src/progressbar.h
index f696da893be..9aa14147ec1 100644
--- a/net/tnftp/files/src/progressbar.h
+++ b/net/tnftp/files/src/progressbar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: progressbar.h,v 1.1.1.1 2003/02/28 10:44:54 lukem Exp $ */
+/* $NetBSD: progressbar.h,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@ GLOBAL int ttywidth; /* width of tty */
GLOBAL off_t bytes; /* current # of bytes read */
GLOBAL off_t filesize; /* size of file being transferred */
GLOBAL off_t restart_point; /* offset to restart transfer */
+GLOBAL char *prefix; /* Text written left of progress bar */
#ifndef STANDALONE_PROGRESS
diff --git a/net/tnftp/files/src/ruserpass.c b/net/tnftp/files/src/ruserpass.c
index 625b566ee56..188c9be86d1 100644
--- a/net/tnftp/files/src/ruserpass.c
+++ b/net/tnftp/files/src/ruserpass.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ruserpass.c,v 1.1.1.1 2003/02/28 10:44:55 lukem Exp $ */
+/* $NetBSD: ruserpass.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
@@ -12,11 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/net/tnftp/files/src/util.c b/net/tnftp/files/src/util.c
index 9b0a9aa11dd..fd1c70b386e 100644
--- a/net/tnftp/files/src/util.c
+++ b/net/tnftp/files/src/util.c
@@ -1,7 +1,7 @@
-/* $NetBSD: util.c,v 1.1.1.1 2003/07/31 07:18:24 lukem Exp $ */
+/* $NetBSD: util.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $ */
/*-
- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1997-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -52,11 +52,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -76,7 +72,7 @@
#if 0
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.1.1.1 2003/07/31 07:18:24 lukem Exp $");
+__RCSID("$NetBSD: util.c,v 1.1.1.2 2005/01/03 10:08:40 lukem Exp $");
#endif /* not lint */
#endif
@@ -304,9 +300,10 @@ cleanuppeer(void)
* Top-level signal handler for interrupted commands.
*/
void
-intr(int dummy)
+intr(int signo)
{
+ sigint_raised = 1;
alarmtimer(0);
if (fromatty)
write(fileno(ttyout), "\n", 1);
@@ -463,7 +460,8 @@ ftp_login(const char *host, const char *user, const char *pass)
break;
}
}
- updateremotepwd();
+ updatelocalcwd();
+ updateremotecwd();
cleanup_ftp_login:
if (user != NULL && freeuser)
@@ -758,10 +756,23 @@ remotemodtime(const char *file, int noisy)
}
/*
- * update global `remotepwd', which contains the state of the remote cwd
+ * Update global `localcwd', which contains the state of the local cwd
*/
void
-updateremotepwd(void)
+updatelocalcwd(void)
+{
+
+ if (getcwd(localcwd, sizeof(localcwd)) == NULL)
+ localcwd[0] = '\0';
+ if (debug)
+ fprintf(ttyout, "got localcwd as `%s'\n", localcwd);
+}
+
+/*
+ * Update global `remotecwd', which contains the state of the remote cwd
+ */
+void
+updateremotecwd(void)
{
int overbose, ocode, i;
char *cp;
@@ -771,31 +782,55 @@ updateremotepwd(void)
if (debug == 0)
verbose = -1;
if (command("PWD") != COMPLETE)
- goto badremotepwd;
+ goto badremotecwd;
cp = strchr(reply_string, ' ');
if (cp == NULL || cp[0] == '\0' || cp[1] != '"')
- goto badremotepwd;
+ goto badremotecwd;
cp += 2;
- for (i = 0; *cp && i < sizeof(remotepwd) - 1; i++, cp++) {
+ for (i = 0; *cp && i < sizeof(remotecwd) - 1; i++, cp++) {
if (cp[0] == '"') {
if (cp[1] == '"')
cp++;
else
break;
}
- remotepwd[i] = *cp;
+ remotecwd[i] = *cp;
}
- remotepwd[i] = '\0';
+ remotecwd[i] = '\0';
if (debug)
- fprintf(ttyout, "got remotepwd as `%s'\n", remotepwd);
- goto cleanupremotepwd;
- badremotepwd:
- remotepwd[0]='\0';
- cleanupremotepwd:
+ fprintf(ttyout, "got remotecwd as `%s'\n", remotecwd);
+ goto cleanupremotecwd;
+ badremotecwd:
+ remotecwd[0]='\0';
+ cleanupremotecwd:
verbose = overbose;
code = ocode;
}
+/*
+ * Ensure file is in or under dir.
+ * Returns 1 if so, 0 if not (or an error occurred).
+ */
+int
+fileindir(const char *file, const char *dir)
+{
+ char realfile[PATH_MAX+1];
+ size_t dirlen;
+
+ if (realpath(file, realfile) == NULL) {
+ warn("Unable to determine real path of `%s'", file);
+ return 0;
+ }
+ if (realfile[0] != '/') /* relative result */
+ return 1;
+ dirlen = strlen(dir);
+#if 0
+printf("file %s realfile %s dir %s [%d]\n", file, realfile, dir, dirlen);
+#endif
+ if (strncmp(realfile, dir, dirlen) == 0 && realfile[dirlen] == '/')
+ return 1;
+ return 0;
+}
/*
* List words in stringlist, vertically arranged
@@ -1042,7 +1077,7 @@ formatbuf(char *buf, size_t len, const char *src)
case '/':
case '.':
case 'c':
- p2 = connected ? remotepwd : "";
+ p2 = connected ? remotecwd : "";
updirs = pdirs = 0;
/* option to determine fixed # of dirs from path */
@@ -1189,14 +1224,29 @@ isipv6addr(const char *addr)
/*
- * Internal version of connect(2); sets socket buffer sizes first.
+ * Internal version of connect(2); sets socket buffer sizes first and
+ * handles the syscall being interrupted.
+ * Returns -1 upon failure (with errno set to the problem), or 0 on success.
*/
int
xconnect(int sock, const struct sockaddr *name, int namelen)
{
+ int rv;
setupsockbufsize(sock);
- return (connect(sock, name, namelen));
+ rv = connect(sock, name, namelen);
+ if (rv == -1 && errno == EINTR) {
+ fd_set connfd;
+
+ FD_ZERO(&connfd);
+ FD_SET(sock, &connfd);
+ do {
+ rv = select(sock + 1, NULL, &connfd, NULL, NULL);
+ } while (rv == -1 && errno == EINTR);
+ if (rv > 0)
+ rv = 0;
+ }
+ return (rv);
}
/*
diff --git a/net/tnftp/files/src/version.h b/net/tnftp/files/src/version.h
index 32dc885e7cb..273fb39d6e2 100644
--- a/net/tnftp/files/src/version.h
+++ b/net/tnftp/files/src/version.h
@@ -1,6 +1,6 @@
-/* $NetBSD: version.h,v 1.1.1.1 2003/07/31 07:13:01 lukem Exp $ */
+/* $NetBSD: version.h,v 1.1.1.2 2005/01/03 09:50:10 lukem Exp $ */
/*-
- * Copyright (c) 1999-2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999-2005 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -40,5 +40,5 @@
#endif
#ifndef FTP_VERSION
-#define FTP_VERSION "20030731b"
+#define FTP_VERSION "20050103"
#endif
diff --git a/net/tnftp/files/tnftp.h b/net/tnftp/files/tnftp.h
index 3fdb79c3165..280a9722f02 100644
--- a/net/tnftp/files/tnftp.h
+++ b/net/tnftp/files/tnftp.h
@@ -1,7 +1,7 @@
-/* $Id: tnftp.h,v 1.1.1.1 2003/08/25 11:52:56 lukem Exp $ */
+/* $Id: tnftp.h,v 1.1.1.2 2005/01/03 10:23:21 lukem Exp $ */
#define FTP_PRODUCT "tnftp"
-#define FTP_VERSION "20030825"
+#define FTP_VERSION "20050103"
#include "config.h"