From 1dcd7de0c3060a25cf1885141646d5f48842acd0 Mon Sep 17 00:00:00 2001 From: Paul Traina Date: Thu, 29 Sep 1994 20:55:25 +0000 Subject: [PATCH] Add -p flag and pftp alias for passive ftp --- usr.bin/ftp/Makefile | 2 ++ usr.bin/ftp/ftp.1 | 3 +++ usr.bin/ftp/main.c | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/usr.bin/ftp/Makefile b/usr.bin/ftp/Makefile index fbb5a9189bdc..dc8197fb2b68 100644 --- a/usr.bin/ftp/Makefile +++ b/usr.bin/ftp/Makefile @@ -2,5 +2,7 @@ PROG= ftp SRCS= cmds.c cmdtab.c ftp.c main.c ruserpass.c domacro.c +LINKS= ${BINDIR}/ftp ${BINDIR}/pftp +MLINKS= ftp.1 pftp.1 .include diff --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1 index 417da08d4446..47904077b2c4 100644 --- a/usr.bin/ftp/ftp.1 +++ b/usr.bin/ftp/ftp.1 @@ -45,6 +45,7 @@ file transfer program .Op Fl d .Op Fl i .Op Fl n +.Op Fl p .Op Fl g .Op Ar host .Sh DESCRIPTION @@ -85,6 +86,8 @@ multiple file transfers. Enables debugging. .It Fl g Disables file name globbing. +.It Fl p +Enable passive mode operation for use behind connection filtering firewalls. .El .Pp The client host with which diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 52a95b03d93a..0edff5ee1473 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -58,6 +58,7 @@ static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 4/3/94"; #include #include #include +#include #include "ftp_var.h" @@ -76,8 +77,14 @@ main(argc, argv) doglob = 1; interactive = 1; autologin = 1; + passivemode = 0; - while ((ch = getopt(argc, argv, "dgintv")) != EOF) { + cp = strrchr(argv[0], '/'); + cp = (cp == NULL) ? argv[0] : cp+1; + if (strcmp(cp, "pftp") == 0) + passivemode = 1; + + while ((ch = getopt(argc, argv, "dginptv")) != EOF) { switch (ch) { case 'd': options |= SO_DEBUG; @@ -96,6 +103,10 @@ main(argc, argv) autologin = 0; break; + case 'p': + passivemode = 1; + break; + case 't': trace++; break; @@ -106,7 +117,7 @@ main(argc, argv) default: (void)fprintf(stderr, - "usage: ftp [-dgintv] [host [port]]\n"); + "usage: ftp [-dginptv] [host [port]]\n"); exit(1); } } @@ -118,7 +129,6 @@ main(argc, argv) verbose++; cpend = 0; /* no pending replies */ proxy = 0; /* proxy not active */ - passivemode = 0;/* passive mode not active */ crflag = 1; /* strip c.r. on ascii gets */ sendport = -1; /* not using ports */ /*