cvs commit: apache/src/modules/proxy proxy_ftp.c
dgaudet 98/01/19 16:49:39 Modified:.Tag: APACHE_1_2_X STATUS src Tag: APACHE_1_2_X CHANGES src/modules/proxy Tag: APACHE_1_2_X proxy_ftp.c Log: mod_proxy was sending HTTP/1.1 responses to ftp requests by mistake. Also removed the auto-generated link to www.apache.org that was the source of so many misdirected bug reports. (fixed in 1.3b1) Submitted by: Roy Fielding, Marc Slemko Reviewed by: Dean Gaudet Revision ChangesPath No revision No revision 1.1.2.17 +1 -0 apache/Attic/STATUS Index: STATUS === RCS file: /export/home/cvs/apache/Attic/STATUS,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -r1.1.2.16 -r1.1.2.17 --- STATUS1998/01/20 00:35:15 1.1.2.16 +++ STATUS1998/01/20 00:49:34 1.1.2.17 @@ -14,6 +14,7 @@ * backport of the netscape header padding fix * general/1666: basic auth token should be tested case-insensitive * protocol/1683: The Connection header may contain multiple close tokens +* proxy was sending HTTP/1.1 responses in error Available: No revision No revision 1.286.2.69 +4 -0 apache/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.286.2.68 retrieving revision 1.286.2.69 diff -u -r1.286.2.68 -r1.286.2.69 --- CHANGES 1998/01/20 00:35:17 1.286.2.68 +++ CHANGES 1998/01/20 00:49:36 1.286.2.69 @@ -1,5 +1,9 @@ Changes with Apache 1.2.6 + *) mod_proxy was sending HTTP/1.1 responses to ftp requests by mistake. + Also removed the auto-generated link to www.apache.org that was the + source of so many misdirected bug reports. [Roy Fielding, Marc Slemko] + *) Multiple close tokens may have been set in the Connection header, not an error, but a waste. [EMAIL PROTECTED] PR#1683 No revision No revision 1.21.2.3 +6 -5 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.21.2.2 retrieving revision 1.21.2.3 diff -u -r1.21.2.2 -r1.21.2.3 --- proxy_ftp.c 1998/01/05 21:05:07 1.21.2.2 +++ proxy_ftp.c 1998/01/20 00:49:38 1.21.2.3 @@ -372,9 +372,10 @@ o+=w; } } -ap_snprintf(buf, sizeof(buf), /PREHRIA HREF=\http://www.apache.org\;%s/A/I/BODY/HTML, SERVER_VERSION); -bwrite(con-client, buf, strlen(buf)); -if (f2 != NULL) bwrite(f2, buf, strlen(buf)); +bputs(/PREHR/BODY/HTML\015\012, con-client); +if (f2 != NULL) { + bputs(/PREHR/BODY/HTML\015\012, f2); +} total_bytes_sent+=strlen(buf); bflush(con-client); @@ -944,9 +945,9 @@ /* send response */ /* write status line */ if (!r-assbackwards) - rvputs(r, SERVER_PROTOCOL, , r-status_line, \015\012, NULL); + rvputs(r, HTTP/1.0 , r-status_line, \015\012, NULL); if (cache != NULL) - if (bvputs(cache, SERVER_PROTOCOL, , r-status_line, \015\012, + if (bvputs(cache, HTTP/1.0 , r-status_line, \015\012, NULL) == -1) cache = proxy_cache_error(c);
cvs commit: apache/src/modules/proxy proxy_ftp.c
marc98/01/05 13:05:08 Modified:src/modules/proxy Tag: APACHE_1_2_X proxy_ftp.c Log: Fix core dump in the ftp proxy when reading incorrectly formatted directory listings. Reviewed by: Martin Kraemer, Mark J Cox, Dean Gaudet, Randy Terbush Revision ChangesPath No revision No revision 1.21.2.2 +2 -2 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -u -r1.21.2.1 -r1.21.2.2 --- proxy_ftp.c 1997/08/15 17:08:55 1.21.2.1 +++ proxy_ftp.c 1998/01/05 21:05:07 1.21.2.2 @@ -286,8 +286,8 @@ buf[sizeof(buf)-1] = '\0'; n=strlen(buf); } -else if(buf[0]=='d' || buf[0]=='-' || buf[0]=='l' || isdigit(buf[0])) -{ +else if (strrchr(buf, ' ') (buf[0]=='d' || buf[0]=='-' || +buf[0]=='l' || isdigit(buf[0])) ) { if(isdigit(buf[0])) { /* handle DOS dir */ searchptr = strchr(buf, ''); if(searchptr != NULL)
cvs commit: apache/src/modules/proxy proxy_ftp.c
dgaudet 97/07/20 20:37:54 Modified:src CHANGES Configure PORTING conf.h dummy.c http_main.c src/modules/proxy proxy_ftp.c Log: Linux porting tweaks for glibc based systems. Linux tweaks to find db libraries. Added NET_SIZE_T for handling size_t * args to some functions. Revision ChangesPath 1.357 +8 -0 apache/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.356 retrieving revision 1.357 diff -C3 -r1.356 -r1.357 *** CHANGES 1997/07/20 23:45:45 1.356 --- CHANGES 1997/07/21 03:37:47 1.357 *** *** 1,5 --- 1,13 Changes with Apache 1.3 + *) PORT: Some architectures use size_t for various lengths in network + functions such as accept(), and getsockname(). The definition + NET_SIZE_T is used to control this. [Dean Gaudet] + + *) PORT: Linux: Attempt to detect glibc based systems and include crypt.h + and -lcrypt. Test for various db libraries (dbm, ndbm, db) when + mod_auth_dbm or mod_auth_db are included. [Dean Gaudet] + *) PORT: QNX doesn't have initgroups() which support/suexec.c uses. [Igor N Kovalenko [EMAIL PROTECTED]] 1.114 +24 -12apache/src/Configure Index: Configure === RCS file: /export/home/cvs/apache/src/Configure,v retrieving revision 1.113 retrieving revision 1.114 diff -C3 -r1.113 -r1.114 *** Configure 1997/07/19 09:34:32 1.113 --- Configure 1997/07/21 03:37:48 1.114 *** *** 279,300 CFLAGS=$CFLAGS -DIRIX fi ;; - alpha-*-linux2) - DEF_WANTHSREGEX=yes - OS='Linux' - CFLAGS=$CFLAGS -DLINUX=2 - LIBS=$LIBS -lcrypt - ;; - sparc-*-linux2) - DEF_WANTHSREGEX=yes - OS='Linux' - CFLAGS=$CFLAGS -DLINUX=2 - LIBS=$LIBS -lm - ;; *-linux2) DEF_WANTHSREGEX=yes OS='Linux' CFLAGS=$CFLAGS -DLINUX=2 ;; *-linux1) DEF_WANTHSREGEX=yes --- 279,289 CFLAGS=$CFLAGS -DIRIX fi ;; *-linux2) DEF_WANTHSREGEX=yes OS='Linux' CFLAGS=$CFLAGS -DLINUX=2 + LIBS=$LIBS -lm ;; *-linux1) DEF_WANTHSREGEX=yes *** *** 684,697 --- 673,709 # before we actually write LIBS to Makefile.config. # Punt for now... + case $PLAT in + *-linux*) + # newer systems using glibc 2.x need -lcrypt + if ./helpers/TestLib crypt; then + LIBS=$LIBS -lcrypt + fi + # many systems have -ldb installed + DB_LIB= + if ./helpers/TestLib db; then + DB_LIB=-ldb + fi; + # many systems don't have -ldbm + DBM_LIB= + if ./helpers/TestLib dbm; then + DBM_LIB=-ldbm + elif ./helpers/TestLib ndbm; then + DBM_LIB=-lndbm + fi + ;; + esac + # # Are they using dbm/db auth? If so, add DBM/DB library. # if grep mod_auth_dbm Makefile /dev/null; then LIBS=$LIBS $DBM_LIB + echo + using $DBM_LIB for mod_auth_dbm fi if grep mod_auth_db Makefile /dev/null; then LIBS=$LIBS $DB_LIB + echo + using $DB_LIB for mod_auth_db fi 1.8 +5 -0 apache/src/PORTING Index: PORTING === RCS file: /export/home/cvs/apache/src/PORTING,v retrieving revision 1.7 retrieving revision 1.8 diff -C3 -r1.7 -r1.8 *** PORTING 1997/07/07 14:34:24 1.7 --- PORTING 1997/07/21 03:37:48 1.8 *** *** 245,250 --- 245,255 Amount to move sbrk() breakpoint, if required, before attaching shared-memory segment. + NET_SIZE_T: +Some functions such as accept(), getsockname(), getpeername() take +an int *len on some architectures and a size_t *len on others. +If left undefined apache will default it to int. + --- Conclusion: --- 1.116 +14 -0 apache/src/conf.h Index: conf.h === RCS file: /export/home/cvs/apache/src/conf.h,v retrieving revision 1.115 retrieving revision 1.116 diff -C3 -r1.115 -r1.116 *** conf.h1997/07/16 00:41:20 1.115 --- conf.h1997/07/21 03:37:48 1.116 *** *** 259,264 --- 259,270 #elif defined(LINUX) #if LINUX 1 + #include features.h + #if defined(__GNU_LIBRARY__) __GNU_LIBRARY__ 1 + /* it's a glibc host */ +
cvs commit: apache/src/modules/proxy proxy_ftp.c
chuck 97/04/13 20:43:34 Modified:src/modules/proxy proxy_ftp.c Log: Encode spaces for displayed filenames in directories. Revision ChangesPath 1.20 +26 -2 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C3 -r1.19 -r1.20 *** proxy_ftp.c 1997/04/13 15:20:30 1.19 --- proxy_ftp.c 1997/04/14 03:43:33 1.20 *** *** 149,155 } else { ! p = proxy_canonenc(pool, r-args, strlen(r-args), enc_path, 1); if (p == NULL) return BAD_REQUEST; path = pstrcat(pool, path, ?, p, NULL); } --- 149,155 } else { ! p = proxy_canonenc(pool, r-args, strlen(r-args), enc_fpath, 1); if (p == NULL) return BAD_REQUEST; path = pstrcat(pool, path, ?, p, NULL); } *** *** 213,218 --- 213,239 return status; } + static char * + encode_space(request_rec *r, char *path) + { + pool *pool=r-pool; + char *newpath; + int i, j, len; + + len = strlen(path); + newpath = palloc(pool, 3 * len + 1); + for (i=0, j=0; i len; i++, j++) { + if (path[i] != ' ') + newpath[j] = path[i]; + else { + proxy_c2hex(' ', newpath[j]); + j += 2; + } + } + newpath[j] = '\0'; + return newpath; + } + static long int send_dir(BUFF *f, request_rec *r, BUFF *f2, struct cache_req *c, char *url) { *** *** 220,225 --- 241,247 char buf2[IOBUFSIZE]; char *filename; char *tempurl; + char *newurlptr; int searchidx = 0; char *searchptr = NULL; int firstfile = 1; *** *** 235,240 --- 257,263 tempurl += n - 5; /* leave room for ftp:// */ } + n = decodeenc(tempurl); ap_snprintf(buf, sizeof(buf), HTMLHEADTITLE%s/TITLE/HEADBODYH1Directory %s/H1HRPRE, tempurl, tempurl); bwrite(con-client, buf, strlen(buf)); if (f2 != NULL) bwrite(f2, buf, strlen(buf)); *** *** 326,332 else { ap_snprintf(urlptr, sizeof(urlptr), %s%s%s,url,(url[strlen(url)-1]=='/' ? : /), filename); ! ap_snprintf(buf2, sizeof(buf2), %s A HREF=\%s\%s/A\015\012, buf, urlptr, filename); } strncpy(buf, buf2, sizeof(buf)); buf[sizeof(buf)-1] = '\0'; --- 349,356 else { ap_snprintf(urlptr, sizeof(urlptr), %s%s%s,url,(url[strlen(url)-1]=='/' ? : /), filename); ! newurlptr = encode_space(r, urlptr); ! ap_snprintf(buf2, sizeof(buf2), %s A HREF=\%s\%s/A\015\012, buf, newurlptr, filename); } strncpy(buf, buf2, sizeof(buf)); buf[sizeof(buf)-1] = '\0';
cvs commit: apache/src/modules/proxy proxy_ftp.c
chuck 97/04/12 22:00:56 Modified:src/modules/proxy proxy_ftp.c Log: Further fine tune for FTP dir display when FTP server fails to format files of very large size properly. Revision ChangesPath 1.18 +2 -1 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C3 -r1.17 -r1.18 *** proxy_ftp.c 1997/04/11 05:10:51 1.17 --- proxy_ftp.c 1997/04/13 05:00:54 1.18 *** *** 275,281 searchptr = filename; searchidx = filename - buf; } ! else if (searchptr != NULL searchidx != 0) { *(--filename) = ' '; buf[searchidx - 1] = 0; filename = buf[searchidx]; --- 275,282 searchptr = filename; searchidx = filename - buf; } ! else if (searchptr != NULL searchidx != 0 ! buf[searchidx] != 0) { *(--filename) = ' '; buf[searchidx - 1] = 0; filename = buf[searchidx];
cvs commit: apache/src/modules/proxy proxy_ftp.c
chuck 97/04/10 22:01:54 Modified:src/modules/proxy proxy_ftp.c Log: Improve handling of directories when filenames have spaces in them. Revision ChangesPath 1.16 +16 -0 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C3 -r1.15 -r1.16 *** proxy_ftp.c 1997/04/09 06:51:07 1.15 --- proxy_ftp.c 1997/04/11 05:01:53 1.16 *** *** 220,225 --- 220,228 char buf2[IOBUFSIZE]; char *filename; char *tempurl; + char *searchptr = NULL; + int searchidx = 0; + int firstfile = 1; char urlptr[HUGE_STRING_LEN]; long total_bytes_sent; register int n, o, w; *** *** 265,270 --- 268,286 filename=strrchr(buf, ' '); *(filename++)=0; filename[strlen(filename)-1]=0; + + /* handle filenames with spaces in 'em */ + if(!strcmp(filename, .) || !strcmp(filename, ..) || firstfile) { + firstfile = 0; + searchptr = filename; + searchidx = filename - buf; + } + else if (searchptr != NULL searchidx != 0) { + *(--filename) = ' '; + buf[searchidx - 1] = 0; + filename = buf[searchidx]; + } + /* Special handling for '.' and '..' */ if (!strcmp(filename, .)) {
cvs commit: apache/src/modules/proxy proxy_ftp.c
chuck 97/02/19 20:14:45 Modified:src/modules/proxy proxy_ftp.c Log: 1) remove setting of SO_DEBUG socket option to make Linux users happy. 2) Make ftp_getrc() more lenient about multiline responses (specifically, 230 responses which don't have continuation 230- on each line). These seem to be all NT FTP servers, and while they may be the mutant spawn of the devil, they appear to be legal by RFC 959. 3) Add missing kill_timeout() after transfer to user completes. This coupled with 2) is very likely the cause of Rasmus' timeout problem. Revision ChangesPath 1.9 +6 -15 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C3 -r1.8 -r1.9 *** proxy_ftp.c 1997/01/20 04:28:33 1.8 --- proxy_ftp.c 1997/02/20 04:14:44 1.9 *** *** 185,197 /* check format */ if (len 5 || !isdigit(linebuff[0]) || !isdigit(linebuff[1]) || !isdigit(linebuff[2]) || (linebuff[3] != ' ' linebuff[3] != '-')) ! return 0; ! status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0'; if (linebuff[len-1] != '\n') { i = bskiplf(f); - if (i != 1) return i; } /* skip continuation lines */ --- 185,199 /* check format */ if (len 5 || !isdigit(linebuff[0]) || !isdigit(linebuff[1]) || !isdigit(linebuff[2]) || (linebuff[3] != ' ' linebuff[3] != '-')) ! status = 0; ! else ! status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0'; ! ! Explain1(FTP: ftp_getrc() status = %d, status); if (linebuff[len-1] != '\n') { i = bskiplf(f); } /* skip continuation lines */ *** *** 203,213 { len = bgets(linebuff, 100, f); if (len == -1) return -1; - if (len 5) return 0; if (linebuff[len-1] != '\n') { i = bskiplf(f); - if (i != 1) return i; } } while (memcmp(linebuff, buff, 4) != 0); } --- 205,213 *** *** 564,579 } note_cleanups_for_fd(pool, dsock); - if (setsockopt(dsock, SOL_SOCKET, SO_DEBUG, (const char *)one, - sizeof (int)) == -1) - { - proxy_log_uerror(setsockopt, NULL, - proxy: error setting PASV debug option, r-server); - pclosef(pool, dsock); - pclosef(pool, sock); - return SERVER_ERROR; - } - bputs(PASV\015\012, f); bflush(f); Explain0(FTP: PASV command issued); --- 564,569 *** *** 867,872 --- 857,863 Explain1(FTP: returned status %d,i); } + kill_timeout(r); proxy_cache_tidy(c); /* finish */
cvs commit: apache/src/modules/proxy proxy_ftp.c
chuck 96/12/24 09:23:26 Modified:src/modules/proxy proxy_ftp.c Log: Add PASV to FTP proxy. Make default MIME type text/plain, so folks get their READMEs OK. Merry Christmas. Revision ChangesPath 1.4 +146 -48 apache/src/modules/proxy/proxy_ftp.c Index: proxy_ftp.c === RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_ftp.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C3 -r1.3 -r1.4 *** proxy_ftp.c 1996/10/20 23:59:02 1.3 --- proxy_ftp.c 1996/12/24 17:23:24 1.4 *** *** 326,346 * Handles direct access of ftp:// URLs * Original (Non-PASV) version from * Troy Morrison [EMAIL PROTECTED] */ int proxy_ftp_handler(request_rec *r, struct cache_req *c, char *url) { char *host, *path, *p, *user, *password, *parms; const char *err; ! int port, userlen, passlen, i, len, sock, dsock, csd, rc, nocache; struct sockaddr_in server; struct hdr_entry *hdr; array_header *resp_hdrs; ! BUFF *f, *cache, *data; pool *pool=r-pool; const int one=1; const long int zero=0L; /* This appears to fix a bug(?) that generates an Address family not supported by protocol error in proxy_doconnect() later (along with making sure server.sin_family = AF_INET - cdm) */ --- 326,358 * Handles direct access of ftp:// URLs * Original (Non-PASV) version from * Troy Morrison [EMAIL PROTECTED] + * PASV added by Chuck */ int proxy_ftp_handler(request_rec *r, struct cache_req *c, char *url) { char *host, *path, *p, *user, *password, *parms; const char *err; ! int port, userlen, passlen, i, len, sock, dsock, rc, nocache; ! int csd = 0; struct sockaddr_in server; struct hdr_entry *hdr; array_header *resp_hdrs; ! BUFF *f, *cache; ! BUFF *data = NULL; pool *pool=r-pool; const int one=1; const long int zero=0L; + /* stuff for PASV mode */ + unsigned int presult, h0, h1, h2, h3, p0, p1; + unsigned int paddr; + unsigned short pport; + struct sockaddr_in data_addr; + int pasvmode = 0; + char pasv[64]; + char *pstr; + /* This appears to fix a bug(?) that generates an Address family not supported by protocol error in proxy_doconnect() later (along with making sure server.sin_family = AF_INET - cdm) */ *** *** 519,574 else if (i == 504) parms[0] = '\0'; } ! /* set up data connection */ ! len = sizeof(struct sockaddr_in); ! if (getsockname(sock, (struct sockaddr *)server, len) 0) ! { ! proxy_log_uerror(getsockname, NULL, ! proxy: error getting socket address, r-server); ! pclosef(pool, sock); ! return SERVER_ERROR; ! } ! dsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (dsock == -1) ! { ! proxy_log_uerror(socket, NULL, proxy: error creating socket, r-server); pclosef(pool, sock); ! return SERVER_ERROR; } note_cleanups_for_fd(pool, dsock); ! if (setsockopt(dsock, SOL_SOCKET, SO_REUSEADDR, (const char *)one, !sizeof(int)) == -1) { proxy_log_uerror(setsockopt, NULL, ! proxy: error setting reuseaddr option, r-server); pclosef(pool, dsock); pclosef(pool, sock); return SERVER_ERROR; } ! if (bind(dsock, (struct sockaddr *)server, sizeof(struct sockaddr_in)) == ! -1) ! { ! char buff[22]; ! sprintf(buff, %s:%d, inet_ntoa(server.sin_addr), server.sin_port); ! proxy_log_uerror(bind, buff, ! proxy: error binding to ftp data socket, r-server); ! pclosef(pool, sock); pclosef(pool, dsock); } - listen(dsock, 2); /* only need a short queue */ /* set request */ len = decodeenc(path); /* TM - if len == 0 then it must be a directory (you can't RETR nothing) */ ! if(len==0) parms=d; ! else { bputs(SIZE , f); bwrite(f, path, len); --- 531,665 else if (i == 504) parms[0] = '\0'; } ! /* try to set up PASV data connection first */ dsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (dsock == -1) ! { ! proxy_log_uerror(socket, NULL, proxy: error creating PASV socket, r-server); pclosef(pool, sock); ! return SERVER_ERROR; } note_cleanups_for_fd(pool, dsock); ! if (setsockopt(dsock, SOL_SOCKET, SO_DEBUG, (const char *)one, ! sizeof (int)) == -1) { proxy_log_uerror(setsockopt, NULL, ! proxy: error setting PASV