summaryrefslogtreecommitdiffstats
path: root/usr.bin/ncftp
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1994-10-06 23:57:21 +0000
committerpst <pst@FreeBSD.org>1994-10-06 23:57:21 +0000
commite377ba704ad289692f56f53811c3c0ba5d8b670b (patch)
tree7d1f20f72956420770324bd8db0d2494bdad50d5 /usr.bin/ncftp
parent3f5ed875460ccb40d3472af4124034f995a9ce28 (diff)
downloadFreeBSD-src-e377ba704ad289692f56f53811c3c0ba5d8b670b.zip
FreeBSD-src-e377ba704ad289692f56f53811c3c0ba5d8b670b.tar.gz
(a) there's no reason for PASSIVEMODE to be conditionally compiled since it's
controlled by a runtime switch. (b) add '-P' to toggle passive mode from the command line (c) turn on passive mode by default - passive mode ftp works on all but a few servers out there - it's easy to disable - no, standard ftp should not run with passive enabled by default, but that doesn't matter because I've already fixed standard mode ftp to take a switch This really should have been implemented as a ncftp "set" command instead of carrying over the same hack that was done to ftp. I will go back and fix it some day.
Diffstat (limited to 'usr.bin/ncftp')
-rw-r--r--usr.bin/ncftp/Makefile2
-rw-r--r--usr.bin/ncftp/cmds.c11
-rw-r--r--usr.bin/ncftp/cmds.h3
-rw-r--r--usr.bin/ncftp/cmdtab.c5
-rw-r--r--usr.bin/ncftp/defaults.h4
-rw-r--r--usr.bin/ncftp/ftp.c8
-rw-r--r--usr.bin/ncftp/main.c8
7 files changed, 13 insertions, 28 deletions
diff --git a/usr.bin/ncftp/Makefile b/usr.bin/ncftp/Makefile
index a93ff77..5d13f04 100644
--- a/usr.bin/ncftp/Makefile
+++ b/usr.bin/ncftp/Makefile
@@ -7,7 +7,7 @@ DPADD= $(LIBREADLINE) $(LIBTERMCAP)
LDADD= -lreadline -ltermcap
CFLAGS+= -DGZCAT=\"/usr/bin/gzcat\" -DREADLINE -DCURSES -DNO_CURSES_H \
- -DSYSLOG -DTRY_ABOR -DGATEWAY -DPASSIVEMODE
+ -DSYSLOG -DTRY_ABOR -DGATEWAY
MK= $(CC) $(CFLAGS) $(LDADD)
diff --git a/usr.bin/ncftp/cmds.c b/usr.bin/ncftp/cmds.c
index c467c3b..9a9b0fc 100644
--- a/usr.bin/ncftp/cmds.c
+++ b/usr.bin/ncftp/cmds.c
@@ -36,14 +36,12 @@
#include "copyright.h"
/* cmds.c globals */
-#ifdef PASSIVEMODE
-int passivemode = 0;
-#endif
int curtype; /* file transfer type */
char *typeabbrs = "abiet";
str32 curtypename; /* name of file transfer type */
int verbose; /* verbosity level of output */
int mprompt; /* interactively prompt on m* cmds */
+int passivemode; /* use passive ftp connections */
int debug; /* debugging level */
int options; /* used during socket creation */
int macnum; /* number of defined macros */
@@ -2059,10 +2057,6 @@ int show_version(int argc, char **argv)
#ifdef NET_ERRNO_H
DStrs[nDStrs++] = "NET_ERRNO_H";
#endif
-#ifdef PASSIVEMODE
- DStrs[nDStrs++] = "PASSIVEMODE";
-#endif
-
/* DONE with #ifdefs for now! */
@@ -2215,14 +2209,11 @@ int unimpl(int argc, char **argv)
return (NOERR);
} /* unimpl */
-#ifdef PASSIVEMODE
int setpassive(int argc, char **argv)
{
passivemode = !passivemode;
printf( "Passive mode %s.\n", (passivemode ? "ON" : "OFF") );
return NOERR;
}
-#endif
-
/* eof cmds.c */
diff --git a/usr.bin/ncftp/cmds.h b/usr.bin/ncftp/cmds.h
index 11dff6a..05fbe3e 100644
--- a/usr.bin/ncftp/cmds.h
+++ b/usr.bin/ncftp/cmds.h
@@ -121,10 +121,7 @@ int unimpl(int argc, char **argv);
long GetDateSizeFromLSLine(char *fName, unsigned long *mod_time);
long GetDateAndSize(char *fName, unsigned long *mod_time);
int SetTypeByNumber(int i);
-#ifdef PASSIVEMODE
int setpassive(int argc, char **argv);
-#endif
-
/* In util.c: */
void cmd_help(struct cmd *c);
diff --git a/usr.bin/ncftp/cmdtab.c b/usr.bin/ncftp/cmdtab.c
index d4e161f..86d4a5f 100644
--- a/usr.bin/ncftp/cmdtab.c
+++ b/usr.bin/ncftp/cmdtab.c
@@ -90,10 +90,7 @@ Examples:\n\
#define PAGEHELP "view a file on the remote host with your $PAGER"
#define PAGEUSAGE REMOTEFILE
-#ifdef PASSIVEMODE
#define PASSIVEHELP "enter passive transfer mode"
-#endif
-
#define PDIRUSAGE " [flags] [remote-files]"
@@ -191,9 +188,7 @@ struct cmd cmdtab[] = {
{ "ntrans", 0, 1, unimpl, UNIMPLHELP, UNIMPLUSAGE },
{ "open", 0, 0, cmdOpen, OPENHELP, OPENUSAGE },
{ "p", 1, 1, get, PAGEHELP, PAGEUSAGE },
-#ifdef PASSIVEMODE
{ "passive", 0, 0, setpassive, PASSIVEHELP, EMPTYSTR },
-#endif
{ "page", 1, 0, get, PAGEHELP, PAGEUSAGE },
{ "pdir", 1, 0, ls,
"view a remote directory listing (long mode) with your $PAGER",
diff --git a/usr.bin/ncftp/defaults.h b/usr.bin/ncftp/defaults.h
index 2452195..0cbd8c7 100644
--- a/usr.bin/ncftp/defaults.h
+++ b/usr.bin/ncftp/defaults.h
@@ -44,6 +44,10 @@
#define dMPROMPT 0
#endif
+#ifndef dPASSIVE
+#define dPASSIVE 1 /* Works for most folks... */
+#endif
+
#ifndef dVERBOSE /* V_QUIET, V_ERRS, V_TERSE, V_VERBOSE */
#define dVERBOSE V_TERSE
#endif
diff --git a/usr.bin/ncftp/ftp.c b/usr.bin/ncftp/ftp.c
index 71f7abe..d8413ad 100644
--- a/usr.bin/ncftp/ftp.c
+++ b/usr.bin/ncftp/ftp.c
@@ -99,9 +99,7 @@ extern struct userinfo uinfo;
extern struct macel macros[];
extern struct lslist *lshead, *lstail;
extern int is_ls;
-#ifdef PASSIVEMODE
extern int passivemode;
-#endif
#ifdef GATEWAY
extern string gateway;
@@ -1693,14 +1691,11 @@ int initconn(void)
int on = 1, rval;
string str;
Sig_t oldintr;
-#ifdef PASSIVEMODE
int a1, a2, a3, a4, p1, p2;
unsigned char n[6];
-#endif
oldintr = Signal(SIGINT, SIG_IGN);
-#ifdef PASSIVEMODE
if (passivemode) {
data = socket(AF_INET, SOCK_STREAM, 0);
if (data < 0) {
@@ -1750,7 +1745,6 @@ int initconn(void)
rval = 0;
goto Return;
}
-#endif
noport:
data_addr = myctladdr;
@@ -1859,10 +1853,8 @@ dataconn(char *mode)
#ifdef SOCKS
s = Raccept(data, (struct sockaddr *) &from, &fromlen);
#else
-#ifdef PASSIVEMODE
if (passivemode)
return( fdopen( data, mode ));
-#endif
s = Accept(data, &from, &fromlen);
#endif
if (s < 0) {
diff --git a/usr.bin/ncftp/main.c b/usr.bin/ncftp/main.c
index e2f620a..f8dd512 100644
--- a/usr.bin/ncftp/main.c
+++ b/usr.bin/ncftp/main.c
@@ -116,7 +116,7 @@ static char tcbuf[2048];
#endif
/* main.c externs */
-extern int debug, verbose, mprompt;
+extern int debug, verbose, mprompt, passivemode;
extern int options, cpend, data, connected, logged_in;
extern int curtype, macnum, remote_is_unix;
extern FILE *cout;
@@ -175,6 +175,7 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n");
mprompt = dMPROMPT;
debug = dDEBUG;
verbose = dVERBOSE;
+ passivemode = dPASSIVE;
(void) Strncpy(vstr, short_verbose_msgs[verbose+1]);
(void) Strncpy(curtypename, dTYPESTR);
@@ -270,6 +271,10 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n");
++ignore_rc;
break;
+ case 'P':
+ passivemode = !passivemode;
+ break;
+
case 'H':
(void) show_version(0, NULL);
exit (0);
@@ -282,6 +287,7 @@ Program Options:\n\
-H : Show version and compilation information.\n\
-I : Toggle interactive (mprompt) mode.\n\
-N : Toggle reading of the .netrc/.ncftprc.\n\
+ -P : Toggle passive mode ftp (for use behind firewalls).\n\
-V x : Set verbosity to level x (-1,0,1,2).\n\
Open Options:\n\
-a : Open anonymously (this is the default).\n\
OpenPOWER on IntegriCloud