diff options
author | ache <ache@FreeBSD.org> | 1994-12-13 20:43:57 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1994-12-13 20:43:57 +0000 |
commit | 9f8a13aa705bc535d9affa95b8fe27a070166d20 (patch) | |
tree | 8f7bdb2c264c75fdb7f92d60eb01be899ff69647 /usr.bin | |
parent | e4ff209da90b097620cd3e7d66fb01b19c6e5418 (diff) | |
download | FreeBSD-src-9f8a13aa705bc535d9affa95b8fe27a070166d20.zip FreeBSD-src-9f8a13aa705bc535d9affa95b8fe27a070166d20.tar.gz |
Upgrade...
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ncftp/cmds.c | 43 | ||||
-rw-r--r-- | usr.bin/ncftp/cmds.h | 4 | ||||
-rw-r--r-- | usr.bin/ncftp/defaults.h | 12 | ||||
-rw-r--r-- | usr.bin/ncftp/ftprc.c | 5 | ||||
-rw-r--r-- | usr.bin/ncftp/ftprc.h | 2 | ||||
-rw-r--r-- | usr.bin/ncftp/main.c | 31 | ||||
-rw-r--r-- | usr.bin/ncftp/main.h | 2 | ||||
-rw-r--r-- | usr.bin/ncftp/ncftp.1 | 3 | ||||
-rw-r--r-- | usr.bin/ncftp/open.c | 7 | ||||
-rw-r--r-- | usr.bin/ncftp/patchlevel.h | 4 | ||||
-rw-r--r-- | usr.bin/ncftp/sys.h | 6 |
11 files changed, 80 insertions, 39 deletions
diff --git a/usr.bin/ncftp/cmds.c b/usr.bin/ncftp/cmds.c index c19cf0c..d576803 100644 --- a/usr.bin/ncftp/cmds.c +++ b/usr.bin/ncftp/cmds.c @@ -1,8 +1,8 @@ /* cmds.c */ /* $RCSfile: cmds.c,v $ - * $Revision: 14020.14 $ - * $Date: 93/07/09 11:31:53 $ + * $Revision: 1.1.1.1 $ + * $Date: 1994/09/22 23:45:33 $ */ #include "sys.h" @@ -37,7 +37,7 @@ /* cmds.c globals */ #ifdef PASSIVEMODE -int passivemode = 1; +int passivemode; /* no reverse FTP connections */ #endif int curtype; /* file transfer type */ char *typeabbrs = "abiet"; @@ -594,6 +594,7 @@ int mget(int argc, char **argv) char *cp; longstring local; Sig_t oldintr; + int errs; if (argc < 2) argv = re_makeargv("(remote-files) ", &argc); @@ -604,7 +605,7 @@ int mget(int argc, char **argv) activemcmd = 1; oldintr = Signal(SIGINT, mabort); (void) setjmp(jabort); - while ((cp = remglob(argv)) != NULL) { + while ((cp = remglob(argv, &errs)) != NULL) { if (*cp == '\0') { activemcmd = 0; continue; @@ -621,19 +622,22 @@ int mget(int argc, char **argv) } (void) Signal(SIGINT,oldintr); activemcmd = 0; + if (!errs) return NOERR; + else + return CMDERR; } /* mget */ -char *remglob(char *argv[]) +char *remglob(char *argv[], int *errs) { static FILE *ftemp = NULL; int oldverbose, i; char *cp, *mode; static string tmpname, str; - int result, errs; + int result; if (!activemcmd) { xx: @@ -647,7 +651,7 @@ xx: if (ftemp == NULL) { (void) tmp_name(tmpname); oldverbose = verbose, verbose = V_QUIET; - errs = 0; + *errs = 0; for (mode = "w", i=1; argv[i] != NULL; i++, mode = "a") { result = recvrequest ("NLST", tmpname, argv[i], mode); if (i == 1) @@ -658,11 +662,11 @@ xx: (strpbrk(argv[i], globchars) != NULL) ? "No match" : "No such file" ); - errs++; + ++(*errs); } } verbose = oldverbose; - if (errs == (i - 1)) { + if (*errs == (i - 1)) { /* Every pattern was in error, so we can't try anything. */ (void) unlink(tmpname); /* Shouldn't be there anyway. */ return NULL; @@ -876,6 +880,7 @@ int mdelete(int argc, char **argv) char *cp; Sig_t oldintr; string str; + int errs; if (argc < 2) argv = re_makeargv("(remote-files) ", &argc); @@ -886,7 +891,7 @@ int mdelete(int argc, char **argv) activemcmd = 1; oldintr = Signal(SIGINT, mabort); (void) setjmp(jabort); - while ((cp = remglob(argv)) != NULL) { + while ((cp = remglob(argv, &errs)) != NULL) { if (*cp == '\0') { activemcmd = 0; continue; @@ -903,6 +908,8 @@ int mdelete(int argc, char **argv) } (void) Signal(SIGINT, oldintr); activemcmd = 0; + if (errs > 0) + return CMDERR; return NOERR; } /* mdelete */ @@ -1282,9 +1289,12 @@ int rmthelp(int argc, char **argv) /*ARGSUSED*/ int quit(int argc, char **argv) { - close_up_shop(); + int rc; + + /* slightly kludge. argc == -1 means failure from some other caller */ + rc = close_up_shop() || argc == -1; trim_log(); - exit(0); + exit(rc); } /* quit */ @@ -1331,19 +1341,22 @@ int disconnect(int argc, char **argv) -void +int close_up_shop(void) { static int only_once = 0; + int rcode = 0; + if (only_once++ > 0) - return; + return (0); if (connected) (void) disconnect(0, NULL); - WriteRecentSitesFile(); + rcode = WriteRecentSitesFile(); if (logf != NULL) { (void) fclose(logf); logf = NULL; } + return rcode; } /* close_up_shop */ diff --git a/usr.bin/ncftp/cmds.h b/usr.bin/ncftp/cmds.h index fe1cacc..11dff6a 100644 --- a/usr.bin/ncftp/cmds.h +++ b/usr.bin/ncftp/cmds.h @@ -77,7 +77,7 @@ int rem_glob_one(char *pattern); int get(int argc, char **argv); void mabort SIG_PARAMS; int mget(int argc, char **argv); -char *remglob(char *argv[]); +char *remglob(char *argv[], int *); int setverbose(int argc, char **argv); int setprompt(int argc, char **argv); int setdebug(int argc, char **argv); @@ -100,7 +100,7 @@ int rmthelp(int argc, char **argv); int quit(int argc, char **argv); void close_streams(int wantShutDown); int disconnect(int argc, char **argv); -void close_up_shop(void); +int close_up_shop(void); int globulize(char **cpp); int cdup(int argc, char **argv); int syst(int argc, char **argv); diff --git a/usr.bin/ncftp/defaults.h b/usr.bin/ncftp/defaults.h index 2452195..f3fbb08 100644 --- a/usr.bin/ncftp/defaults.h +++ b/usr.bin/ncftp/defaults.h @@ -44,6 +44,18 @@ #define dMPROMPT 0 #endif +#ifndef PASSIVEMODE +#define PASSIVEMODE 1 +#endif + +/* If passive FTP can be used, this specifies whether it is turned on + * by default. If not, we have passive mode available, but are using + * Port ftp by default. + */ +#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/ftprc.c b/usr.bin/ncftp/ftprc.c index e8380ce..c048852 100644 --- a/usr.bin/ncftp/ftprc.c +++ b/usr.bin/ncftp/ftprc.c @@ -258,11 +258,12 @@ static void SortRecentList(void) -void WriteRecentSitesFile(void) +int WriteRecentSitesFile(void) { FILE *rfp; recentsite *r; int i; + int retcode = 0; if ((recent_file[0] != 0) && (nRecents > 0) && (keep_recent)) { dbprintf("Attempting to write %s...\n", recent_file); @@ -279,8 +280,10 @@ void WriteRecentSitesFile(void) (void) chmod(recent_file, 0600); } else { perror(recent_file); + ++retcode; } } + return retcode; } /* WriteRecentSitesFile */ diff --git a/usr.bin/ncftp/ftprc.h b/usr.bin/ncftp/ftprc.h index 14eec88..eed0217 100644 --- a/usr.bin/ncftp/ftprc.h +++ b/usr.bin/ncftp/ftprc.h @@ -30,7 +30,7 @@ void AddNewSitePtr(char *word); int ruserpass2(char *host, char **user, char **pass, char **acct); void GetFullSiteName(char *host, char *lastdir); void ReadRecentSitesFile(void); -void WriteRecentSitesFile(void); +int WriteRecentSitesFile(void); void AddRecentSite(char *host, char *lastdir); void UpdateRecentSitesList(char *host, char *lastdir); void PrintSiteList(void); diff --git a/usr.bin/ncftp/main.c b/usr.bin/ncftp/main.c index d51d384..9fdfc06 100644 --- a/usr.bin/ncftp/main.c +++ b/usr.bin/ncftp/main.c @@ -1,13 +1,8 @@ -/* main.c - * - * $RCSfile: main.c,v $ - * $Revision: 14020.15 $ - * $Date: 93/07/09 11:50:12 $ - */ +/* main.c */ #define _main_c_ -#define FTP_VERSION "1.8.6 (Octboer 30, 1994)" +#define FTP_VERSION "1.8.7 (December 11, 1994)" /* #define BETA 1 */ /* If defined, it prints a little warning message. */ @@ -116,7 +111,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 +170,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); @@ -234,7 +230,7 @@ Re-compile, this time with -DZCAT=\\\"/path/to/zcat\\\".\n"); ignore_rc = 0; (void) strcpy(oline, "open "); - while ((opt = Getopt(argc, argv, "D:V:INRHaicmup:rd:g:")) >= 0) { + while ((opt = Getopt(argc, argv, "D:V:INPRHaicmup:rd:g:")) >= 0) { switch(opt) { case 'a': case 'c': @@ -270,6 +266,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 +282,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\ @@ -390,7 +391,8 @@ For testing purposes only. Do not re-distribute or subject to novice users." (void) Signal(SIGPIPE, lostpeer); } for (;;) { - (void) cmdscanner(top); + if (cmdscanner(top)) + exit(1); top = 1; } } /* main */ @@ -569,9 +571,10 @@ void lostpeer SIG_PARAMS /* * Command parser. */ -void cmdscanner(int top) +int cmdscanner(int top) { register struct cmd *c; + int cmd_status, rcode = 0; if (!top) (void) putchar('\n'); @@ -601,13 +604,17 @@ void cmdscanner(int top) (void) printf ("Not connected.\n"); continue; } - if ((*c->c_handler)(margc, margv) == USAGE) + cmd_status = (*c->c_handler)(margc, margv); + if (cmd_status == USAGE) cmd_usage(c); + else if (cmd_status == CMDERR) + rcode = 1; if (c->c_handler != help) break; } (void) Signal(SIGINT, intr); (void) Signal(SIGPIPE, lostpeer); + return rcode; } /* cmdscanner */ diff --git a/usr.bin/ncftp/main.h b/usr.bin/ncftp/main.h index 1891b61..fd6438c 100644 --- a/usr.bin/ncftp/main.h +++ b/usr.bin/ncftp/main.h @@ -22,7 +22,7 @@ int init_arrays(void); void init_transfer_buffer(void); void init_prompt(void); void lostpeer SIG_PARAMS; -void cmdscanner(int top); +int cmdscanner(int top); char *strprompt(void); void makeargv(void); char *slurpstring(void); diff --git a/usr.bin/ncftp/ncftp.1 b/usr.bin/ncftp/ncftp.1 index 37cf474..8eaf758 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 diff --git a/usr.bin/ncftp/open.c b/usr.bin/ncftp/open.c index 66733a8..fbbe794 100644 --- a/usr.bin/ncftp/open.c +++ b/usr.bin/ncftp/open.c @@ -399,6 +399,7 @@ void CheckRemoteSystemType(int force_binary) void ColonMode(OpenOptions *openopt) { int tmpverbose; + int cmdstatus; /* How do we tell if colonmodepath is a file or a directory? * We first try cd'ing to the path first. If we can, then it @@ -437,15 +438,15 @@ void ColonMode(OpenOptions *openopt) /* get() also handles 'more'. */ if (openopt->ftpcat) - (void) get(margc, margv); + cmdstatus = get(margc, margv); else - (void) mget(margc, margv); + cmdstatus = mget(margc, margv); /* If we were invoked from the command line, quit * after we got this file. */ if (eventnumber == 0L) { - (void) quit(0, NULL); + (void) quit(cmdstatus == CMDERR ? -1 : 0, NULL); } } verbose = tmpverbose; diff --git a/usr.bin/ncftp/patchlevel.h b/usr.bin/ncftp/patchlevel.h index 60d128a..3b2259f 100644 --- a/usr.bin/ncftp/patchlevel.h +++ b/usr.bin/ncftp/patchlevel.h @@ -1,3 +1,7 @@ +v1.8.7 - December 11, 1994. Tweaks for FreeBSD. Passive mode enabled and + turned on by default. This should be the last version of ncftp before + version 2. + v1.8.6 - October 30, 1994. Tweaks for Solaris in sys.h. v1.8.5 - September 20, 1994. Better(?) support for term. diff --git a/usr.bin/ncftp/sys.h b/usr.bin/ncftp/sys.h index 372640c..e4b6d55 100644 --- a/usr.bin/ncftp/sys.h +++ b/usr.bin/ncftp/sys.h @@ -398,12 +398,10 @@ extern int errno; # endif #endif /* BSDi */ -#ifdef __386BSD__ -# ifdef __FreeBSD__ +#ifdef __FreeBSD__ # define System "FreeBSD" # define GZCAT "/usr/bin/gzcat" # define HAS_DOMAINNAME 1 -# endif # include <sys/types.h> # include <sys/param.h> /* this two for BSD definition */ /* to avoid redefinition of it to 1 */ @@ -415,7 +413,7 @@ extern int errno; #endif #ifdef BSD -# ifndef __386BSD__ +# ifndef __FreeBSD__ # ifndef SYSDIRH # define SYSDIRH 1 # endif |