summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-06-05 16:44:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-06-05 16:44:02 +0000
commitcb801a7b401559cc77722f53dd56c33f145d7e01 (patch)
treea61c7711d06252d0cd01178c58747b2f9323ec3d /gnu
parentd7262d84a62c3c5643680cd3300195bd2c95f93b (diff)
default to passive, upgrade to active as needed; Andrew Basterfield
list@lostgeneration.freeserve.co.uk
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/lynx/WWW/Library/Implementation/HTFTP.c6
-rw-r--r--gnu/usr.bin/lynx/WWW/Library/Implementation/HTFile.c17
-rw-r--r--gnu/usr.bin/lynx/lynx.cfg5
-rw-r--r--gnu/usr.bin/lynx/src/LYGlobalDefs.h2
-rw-r--r--gnu/usr.bin/lynx/src/LYMain.c8
-rw-r--r--gnu/usr.bin/lynx/userdefs.h2
6 files changed, 32 insertions, 8 deletions
diff --git a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFTP.c b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFTP.c
index 7924b0bacdc..87729de3d7c 100644
--- a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFTP.c
+++ b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFTP.c
@@ -2570,7 +2570,7 @@ PUBLIC int HTFTPLoad ARGS4(
if (status < 0)
return status;
- if (!ftp_passive) {
+ if (!ftp_local_passive) {
status = get_listen_socket();
if (status < 0) {
NETCLOSE (control->socket);
@@ -3133,7 +3133,7 @@ PUBLIC int HTFTPLoad ARGS4(
}
listen:
- if (!ftp_passive) {
+ if (!ftp_local_passive) {
/* Wait for the connection */
struct sockaddr_in soc_address;
int soc_addrlen=sizeof(soc_address);
@@ -3153,7 +3153,7 @@ listen:
}
CTRACE(tfp, "TCP: Accepted new socket %d\n", status);
data_soc = status;
- } /* !ftp_passive */
+ } /* !ftp_local_passive */
if (isDirectory) {
status = read_directory (anchor, name, format_out, sink);
diff --git a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFile.c b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFile.c
index f0b294e7952..35d77ea679a 100644
--- a/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFile.c
+++ b/gnu/usr.bin/lynx/WWW/Library/Implementation/HTFile.c
@@ -1848,6 +1848,7 @@ PUBLIC int HTLoadFile ARGS4(
{
char * filename = NULL;
char * acc_method = NULL;
+ char * ftp_newhost;
HTFormat format;
char * nodename = NULL;
char * newname = NULL; /* Simplified name of file */
@@ -1886,7 +1887,21 @@ PUBLIC int HTLoadFile ARGS4(
FREE(nodename);
FREE(acc_method);
#ifndef DISABLE_FTP
- return HTFTPLoad(addr, anchor, format_out, sink);
+ ftp_newhost = HTParse(addr, "", PARSE_HOST); /* HTParse mallocs */
+ if (strcmp(ftp_lasthost, ftp_newhost))
+ ftp_local_passive = ftp_passive; /* set to default */
+
+ status = HTFTPLoad(addr, anchor, format_out, sink);
+
+ if ( ftp_passive == ftp_local_passive ) {
+ if (( status <= -4 ) || ( status == -1 )) {
+ ftp_local_passive = !ftp_passive;
+ status = HTFTPLoad(addr, anchor, format_out, sink);
+ }
+ }
+ free(ftp_lasthost);
+ ftp_lasthost = ftp_newhost;
+ return status;
#else
return -1;
#endif /* DISABLE_FTP */
diff --git a/gnu/usr.bin/lynx/lynx.cfg b/gnu/usr.bin/lynx/lynx.cfg
index 236d474b76c..1dd7da86a41 100644
--- a/gnu/usr.bin/lynx/lynx.cfg
+++ b/gnu/usr.bin/lynx/lynx.cfg
@@ -2095,6 +2095,5 @@ MINIMAL_COMMENTS:TRUE
#HTMLSRC_TAGNAME_XFORM:2
#HTMLSRC_ATTRNAME_XFORM:2
-# Set FTP_PASSIVE to TRUE if you want to use passive mode ftp transfers.
-# You might have to do this if you're behind a restrictive firewall.
-#FTP_PASSIVE:FALSE
+# Set FTP_PASSIVE to FALSE if you want to use active mode ftp transfers.
+#FTP_PASSIVE:TRUE
diff --git a/gnu/usr.bin/lynx/src/LYGlobalDefs.h b/gnu/usr.bin/lynx/src/LYGlobalDefs.h
index 40e7c51ab3e..c25136ecf91 100644
--- a/gnu/usr.bin/lynx/src/LYGlobalDefs.h
+++ b/gnu/usr.bin/lynx/src/LYGlobalDefs.h
@@ -170,6 +170,8 @@ extern BOOLEAN telnet_ok;
extern BOOLEAN news_ok;
extern BOOLEAN ftp_ok;
extern BOOLEAN ftp_passive; /* TRUE if we want to use passive mode ftp */
+extern BOOLEAN ftp_local_passive;
+extern char *ftp_lasthost;
extern BOOLEAN rlogin_ok;
extern BOOLEAN system_editor; /* True if locked-down editor */
extern BOOLEAN child_lynx; /* TRUE to exit with an arrow */
diff --git a/gnu/usr.bin/lynx/src/LYMain.c b/gnu/usr.bin/lynx/src/LYMain.c
index 27cc9e4a6fc..136bc6c5890 100644
--- a/gnu/usr.bin/lynx/src/LYMain.c
+++ b/gnu/usr.bin/lynx/src/LYMain.c
@@ -168,6 +168,8 @@ PUBLIC BOOLEAN LYJumpFileURL = FALSE; /* always FALSE the first time */
PUBLIC BOOLEAN jump_buffer = JUMPBUFFER; /* TRUE if offering default shortcut */
PUBLIC BOOLEAN goto_buffer = GOTOBUFFER; /* TRUE if offering default goto URL */
PUBLIC BOOLEAN ftp_passive = FTP_PASSIVE; /* TRUE if doing ftp in passive mode */
+PUBLIC BOOLEAN ftp_local_passive; /* TRUE for PASV for this server only */
+PUBLIC char *ftp_lasthost; /* host of last ftp transaction */
PUBLIC BOOLEAN recent_sizechange = FALSE;/* the window size changed recently? */
PUBLIC int user_mode = NOVICE_MODE;
PUBLIC BOOLEAN dump_output_immediately = FALSE;
@@ -664,6 +666,12 @@ PUBLIC int main ARGS2(
char filename[LY_MAXPATH];
BOOL LYGetStdinArgs = FALSE;
+#ifndef DISABLE_FTP
+ /* malloc a sizeof(char) so 1st strcmp() won't dump in HTLoadFile() */
+ ftp_lasthost = (char *)malloc(sizeof(char));
+ *ftp_lasthost = NULL;
+#endif /* DISABLE_FTP */
+
#ifdef NOT_ASCII
FixCharacters();
#endif /* NOT_ASCII */
diff --git a/gnu/usr.bin/lynx/userdefs.h b/gnu/usr.bin/lynx/userdefs.h
index b6bda1c9cdd..a8fd721a3c1 100644
--- a/gnu/usr.bin/lynx/userdefs.h
+++ b/gnu/usr.bin/lynx/userdefs.h
@@ -498,7 +498,7 @@
* If FTP_PASSIVE is set to TRUE here or in lynx.cfg, ftp transfers will
* be done in passive mode.
*/
-#define FTP_PASSIVE FALSE
+#define FTP_PASSIVE TRUE
/*****************************
* JUMPFILE is the default local file checked for shortcut URLs when