summaryrefslogtreecommitdiff
path: root/usr.bin/ftp/main.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-12-17 16:03:06 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-12-17 16:03:06 +0000
commitc8f9924fcf1891ef48d930a33d2431230b65d1d4 (patch)
tree808da54b7316669f53251a4aed099cdaf7fab195 /usr.bin/ftp/main.c
parent8cea511de8022ef4c932d0936bb1b9e3fad5a4d4 (diff)
By default, use passive mode and fall back to active as needed.
The user can specify active only with the -A flag, or use the new FTPMODE envariable.
Diffstat (limited to 'usr.bin/ftp/main.c')
-rw-r--r--usr.bin/ftp/main.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c
index f9ae7bbf942..b09fc7aaba0 100644
--- a/usr.bin/ftp/main.c
+++ b/usr.bin/ftp/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.36 1997/09/04 04:37:16 millert Exp $ */
+/* $OpenBSD: main.c,v 1.37 1997/12/17 16:03:05 millert Exp $ */
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.36 1997/09/04 04:37:16 millert Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.37 1997/12/17 16:03:05 millert Exp $";
#endif
#endif /* not lint */
@@ -110,7 +110,8 @@ main(argc, argv)
doglob = 1;
interactive = 1;
autologin = 1;
- passivemode = 0;
+ passivemode = 1;
+ activefallback = 1;
preserve = 1;
verbose = 0;
progress = 0;
@@ -123,20 +124,32 @@ main(argc, argv)
mark = HASHBYTES;
marg_sl = sl_init();
- cp = strrchr(argv[0], '/');
- cp = (cp == NULL) ? argv[0] : cp + 1;
- if (strcmp(cp, "pftp") == 0)
- passivemode = 1;
- else if (strcmp(cp, "gate-ftp") == 0)
- gatemode = 1;
+ /* Set default operation mode based on FTPMODE environment variable */
+ if ((cp = getenv("FTPMODE")) != NULL) {
+ if (strcmp(cp, "passive") == 0) {
+ passivemode = 1;
+ activefallback = 0;
+ } else if (strcmp(cp, "active") == 0) {
+ passivemode = 0;
+ activefallback = 0;
+ } else if (strcmp(cp, "gate") == 0) {
+ gatemode = 1;
+ } else if (strcmp(cp, "auto") == 0) {
+ passivemode = 1;
+ activefallback = 1;
+ } else
+ warnx("unknown FTPMODE: %s. Using defaults", cp);
+ }
+ if (strcmp(__progname, "gate-ftp") == 0)
+ gatemode = 1;
gateserver = getenv("FTPSERVER");
if (gateserver == NULL || *gateserver == '\0')
gateserver = GATE_SERVER;
if (gatemode) {
if (*gateserver == '\0') {
warnx(
-"Neither $FTPSERVER nor GATE_SERVER is defined; disabling gate-ftp");
+"Neither $FTPSERVER nor $GATE_SERVER is defined; disabling gate-ftp");
gatemode = 0;
}
}
@@ -162,8 +175,13 @@ main(argc, argv)
ttyout = stderr;
}
- while ((ch = getopt(argc, argv, "adeginpPr:tvV")) != -1) {
+ while ((ch = getopt(argc, argv, "AadeginpPr:tvV")) != -1) {
switch (ch) {
+ case 'A':
+ activefallback = 0;
+ passivemode = 0;
+ break;
+
case 'a':
anonftp = 1;
break;
@@ -193,6 +211,7 @@ main(argc, argv)
case 'p':
passivemode = 1;
+ activefallback = 0;
break;
case 'P':