summaryrefslogtreecommitdiffstats
path: root/usr.bin/ftp/ruserpass.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1997-06-25 08:56:46 +0000
committermsmith <msmith@FreeBSD.org>1997-06-25 08:56:46 +0000
commit89334bc82c5b7ad1189c9a5fd805f53e80ad65b1 (patch)
treeda509a34c25bd98d42aa22dab0f6cd5363f3c6a8 /usr.bin/ftp/ruserpass.c
parent556be62658f72a2060b34dc2e2d5ec070e75dd41 (diff)
downloadFreeBSD-src-89334bc82c5b7ad1189c9a5fd805f53e80ad65b1.zip
FreeBSD-src-89334bc82c5b7ad1189c9a5fd805f53e80ad65b1.tar.gz
Import substantial improvements to ftp(1) from NetBSD, largely the
work of Luke Mewburn. This includes, but is not limited to : - commandline editing and history. - local and remote filename completion. - a new progress display. - the ability to access files using either the ftp or http protocols, and use http proxies for ftp transfers. The FreeeBSD "restricted ports" functionality was preserved. Obtained from: NetBSD
Diffstat (limited to 'usr.bin/ftp/ruserpass.c')
-rw-r--r--usr.bin/ftp/ruserpass.c57
1 files changed, 39 insertions, 18 deletions
diff --git a/usr.bin/ftp/ruserpass.c b/usr.bin/ftp/ruserpass.c
index 85a190e..315cd79 100644
--- a/usr.bin/ftp/ruserpass.c
+++ b/usr.bin/ftp/ruserpass.c
@@ -1,3 +1,6 @@
+/* $Id$ */
+/* $NetBSD: ruserpass.c,v 1.13 1997/04/01 14:20:34 mrg Exp $ */
+
/*
* Copyright (c) 1985, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -32,7 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94";
+#if 0
+static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
+#else
+static char rcsid[] = "$Id$";
+#endif
#endif /* not lint */
#include <sys/types.h>
@@ -77,7 +84,8 @@ static struct toktab {
int
ruserpass(host, aname, apass, aacct)
- char *host, **aname, **apass, **aacct;
+ const char *host;
+ char **aname, **apass, **aacct;
{
char *hdir, buf[BUFSIZ], *tmp;
char myname[MAXHOSTNAMELEN], *mydomain;
@@ -87,7 +95,12 @@ ruserpass(host, aname, apass, aacct)
hdir = getenv("HOME");
if (hdir == NULL)
hdir = ".";
- (void) snprintf(buf, sizeof(buf), "%s/.netrc", hdir);
+ if (strlen(hdir) + sizeof(".netrc") < sizeof(buf)) {
+ (void)snprintf(buf, sizeof buf, "%s/.netrc", hdir);
+ } else {
+ warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
+ return (0);
+ }
cfile = fopen(buf, "r");
if (cfile == NULL) {
if (errno != ENOENT)
@@ -136,8 +149,9 @@ next:
case LOGIN:
if (token())
if (*aname == 0) {
- *aname = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*aname, tokval);
+ *aname = malloc((unsigned)
+ strlen(tokval) + 1);
+ (void)strcpy(*aname, tokval);
} else {
if (strcmp(*aname, tokval))
goto next;
@@ -153,7 +167,7 @@ next:
}
if (token() && *apass == 0) {
*apass = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*apass, tokval);
+ (void)strcpy(*apass, tokval);
}
break;
case ACCOUNT:
@@ -165,21 +179,24 @@ next:
}
if (token() && *aacct == 0) {
*aacct = malloc((unsigned) strlen(tokval) + 1);
- (void) strcpy(*aacct, tokval);
+ (void)strcpy(*aacct, tokval);
}
break;
case MACDEF:
if (proxy) {
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (0);
}
- while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t');
+ while ((c=getc(cfile)) != EOF)
+ if (c != ' ' && c != '\t')
+ break;
if (c == EOF || c == '\n') {
- printf("Missing macdef name argument.\n");
+ puts("Missing macdef name argument.");
goto bad;
}
if (macnum == 16) {
- printf("Limit of 16 macros have already been defined\n");
+ puts(
+"Limit of 16 macros have already been defined.");
goto bad;
}
tmp = macros[macnum].mac_name;
@@ -189,7 +206,8 @@ next:
*tmp++ = c;
}
if (c == EOF) {
- printf("Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
*tmp = '\0';
@@ -197,19 +215,22 @@ next:
while ((c=getc(cfile)) != EOF && c != '\n');
}
if (c == EOF) {
- printf("Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
if (macnum == 0) {
macros[macnum].mac_start = macbuf;
}
else {
- macros[macnum].mac_start = macros[macnum-1].mac_end + 1;
+ macros[macnum].mac_start =
+ macros[macnum-1].mac_end + 1;
}
tmp = macros[macnum].mac_start;
while (tmp != macbuf + 4096) {
if ((c=getc(cfile)) == EOF) {
- printf("Macro definition missing null line terminator.\n");
+ puts(
+"Macro definition missing null line terminator.");
goto bad;
}
*tmp = c;
@@ -223,7 +244,7 @@ next:
tmp++;
}
if (tmp == macbuf + 4096) {
- printf("4K macro buffer exceeded\n");
+ puts("4K macro buffer exceeded.");
goto bad;
}
break;
@@ -234,10 +255,10 @@ next:
goto done;
}
done:
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (0);
bad:
- (void) fclose(cfile);
+ (void)fclose(cfile);
return (-1);
}
OpenPOWER on IntegriCloud