aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-12-13 20:43:57 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-12-13 20:43:57 +0000
commit5d9b1b20cbb0bf76d66eaef20b9d67e57b0ebae1 (patch)
tree0240080dd589edea4070e7558d6ff569f924a41a
parent39ac25d619f7c339f8dd118cd40c7fd3fbdf2618 (diff)
downloadsrc-5d9b1b20cbb0bf76d66eaef20b9d67e57b0ebae1.tar.gz
src-5d9b1b20cbb0bf76d66eaef20b9d67e57b0ebae1.zip
Notes
Notes: svn path=/vendor/ncftp/dist/; revision=5093 svn path=/vendor/ncftp/1.8.7/; revision=5095; tag=vendor/ncftp/1.8.7
-rw-r--r--usr.bin/ncftp/cmds.c43
-rw-r--r--usr.bin/ncftp/cmds.h4
-rw-r--r--usr.bin/ncftp/defaults.h12
-rw-r--r--usr.bin/ncftp/ftprc.c5
-rw-r--r--usr.bin/ncftp/ftprc.h2
-rw-r--r--usr.bin/ncftp/main.c31
-rw-r--r--usr.bin/ncftp/main.h2
-rw-r--r--usr.bin/ncftp/ncftp.13
-rw-r--r--usr.bin/ncftp/open.c7
-rw-r--r--usr.bin/ncftp/patchlevel.h4
-rw-r--r--usr.bin/ncftp/sys.h6
11 files changed, 80 insertions, 39 deletions
diff --git a/usr.bin/ncftp/cmds.c b/usr.bin/ncftp/cmds.c
index c19cf0c61f2d..d576803ea19f 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 fe1cacc494b2..11dff6acc06d 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 24521959c3cc..f3fbb0814cda 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 e8380cef6e0e..c048852f16fd 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 14eec88ad860..eed0217ea721 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 d51d384e8cf2..9fdfc06ec0a5 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 1891b61d77c6..fd6438c38549 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 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
diff --git a/usr.bin/ncftp/open.c b/usr.bin/ncftp/open.c
index 66733a88ec9c..fbbe7945f7dd 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 60d128ae47c2..3b2259fd606f 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 372640cdcd19..e4b6d55f8f0d 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