--- lynx2-8-2/WWW/Library/Implementation/HTFTP.c.passive Mon Jan 31 13:20:57 2000 +++ lynx2-8-2/WWW/Library/Implementation/HTFTP.c Mon Jan 31 13:20:57 2000 @@ -38,11 +38,6 @@ ** and code to parse dates and sizes on most hosts. ** 27 Mar 93 (FM) Added code for getting dates and sizes on VMS hosts. ** -** Options: -** LISTEN We listen, the other guy connects for data. -** Otherwise, other way round, but problem finding our -** internet address! -** ** Notes: ** Portions Copyright 1994 Trustees of Dartmouth College ** Code for recognizing different FTP servers and @@ -52,15 +47,6 @@ */ /* -** If LISTEN is not defined, PASV is used instead of PORT, and not -** all FTP servers support PASV, so define it unless there is no -** alternative for your system. -*/ -#ifndef NOPORT -#define LISTEN /* @@@@ Test LJM */ -#endif /* !NOPORT */ - -/* BUGS: @@@ Limit connection cache size! Error reporting to user. 400 & 500 errors are ack'ed by user with windows. @@ -188,14 +174,11 @@ PRIVATE unsigned short port_number = FIRST_TCP_PORT; #endif /* POLL_PORTS */ -#ifdef LISTEN PRIVATE int master_socket = -1; /* Listening socket = invalid */ PRIVATE char port_command[255]; /* Command for setting the port */ PRIVATE fd_set open_sockets; /* Mask of active channels */ PRIVATE int num_sockets; /* Number of sockets to scan */ -#else PRIVATE unsigned short passive_port; /* Port server specified for data */ -#endif /* LISTEN */ #define NEXT_CHAR HTGetCharacter() /* Use function in HTFormat.c */ @@ -1012,8 +995,6 @@ } -#ifdef LISTEN - /* Close Master (listening) socket ** ------------------------------- ** @@ -1169,7 +1150,7 @@ #ifdef REPEAT_LISTEN if (master_socket >= 0) (void) close_master_socket(); -#endif /* REPEAD_LISTEN */ +#endif /* REPEAT_LISTEN */ master_socket = new_socket; @@ -1209,7 +1190,6 @@ return master_socket; /* Good */ } /* get_listen_socket */ -#endif /* LISTEN */ PRIVATE char * months[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" @@ -2616,11 +2596,12 @@ ** returns Socket number for file if good. ** <0 if bad. */ -PUBLIC int HTFTPLoad ARGS4( +PUBLIC int HTFTPLoad ARGS5( CONST char *, name, HTParentAnchor *, anchor, HTFormat, format_out, - HTStream *, sink) + HTStream *, sink, + BOOL, passive) { BOOL isDirectory = NO; HTAtom * encoding = NULL; @@ -2640,86 +2621,86 @@ if (status < 0) return status; -#ifdef LISTEN - status = get_listen_socket(); - if (status < 0) { - NETCLOSE (control->socket); - control->socket = -1; - close_master_socket (); - /* HT_INTERRUPTED would fall through, if we could interrupt - somehow in the middle of it, which we currently can't. */ - return status; - } + if(!passive) { + status = get_listen_socket(); + if (status < 0) { + NETCLOSE (control->socket); + control->socket = -1; + close_master_socket (); + /* HT_INTERRUPTED would fall through, if we could interrupt + somehow in the middle of it, which we currently can't. */ + return status; + } #ifdef REPEAT_PORT /* Inform the server of the port number we will listen on */ - { - status = response(port_command); - if (status == HT_INTERRUPTED) { - CTRACE (tfp, "HTFTP: Interrupted in response (port_command)\n"); - _HTProgress (CONNECTION_INTERRUPTED); - NETCLOSE (control->socket); - control->socket = -1; - close_master_socket (); - return HT_INTERRUPTED; - } - if (status != 2) { /* Could have timed out */ - if (status < 0) - continue; /* try again - net error*/ - return -status; /* bad reply */ - } - CTRACE(tfp, "HTFTP: Port defined.\n"); - } + { + status = response(port_command); + if (status == HT_INTERRUPTED) { + CTRACE (tfp, "HTFTP: Interrupted in response (port_command)\n"); + _HTProgress (CONNECTION_INTERRUPTED); + NETCLOSE (control->socket); + control->socket = -1; + close_master_socket (); + return HT_INTERRUPTED; + } + if (status != 2) { /* Could have timed out */ + if (status < 0) + continue; /* try again - net error*/ + return -status; /* bad reply */ + } + CTRACE(tfp, "HTFTP: Port defined.\n"); + } #endif /* REPEAT_PORT */ -#else /* Use PASV */ + } else { /* passive mode */ /* Tell the server to be passive */ - { - char command[LINE_LENGTH+1]; - char *p; - int reply, h0, h1, h2, h3, p0, p1; /* Parts of reply */ - int status; - data_soc = status; + { + char command[LINE_LENGTH+1]; + char *p; + int reply, h0, h1, h2, h3, p0, p1; /* Parts of reply */ + int status; + data_soc = status; - status = send_cmd_1("PASV"); - if (status != 2) { - if (status < 0) - continue; /* retry or Bad return */ - return -status; /* bad reply */ - } - for (p = response_text; *p && *p != ','; p++) - ; /* null body */ - - while (--p > response_text && '0' <= *p && *p <= '9') - ; /* null body */ - - status = sscanf(p+1, "%d,%d,%d,%d,%d,%d", - &h0, &h1, &h2, &h3, &p0, &p1); - if (status < 4) { - fprintf(tfp, "HTFTP: PASV reply has no inet address!\n"); - return -99; - } - passive_port = (p0<<8) + p1; - CTRACE(tfp, "HTFTP: Server is listening on port %d\n", - passive_port); + status = send_cmd_1("PASV"); + if (status != 2) { + if (status < 0) + continue; /* retry or Bad return */ + return -status; /* bad reply */ + } + for (p = response_text; *p && *p != ','; p++) + ; /* null body */ + + while (--p > response_text && '0' <= *p && *p <= '9') + ; /* null body */ + + status = sscanf(p+1, "%d,%d,%d,%d,%d,%d", + &h0, &h1, &h2, &h3, &p0, &p1); + if (status < 4) { + fprintf(tfp, "HTFTP: PASV reply has no inet address!\n"); + return -99; + } + passive_port = (p0<<8) + p1; + CTRACE(tfp, "HTFTP: Server is listening on port %d\n", + passive_port); /* Open connection for data: */ - sprintf(command, - "ftp://%d.%d.%d.%d:%d/",h0,h1,h2,h3,passive_port); - status = HTDoConnect(name, "FTP", passive_port, &data_soc); - - if (status < 0) { - (void) HTInetStatus(gettext("connect for data")); - NETCLOSE(data_soc); - return status; /* Bad return */ - } + sprintf(command, + "ftp://%d.%d.%d.%d:%d/",h0,h1,h2,h3,passive_port); + status = HTDoConnect(name, "FTP", passive_port, &data_soc); + + if (status < 0) { + (void) HTInetStatus(gettext("connect for data")); + NETCLOSE(data_soc); + return status; /* Bad return */ + } - CTRACE(tfp, "FTP data connected, socket %d\n", data_soc); + CTRACE(tfp, "FTP data connected, socket %d\n", data_soc); + } } -#endif /* use PASV */ status = 0; break; /* No more retries */ @@ -3209,32 +3190,30 @@ } listen: -#ifdef LISTEN + if(!passive) { /* Wait for the connection */ - { - struct sockaddr_in soc_address; - int soc_addrlen=sizeof(soc_address); + { + struct sockaddr_in soc_address; + int soc_addrlen=sizeof(soc_address); #ifdef SOCKS - if (socks_flag) - status = Raccept(master_socket, - (struct sockaddr *)&soc_address, - (void *)&soc_addrlen); - else + if (socks_flag) + status = Raccept(master_socket, + (struct sockaddr *)&soc_address, + (void *)&soc_addrlen); + else #endif /* SOCKS */ - status = accept(master_socket, - (struct sockaddr *)&soc_address, - (void *)&soc_addrlen); - if (status < 0) { - init_help_message_cache(); /* to free memory */ - return HTInetStatus("accept"); - } - CTRACE(tfp, "TCP: Accepted new socket %d\n", status); - data_soc = status; - } -#else -/* @@ */ -#endif /* LISTEN */ + status = accept(master_socket, + (struct sockaddr *)&soc_address, + (void *)&soc_addrlen); + if (status < 0) { + init_help_message_cache(); /* to free memory */ + return HTInetStatus("accept"); + } + CTRACE(tfp, "TCP: Accepted new socket %d\n", status); + data_soc = status; + } + } /* !passive */ if (isDirectory) { status = read_directory (anchor, name, format_out, sink); NETCLOSE(data_soc); --- lynx2-8-2/WWW/Library/Implementation/HTFile.c.passive Mon May 24 21:00:53 1999 +++ lynx2-8-2/WWW/Library/Implementation/HTFile.c Mon Jan 31 13:20:57 2000 @@ -20,6 +20,7 @@ ** the device or top directory. */ +#include #include #ifndef VMS @@ -1840,11 +1841,12 @@ ** HTLOADED OK ** */ -PUBLIC int HTLoadFile ARGS4( +PUBLIC int HTLoadFile ARGS5( CONST char *, addr, HTParentAnchor *, anchor, HTFormat, format_out, - HTStream *, sink) + HTStream *, sink, + BOOL, passive) { char * filename = NULL; char * acc_method = NULL; @@ -1886,7 +1888,7 @@ FREE(nodename); FREE(acc_method); #ifndef DISABLE_FTP - return HTFTPLoad(addr, anchor, format_out, sink); + return HTFTPLoad(addr, anchor, format_out, sink, passive); #else return -1; #endif /* DISABLE_FTP */ @@ -2516,7 +2518,7 @@ */ } else { #ifndef DISABLE_FTP - return HTFTPLoad(addr, anchor, format_out, sink); + return HTFTPLoad(addr, anchor, format_out, sink, passive); #else return -1; #endif /* DISABLE_FTP */ --- lynx2-8-2/WWW/Library/Implementation/HTFile.h.passive Thu Dec 3 19:28:20 1998 +++ lynx2-8-2/WWW/Library/Implementation/HTFile.h Mon Jan 31 13:20:57 2000 @@ -78,7 +78,8 @@ CONST char * addr, HTParentAnchor * anchor, HTFormat format_out, - HTStream * sink)); + HTStream * sink, + BOOL passive)); /* ** Output a directory entry --- lynx2-8-2/WWW/Library/Implementation/HTFTP.h.passive Sun Dec 13 05:10:36 1998 +++ lynx2-8-2/WWW/Library/Implementation/HTFTP.h Mon Jan 31 13:20:57 2000 @@ -51,7 +51,8 @@ CONST char * name, HTParentAnchor * anchor, HTFormat format_out, - HTStream* sink + HTStream* sink, + BOOL passive )); /* --- lynx2-8-2/src/LYCgi.c.passive Mon May 24 21:00:53 1999 +++ lynx2-8-2/src/LYCgi.c Mon Jan 31 13:20:57 2000 @@ -263,7 +263,7 @@ LYLocalFileToURL (&new_arg, orig_pgm); CTRACE(tfp, "%s is not an executable file, passing the buck.\n", arg); - status = HTLoadFile(new_arg, anAnchor, format_out, sink); + status = HTLoadFile(new_arg, anAnchor, format_out, sink, passive); FREE(new_arg); } else if (path_info && --- lynx2-8-2/src/HTFWriter.c.passive Sun May 30 05:27:26 1999 +++ lynx2-8-2/src/HTFWriter.c Mon Jan 31 13:20:57 2000 @@ -308,7 +308,8 @@ status = HTLoadFile(addr, me->anchor, me->output_format, - me->sink); + me->sink, + passive); if (dump_output_immediately && me->output_format == HTAtom_for("www/present")) { FREE(addr); --- lynx2-8-2/src/LYMain.c.passive Tue Jun 1 15:22:18 1999 +++ lynx2-8-2/src/LYMain.c Mon Jan 31 13:20:57 2000 @@ -167,6 +167,7 @@ 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 passive = PASSIVE; /* TRUE if doing ftp in passive mode */ PUBLIC BOOLEAN recent_sizechange = FALSE;/* the window size changed recently? */ PUBLIC int user_mode = NOVICE_MODE; PUBLIC BOOLEAN dump_output_immediately = FALSE; --- lynx2-8-2/src/LYReadCFG.c.passive Thu May 20 14:48:10 1999 +++ lynx2-8-2/src/LYReadCFG.c Mon Jan 31 13:20:57 2000 @@ -1023,6 +1023,7 @@ PARSE_STR("global_mailcap", CONF_STR, &global_type_map), PARSE_ENV("gopher_proxy", CONF_ENV, 0 ), PARSE_SET("gotobuffer", CONF_BOOL, &goto_buffer), + PARSE_SET("passive", CONF_BOOL, &passive), PARSE_STR("helpfile", CONF_STR, &helpfile), PARSE_SET("historical_comments", CONF_BOOL, &historical_comments), --- lynx2-8-2/src/LYGlobalDefs.h.passive Mon Jan 31 13:54:35 2000 +++ lynx2-8-2/src/LYGlobalDefs.h Mon Jan 31 13:54:58 2000 @@ -123,6 +123,7 @@ extern BOOLEAN LYJumpFileURL; /* URL from the jump file shortcuts? */ extern BOOLEAN jump_buffer; /* TRUE if offering default shortcut */ extern BOOLEAN goto_buffer; /* TRUE if offering default goto URL */ +extern BOOLEAN passive; /* TRUE if we want to use passive mode ftp */ extern char *LYRequestTitle; /* newdoc.title in calls to getfile() */ extern char *jumpprompt; /* The default jump statusline prompt */ extern int more; /* is there more document to display? */ --- lynx2-8-2/lynx.cfg.passive Mon Jan 31 13:20:57 2000 +++ lynx2-8-2/lynx.cfg Mon Jan 31 13:20:57 2000 @@ -111,6 +111,11 @@ # #GOTOBUFFER:FALSE +# Set 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. +# This option is specific to Red Hat Linux +PASSIVE:TRUE + # JUMP_PROMPT is the default statusline prompt for selecting a jumps file # shortcut. (see below). # You can change the prompt here from that defined in userdefs.h. Any --- lynx2-8-2/userdefs.h.passive Mon Jan 31 13:20:57 2000 +++ lynx2-8-2/userdefs.h Mon Jan 31 13:20:57 2000 @@ -495,6 +495,13 @@ #define GOTOBUFFER FALSE /***************************** + * If PASSIVE is set to TRUE here or in lynx.cfg, ftp transfers will + * be done in passive mode. + * This option is specific to Red Hat Linux. + */ +#define PASSIVE FALSE + +/***************************** * JUMPFILE is the default local file checked for shortcut URLs when * the user presses the 'J' (JUMP) key. The user will be prompted for * a shortcut entry (analogously to 'g'oto), and can enter one