From d456d8f48d7d76f450ee5299193ba604a20d44de Mon Sep 17 00:00:00 2001 From: Paul Traina Date: Fri, 7 Oct 1994 07:48:18 +0000 Subject: [PATCH] Back out the fluff, leave the meat --- usr.bin/ncftp/Makefile | 2 +- usr.bin/ncftp/cmds.c | 11 ++++++++++- usr.bin/ncftp/cmds.h | 3 +++ usr.bin/ncftp/cmdtab.c | 5 +++++ usr.bin/ncftp/ftp.c | 8 ++++++++ usr.bin/ncftp/ncftp.1 | 3 +++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/usr.bin/ncftp/Makefile b/usr.bin/ncftp/Makefile index 5d13f0403aac..a93ff773566d 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 + -DSYSLOG -DTRY_ABOR -DGATEWAY -DPASSIVEMODE MK= $(CC) $(CFLAGS) $(LDADD) diff --git a/usr.bin/ncftp/cmds.c b/usr.bin/ncftp/cmds.c index 9a9b0fc6086a..8b82152d5927 100644 --- a/usr.bin/ncftp/cmds.c +++ b/usr.bin/ncftp/cmds.c @@ -36,12 +36,14 @@ #include "copyright.h" /* cmds.c globals */ +#ifdef PASSIVEMODE +int passivemode; /* no reverse FTP connections */ +#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 */ @@ -2057,6 +2059,10 @@ 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! */ @@ -2209,11 +2215,14 @@ 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 05fbe3e07a1e..11dff6acc06d 100644 --- a/usr.bin/ncftp/cmds.h +++ b/usr.bin/ncftp/cmds.h @@ -121,7 +121,10 @@ 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 86d4a5fce9b7..d4e161f3fcc5 100644 --- a/usr.bin/ncftp/cmdtab.c +++ b/usr.bin/ncftp/cmdtab.c @@ -90,7 +90,10 @@ 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]" @@ -188,7 +191,9 @@ 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/ftp.c b/usr.bin/ncftp/ftp.c index d8413adb12bb..71f7abe2b5c2 100644 --- a/usr.bin/ncftp/ftp.c +++ b/usr.bin/ncftp/ftp.c @@ -99,7 +99,9 @@ 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; @@ -1691,11 +1693,14 @@ 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) { @@ -1745,6 +1750,7 @@ int initconn(void) rval = 0; goto Return; } +#endif noport: data_addr = myctladdr; @@ -1853,8 +1859,10 @@ 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/ncftp.1 b/usr.bin/ncftp/ncftp.1 index 37cf474748e2..8eaf7584a409 100644 --- a/usr.bin/ncftp/ncftp.1 +++ b/usr.bin/ncftp/ncftp.1 @@ -1257,6 +1257,9 @@ disables reading of the RC file; this is provided for compatibility with .RB `` "ftp \-n" ''. .TP +.B \-P +toggle passive mode (defaults to on). Useful for work behind firewalls. +.TP .BI \-V " x" sets verbosity to level .I x