diff -rc squid-1.0.beta5/ChangeLog squid-1.0.beta6/ChangeLog *** squid-1.0.beta5/ChangeLog Thu Apr 25 22:38:50 1996 --- squid-1.0.beta6/ChangeLog Fri May 03 13:25:36 1996 *************** *** 120,122 **** --- 120,143 ---- - Fixed cachemgr to send 'HTTP/1.0' on request so it works with beta4 fixes to icp.c. + + Changes to squid-1.0.beta6: + + - Fixed null error message coredump in ftpget. + - Added -m Method option to `client'. + - Fixed ftpget server bug with missing trailing slash. + - Removed 'connect_ports' from config, use general ACLs instead. + - Changed requested listen queue length to 1/4 of getMaxFD(). + - Rewrote SSL/CONNECT handlers. Now doesn't use a StoreEntry. + - Fixed some aborted objects getting stuck in VM bug. + - Fixed ftpget PASV reply sscanf to work for VMS ftpd. + - Changed FTP URL parsing to use urlParse(). + - Changed ftpget to skip RETR command if URLs ends with '/'. + - Changed ftpget to display README at the bottom if there are other + server messages. + - Changed ftpget to not reopen a new data connection + if one is already open. + - Fixed handling of FTP URLs with spaces (and other unsafe characters) + - Changed ftpget to only generate BASE HREF if the FTP URL does + not end with '/'. + diff -rc squid-1.0.beta5/Makefile squid-1.0.beta6/Makefile *** squid-1.0.beta5/Makefile Mon Apr 08 16:25:16 1996 --- squid-1.0.beta6/Makefile Wed May 01 16:46:32 1996 *************** *** 1,10 **** # Makefile for SQUID Cache # ! # $Id: Makefile,v 1.4 1996/04/08 23:25:16 wessels Exp $ # prefix = /usr/local/squid ! exec_prefix = ${prefix} SHELL = /bin/sh --- 1,10 ---- # Makefile for SQUID Cache # ! # $Id: Makefile,v 1.4.2.1 1996/05/01 23:46:32 wessels Exp $ # prefix = /usr/local/squid ! exec_prefix = '$${prefix}' SHELL = /bin/sh Only in squid-1.0.beta6: config.site diff -rc squid-1.0.beta5/configure squid-1.0.beta6/configure *** squid-1.0.beta5/configure Thu Apr 25 09:37:08 1996 --- squid-1.0.beta6/configure Wed May 01 16:46:33 1996 *************** *** 517,523 **** ! # From configure.in Revision: 1.18.2.3 ac_aux_dir= for ac_dir in aux $srcdir/aux; do if test -f $ac_dir/install-sh; then --- 517,523 ---- ! # From configure.in Revision: 1.18.2.4 ac_aux_dir= for ac_dir in aux $srcdir/aux; do if test -f $ac_dir/install-sh; then *************** *** 565,589 **** echo "$ac_t""$host" 1>&6 - - if test -n "$prefix"; then - myprefix="$prefix"; - else - myprefix="$ac_default_prefix" - fi - - INSTALL_TOPDIR="$myprefix"; - INSTALL_LIBDIR="$myprefix/lib"; - INSTALL_BINDIR="$myprefix/bin"; - INSTALL_MANDIR="$myprefix/man"; - - eval "sysconfdirval=$sysconfdir" - eval "bindirval=$bindir" - - THIS_HOST="`hostname`" XTRA_CFLAGS='' CRYPT_LIB='' if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi --- 565,579 ---- echo "$ac_t""$host" 1>&6 XTRA_CFLAGS='' CRYPT_LIB='' + if test "$libexecdir" = '${exec_prefix}/libexec'; then + libexecdir='${bindir}' + localstatedir='${prefix}' + + fi + if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi *************** *** 599,612 **** - - - - - - - - # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 --- 589,594 ---- *************** *** 712,718 **** # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error --- 694,700 ---- # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error *************** *** 726,732 **** rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error --- 708,714 ---- rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error *************** *** 985,996 **** # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 ! if eval "test \"`echo '$''{'ac_cv_path_CMD_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ! case "$CMD_PERL" in /*) ! ac_cv_path_CMD_PERL="$CMD_PERL" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" --- 967,978 ---- # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 ! if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ! case "$PERL" in /*) ! ac_cv_path_PERL="$PERL" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" *************** *** 997,1022 **** for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ! ac_cv_path_CMD_PERL="$ac_dir/$ac_word" break fi done IFS="$ac_save_ifs" ! test -z "$ac_cv_path_CMD_PERL" && ac_cv_path_CMD_PERL="/usr/local/bin/perl" ;; esac fi ! CMD_PERL="$ac_cv_path_CMD_PERL" ! if test -n "$CMD_PERL"; then ! echo "$ac_t""$CMD_PERL" 1>&6 else echo "$ac_t""no" 1>&6 fi - PERL="$CMD_PERL" - ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do --- 979,1002 ---- for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ! ac_cv_path_PERL="$ac_dir/$ac_word" break fi done IFS="$ac_save_ifs" ! test -z "$ac_cv_path_PERL" && ac_cv_path_PERL="/usr/local/bin/perl" ;; esac fi ! PERL="$ac_cv_path_PERL" ! if test -n "$PERL"; then ! echo "$ac_t""$PERL" 1>&6 else echo "$ac_t""no" 1>&6 fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h do *************** *** 1026,1032 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> --- 1006,1012 ---- echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_hdr> *************** *** 1066,1072 **** ac_save_LIBS="$LIBS" LIBS="-ldir $LIBS" cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext < #include --- 1140,1146 ---- echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include *************** *** 1182,1188 **** if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF --- 1162,1168 ---- if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF *************** *** 1200,1206 **** if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF --- 1180,1186 ---- if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF *************** *** 1221,1227 **** : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') --- 1201,1207 ---- : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') *************** *** 1281,1287 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF --- 1261,1267 ---- echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF *************** *** 1312,1318 **** echo $ac_n "checking for tm->tm_gmtoff""... $ac_c" 1>&6 cat > conftest.$ac_ext < #include --- 1292,1298 ---- echo $ac_n "checking for tm->tm_gmtoff""... $ac_c" 1>&6 cat > conftest.$ac_ext < #include *************** *** 1338,1344 **** echo $ac_n "checking for extended mallinfo""... $ac_c" 1>&6 cat > conftest.$ac_ext < #include --- 1318,1324 ---- echo $ac_n "checking for extended mallinfo""... $ac_c" 1>&6 cat > conftest.$ac_ext < #include *************** *** 1371,1377 **** echo "$ac_t""yes" 1>&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&2; exit 1; } else cat > conftest.$ac_ext < main() --- 1377,1383 ---- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() *************** *** 1431,1437 **** { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() --- 1411,1417 ---- { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < main() *************** *** 1465,1471 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } --- 1445,1451 ---- echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { return 0; } *************** *** 1497,1503 **** echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < conftest.$ac_ext < --- 2042,2048 ---- SQUID_FD_SETSIZE=256 else cat > conftest.$ac_ext < *************** *** 2274,2280 **** ./scripts/RunCache \ ./scripts/RunAccel \ ./src/Makefile \ ! ./src/squid.conf \ include/autoconf.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF --- 2324,2330 ---- ./scripts/RunCache \ ./scripts/RunAccel \ ./src/Makefile \ ! ./src/squid.conf.pre \ "} EOF cat >> $CONFIG_STATUS <<\EOF diff -rc squid-1.0.beta5/configure.in squid-1.0.beta6/configure.in *** squid-1.0.beta5/configure.in Thu Apr 25 09:37:07 1996 --- squid-1.0.beta6/configure.in Wed May 01 16:46:34 1996 *************** *** 1,40 **** dnl dnl Configuration input file for Squid dnl ! dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.7) dnl ! dnl $Id: configure.in,v 1.18.2.4 1996/04/25 16:37:07 wessels Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) ! AC_REVISION($Revision: 1.18.2.4 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(aux) AC_CANONICAL_HOST - dnl Build a copy of prefix - - if test -n "$prefix"; then - myprefix="$prefix"; - else - myprefix="$ac_default_prefix" - fi - - INSTALL_TOPDIR="$myprefix"; - INSTALL_LIBDIR="$myprefix/lib"; - INSTALL_BINDIR="$myprefix/bin"; - INSTALL_MANDIR="$myprefix/man"; - - eval "sysconfdirval=$sysconfdir" - eval "bindirval=$bindir" - - THIS_HOST="`hostname`" XTRA_CFLAGS='' CRYPT_LIB='' if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi --- 1,30 ---- dnl dnl Configuration input file for Squid dnl ! dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9) dnl ! dnl $Id: configure.in,v 1.18.2.5 1996/05/01 23:46:34 wessels Exp $ dnl dnl dnl AC_INIT(src/main.c) AC_CONFIG_HEADER(include/autoconf.h) ! AC_REVISION($Revision: 1.18.2.5 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AC_CONFIG_AUX_DIR(aux) AC_CANONICAL_HOST XTRA_CFLAGS='' CRYPT_LIB='' + dnl use directory structure of cached as default (hack) + if test "$libexecdir" = '${exec_prefix}/libexec'; then + libexecdir='${bindir}' + localstatedir='${prefix}' + + fi + if test -z "$CACHE_HTTP_PORT"; then CACHE_HTTP_PORT="3128" fi *************** *** 46,63 **** fi dnl Subsitutions - AC_SUBST(INSTALL_TOPDIR) - AC_SUBST(INSTALL_LIBDIR) - AC_SUBST(INSTALL_BINDIR) - AC_SUBST(INSTALL_MANDIR) - AC_SUBST(DEFS) AC_SUBST(XTRA_CFLAGS) - AC_SUBST(THIS_HOST) AC_SUBST(CACHE_HTTP_PORT) AC_SUBST(CACHE_ICP_PORT) AC_SUBST(CACHE_FTP_PORT) - AC_SUBST(sysconfdirval) - AC_SUBST(bindirval) dnl Check for GNU cc AC_PROG_CC --- 36,45 ---- *************** *** 86,96 **** AC_PATH_PROG(MV, mv, /bin/false) AC_PATH_PROG(MKDIR, mkdir, /bin/false) AC_PATH_PROG(LN, ln, cp) ! AC_PATH_PROG(CMD_PERL, perl, /usr/local/bin/perl) - dnl Set PERL too - PERL="$CMD_PERL" - AC_SUBST(PERL) dnl Check for headers AC_HEADER_DIRENT --- 68,75 ---- AC_PATH_PROG(MV, mv, /bin/false) AC_PATH_PROG(MKDIR, mkdir, /bin/false) AC_PATH_PROG(LN, ln, cp) ! AC_PATH_PROG(PERL, perl, /usr/local/bin/perl) dnl Check for headers AC_HEADER_DIRENT *************** *** 327,331 **** ./scripts/RunCache \ ./scripts/RunAccel \ ./src/Makefile \ ! ./src/squid.conf \ ) --- 306,310 ---- ./scripts/RunCache \ ./scripts/RunAccel \ ./src/Makefile \ ! ./src/squid.conf.pre \ ) diff -rc squid-1.0.beta5/makefile.in squid-1.0.beta6/makefile.in *** squid-1.0.beta5/makefile.in Wed Mar 27 18:32:49 1996 --- squid-1.0.beta6/makefile.in Fri May 03 13:27:57 1996 *************** *** 1,4 **** ! # $Id: makefile.in,v 1.6 1996/03/28 02:32:49 wessels Exp $ # srcdir = @srcdir@ --- 1,4 ---- ! # $Id: makefile.in,v 1.6.2.1 1996/05/03 20:27:57 wessels Exp $ # srcdir = @srcdir@ *************** *** 25,31 **** realclean: clean rm -f config.status config.cache config.log makefile ! rm -f include/paths.h include/autoconf.h @for dir in $(SUBDIRS); do \ echo Making $@ in $$dir; \ (cd $$dir; $(MAKE) $(MFLAGS) prefix="$(prefix)" $@); \ --- 25,31 ---- realclean: clean rm -f config.status config.cache config.log makefile ! rm -f include/paths.h include/autoconf.h include/config.h @for dir in $(SUBDIRS); do \ echo Making $@ in $$dir; \ (cd $$dir; $(MAKE) $(MFLAGS) prefix="$(prefix)" $@); \ diff -rc squid-1.0.beta5/include/config.h.in squid-1.0.beta6/include/config.h.in *** squid-1.0.beta5/include/config.h.in Tue Apr 16 13:53:31 1996 --- squid-1.0.beta6/include/config.h.in Thu May 02 18:12:50 1996 *************** *** 1,6 **** /* ! * $Id: config.h.in,v 1.6 1996/04/16 20:53:31 wessels Exp $ */ #ifndef _CONFIG_H_ --- 1,6 ---- /* ! * $Id: config.h.in,v 1.6.2.2 1996/05/03 01:12:50 wessels Exp $ */ #ifndef _CONFIG_H_ *************** *** 29,41 **** #endif #endif - #ifndef BUFSIZ - #include /* try to find it... */ - #ifndef BUFSIZ - #define BUFSIZ 4096 /* make reasonable guess */ - #endif - #endif - #if defined(SYSTYPE_SYSV) || defined(__svr4__) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__) #define _SQUID_SYSV_ #else --- 29,34 ---- *************** *** 86,123 **** #if !defined(CACHEMGR_HOSTNAME) #define CACHEMGR_HOSTNAME "" - #endif - - #if !defined(DEFAULT_CONFIG_FILE) - #define DEFAULT_CONFIG_FILE "@prefix@/etc/squid.conf" - #endif - - #if !defined(DEFAULT_CACHE_LOG) - #define DEFAULT_CACHE_LOG "@prefix@/logs/cache.log" - #endif - - #if !defined(DEFAULT_ACCESS_LOG) - #define DEFAULT_ACCESS_LOG "@prefix@/logs/access.log" - #endif - - #if !defined(DEFAULT_HIERARCHY_LOG) - #define DEFAULT_HIERARCHY_LOG "@prefix@/logs/hierarchy.log" - #endif - - #if !defined(DEFAULT_STORE_LOG) - #define DEFAULT_STORE_LOG "@prefix@/logs/store.log" - #endif - - #if !defined(DEFAULT_FTPGET_PATH) - #define DEFAULT_FTPGET_PATH "@prefix@/bin/ftpget" - #endif - - #if !defined(DEFAULT_DNSSERVER_PATH) - #define DEFAULT_DNSSERVER_PATH "@prefix@/bin/dnsserver" - #endif - - #if !defined(DEFAULT_SWAP_DIR) - #define DEFAULT_SWAP_DIR "@prefix@/cache" #endif #endif /* _CONFIG_H_ */ --- 79,84 ---- diff -rc squid-1.0.beta5/include/version.h squid-1.0.beta6/include/version.h *** squid-1.0.beta5/include/version.h Thu Apr 25 22:40:27 1996 --- squid-1.0.beta6/include/version.h Wed May 01 15:23:16 1996 *************** *** 1,7 **** ! /* $Id: version.h,v 1.19.4.4 1996/04/26 05:40:27 wessels Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION ! #define SQUID_VERSION "1.0.beta5" #endif --- 1,7 ---- ! /* $Id: version.h,v 1.19.4.5 1996/05/01 22:23:16 wessels Exp $ * * SQUID_VERSION - String for version id of this distribution */ #ifndef SQUID_VERSION ! #define SQUID_VERSION "1.0.beta6" #endif diff -rc squid-1.0.beta5/lib/util.c squid-1.0.beta6/lib/util.c *** squid-1.0.beta5/lib/util.c Sun Apr 14 21:23:42 1996 --- squid-1.0.beta6/lib/util.c Wed May 01 16:46:42 1996 *************** *** 1,10 **** ! /* $Id: util.c,v 1.6 1996/04/15 04:23:42 wessels Exp $ */ #include #include #include #include #include #include void (*failure_notify) () = NULL; --- 1,12 ---- ! /* $Id: util.c,v 1.6.2.1 1996/05/01 23:46:42 wessels Exp $ */ #include #include #include #include + #ifndef _SQUID_FREEBSD_ /* "Obsolete" Markus Stumpf */ #include + #endif #include void (*failure_notify) () = NULL; diff -rc squid-1.0.beta5/scripts/Makefile.in squid-1.0.beta6/scripts/Makefile.in *** squid-1.0.beta5/scripts/Makefile.in Sat Apr 20 12:57:00 1996 --- squid-1.0.beta6/scripts/Makefile.in Wed May 01 16:46:44 1996 *************** *** 21,29 **** all: install: ! @if test ! -d $(prefix); then \ ! echo "mkdir $(prefix)"; \ ! mkdir $(prefix); \ fi @if test ! -d $(bindir); then \ echo "mkdir $(bindir)"; \ --- 21,29 ---- all: install: ! @if test ! -d $(exec_prefix); then \ ! echo "mkdir $(exec_prefix)"; \ ! mkdir $(exec_prefix); \ fi @if test ! -d $(bindir); then \ echo "mkdir $(bindir)"; \ diff -rc squid-1.0.beta5/scripts/RunAccel.in squid-1.0.beta6/scripts/RunAccel.in *** squid-1.0.beta5/scripts/RunAccel.in Tue Apr 16 09:37:53 1996 --- squid-1.0.beta6/scripts/RunAccel.in Wed May 01 16:46:44 1996 *************** *** 1,20 **** #!/bin/sh # ! # $Id: RunAccel.in,v 1.2 1996/04/16 16:37:53 wessels Exp $ # enable HTTP requests on port 80 ! set port="-a 80" ! PATH=@prefix@/bin:/bin export PATH ! if test $#argv = 1 ; then conf="-f $1" ! shift; fi failcount=0 ! while test 1 ; do echo "Running: squid $port -s $conf >> squid.out 2>&1" start=`date '+%d%H%M%S'` squid $port -s $conf >> squid.out 2>&1 --- 1,22 ---- #!/bin/sh # ! # $Id: RunAccel.in,v 1.2.2.1 1996/05/01 23:46:44 wessels Exp $ # enable HTTP requests on port 80 ! port="-a 80" ! prefix=@prefix@ ! exec_prefix=@exec_prefix@ ! PATH=@bindir@:/bin export PATH ! if test $# = 1 ; then conf="-f $1" ! shift fi failcount=0 ! while : ; do echo "Running: squid $port -s $conf >> squid.out 2>&1" start=`date '+%d%H%M%S'` squid $port -s $conf >> squid.out 2>&1 *************** *** 26,32 **** failcount=0 fi if test $failcount -gt 5 ; then ! echo "RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES" exit 1 fi sleep 10 --- 28,34 ---- failcount=0 fi if test $failcount -gt 5 ; then ! echo "RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES" >&2 exit 1 fi sleep 10 diff -rc squid-1.0.beta5/scripts/RunCache.in squid-1.0.beta6/scripts/RunCache.in *** squid-1.0.beta5/scripts/RunCache.in Sat Apr 20 12:39:06 1996 --- squid-1.0.beta6/scripts/RunCache.in Wed May 01 16:46:45 1996 *************** *** 1,18 **** #!/bin/sh # ! # $Id: RunCache.in,v 1.3.2.1 1996/04/20 19:39:06 wessels Exp $ ! PATH=@prefix@/bin:/bin export PATH conf="" if test "$1" ; then conf="-f $1" ! shift; fi failcount=0 ! while test 1 ; do echo "Running: squid -s $conf >> squid.out 2>&1" start=`date '+%d%H%M%S'` squid -s $conf >> squid.out 2>&1 --- 1,20 ---- #!/bin/sh # ! # $Id: RunCache.in,v 1.3.2.2 1996/05/01 23:46:45 wessels Exp $ ! prefix=@prefix@ ! exec_prefix=@exec_prefix@ ! PATH=@bindir@:/bin export PATH conf="" if test "$1" ; then conf="-f $1" ! shift fi failcount=0 ! while : ; do echo "Running: squid -s $conf >> squid.out 2>&1" start=`date '+%d%H%M%S'` squid -s $conf >> squid.out 2>&1 *************** *** 24,30 **** failcount=0 fi if test $failcount -gt 5 ; then ! echo "RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES" exit 1 fi sleep 10 --- 26,32 ---- failcount=0 fi if test $failcount -gt 5 ; then ! echo "RunCache: EXITING DUE TO REPEATED, FREQUENT FAILURES" >&2 exit 1 fi sleep 10 diff -rc squid-1.0.beta5/src/Makefile.in squid-1.0.beta6/src/Makefile.in *** squid-1.0.beta5/src/Makefile.in Sat Apr 20 13:25:12 1996 --- squid-1.0.beta6/src/Makefile.in Thu May 02 16:24:42 1996 *************** *** 1,22 **** # # Makefile for the Squid Object Cache server # ! # $Id: Makefile.in,v 1.22.2.2 1996/04/20 20:25:12 wessels Exp $ # # Uncomment and customize the following to suit your needs: # - LOG_OPT = # -DNO_LOGGGING HOST_OPT = # -DCACHEMGR_HOSTNAME="getfullhostname()" ! DEFINES = $(LOG_OPT) $(HOST_OPT) prefix = @prefix@ exec_prefix = @exec_prefix@ top_srcdir = @top_srcdir@ bindir = @bindir@ sysconfdir = @sysconfdir@ srcdir = @srcdir@ VPATH = @srcdir@ CC = @CC@ INSTALL = @INSTALL@ INSTALL_BIN = @INSTALL_PROGRAM@ --- 1,32 ---- # # Makefile for the Squid Object Cache server # ! # $Id: Makefile.in,v 1.22.2.4 1996/05/02 23:24:42 wessels Exp $ # # Uncomment and customize the following to suit your needs: # HOST_OPT = # -DCACHEMGR_HOSTNAME="getfullhostname()" ! DEFINES = $(HOST_OPT) prefix = @prefix@ exec_prefix = @exec_prefix@ top_srcdir = @top_srcdir@ bindir = @bindir@ + libexecdir = @libexecdir@ sysconfdir = @sysconfdir@ + localstatedir = @localstatedir@ srcdir = @srcdir@ VPATH = @srcdir@ + DEFAULT_CONFIG_FILE = $(sysconfdir)/squid.conf + DEFAULT_FTPGET = $(libexecdir)/ftpget + DEFAULT_DNSSERVER = $(libexecdir)/dnsserver + DEFAULT_CACHE_LOG = $(localstatedir)/logs/cache.log + DEFAULT_ACCESS_LOG = $(localstatedir)/logs/access.log + DEFAULT_HIERARCHY_LOG = $(localstatedir)/logs/hierarchy.log + DEFAULT_STORE_LOG = $(localstatedir)/logs/store.log + DEFAULT_SWAP_DIR = $(localstatedir)/cache + CC = @CC@ INSTALL = @INSTALL@ INSTALL_BIN = @INSTALL_PROGRAM@ *************** *** 23,29 **** INSTALL_FILE = @INSTALL_DATA@ RANLIB = @RANLIB@ LN_S = @LN_S@ ! PERL = @CMD_PERL@ CRYPT_LIB = @CRYPT_LIB@ STD_CFLAGS = @STD_CFLAGS@ STD_LDFLAGS = @STD_LDFLAGS@ --- 33,39 ---- INSTALL_FILE = @INSTALL_DATA@ RANLIB = @RANLIB@ LN_S = @LN_S@ ! PERL = @PERL@ CRYPT_LIB = @CRYPT_LIB@ STD_CFLAGS = @STD_CFLAGS@ STD_LDFLAGS = @STD_LDFLAGS@ *************** *** 39,67 **** LIBS = -L../lib -lregex -lutil $(XTRA_LIBS) CLIENT_LIBS = -L../lib -lutil $(XTRA_LIBS) ! PROGS = squid ! UTILS = client dnsserver ftpget CGIPROGS = cachemgr.cgi OBJS = acl.o background.o cache_cf.o errorpage.o comm.o \ ! connect.o debug.o disk.o dynamic_array.o \ fdstat.o filemap.o ftp.o gopher.o \ hash.o http.o icp.o ipcache.o \ main.o mime.o neighbors.o objcache.o \ ! proto.o send-announce.o stack.o stat.o stmem.o \ store.o storetoString.o tools.o ttl.o \ url.o wais.o $(XTRA_OBJS) DEFAULTS = \ ! -DDEFAULT_CONFIG_FILE=\"$(sysconfdir)/squid.conf\" \ ! -DDEFAULT_FTPGET=\"$(bindir)/ftpget\" \ ! -DDEFAULT_DNSSERVER=\"$(bindir)/dnsserver\" \ ! -DDEFAULT_CACHE_LOG=\"$(prefix)/logs/cache.log\" \ ! -DDEFAULT_ACCESS_LOG=\"$(prefix)/logs/access.log\" \ ! -DDEFAULT_HIERARCHY_LOG=\"$(prefix)/logs/hierarchy.log\" \ ! -DDEFAULT_STORE_LOG=\"$(prefix)/logs/store.log\" \ ! -DDEFAULT_SWAP_DIR=\"$(prefix)/cache\" ! all: $(PROGS) $(UTILS) $(CGIPROGS) squid: $(OBJS) $(CC) -o $@ $(LDFLAGS) $(OBJS) $(CRYPT_LIB) $(LIBS) --- 49,77 ---- LIBS = -L../lib -lregex -lutil $(XTRA_LIBS) CLIENT_LIBS = -L../lib -lutil $(XTRA_LIBS) ! PROGS = squid client ! UTILS = dnsserver ftpget CGIPROGS = cachemgr.cgi OBJS = acl.o background.o cache_cf.o errorpage.o comm.o \ ! debug.o disk.o dynamic_array.o \ fdstat.o filemap.o ftp.o gopher.o \ hash.o http.o icp.o ipcache.o \ main.o mime.o neighbors.o objcache.o \ ! proto.o send-announce.o ssl.o stack.o stat.o stmem.o \ store.o storetoString.o tools.o ttl.o \ url.o wais.o $(XTRA_OBJS) DEFAULTS = \ ! -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\" \ ! -DDEFAULT_FTPGET=\"$(DEFAULT_FTPGET)\" \ ! -DDEFAULT_DNSSERVER=\"$(DEFAULT_DNSSERVER)\" \ ! -DDEFAULT_CACHE_LOG=\"$(DEFAULT_CACHE_LOG)\" \ ! -DDEFAULT_ACCESS_LOG=\"$(DEFAULT_ACCESS_LOG)\" \ ! -DDEFAULT_HIERARCHY_LOG=\"$(DEFAULT_HIERARCHY_LOG)\" \ ! -DDEFAULT_STORE_LOG=\"$(DEFAULT_STORE_LOG)\" \ ! -DDEFAULT_SWAP_DIR=\"$(DEFAULT_SWAP_DIR)\" ! all: squid.conf $(PROGS) $(UTILS) $(CGIPROGS) squid: $(OBJS) $(CC) -o $@ $(LDFLAGS) $(OBJS) $(CRYPT_LIB) $(LIBS) *************** *** 81,86 **** --- 91,107 ---- ftpget: ftpget.o $(CC) -o $@ $(LDFLAGS) ftpget.o $(LIBS) + squid.conf: squid.conf.pre + sed "\ + s%@DEFAULT_CONFIG_FILE@%$(DEFAULT_CONFIG_FILE)%g;\ + s%@DEFAULT_FTPGET@%$(DEFAULT_FTPGET)%g;\ + s%@DEFAULT_DNSSERVER@%$(DEFAULT_DNSSERVER)%g;\ + s%@DEFAULT_CACHE_LOG@%$(DEFAULT_CACHE_LOG)%g;\ + s%@DEFAULT_ACCESS_LOG@%$(DEFAULT_ACCESS_LOG)%g;\ + s%@DEFAULT_HIERARCHY_LOG@%$(DEFAULT_HIERARCHY_LOG)%g;\ + s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\ + s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g" <$? >$@ + install-mkdirs: @if test ! -d $(prefix); then \ echo "mkdir $(prefix)"; \ *************** *** 94,107 **** echo "mkdir $(bindir)"; \ mkdir $(bindir); \ fi @if test ! -d $(sysconfdir); then \ echo "mkdir $(sysconfdir)"; \ mkdir $(sysconfdir); \ fi ! @if test ! -d $(exec_prefix)/logs; then \ ! echo "mkdir $(exec_prefix)/logs"; \ ! mkdir $(exec_prefix)/logs; \ fi install: all install-mkdirs @for f in $(PROGS); do \ --- 115,136 ---- echo "mkdir $(bindir)"; \ mkdir $(bindir); \ fi + @if test ! -d $(libexecdir); then \ + echo "mkdir $(libexecdir)"; \ + mkdir $(libexecdir); \ + fi @if test ! -d $(sysconfdir); then \ echo "mkdir $(sysconfdir)"; \ mkdir $(sysconfdir); \ fi ! @if test ! -d $(localstatedir); then \ ! echo "mkdir $(localstatedir)"; \ ! mkdir $(localstatedir); \ fi + @if test ! -d $(localstatedir)/logs; then \ + echo "mkdir $(localstatedir)/logs"; \ + mkdir $(localstatedir)/logs; \ + fi install: all install-mkdirs @for f in $(PROGS); do \ *************** *** 109,120 **** $(INSTALL_BIN) $$f $(bindir); \ done @for f in $(UTILS); do \ ! echo $(INSTALL_BIN) $$f $(bindir); \ ! $(INSTALL_BIN) $$f $(bindir); \ done @for f in $(CGIPROGS); do \ ! echo $(INSTALL_BIN) $$f $(bindir); \ ! $(INSTALL_BIN) $$f $(bindir); \ done $(INSTALL_FILE) squid.conf $(sysconfdir)/squid.conf.default @if test -f $(sysconfdir)/squid.conf ; then \ --- 138,149 ---- $(INSTALL_BIN) $$f $(bindir); \ done @for f in $(UTILS); do \ ! echo $(INSTALL_BIN) $$f $(libexecdir); \ ! $(INSTALL_BIN) $$f $(libexecdir); \ done @for f in $(CGIPROGS); do \ ! echo $(INSTALL_BIN) $$f $(libexecdir); \ ! $(INSTALL_BIN) $$f $(libexecdir); \ done $(INSTALL_FILE) squid.conf $(sysconfdir)/squid.conf.default @if test -f $(sysconfdir)/squid.conf ; then \ *************** *** 128,131 **** -rm -rf *.o *pure_* core $(PROGS) $(UTILS) $(CGIPROGS) realclean: clean ! -rm -f Makefile squid.conf --- 157,160 ---- -rm -rf *.o *pure_* core $(PROGS) $(UTILS) $(CGIPROGS) realclean: clean ! -rm -f Makefile squid.conf squid.conf.pre diff -rc squid-1.0.beta5/src/acl.c squid-1.0.beta6/src/acl.c *** squid-1.0.beta5/src/acl.c Tue Apr 23 16:22:05 1996 --- squid-1.0.beta6/src/acl.c Wed May 01 16:46:48 1996 *************** *** 1,4 **** ! /* "$Id: acl.c,v 1.12.2.3 1996/04/23 23:22:05 wessels Exp $" */ /* * DEBUG: Section 28 acl --- 1,4 ---- ! /* "$Id: acl.c,v 1.12.2.4 1996/05/01 23:46:48 wessels Exp $" */ /* * DEBUG: Section 28 acl *************** *** 329,334 **** --- 329,335 ---- debug(28, 0, "aclParseAclLine: Invalid ACL type '%s'\n", t); xfree(A); return; + /* NOTREACHED */ break; } A->cfgline = xstrdup(config_input_line); *************** *** 500,528 **** switch (acl->type) { case ACL_SRC_IP: return aclMatchIp(acl->data, c); break; case ACL_DST_DOMAIN: return aclMatchWord(acl->data, h); break; case ACL_TIME: return aclMatchTime(acl->data, squid_curtime); ! return 0; break; case ACL_URL_REGEX: return aclMatchRegex(acl->data, r); break; case ACL_URL_PORT: return aclMatchInteger(acl->data, po); break; case ACL_USER: debug(28, 0, "aclMatchAcl: ACL_USER unimplemented\n"); return 0; break; case ACL_PROTO: return aclMatchInteger(acl->data, pr); break; case ACL_METHOD: return aclMatchInteger(acl->data, m); break; case ACL_NONE: default: --- 501,536 ---- switch (acl->type) { case ACL_SRC_IP: return aclMatchIp(acl->data, c); + /* NOTREACHED */ break; case ACL_DST_DOMAIN: return aclMatchWord(acl->data, h); + /* NOTREACHED */ break; case ACL_TIME: return aclMatchTime(acl->data, squid_curtime); ! /* NOTREACHED */ break; case ACL_URL_REGEX: return aclMatchRegex(acl->data, r); + /* NOTREACHED */ break; case ACL_URL_PORT: return aclMatchInteger(acl->data, po); + /* NOTREACHED */ break; case ACL_USER: debug(28, 0, "aclMatchAcl: ACL_USER unimplemented\n"); return 0; + /* NOTREACHED */ break; case ACL_PROTO: return aclMatchInteger(acl->data, pr); + /* NOTREACHED */ break; case ACL_METHOD: return aclMatchInteger(acl->data, m); + /* NOTREACHED */ break; case ACL_NONE: default: diff -rc squid-1.0.beta5/src/cache_cf.c squid-1.0.beta6/src/cache_cf.c *** squid-1.0.beta5/src/cache_cf.c Thu Apr 25 15:05:38 1996 --- squid-1.0.beta6/src/cache_cf.c Thu May 02 17:11:58 1996 *************** *** 1,4 **** ! /* $Id: cache_cf.c,v 1.53.4.6 1996/04/25 22:05:38 wessels Exp $ */ /* DEBUG: Section 3 cache_cf: Configuration file parsing */ --- 1,4 ---- ! /* $Id: cache_cf.c,v 1.53.4.11 1996/05/03 00:11:58 wessels Exp $ */ /* DEBUG: Section 3 cache_cf: Configuration file parsing */ *************** *** 151,170 **** #define DefaultAnnounceFile (char *)NULL /* default NONE */ #define DefaultAnnounceRate 86400 /* every 24 hours */ - /* default CONNECT ports */ - intlist snews = - { - 563, - NULL - }; - intlist https = - { - 443, - &snews - }; - intlist *connect_port_list = &https; - - ip_acl *local_ip_list = NULL; int zap_disk_store = 0; /* off, try to rebuild from disk */ --- 151,156 ---- *************** *** 371,400 **** *list = NULL; } - static void intlistAdd(list, str) - intlist **list; - char *str; - { - intlist *p = NULL; - intlist *q = NULL; - if (!(*list)) { - /* empty list */ - *list = (intlist *) xcalloc(1, sizeof(intlist)); - (*list)->i = atoi(str); - (*list)->next = NULL; - } else { - p = *list; - while (p->next) - p = p->next; - q = (intlist *) xcalloc(1, sizeof(intlist)); - q->i = atoi(str); - q->next = NULL; - p->next = q; - } - } - - /* Use this #define in all the parse*() functions. Assumes * ** char *token is defined */ --- 357,363 ---- *************** *** 929,942 **** wordlistAdd(&Config.bind_addr_list, token); } static void parseLocalDomainLine() { ! char *token; while ((token = strtok(NULL, w_space))) { ! wordlistAdd(&Config.local_domain_list, token); } } static void parseInsideFirewallLine() { char *token; --- 892,938 ---- wordlistAdd(&Config.bind_addr_list, token); } + static void parseLocalDomainFile(fname) + char *fname; + { + char tmp_line[BUFSIZ]; + FILE *fp = NULL; + char *t = NULL; + + if ((fp = fopen(fname, "r")) == NULL) { + debug(3, 1, "parseLocalDomainFile: %s: %s\n", fname, xstrerror()); + return; + } + memset(tmp_line, '\0', BUFSIZ); + while (fgets(tmp_line, BUFSIZ, fp)) { + if (tmp_line[0] == '#') + continue; + if (tmp_line[0] == '\0') + continue; + if (tmp_line[0] == '\n') + continue; + for (t = strtok(tmp_line, w_space); t; t = strtok(NULL, w_space)) { + debug(3, 1, "parseLocalDomainFileLine: adding %s\n", t); + wordlistAdd(&Config.local_domain_list, t); + } + } + fclose(fp); + } + static void parseLocalDomainLine() { ! char *token = NULL; ! struct stat sb; while ((token = strtok(NULL, w_space))) { ! if (stat(token, &sb) < 0) { ! wordlistAdd(&Config.local_domain_list, token); ! } else { ! parseLocalDomainFile(token); ! } } } + static void parseInsideFirewallLine() { char *token; *************** *** 1029,1047 **** Config.ftpUser = xstrdup(token); } - static void parseConnectPortsLine() - { - char *token; - static char origPortList = 1; - if (origPortList) { - connect_port_list = NULL; - origPortList = 0; - } - while ((token = strtok(NULL, w_space))) { - intlistAdd(&connect_port_list, token); - } - } - static void parseCacheAnnounceLine() { char *token; --- 1025,1030 ---- *************** *** 1341,1349 **** else if (!strcmp(token, "ftp_user")) parseFtpUserLine(); - else if (!strcmp(token, "connect_ports")) - parseConnectPortsLine(); - else if (!strcmp(token, "cache_announce")) parseCacheAnnounceLine(); --- 1324,1329 ---- *************** *** 1681,1686 **** --- 1661,1667 ---- safe_free(Config.Log.log); safe_free(Config.Log.access); safe_free(Config.Log.hierarchy); + safe_free(Config.Log.store); safe_free(Config.adminEmail); safe_free(Config.effectiveUser); safe_free(Config.effectiveGroup); diff -rc squid-1.0.beta5/src/cache_cf.h squid-1.0.beta6/src/cache_cf.h *** squid-1.0.beta5/src/cache_cf.h Wed Apr 17 16:46:32 1996 --- squid-1.0.beta6/src/cache_cf.h Wed May 01 12:43:49 1996 *************** *** 1,5 **** ! /* $Id: cache_cf.h,v 1.31 1996/04/17 23:46:32 wessels Exp $ */ #ifndef _CACHE_CONFIG_H_ #define _CACHE_CONFIG_H_ --- 1,5 ---- ! /* $Id: cache_cf.h,v 1.31.4.1 1996/05/01 19:43:49 wessels Exp $ */ #ifndef _CACHE_CONFIG_H_ #define _CACHE_CONFIG_H_ *************** *** 46,52 **** extern int httpd_accel_mode; extern int unbuffered_logs; extern int zap_disk_store; - extern intlist *connect_port_list; extern wordlist *bind_addr_list; extern wordlist *ftp_stoplist; extern wordlist *gopher_stoplist; --- 46,51 ---- diff -rc squid-1.0.beta5/src/cachemgr.c squid-1.0.beta6/src/cachemgr.c *** squid-1.0.beta5/src/cachemgr.c Thu Apr 25 22:39:59 1996 --- squid-1.0.beta6/src/cachemgr.c Thu May 02 18:12:50 1996 *************** *** 1,7 **** ! /* $Id: cachemgr.c,v 1.7.2.1 1996/04/26 05:39:59 wessels Exp $ */ #include "config.h" #include "autoconf.h" #include #include --- 1,8 ---- ! /* $Id: cachemgr.c,v 1.7.2.6 1996/05/03 01:12:50 wessels Exp $ */ #include "config.h" #include "autoconf.h" + #include "version.h" #include #include *************** *** 11,17 **** --- 12,20 ---- #include #include #include + #ifndef _SQUID_FREEBSD_ /* "Obsolete" Markus Stumpf */ #include + #endif #include #include #include *************** *** 51,95 **** #define MAX_ENTRIES 10000 #define FALSE 0 #define TRUE !FALSE #define LF 10 #define CR 13 typedef enum { ! INFO, ! CACHED, ! SERVER, ! LOG, ! PARAM, ! STATS_G, ! STATS_O, ! STATS_VM, ! STATS_U, ! SHUTDOWN, ! REFRESH, #ifdef REMOVE_OBJECT ! REMOVE, #endif ! MAXOP } op_t; ! static char *op_cmds[] = { ! "info", ! "squid.conf", ! "server_list", ! "log", ! "parameter", ! "stats/general", ! "stats/objects", ! "stats/vm_objects", ! "stats/utilization", ! "shutdown", ! "", #ifdef REMOVE_OBJECT ! "", #endif ! "" }; typedef struct { --- 54,104 ---- #define MAX_ENTRIES 10000 + #ifndef FALSE #define FALSE 0 + #endif + #ifndef TRUE #define TRUE !FALSE + #endif + #define LF 10 #define CR 13 typedef enum { ! INFO, ! CACHED, ! SERVER, ! LOG, ! PARAM, ! STATS_G, ! STATS_O, ! STATS_VM, ! STATS_U, ! SHUTDOWN, ! REFRESH, #ifdef REMOVE_OBJECT ! REMOVE, #endif ! MAXOP } op_t; ! static char *op_cmds[] = ! { ! "info", ! "squid.conf", ! "server_list", ! "log", ! "parameter", ! "stats/general", ! "stats/objects", ! "stats/vm_objects", ! "stats/utilization", ! "shutdown", ! "", #ifdef REMOVE_OBJECT ! "", #endif ! "" }; typedef struct { *************** *** 195,201 **** ll = 0; word = (char *) malloc(sizeof(char) * (wsize + 1)); ! while (1) { word[ll] = (char) fgetc(f); if (ll == wsize) { word[ll + 1] = '\0'; --- 204,210 ---- ll = 0; word = (char *) malloc(sizeof(char) * (wsize + 1)); ! for (;;) { word[ll] = (char) fgetc(f); if (ll == wsize) { word[ll + 1] = '\0'; *************** *** 347,353 **** int len; int bytesWritten; int portnum = CACHE_HTTP_PORT; ! int op; int p_state; int n_loops; int cpy_ind; --- 356,362 ---- int len; int bytesWritten; int portnum = CACHE_HTTP_PORT; ! int op = 0; int p_state; int n_loops; int cpy_ind; *************** *** 469,479 **** case STATS_VM: case STATS_U: sprintf(msg, "GET cache_object://%s/%s HTTP/1.0\r\n\r\n", ! hostname, op_cmds[op]); break; case SHUTDOWN: sprintf(msg, "GET cache_object://%s/%s@%s HTTP/1.0\r\n\r\n", ! hostname, op_cmds[op], password); break; case REFRESH: sprintf(msg, "GET %s HTTP/1.0\r\nPragma: no-cache\r\nAccept: */*\r\n\r\n", url); --- 478,488 ---- case STATS_VM: case STATS_U: sprintf(msg, "GET cache_object://%s/%s HTTP/1.0\r\n\r\n", ! hostname, op_cmds[op]); break; case SHUTDOWN: sprintf(msg, "GET cache_object://%s/%s@%s HTTP/1.0\r\n\r\n", ! hostname, op_cmds[op], password); break; case REFRESH: sprintf(msg, "GET %s HTTP/1.0\r\nPragma: no-cache\r\nAccept: */*\r\n\r\n", url); *************** *** 669,674 **** --- 678,684 ---- (void) close(conn); exit(0); /* NOTREACHED */ + return 0; } static int client_comm_connect(sock, dest_host, dest_port) diff -rc squid-1.0.beta5/src/client.c squid-1.0.beta6/src/client.c *** squid-1.0.beta5/src/client.c Tue Apr 23 22:35:29 1996 --- squid-1.0.beta6/src/client.c Wed May 01 16:46:49 1996 *************** *** 1,5 **** ! /* $Id: client.c,v 1.4.2.1 1996/04/24 05:35:29 wessels Exp $ */ #include "squid.h" --- 1,5 ---- ! /* $Id: client.c,v 1.4.2.3 1996/05/01 23:46:49 wessels Exp $ */ #include "squid.h" *************** *** 21,26 **** --- 21,27 ---- -s Silent. Do not print data to stdout.\n\ -h host Retrieve URL from cache on hostname. Default is localhost.\n\ -p port Port number of cache. Default is %d.\n\ + -m method Request method, default is GET\n\ ", progname, CACHE_HTTP_PORT); exit(1); } *************** *** 32,37 **** --- 33,39 ---- int conn, c, len, bytesWritten; int port, to_stdout, reload; char url[BUFSIZ], msg[BUFSIZ], buf[BUFSIZ], hostname[BUFSIZ]; + char *method = "GET"; extern char *optarg; time_t ims = 0; *************** *** 47,53 **** strcpy(url, argv[argc - 1]); if (url[0] == '-') usage(argv[0]); ! while ((c = getopt(argc, argv, "fsrnp:c:h:i:?")) != -1) switch (c) { case 'h': /* host:arg */ case 'c': /* backward compat */ --- 49,55 ---- strcpy(url, argv[argc - 1]); if (url[0] == '-') usage(argv[0]); ! while ((c = getopt(argc, argv, "fsrnp:c:h:i:m:?")) != -1) switch (c) { case 'h': /* host:arg */ case 'c': /* backward compat */ *************** *** 69,74 **** --- 71,79 ---- case 'i': /* IMS */ ims = (time_t) atoi(optarg); break; + case 'm': + method = xstrdup(optarg); + break; case '?': /* usage */ default: usage(argv[0]); *************** *** 92,98 **** exit(1); } /* Build the HTTP request */ ! sprintf(msg, "GET %s HTTP/1.0\r\n", url); if (reload) { sprintf(buf, "Pragma: no-cache\r\n"); strcat(msg, buf); --- 97,103 ---- exit(1); } /* Build the HTTP request */ ! sprintf(msg, "%s %s HTTP/1.0\r\n", method, url); if (reload) { sprintf(buf, "Pragma: no-cache\r\n"); strcat(msg, buf); *************** *** 123,128 **** --- 128,134 ---- (void) close(conn); /* done with socket */ exit(0); /*NOTREACHED */ + return 0; } static int client_comm_connect(sock, dest_host, dest_port) diff -rc squid-1.0.beta5/src/comm.c squid-1.0.beta6/src/comm.c *** squid-1.0.beta5/src/comm.c Thu Apr 25 15:11:28 1996 --- squid-1.0.beta6/src/comm.c Thu May 02 13:52:29 1996 *************** *** 1,5 **** ! /* $Id: comm.c,v 1.30.4.2 1996/04/25 22:11:28 wessels Exp $ */ /* DEBUG: Section 5 comm: socket level functions */ --- 1,5 ---- ! /* $Id: comm.c,v 1.30.4.5 1996/05/02 20:52:29 wessels Exp $ */ /* DEBUG: Section 5 comm: socket level functions */ *************** *** 168,174 **** } /* ! * NOTE: set the listen queue to 50 and rely on the kernel to * impose an upper limit. Solaris' listen(3n) page says it has * no limit on this parameter, but sys/socket.h sets SOMAXCONN * to 5. HP-UX currently has a limit of 20. SunOS is 5 and --- 168,174 ---- } /* ! * NOTE: set the listen queue to getMaxFD()/4 and rely on the kernel to * impose an upper limit. Solaris' listen(3n) page says it has * no limit on this parameter, but sys/socket.h sets SOMAXCONN * to 5. HP-UX currently has a limit of 20. SunOS is 5 and *************** *** 178,185 **** int sock; { int x; ! if ((x = listen(sock, 50)) < 0) { ! debug(5, 0, "comm_listen: listen(%d, 50): %s\n", sock, xstrerror()); return x; } --- 178,186 ---- int sock; { int x; ! if ((x = listen(sock, getMaxFD() >> 2)) < 0) { ! debug(5, 0, "comm_listen: listen(%d, %d): %s\n", ! getMaxFD() >> 2, sock, xstrerror()); return x; } *************** *** 364,370 **** conn = &fd_table[fd]; comm_set_fd_lifetime(fd, -1); /* invalidate the lifetime */ ! debug(5, 10, "comm_close: FD %d\n", fd); /* update fdstat */ fdstat_close(fd); if (conn->close_handler) --- 365,371 ---- conn = &fd_table[fd]; comm_set_fd_lifetime(fd, -1); /* invalidate the lifetime */ ! debug(5, 5, "comm_close: FD %d\n", fd); /* update fdstat */ fdstat_close(fd); if (conn->close_handler) *************** *** 569,575 **** FD_CLR(theAsciiConnection, &readfds); } if (shutdown_pending || reread_pending) ! debug(5, 1, "comm_select: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; while (1) { --- 570,576 ---- FD_CLR(theAsciiConnection, &readfds); } if (shutdown_pending || reread_pending) ! debug(5, 2, "comm_select: Still waiting on %d FDs\n", nfds); if (nfds == 0) return COMM_SHUTDOWN; while (1) { diff -rc squid-1.0.beta5/src/connect.c squid-1.0.beta6/src/connect.c *** squid-1.0.beta5/src/connect.c Thu Apr 25 16:25:24 1996 --- squid-1.0.beta6/src/connect.c Thu May 02 13:59:04 1996 *************** *** 1,11 **** /* ! * $Id: connect.c,v 1.11.4.3 1996/04/25 23:25:24 wessels Exp $ * * DEBUG: Section 26 connect */ #include "squid.h" ! #define CONNECT_BUFSIZE 4096 #define CONNECT_DELETE_GAP (64*1024) #define ConnectMaxObjSize (4 << 20) /* 4 MB */ --- 1,11 ---- /* ! * $Id: connect.c,v 1.11.4.8 1996/05/02 20:59:04 wessels Exp $ * * DEBUG: Section 26 connect */ #include "squid.h" ! #define CONNECT_BUFSIZE (1<<14) #define CONNECT_DELETE_GAP (64*1024) #define ConnectMaxObjSize (4 << 20) /* 4 MB */ *************** *** 32,49 **** static void connectConnInProgress _PARAMS((int fd, ConnectData * data)); /* This will be called when socket lifetime is expired. */ ! static void connectLifetimeExpire(fd, data) ! int fd; ConnectData *data; { ! debug(26, 4, "connectLifeTimeExpire: FD %d: \n", fd, data->entry->url); ! comm_close(fd); } /* This will be called when data is ready to be read from fd. Read until * error or connection closed. */ ! static void connectReadRemote(fd, data) ! int fd; ConnectData *data; { static char buf[CONNECT_BUFSIZE]; --- 32,56 ---- static void connectConnInProgress _PARAMS((int fd, ConnectData * data)); /* This will be called when socket lifetime is expired. */ ! static void connectLifetimeExpire(rfd, data) ! int rfd; ConnectData *data; { ! StoreEntry *entry = data->entry; ! debug(26, 4, "connectLifeTimeExpire: FD %d: \n", ! rfd, entry->url); ! squid_error_entry(entry, ERR_LIFETIME_EXP, NULL); ! comm_set_select_handler(rfd, ! COMM_SELECT_READ | COMM_SELECT_WRITE, ! NULL, ! NULL); ! comm_close(rfd); } /* This will be called when data is ready to be read from fd. Read until * error or connection closed. */ ! static void connectReadRemote(rfd, data) ! int rfd; ConnectData *data; { static char buf[CONNECT_BUFSIZE]; *************** *** 60,66 **** entry->mem_obj->e_current_len - entry->mem_obj->e_lowest_offset); /* reschedule, so it will automatically reactivated when Gap is big enough. */ ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); --- 67,73 ---- entry->mem_obj->e_current_len - entry->mem_obj->e_lowest_offset); /* reschedule, so it will automatically reactivated when Gap is big enough. */ ! comm_set_select_handler(rfd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); *************** *** 69,91 **** } else { /* we can terminate connection right now */ squid_error_entry(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL); ! comm_close(fd); return; } } ! len = read(fd, buf, CONNECT_BUFSIZE); ! debug(26, 5, "connectReadRemote FD %d read len:%d\n", fd, len); if (len < 0) { ! debug(26, 1, "connectReadRemote: FD %d: read failure: %s.\n", fd, xstrerror()); if (errno == EAGAIN || errno == EWOULDBLOCK) { /* reinstall handlers */ /* XXX This may loop forever */ ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); ! comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, --- 76,99 ---- } else { /* we can terminate connection right now */ squid_error_entry(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL); ! comm_close(rfd); return; } } ! len = read(rfd, buf, CONNECT_BUFSIZE); ! debug(26, 5, "connectReadRemote FD %d read len:%d\n", rfd, len); if (len < 0) { ! debug(26, 1, "connectReadRemote: FD %d: read failure: %s.\n", ! rfd, xstrerror()); if (errno == EAGAIN || errno == EWOULDBLOCK) { /* reinstall handlers */ /* XXX This may loop forever */ ! comm_set_select_handler(rfd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); ! comm_set_select_handler_plus_timeout(rfd, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, *************** *** 94,133 **** BIT_RESET(entry->flag, CACHABLE); storeReleaseRequest(entry); squid_error_entry(entry, ERR_READ_ERROR, xstrerror()); ! comm_close(fd); } } else if (len == 0 && entry->mem_obj->e_current_len == 0) { squid_error_entry(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL); ! comm_close(fd); } else if (len == 0) { /* Connection closed; retrieval done. */ storeExpireNow(entry); storeComplete(entry); ! comm_close(fd); } else if (((entry->mem_obj->e_current_len + len) > ConnectMaxObjSize) && !(entry->flag & DELETE_BEHIND)) { /* accept data, but start to delete behind it */ storeStartDeleteBehind(entry); storeAppend(entry, buf, len); ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); } else { storeAppend(entry, buf, len); ! comm_set_select_handler_plus_timeout(data->client, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, data->timeout); ! comm_set_select_handler_plus_timeout(data->remote, ! COMM_SELECT_TIMEOUT, ! (PF) connectReadTimeout, ! (void *) data, ! data->timeout); ! comm_set_select_handler(fd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); --- 102,136 ---- BIT_RESET(entry->flag, CACHABLE); storeReleaseRequest(entry); squid_error_entry(entry, ERR_READ_ERROR, xstrerror()); ! comm_close(rfd); } } else if (len == 0 && entry->mem_obj->e_current_len == 0) { squid_error_entry(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL); ! comm_close(rfd); } else if (len == 0) { /* Connection closed; retrieval done. */ storeExpireNow(entry); storeComplete(entry); ! comm_close(rfd); } else if (((entry->mem_obj->e_current_len + len) > ConnectMaxObjSize) && !(entry->flag & DELETE_BEHIND)) { /* accept data, but start to delete behind it */ storeStartDeleteBehind(entry); storeAppend(entry, buf, len); ! comm_set_select_handler(rfd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); } else { storeAppend(entry, buf, len); ! comm_set_select_handler_plus_timeout(rfd, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, (void *) data, data->timeout); ! comm_set_select_handler(rfd, COMM_SELECT_READ, (PF) connectReadRemote, (void *) data); *************** *** 135,153 **** } /* This will be called when connect completes. Write request. */ ! static void connectSendRemote(fd, data) ! int fd; ConnectData *data; { int len; ! debug(26, 5, "connectSendRemote FD %d\n", fd); ! len = write(fd, data->buf + data->offset, data->len - data->offset); if (len < 0) { debug(26, 2, "connectSendRemote: FD %d: write failure: %s.\n", ! fd, xstrerror()); ! comm_close(fd); return; } if ((data->offset += len) >= data->len) { --- 138,156 ---- } /* This will be called when connect completes. Write request. */ ! static void connectSendRemote(rfd, data) ! int rfd; ConnectData *data; { int len; ! debug(26, 5, "connectSendRemote FD %d\n", rfd); ! len = write(rfd, data->buf + data->offset, data->len - data->offset); if (len < 0) { debug(26, 2, "connectSendRemote: FD %d: write failure: %s.\n", ! rfd, xstrerror()); ! comm_close(rfd); return; } if ((data->offset += len) >= data->len) { *************** *** 165,189 **** } } ! static void connectReadClient(fd, data) ! int fd; ConnectData *data; { ! data->len = read(fd, data->buf, CONNECT_BUFSIZE); ! debug(26, 2, "connectReadClient FD: %d read len: %d\n", fd, data->len); if (data->len <= 0) { if (data->len < 0) debug(26, 2, "connectReadClient: FD %d: read failure: %s.\n", ! fd, xstrerror()); ! comm_close(fd); return; } data->offset = 0; - comm_set_select_handler_plus_timeout(data->client, - COMM_SELECT_TIMEOUT, - (PF) connectReadTimeout, - (void *) data, - data->timeout); comm_set_select_handler_plus_timeout(data->remote, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, --- 168,194 ---- } } ! static void connectReadClient(cfd, data) ! int cfd; ConnectData *data; { ! data->len = read(cfd, data->buf, CONNECT_BUFSIZE); ! debug(26, 2, "connectReadClient FD: %d read len: %d\n", cfd, data->len); if (data->len <= 0) { if (data->len < 0) debug(26, 2, "connectReadClient: FD %d: read failure: %s.\n", ! cfd, xstrerror()); ! /* disable client read handler */ ! comm_set_select_handler(cfd, ! COMM_SELECT_READ, ! NULL, ! NULL); ! comm_close(data->remote); return; } + if (!fdstat_isopen(data->remote)) + fatal_dump("connectReadClient called after remote side closed\n"); data->offset = 0; comm_set_select_handler_plus_timeout(data->remote, COMM_SELECT_TIMEOUT, (PF) connectReadTimeout, *************** *** 195,244 **** (void *) data); } ! static void connectReadTimeout(fd, data) ! int fd; ConnectData *data; { squid_error_entry(data->entry, ERR_READ_TIMEOUT, NULL); ! comm_close(fd); } ! static void connectConnected(fd, data) ! int fd; ConnectData *data; { storeAppend(data->entry, conn_established, strlen(conn_established)); ! comm_set_fd_lifetime(fd, -1); /* disable lifetime DPW */ ! comm_set_select_handler_plus_timeout(data->remote, COMM_SELECT_TIMEOUT, ! (PF) connectReadTimeout, (void *) data, data->timeout); ! comm_set_select_handler(data->remote, COMM_SELECT_READ, ! (PF) connectReadRemote, (void *) data); ! comm_set_select_handler_plus_timeout(data->client, COMM_SELECT_TIMEOUT, ! (PF) connectReadTimeout, (void *) data, data->timeout); ! comm_set_select_handler(data->client, COMM_SELECT_READ, ! (PF) connectReadClient, (void *) data); } ! static int connectStateFree(fd, connectState) ! int fd; ConnectData *connectState; { if (connectState == NULL) return 1; safe_free(connectState); return 0; } ! void connectConnInProgress(fd, data) ! int fd; ConnectData *data; { request_t *req = data->request; ! debug(26, 5, "connectConnInProgress: FD %d data=%p\n", fd, data); ! if (comm_connect(fd, req->host, req->port) != COMM_OK) { ! debug(26, 5, "connectConnInProgress: FD %d: %s", fd, xstrerror()); switch (errno) { #if EINPROGRESS != EALREADY case EINPROGRESS: --- 200,271 ---- (void *) data); } ! static void connectReadTimeout(rfd, data) ! int rfd; ConnectData *data; { + if (rfd != data->remote) + fatal_dump("connectReadTimeout: FD mismatch!\n"); + debug(26, 3, "connectReadTimeout: FD %d\n", rfd); squid_error_entry(data->entry, ERR_READ_TIMEOUT, NULL); ! comm_set_select_handler(data->remote, ! COMM_SELECT_READ | COMM_SELECT_WRITE, ! NULL, ! NULL); ! /* no matter which side times out, close the server side */ ! comm_close(rfd); } ! static void connectConnected(rfd, data) ! int rfd; ConnectData *data; { + debug(26, 3, "connectConnected: FD %d data=%p\n", rfd, data); storeAppend(data->entry, conn_established, strlen(conn_established)); ! comm_set_fd_lifetime(rfd, -1); /* disable lifetime */ ! comm_set_select_handler_plus_timeout(data->remote, ! COMM_SELECT_TIMEOUT, ! (PF) connectReadTimeout, ! (void *) data, ! data->timeout); ! comm_set_select_handler(data->remote, ! COMM_SELECT_READ, ! (PF) connectReadRemote, ! (void *) data); ! comm_set_select_handler(data->client, ! COMM_SELECT_READ, ! (PF) connectReadClient, ! (void *) data); } ! static int connectStateFree(rfd, connectState) ! int rfd; ConnectData *connectState; { + debug(26, 3, "connectStateFree: FD %d, connectState=%p\n", rfd, connectState); if (connectState == NULL) return 1; + if (rfd != connectState->remote) + fatal_dump("connectStateFree: FD mismatch!\n"); + comm_set_select_handler(connectState->client, + COMM_SELECT_READ, + NULL, + NULL); + memset(connectState, '\0', sizeof(ConnectData)); safe_free(connectState); return 0; } ! static void connectConnInProgress(rfd, data) ! int rfd; ConnectData *data; { request_t *req = data->request; ! debug(26, 5, "connectConnInProgress: FD %d data=%p\n", rfd, data); ! if (comm_connect(rfd, req->host, req->port) != COMM_OK) { ! debug(26, 5, "connectConnInProgress: FD %d: %s", rfd, xstrerror()); switch (errno) { #if EINPROGRESS != EALREADY case EINPROGRESS: *************** *** 245,267 **** #endif case EALREADY: /* We are not connectedd yet. schedule this handler again */ ! comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) connectConnInProgress, (void *) data); return; - case EISCONN: - /* We are connected (doesn't comm_connect return - * COMM_OK on EISCONN?) - */ - break; default: squid_error_entry(data->entry, ERR_CONNECT_FAIL, xstrerror()); ! comm_close(fd); return; } } /* We are now fully connected */ ! connectConnected(fd, data); return; } --- 272,289 ---- #endif case EALREADY: /* We are not connectedd yet. schedule this handler again */ ! comm_set_select_handler(rfd, COMM_SELECT_WRITE, (PF) connectConnInProgress, (void *) data); return; default: squid_error_entry(data->entry, ERR_CONNECT_FAIL, xstrerror()); ! comm_close(rfd); return; } } /* We are now fully connected */ ! connectConnected(rfd, data); return; } *************** *** 298,304 **** data->remote = sock; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! connectStateFree, (void *) data); #ifdef STAT_FD_ASSOC --- 320,326 ---- data->remote = sock; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! (PF) connectStateFree, (void *) data); #ifdef STAT_FD_ASSOC *************** *** 333,338 **** --- 355,361 ---- COMM_SELECT_WRITE, (PF) connectConnInProgress, (void *) data); + return COMM_OK; } } /* We got immediately connected. (can this happen?) */ diff -rc squid-1.0.beta5/src/dnsserver.c squid-1.0.beta6/src/dnsserver.c *** squid-1.0.beta5/src/dnsserver.c Mon Apr 15 22:05:20 1996 --- squid-1.0.beta6/src/dnsserver.c Wed May 01 16:46:50 1996 *************** *** 1,4 **** ! /* $Id: dnsserver.c,v 1.5 1996/04/16 05:05:20 wessels Exp $ */ #include "squid.h" --- 1,4 ---- ! /* $Id: dnsserver.c,v 1.5.2.1 1996/05/01 23:46:50 wessels Exp $ */ #include "squid.h" *************** *** 199,202 **** --- 199,203 ---- exit(0); /*NOTREACHED */ + return 0; } diff -rc squid-1.0.beta5/src/ftp.c squid-1.0.beta6/src/ftp.c *** squid-1.0.beta5/src/ftp.c Thu Apr 25 15:11:29 1996 --- squid-1.0.beta6/src/ftp.c Thu May 02 19:33:50 1996 *************** *** 1,4 **** ! /* $Id: ftp.c,v 1.37.2.8 1996/04/25 22:11:29 wessels Exp $ */ /* * DEBUG: Section 9 ftp: FTP --- 1,4 ---- ! /* $Id: ftp.c,v 1.37.2.14 1996/05/03 02:33:50 wessels Exp $ */ /* * DEBUG: Section 9 ftp: FTP *************** *** 13,28 **** static char ftpASCII[] = "A"; static char ftpBinary[] = "I"; ! static char localhost[] = "localhost"; static int ftpget_server_pipe = -1; typedef struct _Ftpdata { StoreEntry *entry; ! char host[SQUIDHOSTNAMELEN + 1]; ! char request[MAX_URL]; char user[MAX_URL]; char password[MAX_URL]; - int port; char *reply_hdr; int ftp_fd; char *icp_page_ptr; /* Used to send proxy-http request: --- 13,26 ---- static char ftpASCII[] = "A"; static char ftpBinary[] = "I"; ! static char localhost[] = "127.0.0.1"; static int ftpget_server_pipe = -1; typedef struct _Ftpdata { StoreEntry *entry; ! request_t *request; char user[MAX_URL]; char password[MAX_URL]; char *reply_hdr; int ftp_fd; char *icp_page_ptr; /* Used to send proxy-http request: *************** *** 35,40 **** --- 33,53 ---- int reply_hdr_state; } FtpData; + + /* Local functions */ + static int ftpStateFree _PARAMS((int fd, FtpData * ftpState)); + static void ftpProcessReplyHeader _PARAMS((FtpData * data, char *buf, int size)); + static void ftpServerClosed _PARAMS((int fd, void *nodata)); + static void ftp_login_parser _PARAMS((char *login, FtpData * data)); + + /* Global functions not declared in ftp.h */ + void ftpLifetimeExpire _PARAMS((int fd, FtpData * data)); + int ftpReadReply _PARAMS((int fd, FtpData * data)); + void ftpSendComplete _PARAMS((int fd, char *buf, int size, int errflag, FtpData * data)); + void ftpSendRequest _PARAMS((int fd, FtpData * data)); + void ftpConnInProgress _PARAMS((int fd, FtpData * data)); + void ftpServerClose _PARAMS((void)); + static int ftpStateFree(fd, ftpState) int fd; FtpData *ftpState; *************** *** 55,123 **** return 0; } ! int ftp_url_parser(url, data) ! char *url; FtpData *data; { - static char proto[MAX_URL]; - static char hostbuf[MAX_URL]; - char *s = NULL; - int t; - char *host = data->host; - char *request = data->request; char *user = data->user; char *password = data->password; ! debug(9, 3, "ftp_url_parser: parsing '%s'\n", url); ! ! /* initialize everything */ ! proto[0] = hostbuf[0] = '\0'; ! ! t = sscanf(url, "%[a-zA-Z]://%[^/]%s", proto, hostbuf, request); ! if (t < 2) ! return -1; ! if (strcasecmp(proto, "ftp") && strcasecmp(proto, "file")) ! return -1; ! if (t == 2) /* no request */ ! strcpy(request, "/"); ! (void) url_convert_hex(request, 0); /* convert %xx to char */ ! ! /* hostbuf is of the format userid:password@host:port */ ! ! /* separate into user-part and host-part */ ! if ((s = strchr(hostbuf, '@'))) { ! *s = '\0'; ! strcpy(user, hostbuf); ! strcpy(hostbuf, s + 1); ! } ! /* separate into user and password */ ! if ((s = strchr(user, ':'))) { ! *s = '\0'; strcpy(password, s + 1); } ! /* separate into host and port */ ! if ((s = strchr(hostbuf, ':'))) { ! *s = '\0'; ! data->port = atoi(s + 1); ! } ! strncpy(host, hostbuf, SQUIDHOSTNAMELEN); ! if (*user == '\0') strcpy(user, "anonymous"); - if (*password == '\0') strcpy(password, getFtpUser()); ! ! /* we need to convert user and password for URL encodings */ ! (void) url_convert_hex(user, 0); ! ! (void) url_convert_hex(password, 0); ! ! debug(9, 5, "ftp_url_parser: proto = %s\n", proto); ! debug(9, 5, "ftp_url_parser: user = %s\n", data->user); ! debug(9, 5, "ftp_url_parser: pass = %s\n", data->password); ! debug(9, 5, "ftp_url_parser: host = %s\n", data->host); ! debug(9, 5, "ftp_url_parser: port = %d\n", data->port); ! ! return 0; } int ftpCachable(url) --- 68,94 ---- return 0; } ! static void ftp_login_parser(login, data) ! char *login; FtpData *data; { char *user = data->user; char *password = data->password; + char *s = NULL; ! strcpy(user, login); ! s = strchr(user, ':'); ! if (s) { ! *s = 0; strcpy(password, s + 1); + } else { + strcpy(password, ""); } ! ! if (!*user && !*password) { strcpy(user, "anonymous"); strcpy(password, getFtpUser()); ! } } int ftpCachable(url) *************** *** 451,462 **** debug(9, 5, "ftpSendRequest: FD %d\n", fd); ! buflen = strlen(data->request) + 256; buf = (char *) get_free_8k_page(); data->icp_page_ptr = buf; memset(buf, '\0', buflen); ! path = data->request; l = strlen(path); if (path[l - 1] == '/') mode = ftpASCII; --- 422,433 ---- debug(9, 5, "ftpSendRequest: FD %d\n", fd); ! buflen = strlen(data->request->urlpath) + 256; buf = (char *) get_free_8k_page(); data->icp_page_ptr = buf; memset(buf, '\0', buflen); ! path = data->request->urlpath; l = strlen(path); if (path[l - 1] == '/') mode = ftpASCII; *************** *** 470,475 **** --- 441,447 ---- mode = ftpBinary; } + #ifdef NO_NEED_TO_DO_THIS /* Remove leading slash from FTP url-path so that we can * handle ftp://user:pw@host/path objects where path and /path * are quite different. -DW */ *************** *** 477,482 **** --- 449,455 ---- *path = '.'; if (*path == '/') path++; + #endif /* Start building the buffer ... */ *************** *** 500,520 **** sprintf(tbuf, "-n %d ", getNegativeTTL()); strcat(buf, tbuf); } ! if (data->port) { ! sprintf(tbuf, "-P %d ", data->port); strcat(buf, tbuf); } strcat(buf, "-h "); /* httpify */ strcat(buf, "- "); /* stdout */ ! strcat(buf, data->host); strcat(buf, space); ! strcat(buf, path); strcat(buf, space); strcat(buf, mode); /* A or I */ strcat(buf, space); ! strcat(buf, data->user); strcat(buf, space); ! strcat(buf, data->password); strcat(buf, "\n"); debug(9, 5, "ftpSendRequest: FD %d: buf '%s'\n", fd, buf); data->icp_rwd_ptr = icpWrite(fd, --- 473,493 ---- sprintf(tbuf, "-n %d ", getNegativeTTL()); strcat(buf, tbuf); } ! if (data->request->port) { ! sprintf(tbuf, "-P %d ", data->request->port); strcat(buf, tbuf); } strcat(buf, "-h "); /* httpify */ strcat(buf, "- "); /* stdout */ ! strcat(buf, data->request->host); strcat(buf, space); ! strcat(buf, *path ? path : "\"\""); strcat(buf, space); strcat(buf, mode); /* A or I */ strcat(buf, space); ! strcat(buf, *data->user ? data->user : "\"\""); strcat(buf, space); ! strcat(buf, *data->password ? data->password : "\"\""); strcat(buf, "\n"); debug(9, 5, "ftpSendRequest: FD %d: buf '%s'\n", fd, buf); data->icp_rwd_ptr = icpWrite(fd, *************** *** 533,539 **** debug(9, 5, "ftpConnInProgress: FD %d\n", fd); ! if (comm_connect(fd, localhost, CACHE_FTP_PORT) != COMM_OK) switch (errno) { case EINPROGRESS: case EALREADY: --- 506,512 ---- debug(9, 5, "ftpConnInProgress: FD %d\n", fd); ! if (comm_connect(fd, localhost, CACHE_FTP_PORT) != COMM_OK) { switch (errno) { case EINPROGRESS: case EALREADY: *************** *** 543,556 **** (PF) ftpConnInProgress, (void *) data); return; - case EISCONN: - debug(9, 5, "ftpConnInProgress: FD %d is now connected.", fd); - break; /* cool, we're connected */ default: squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(fd); return; } /* Call the real write handler, now that we're fully connected */ comm_set_select_handler(fd, COMM_SELECT_WRITE, --- 516,527 ---- (PF) ftpConnInProgress, (void *) data); return; default: squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(fd); return; } + } /* Call the real write handler, now that we're fully connected */ comm_set_select_handler(fd, COMM_SELECT_WRITE, *************** *** 559,567 **** } ! int ftpStart(unusedfd, url, entry) int unusedfd; char *url; StoreEntry *entry; { FtpData *data = NULL; --- 530,539 ---- } ! int ftpStart(unusedfd, url, request, entry) int unusedfd; char *url; + request_t *request; StoreEntry *entry; { FtpData *data = NULL; *************** *** 571,586 **** data = (FtpData *) xcalloc(1, sizeof(FtpData)); data->entry = entry; ! /* Parse url. */ ! if (ftp_url_parser(url, data)) { ! squid_error_entry(entry, ERR_INVALID_URL, NULL); ! safe_free(data); ! return COMM_ERROR; ! } ! debug(9, 5, "FtpStart: FD %d, host=%s, request=%s, user=%s, passwd=%s\n", ! unusedfd, data->host, data->request, data->user, data->password); data->ftp_fd = comm_open(COMM_NONBLOCKING, 0, 0, url); if (data->ftp_fd == COMM_ERROR) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); --- 543,557 ---- data = (FtpData *) xcalloc(1, sizeof(FtpData)); data->entry = entry; + data->request = request; ! /* Parse login info. */ ! ftp_login_parser(request->login, data); + debug(9, 5, "FtpStart: FD %d, host=%s, path=%s, user=%s, passwd=%s\n", + unusedfd, data->request->host, data->request->urlpath, + data->user, data->password); + data->ftp_fd = comm_open(COMM_NONBLOCKING, 0, 0, url); if (data->ftp_fd == COMM_ERROR) { squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); *************** *** 592,598 **** /* register close handler */ comm_set_select_handler(data->ftp_fd, COMM_SELECT_CLOSE, ! ftpStateFree, (void *) data); /* Now connect ... */ --- 563,569 ---- /* register close handler */ comm_set_select_handler(data->ftp_fd, COMM_SELECT_CLOSE, ! (PF) ftpStateFree, (void *) data); /* Now connect ... */ diff -rc squid-1.0.beta5/src/ftp.h squid-1.0.beta6/src/ftp.h *** squid-1.0.beta5/src/ftp.h Wed Apr 03 17:30:43 1996 --- squid-1.0.beta6/src/ftp.h Thu May 02 18:58:39 1996 *************** *** 1,6 **** ! /* $Id: ftp.h,v 1.5 1996/04/04 01:30:43 wessels Exp $ */ ! extern int ftpStart _PARAMS((int unusedfd, char *url, StoreEntry * entry)); extern int ftpInitialize _PARAMS((void)); extern int ftpCachable _PARAMS((char *)); --- 1,7 ---- ! /* $Id: ftp.h,v 1.5.2.2 1996/05/03 01:58:39 wessels Exp $ */ ! extern int ftpStart _PARAMS((int unusedfd, char *url, request_t * req, StoreEntry * entry)); extern int ftpInitialize _PARAMS((void)); extern int ftpCachable _PARAMS((char *)); + extern void ftpServerClose _PARAMS((void)); diff -rc squid-1.0.beta5/src/ftpget.c squid-1.0.beta6/src/ftpget.c *** squid-1.0.beta5/src/ftpget.c Thu Apr 25 09:37:31 1996 --- squid-1.0.beta6/src/ftpget.c Fri May 03 13:30:30 1996 *************** *** 1,4 **** ! /* $Id: ftpget.c,v 1.23.2.9 1996/04/25 16:37:31 wessels Exp $ */ /* * NOTES --- 1,4 ---- ! /* $Id: ftpget.c,v 1.23.2.24 1996/05/03 20:30:30 wessels Exp $ */ /* * NOTES *************** *** 99,106 **** #include "util.h" ! char *rfc1738_escape(); char *http_time(); typedef struct _ext_table_entry { --- 99,111 ---- #include "util.h" + #ifndef BUFSIZ + #define BUFSIZ 4096 + #endif ! ! char *rfc1738_escape _PARAMS((char *)); ! void rfc1738_unescape _PARAMS((char *)); char *http_time(); typedef struct _ext_table_entry { *************** *** 126,131 **** --- 131,137 ---- #define F_TRYDIR 0x10 #define F_NEEDACCEPT 0x20 #define F_USEBASE 0x40 + #define F_BASEDIR 0x80 typedef enum { BEGIN, *************** *** 158,163 **** --- 164,173 ---- FAIL_HARD /* do cache these */ } state_t; + #define DFD_TYPE_NONE 0 + #define DFD_TYPE_PASV 1 + #define DFD_TYPE_PORT 2 + typedef struct _request { char *host; int port; *************** *** 171,176 **** --- 181,187 ---- int cfd; int sfd; int dfd; + int dfd_type; int conn_att; int login_att; state_t state; *************** *** 301,307 **** While trying to retrieve the URL:\n\ %s\n\

\n\ ! The following %s error was encountered:\n\

    \n\
  • %s\n\
\n\ --- 312,318 ---- While trying to retrieve the URL:\n\ %s\n\

\n\ ! The following FTP error was encountered:\n\

    \n\
  • %s\n\
\n\ *************** *** 365,376 **** log_errno2(__FILE__, __LINE__, "fdopen"); exit(1); } setbuf(fp, NULL); htmlbuf[0] = '\0'; sprintf(htmlbuf, CACHED_RETRIEVE_ERROR_MSG, r->title_url, r->title_url, - "FTP", r->errmsg, longmsg); if (!(r->flags & F_HDRSENT)) { --- 376,388 ---- log_errno2(__FILE__, __LINE__, "fdopen"); exit(1); } + if (r->errmsg == NULL) + r->errmsg = xstrdup(xstrerror()); /* safety net */ setbuf(fp, NULL); htmlbuf[0] = '\0'; sprintf(htmlbuf, CACHED_RETRIEVE_ERROR_MSG, r->title_url, r->title_url, r->errmsg, longmsg); if (!(r->flags & F_HDRSENT)) { *************** *** 401,407 **** fputs(html_trailer(), fp); fclose(fp); if (r->flags & F_HTTPIFY) { ! Debug(26, 9, ("Writing Marker to FD %d\n", r->cfd)); write_with_timeout(r->cfd, MAGIC_MARKER, MAGIC_MARKER_SZ); } } else if (r->errmsg) { --- 413,419 ---- fputs(html_trailer(), fp); fclose(fp); if (r->flags & F_HTTPIFY) { ! Debug(26, 7, ("Writing Marker to FD %d\n", r->cfd)); write_with_timeout(r->cfd, MAGIC_MARKER, MAGIC_MARKER_SZ); } } else if (r->errmsg) { *************** *** 452,458 **** #endif } ! int write_with_timeout(fd, buf, sz) int fd; char *buf; int sz; --- 464,470 ---- #endif } ! static int write_with_timeout(fd, buf, sz) int fd; char *buf; int sz; *************** *** 467,477 **** tv.tv_sec = o_timeout; tv.tv_usec = 0; FD_ZERO(&R); FD_SET(fd, &W); FD_SET(0, &R); last_alarm_set = time(NULL); x = select(fd + 1, &R, &W, NULL, &tv); ! Debug(26, 9, ("write_with_timeout: select returned %d\n", x)); if (x < 0) return x; if (x == 0) /* timeout */ --- 479,491 ---- tv.tv_sec = o_timeout; tv.tv_usec = 0; FD_ZERO(&R); + FD_ZERO(&W); FD_SET(fd, &W); FD_SET(0, &R); last_alarm_set = time(NULL); + Debug(26, 7, ("write_with_timeout: FD %d, %d seconds\n", fd, tv.tv_sec)); x = select(fd + 1, &R, &W, NULL, &tv); ! Debug(26, 7, ("write_with_timeout: select returned %d\n", x)); if (x < 0) return x; if (x == 0) /* timeout */ *************** *** 479,485 **** if (FD_ISSET(0, &R)) exit(1); /* XXX very ungraceful! */ x = write(fd, buf, sz); ! Debug(26, 9, ("write_with_timeout: write returned %d\n", x)); if (x < 0) { log_errno2(__FILE__, __LINE__, "write"); return x; --- 493,499 ---- if (FD_ISSET(0, &R)) exit(1); /* XXX very ungraceful! */ x = write(fd, buf, sz); ! Debug(26, 7, ("write_with_timeout: write returned %d\n", x)); if (x < 0) { log_errno2(__FILE__, __LINE__, "write"); return x; *************** *** 507,512 **** --- 521,527 ---- FD_SET(fd, &R); FD_SET(0, &R); last_alarm_set = time(NULL); + Debug(26, 3, ("read_with_timeout: FD %d, %d seconds\n", fd, tv.tv_sec)); x = select(fd + 1, &R, NULL, NULL, &tv); if (x < 0) return x; *************** *** 559,565 **** int connect_with_timeout2(fd, S, len) int fd; ! struct sockaddr *S; int len; { int x; --- 574,580 ---- int connect_with_timeout2(fd, S, len) int fd; ! struct sockaddr_in *S; int len; { int x; *************** *** 567,583 **** fd_set W; fd_set R; struct timeval tv; ! Debug(26, 9, ("connect_with_timeout2: starting...\n")); ! while (1) { ! y = connect(fd, S, len); ! Debug(26, 9, ("connect returned %d\n", y)); if (y < 0) ! Debug(26, 9, ("connect: %s\n", xstrerror())); if (y >= 0) return y; if (errno == EISCONN) return 0; if (errno != EINPROGRESS && errno != EAGAIN) return y; --- 582,607 ---- fd_set W; fd_set R; struct timeval tv; ! Debug(26, 7, ("connect_with_timeout2: starting...\n")); ! for (;;) { ! Debug(26, 5, ("Connecting FD %d to: %s, port %d, len = %d\n", fd, ! inet_ntoa(S->sin_addr), ! (int) ntohs(S->sin_port), ! len)); ! y = connect(fd, (struct sockaddr *) S, len); ! Debug(26, 7, ("connect returned %d\n", y)); if (y < 0) ! Debug(26, 7, ("connect: %s\n", xstrerror())); if (y >= 0) return y; if (errno == EISCONN) return 0; + if (errno == EINVAL) { + len = sizeof(x); + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *) &x, &len) >= 0) + errno = x; + } if (errno != EINPROGRESS && errno != EAGAIN) return y; *************** *** 590,598 **** FD_SET(fd, &W); FD_SET(0, &R); last_alarm_set = time(NULL); ! Debug(26, 9, ("selecting on FD %d\n", fd)); x = select(fd + 1, &R, &W, NULL, &tv); ! Debug(26, 9, ("select returned: %d\n", x)); if (x == 0) return READ_TIMEOUT; if (x < 0) --- 614,622 ---- FD_SET(fd, &W); FD_SET(0, &R); last_alarm_set = time(NULL); ! Debug(26, 7, ("connect_with_timeout2: selecting on FD %d\n", fd)); x = select(fd + 1, &R, &W, NULL, &tv); ! Debug(26, 7, ("select returned: %d\n", x)); if (x == 0) return READ_TIMEOUT; if (x < 0) *************** *** 605,611 **** /* stupid wrapper for so we can set and clear O_NDELAY */ int connect_with_timeout(fd, S, len) int fd; ! struct sockaddr *S; int len; { int orig_flags; --- 629,635 ---- /* stupid wrapper for so we can set and clear O_NDELAY */ int connect_with_timeout(fd, S, len) int fd; ! struct sockaddr_in *S; int len; { int orig_flags; *************** *** 612,618 **** int rc; orig_flags = fcntl(fd, F_GETFL, 0); ! Debug(26, 9, ("orig_flags = %x\n", orig_flags)); if (fcntl(fd, F_SETFL, O_NDELAY) < 0) log_errno2(__FILE__, __LINE__, "fcntl O_NDELAY"); rc = connect_with_timeout2(fd, S, len); --- 636,642 ---- int rc; orig_flags = fcntl(fd, F_GETFL, 0); ! Debug(26, 7, ("orig_flags = %x\n", orig_flags)); if (fcntl(fd, F_SETFL, O_NDELAY) < 0) log_errno2(__FILE__, __LINE__, "fcntl O_NDELAY"); rc = connect_with_timeout2(fd, S, len); *************** *** 623,629 **** int accept_with_timeout(fd, S, len) int fd; ! struct sockaddr *S; int *len; { int x; --- 647,653 ---- int accept_with_timeout(fd, S, len) int fd; ! struct sockaddr_in *S; int *len; { int x; *************** *** 635,643 **** FD_SET(fd, &R); FD_SET(0, &R); last_alarm_set = time(NULL); ! Debug(26, 9, ("selecting on FD %d\n", fd)); x = select(fd + 1, &R, NULL, NULL, &tv); ! Debug(26, 9, ("select returned: %d\n", x)); if (x == 0) return READ_TIMEOUT; if (x < 0) --- 659,667 ---- FD_SET(fd, &R); FD_SET(0, &R); last_alarm_set = time(NULL); ! Debug(26, 7, ("accept_with_timeout: selecting on FD %d\n", fd)); x = select(fd + 1, &R, NULL, NULL, &tv); ! Debug(26, 7, ("select returned: %d\n", x)); if (x == 0) return READ_TIMEOUT; if (x < 0) *************** *** 644,650 **** return x; if (FD_ISSET(0, &R)) exit(1); ! return accept(fd, S, len); } --- 668,674 ---- return x; if (FD_ISSET(0, &R)) exit(1); ! return accept(fd, (struct sockaddr *) S, len); } *************** *** 832,838 **** while (!quit) { n = readline_with_timeout(fd, buf, SMALLBUFSIZ); ! Debug(26, 1, ("read_reply: readline returned %d\n", n)); if (n < 0) { xfree(server_reply_msg); server_reply_msg = xstrdup(xstrerror()); --- 856,862 ---- while (!quit) { n = readline_with_timeout(fd, buf, SMALLBUFSIZ); ! Debug(26, 9, ("read_reply: readline returned %d\n", n)); if (n < 0) { xfree(server_reply_msg); server_reply_msg = xstrdup(xstrerror()); *************** *** 979,985 **** S.sin_family = AF_INET; S.sin_port = htons(r->port); ! x = connect_with_timeout(sock, (struct sockaddr *) &S, sizeof(S)); if (x == READ_TIMEOUT) { (void) request_timeout(r); return FAIL_CONNECT; --- 1003,1009 ---- S.sin_family = AF_INET; S.sin_port = htons(r->port); ! x = connect_with_timeout(sock, &S, sizeof(S)); if (x == READ_TIMEOUT) { (void) request_timeout(r); return FAIL_CONNECT; *************** *** 1154,1159 **** --- 1178,1201 ---- int port = 0; static int init = 0; + if (r->dfd >= 0 && r->dfd_type == DFD_TYPE_PORT) { + fd_set R; + struct timeval tv; + FD_ZERO(&R); + FD_SET(r->dfd, &R); + tv.tv_sec = 0; + tv.tv_usec = 0; + if (select(r->dfd + 1, &R, NULL, NULL, &tv) == 0) { + Debug(26, 3, ("do_port: FD %d Already connected\n", r->dfd)); + r->flags |= F_NEEDACCEPT; + return PORT_OK; + } else { + Debug(26, 2, ("Data connection closed by server (%s)\n", xstrerror())); + close(r->dfd); + r->dfd = -1; + r->dfd_type = DFD_TYPE_NONE; + } + } if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "socket: %s", xstrerror()); *************** *** 1171,1177 **** srand(time(NULL)); #endif } ! while (1) { #if defined(HAVE_LRAND48) port = (lrand48() % (o_conn_max - o_conn_min)) + o_conn_min; #else --- 1213,1219 ---- srand(time(NULL)); #endif } ! for (;;) { #if defined(HAVE_LRAND48) port = (lrand48() % (o_conn_max - o_conn_min)) + o_conn_min; #else *************** *** 1194,1199 **** --- 1236,1242 ---- r->rc = 2; return FAIL_SOFT; } + Debug(26, 3, ("listening on FD %d\n", sock)); naddr = ntohl(ifc_addr.sin_addr.s_addr); sprintf(cbuf, "PORT %d,%d,%d,%d,%d,%d", (naddr >> 24) & 0xFF, *************** *** 1207,1212 **** --- 1250,1256 ---- if ((code = read_reply(r->sfd)) > 0) { if (code == 200) { r->dfd = sock; + r->dfd_type = DFD_TYPE_PORT; r->flags |= F_NEEDACCEPT; return PORT_OK; } *************** *** 1234,1239 **** --- 1278,1302 ---- if (!pasv_supported) return PASV_FAIL; + if (r->dfd >= 0 && r->dfd_type == DFD_TYPE_PASV) { + fd_set R; + struct timeval tv; + FD_ZERO(&R); + FD_SET(r->dfd, &R); + tv.tv_sec = 0; + tv.tv_usec = 0; + if (select(r->dfd + 1, &R, NULL, NULL, &tv) == 0) { + Debug(26, 3, ("do_pasv: FD %d Already connected\n", r->dfd)); + return PORT_OK; + } else { + Debug(26, 2, ("Data connection closed by server (%s)\n", xstrerror())); + close(r->dfd); + r->dfd = -1; + r->dfd_type = DFD_TYPE_NONE; + } + } + r->flags &= ~F_NEEDACCEPT; + if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "socket: %s", xstrerror()); *************** *** 1253,1259 **** return PASV_FAIL; } /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */ ! n = sscanf(server_reply_msg, "%[^(](%d,%d,%d,%d,%d,%d)", junk, &h1, &h2, &h3, &h4, &p1, &p2); if (n != 7) { r->errmsg = xstrdup(server_reply_msg); --- 1316,1322 ---- return PASV_FAIL; } /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */ ! n = sscanf(server_reply_msg + 3, "%[^0-9]%d,%d,%d,%d,%d,%d", junk, &h1, &h2, &h3, &h4, &p1, &p2); if (n != 7) { r->errmsg = xstrdup(server_reply_msg); *************** *** 1263,1271 **** } sprintf(junk, "%d.%d.%d.%d", h1, h2, h3, h4); S.sin_addr.s_addr = inet_addr(junk); ! S.sin_port = htons((p1 << 8) + p2); ! if (connect_with_timeout(sock, (struct sockaddr *) &S, sizeof(S)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "%s, port %d: %s", junk, port, xstrerror()); r->rc = 2; --- 1326,1334 ---- } sprintf(junk, "%d.%d.%d.%d", h1, h2, h3, h4); S.sin_addr.s_addr = inet_addr(junk); ! S.sin_port = htons(port = ((p1 << 8) + p2)); ! if (connect_with_timeout(sock, &S, sizeof(S)) < 0) { r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "%s, port %d: %s", junk, port, xstrerror()); r->rc = 2; *************** *** 1272,1277 **** --- 1335,1341 ---- return FAIL_SOFT; } r->dfd = sock; + r->dfd_type = DFD_TYPE_PASV; return PORT_OK; } *************** *** 1280,1286 **** { int code; ! if (!strcmp(r->path, ".")) return CWD_OK; sprintf(cbuf, "CWD %s", r->path); --- 1344,1352 ---- { int code; ! Debug(26, 10, ("do_cwd: \"%s\"\n", r->path)); ! ! if (r->flags & F_BASEDIR) return CWD_OK; sprintf(cbuf, "CWD %s", r->path); *************** *** 1290,1301 **** if (code >= 200 && code < 300) return CWD_OK; #ifdef TRY_CWD_FIRST ! return CWD_FAIL; ! #else r->errmsg = xstrdup(server_reply_msg); r->rc = 10; return FAIL_HARD; - #endif } r->errmsg = xstrdup(server_reply_msg); r->rc = code < 0 ? 4 : 5; --- 1356,1367 ---- if (code >= 200 && code < 300) return CWD_OK; #ifdef TRY_CWD_FIRST ! if (!r->flags & F_ISDIR) ! return CWD_FAIL; ! #endif r->errmsg = xstrdup(server_reply_msg); r->rc = 10; return FAIL_HARD; } r->errmsg = xstrdup(server_reply_msg); r->rc = code < 0 ? 4 : 5; *************** *** 1344,1351 **** return FAIL_HARD; } #else - if (r->dfd > 0) - close(r->dfd); if (r->flags & F_TRYDIR) return RETR_FAIL; r->errmsg = xstrdup(server_reply_msg); --- 1410,1415 ---- *************** *** 1414,1421 **** r->rc = 3; return FAIL_SOFT; } ! close(r->dfd); r->dfd = sock; return DATA_TRANSFER; } --- 1478,1488 ---- r->rc = 3; return FAIL_SOFT; } ! r->flags &= ~F_NEEDACCEPT; ! if (r->dfd >= 0) ! close(r->dfd); r->dfd = sock; + r->dfd_type = DFD_TYPE_PORT; return DATA_TRANSFER; } *************** *** 1431,1441 **** --- 1498,1518 ---- if (n == READ_TIMEOUT) { return request_timeout(r); } else if (n < 0) { + if (r->dfd >= 0) { + close(r->dfd); + r->dfd = -1; + r->dfd_type = DFD_TYPE_NONE; + } r->errmsg = (char *) xmalloc(SMALLBUFSIZ); sprintf(r->errmsg, "read: %s", xstrerror()); r->rc = 4; return FAIL_SOFT; } else if (n == 0) { + if (r->dfd >= 0) { + close(r->dfd); + r->dfd = -1; + r->dfd_type = DFD_TYPE_NONE; + } if ((code = read_reply(r->sfd)) > 0) { if (code == 226) return TRANSFER_DONE; *************** *** 1448,1453 **** --- 1525,1532 ---- if (x == READ_TIMEOUT) return request_timeout(r); if (x < 0) { + r->errmsg = (char *) xmalloc(SMALLBUFSIZ); + sprintf(r->errmsg, "write: %s", xstrerror()); r->rc = 4; return FAIL_SOFT; } *************** *** 1699,1705 **** readme->path = xstrdup("README"); readme->cfd = fd; readme->sfd = r->sfd; ! readme->dfd = -1; #ifdef TRY_CWD_FIRST readme->state = CWD_FAIL; #else --- 1778,1786 ---- readme->path = xstrdup("README"); readme->cfd = fd; readme->sfd = r->sfd; ! readme->dfd = r->dfd; ! r->dfd = -1; ! r->dfd_type = DFD_TYPE_NONE; #ifdef TRY_CWD_FIRST readme->state = CWD_FAIL; #else *************** *** 1708,1718 **** readme->flags = F_NOERRS; process_request(readme); ! if (readme->cfd > 0) close(readme->cfd); ! if (readme->dfd > 0) ! close(readme->dfd); ! fp = fopen(tfname, "r"); unlink(tfname); --- 1789,1806 ---- readme->flags = F_NOERRS; process_request(readme); ! if (readme->cfd >= 0) { close(readme->cfd); ! readme->cfd = -1; ! } ! if (readme->dfd >= 0) { ! if (r->dfd == -1) ! r->dfd = readme->dfd; ! else ! close(readme->dfd); ! readme->dfd = -1; ! readme->dfd_type = DFD_TYPE_NONE; ! } fp = fopen(tfname, "r"); unlink(tfname); *************** *** 1760,1771 **** write_with_timeout(r->cfd, l->ptr, strlen(l->ptr)); fprintf(wfp, "\n"); fprintf(wfp, "
\n"); ! } else if (r->readme_fp) { fprintf(wfp, "

README file from %s

\n", r->title_url); fprintf(wfp, "
\n");
  	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
  	    fputs(buf, wfp);
  	fclose(r->readme_fp);
  	fprintf(wfp, "
\n"); fprintf(wfp, "
\n"); } --- 1848,1860 ---- write_with_timeout(r->cfd, l->ptr, strlen(l->ptr)); fprintf(wfp, "\n"); fprintf(wfp, "
\n"); ! } else if (r->readme_fp && r->flags & F_BASEDIR) { fprintf(wfp, "

README file from %s

\n", r->title_url); fprintf(wfp, "
\n");
  	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
  	    fputs(buf, wfp);
  	fclose(r->readme_fp);
+ 	r->readme_fp = NULL;
  	fprintf(wfp, "
\n"); fprintf(wfp, "
\n"); } *************** *** 1773,1779 **** fprintf(wfp, "FTP Directory: %s\n", r->title_url); fprintf(wfp, "\n"); fprintf(wfp, "
\n");
!     if (strcmp(r->path, ".")) {
  	if ((t = htmlize_list_entry("..", r))) {
  	    fputs(t, wfp);
  	    xfree(t);
--- 1862,1868 ----
      fprintf(wfp, "FTP Directory: %s\n", r->title_url);
      fprintf(wfp, "\n");
      fprintf(wfp, "
\n");
!     if (!(r->flags & F_BASEDIR)) {
  	if ((t = htmlize_list_entry("..", r))) {
  	    fputs(t, wfp);
  	    xfree(t);
***************
*** 1792,1797 ****
--- 1881,1891 ----
  	    xfree(t);
  	}
      }
+     if (r->dfd >= 0) {
+ 	close(r->dfd);
+ 	r->dfd = -1;
+ 	r->dfd_type = DFD_TYPE_NONE;
+     }
      if (n == READ_TIMEOUT) {
  	return request_timeout(r);
      } else if (n < 0) {
***************
*** 1802,1807 ****
--- 1896,1910 ----
      }
      fprintf(wfp, "
\n"); fprintf(wfp, "
\n"); + if (r->readme_fp) { + fprintf(wfp, "

README file from %s

\n", r->title_url); + fprintf(wfp, "
\n");
+ 	while (fgets(buf, SMALLBUFSIZ, r->readme_fp))
+ 	    fputs(buf, wfp);
+ 	fclose(r->readme_fp);
+ 	fprintf(wfp, "
\n"); + fprintf(wfp, "
\n"); + } fprintf(wfp, "
\n"); fprintf(wfp, "Generated %s, by %s/%s@%s\n", http_time(stamp), progname, SQUID_VERSION, getfullhostname()); *************** *** 1823,1829 **** if (r == (request_t *) NULL) return 1; ! while (1) { Debug(26, 1, ("process_request: in state %s\n", state_str[r->state])); switch (r->state) { --- 1926,1932 ---- if (r == (request_t *) NULL) return 1; ! for (;;) { Debug(26, 1, ("process_request: in state %s\n", state_str[r->state])); switch (r->state) { *************** *** 1835,1840 **** --- 1938,1948 ---- break; case CONNECTED: r->state = read_welcome(r); + if ((r->flags & F_HTTPIFY) && (r->flags & F_BASEDIR) && cmd_msg) { + list_t *t = r->cmd_msg; + r->cmd_msg = cmd_msg; + cmd_msg = t; + } break; case FAIL_CONNECT: r->state = FAIL_SOFT; *************** *** 1850,1855 **** --- 1958,1968 ---- r->state = do_passwd(r); break; case LOGGED_IN: + if ((r->flags & F_HTTPIFY) && (r->flags & F_BASEDIR) && cmd_msg) { + list_t *t = r->cmd_msg; + r->cmd_msg = cmd_msg; + cmd_msg = t; + } r->state = do_type(r); break; case FAIL_LOGIN: *************** *** 1860,1866 **** } break; case TYPE_OK: ! r->state = do_mdtm(r); break; case MDTM_OK: r->state = do_size(r); --- 1973,1982 ---- } break; case TYPE_OK: ! if (r->flags & F_ISDIR) ! r->state = do_cwd(r); ! else ! r->state = do_mdtm(r); break; case MDTM_OK: r->state = do_size(r); *************** *** 1873,1909 **** #endif break; case CWD_OK: r->flags |= F_ISDIR; ! if (strcmp(r->path, ".")) { /* tack on the trailing slash now that we know its a dir */ strcat(r->url, "/"); strcat(r->title_url, "/"); strcat(r->url_escaped, "/"); - if (*(r->path + strlen(r->path) - 1) != '/') - r->flags |= F_USEBASE; - } else { - /* We must do this only because Netscape's browser is broken */ - r->flags |= F_USEBASE; } if (r->flags & F_HTTPIFY) { ! if (cmd_msg) { r->cmd_msg = cmd_msg; ! cmd_msg = NULL; ! } else { ! if (o_readme) ! try_readme(r); } } r->state = do_pasv(r); break; #ifdef TRY_CWD_FIRST case CWD_FAIL: - r->flags &= ~F_ISDIR; r->state = do_pasv(r); break; #else case RETR_FAIL: - r->flags |= F_ISDIR; r->state = do_cwd(r); break; #endif --- 1989,2020 ---- #endif break; case CWD_OK: + if (!r->flags & F_ISDIR) + r->flags |= F_USEBASE; r->flags |= F_ISDIR; ! if (!(r->flags & F_BASEDIR)) { /* tack on the trailing slash now that we know its a dir */ strcat(r->url, "/"); strcat(r->title_url, "/"); strcat(r->url_escaped, "/"); } if (r->flags & F_HTTPIFY) { ! if (!(r->flags & F_BASEDIR) || cmd_msg) { ! list_t *t = r->cmd_msg; r->cmd_msg = cmd_msg; ! cmd_msg = t; } + if (o_readme) + try_readme(r); } r->state = do_pasv(r); break; #ifdef TRY_CWD_FIRST case CWD_FAIL: r->state = do_pasv(r); break; #else case RETR_FAIL: r->state = do_cwd(r); break; #endif *************** *** 1937,1943 **** break; case DONE: if (r->flags & F_HTTPIFY) { ! Debug(26, 9, ("Writing Marker to FD %d\n", r->cfd)); write_with_timeout(r->cfd, MAGIC_MARKER, MAGIC_MARKER_SZ); } return 0; --- 2048,2054 ---- break; case DONE: if (r->flags & F_HTTPIFY) { ! Debug(26, 7, ("Writing Marker to FD %d\n", r->cfd)); write_with_timeout(r->cfd, MAGIC_MARKER, MAGIC_MARKER_SZ); } return 0; *************** *** 1949,1959 **** r->state = PARSE_OK; } break; - case FAIL_HARD: case FAIL_SOFT: fail(r); return (r->rc); /* NOTREACHED */ default: errorlog("Nothing to do with state %s\n", state_str[r->state]); --- 2060,2073 ---- r->state = PARSE_OK; } break; case FAIL_SOFT: fail(r); return (r->rc); /* NOTREACHED */ + case FAIL_HARD: + fail(r); + return (r->rc); + /* NOTREACHED */ default: errorlog("Nothing to do with state %s\n", state_str[r->state]); *************** *** 1978,1985 **** --- 2092,2112 ---- if (*r->path == '\0') { t = r->path; r->path = xstrdup("."); + r->flags |= F_BASEDIR; xfree(t); again = 1; + } else if ((l >= 1) && (*(r->path + l - 1) == '/')) { + /* remove any trailing slashes from path */ + *(r->path + l - 1) = '\0'; + r->flags |= F_ISDIR; + r->flags &= ~F_USEBASE; + again = 1; + } else if ((l >= 2) && (!strcmp(r->path + l - 2, "/."))) { + /* remove trailing /. */ + *(r->path + l - 2) = '\0'; + r->flags |= F_ISDIR; + r->flags &= ~F_USEBASE; + again = 1; } else if (*r->path == '/') { /* remove any leading slashes from path */ t = r->path; *************** *** 1992,2005 **** r->path = xstrdup(t + 2); xfree(t); again = 1; - } else if (*(r->path + l - 1) == '/') { - /* remove any trailing slashes from path */ - *(r->path + l - 1) = '\0'; - again = 1; - } else if (!strcmp(r->path + l - 2, "/.")) { - /* remove trailing /. */ - *(r->path + l - 2) = '\0'; - again = 1; } else if ((t = strstr(r->path, "/./"))) { /* remove /./ */ s = xstrdup(t + 2); --- 2119,2124 ---- *************** *** 2062,2068 **** log_errno2(__FILE__, __LINE__, "listen"); exit(1); } ! while (1) { FD_ZERO(&R); FD_SET(0, &R); FD_SET(sock, &R); --- 2181,2187 ---- log_errno2(__FILE__, __LINE__, "listen"); exit(1); } ! for (;;) { FD_ZERO(&R); FD_SET(0, &R); FD_SET(sock, &R); *************** *** 2101,2107 **** --- 2220,2229 ---- i = 0; t = strtok(buf, w_space); while (t && i < MAX_ARGS - 1) { + if (strcmp(t, "\"\"") == 0) + t = ""; args[i] = xstrdup(t); + rfc1738_unescape(args[i]); Debug(26, 5, ("args[%d] = %s\n", i, args[i])); t = strtok(NULL, w_space); i++; *************** *** 2192,2198 **** } for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) { ! Debug(26, 9, ("processing arg '%s'\n", *argv)); if (!strcmp(*argv, "-")) break; if (!strncmp(*argv, "-D", 2)) { --- 2314,2320 ---- } for (argc--, argv++; argc > 0 && **argv == '-'; argc--, argv++) { ! Debug(26, 7, ("processing arg '%s'\n", *argv)); if (!strcmp(*argv, "-")) break; if (!strncmp(*argv, "-D", 2)) { *************** *** 2333,2342 **** --- 2455,2466 ---- r->port = port; r->sfd = -1; r->dfd = -1; + r->dfd_type = DFD_TYPE_NONE; r->size = -1; r->state = BEGIN; r->flags |= o_httpify ? F_HTTPIFY : 0; r->flags |= F_TRYDIR; + r->flags |= F_USEBASE; r->rest_implemented = 1; if (*(r->type) != 'A' && *(r->type) != 'I') { *************** *** 2360,2366 **** } strcat(r->url, r->host); strcat(r->url, "/"); ! if (strcmp(r->path, ".")) strcat(r->url, r->path); *r->title_url = '\0'; --- 2484,2490 ---- } strcat(r->url, r->host); strcat(r->url, "/"); ! if (!(r->flags & F_BASEDIR)) strcat(r->url, r->path); *r->title_url = '\0'; *************** *** 2371,2377 **** } strcat(r->title_url, r->host); strcat(r->title_url, "/"); ! if (strcmp(r->path, ".")) strcat(r->title_url, r->path); /* Make a copy of the escaped URL with some room to grow at the end */ --- 2495,2501 ---- } strcat(r->title_url, r->host); strcat(r->title_url, "/"); ! if (!(r->flags & F_BASEDIR)) strcat(r->title_url, r->path); /* Make a copy of the escaped URL with some room to grow at the end */ *************** *** 2380,2392 **** strcpy(r->url_escaped, t); rc = process_request(MainRequest = r); ! if (r->sfd > 0) send_cmd(r->sfd, "QUIT"); ! if (r->sfd > 0) close(r->sfd); ! if (r->cfd > 0) close(r->cfd); ! if (r->dfd > 0) close(r->dfd); close(0); close(1); --- 2504,2516 ---- strcpy(r->url_escaped, t); rc = process_request(MainRequest = r); ! if (r->sfd >= 0) send_cmd(r->sfd, "QUIT"); ! if (r->sfd >= 0) close(r->sfd); ! if (r->cfd >= 0) close(r->cfd); ! if (r->dfd >= 0) close(r->dfd); close(0); close(1); diff -rc squid-1.0.beta5/src/gopher.c squid-1.0.beta6/src/gopher.c *** squid-1.0.beta5/src/gopher.c Tue Apr 23 22:52:50 1996 --- squid-1.0.beta6/src/gopher.c Wed May 01 16:46:52 1996 *************** *** 1,4 **** ! /* $Id: gopher.c,v 1.28.2.1 1996/04/24 05:52:50 wessels Exp $ */ /* * DEBUG: Section 10 gopher: GOPHER --- 1,4 ---- ! /* $Id: gopher.c,v 1.28.2.2 1996/05/01 23:46:52 wessels Exp $ */ /* * DEBUG: Section 10 gopher: GOPHER *************** *** 874,880 **** } comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! gopherStateFree, (void *) data); /* check if IP is already in cache. It must be. --- 874,880 ---- } comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! (PF) gopherStateFree, (void *) data); /* check if IP is already in cache. It must be. diff -rc squid-1.0.beta5/src/http.c squid-1.0.beta6/src/http.c *** squid-1.0.beta5/src/http.c Thu Apr 25 15:05:15 1996 --- squid-1.0.beta6/src/http.c Thu May 02 09:53:58 1996 *************** *** 1,4 **** ! /* $Id: http.c,v 1.56.2.4 1996/04/25 22:05:15 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP --- 1,4 ---- ! /* $Id: http.c,v 1.56.2.6 1996/05/02 16:53:58 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP *************** *** 474,480 **** debug(11, 5, "httpConnInProgress: FD %d data=%p\n", fd, data); if (comm_connect(fd, req->host, req->port) != COMM_OK) { ! debug(11, 5, "httpConnInProgress: FD %d errno=%d\n", fd, errno); switch (errno) { case EINPROGRESS: case EALREADY: --- 474,480 ---- debug(11, 5, "httpConnInProgress: FD %d data=%p\n", fd, data); if (comm_connect(fd, req->host, req->port) != COMM_OK) { ! debug(11, 5, "httpConnInProgress: FD %d: %s\n", fd, xstrerror()); switch (errno) { case EINPROGRESS: case EALREADY: *************** *** 484,491 **** (PF) httpConnInProgress, (void *) data); return; - case EISCONN: - break; /* cool, we're connected */ default: squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror()); comm_close(fd); --- 484,489 ---- *************** *** 531,537 **** /* register the handler to free HTTP state data when the FD closes */ comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! httpStateFree, (void *) data); request->method = entry->method; --- 529,535 ---- /* register the handler to free HTTP state data when the FD closes */ comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! (PF) httpStateFree, (void *) data); request->method = entry->method; *************** *** 602,608 **** data->request = request; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! httpStateFree, (void *) data); /* check if IP is already in cache. It must be. --- 600,606 ---- data->request = request; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! (PF) httpStateFree, (void *) data); /* check if IP is already in cache. It must be. diff -rc squid-1.0.beta5/src/icp.c squid-1.0.beta6/src/icp.c *** squid-1.0.beta5/src/icp.c Thu Apr 25 16:25:04 1996 --- squid-1.0.beta6/src/icp.c Thu May 02 17:11:13 1996 *************** *** 1,6 **** ! /* $Id: icp.c,v 1.61.2.15 1996/04/25 23:25:04 wessels Exp $ */ /* * DEBUG: Section 12 icp: --- 1,6 ---- ! /* $Id: icp.c,v 1.61.2.19 1996/05/03 00:11:13 wessels Exp $ */ /* * DEBUG: Section 12 icp: *************** *** 59,64 **** --- 59,65 ---- char *buf; struct timeval start; int flags; + int size; /* hack for CONNECT which doesnt use sentry */ } icpStateData; static icpUdpData *UdpQueueHead = NULL; *************** *** 115,120 **** --- 116,125 ---- fatal_dump("icpStateFree: icpState->log_type out of range."); if (icpState->entry) { size = icpState->entry->mem_obj->e_current_len; + } else { + size = icpState->size; /* hack added for CONNECT objects */ + } + if (icpState->entry) { http_code = icpState->entry->mem_obj->reply->code; } else { http_code = icpState->http_code; *************** *** 341,347 **** /* A successful write, continue */ rwsm->offset += len; if (rwsm->offset < rwsm->size) { ! /* Reinstall the read handler and get some more */ comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) icpHandleWrite, --- 346,352 ---- /* A successful write, continue */ rwsm->offset += len; if (rwsm->offset < rwsm->size) { ! /* Reinstall the read handler and write some more */ comm_set_select_handler(fd, COMM_SELECT_WRITE, (PF) icpHandleWrite, *************** *** 433,439 **** /* This file descriptor isn't bound to a socket anymore. * It probably timed out. */ debug(12, 2, "icpSendERROR: COMM_ERROR msg: %80.80s\n", msg); ! comm_close(fd); return COMM_ERROR; } if (port != getAsciiPortNum()) { --- 438,445 ---- /* This file descriptor isn't bound to a socket anymore. * It probably timed out. */ debug(12, 2, "icpSendERROR: COMM_ERROR msg: %80.80s\n", msg); ! /* comm_close(fd); */ ! icpSendERRORComplete(fd, NULL, 0, 1, state); return COMM_ERROR; } if (port != getAsciiPortNum()) { *************** *** 550,556 **** icpSendMoreData(fd, state); } ! void icpHandleStoreComplete(fd, buf, size, errflag, state) int fd; char *buf; int size; --- 556,562 ---- icpSendMoreData(fd, state); } ! static void icpHandleStoreComplete(fd, buf, size, errflag, state) int fd; char *buf; int size; *************** *** 629,634 **** --- 635,645 ---- RequestMethodStr[usm->method], url); + if (usm->method == METHOD_CONNECT) { + usm->log_type = LOG_TCP_MISS; + sslStart(fd, url, usm->request, usm->request_hdr, &usm->size); + return; + } if (icpCachable(usm)) BIT_SET(usm->flags, REQ_CACHABLE); if (icpHierarchical(usm)) *************** *** 828,834 **** buf_len += sizeof(u_num32); buf = xcalloc(buf_len, 1); ! headerp = (icp_common_t *) buf; headerp->opcode = opcode; headerp->version = ICP_VERSION_CURRENT; headerp->length = htons(buf_len); --- 839,845 ---- buf_len += sizeof(u_num32); buf = xcalloc(buf_len, 1); ! headerp = (icp_common_t *) (void *) buf; headerp->opcode = opcode; headerp->version = ICP_VERSION_CURRENT; headerp->length = htons(buf_len); *************** *** 899,905 **** return result; } /* Get fields from incoming message. */ ! headerp = (icp_common_t *) buf; header.opcode = headerp->opcode; header.version = headerp->version; header.length = ntohs(headerp->length); --- 910,916 ---- return result; } /* Get fields from incoming message. */ ! headerp = (icp_common_t *) (void *) buf; header.opcode = headerp->opcode; header.version = headerp->version; header.length = ntohs(headerp->length); *************** *** 1342,1348 **** k, /* size */ 30, /* timeout */ TRUE, /* handle immed */ ! asciiProcessInput, (void *) astm); } else { /* parser returned -1 */ --- 1353,1359 ---- k, /* size */ 30, /* timeout */ TRUE, /* handle immed */ ! (complete_handler) asciiProcessInput, (void *) astm); } else { /* parser returned -1 */ *************** *** 1458,1464 **** (void *) astm); comm_set_select_handler(fd, COMM_SELECT_CLOSE, ! icpStateFree, (void *) astm); icpRead(fd, FALSE, --- 1469,1475 ---- (void *) astm); comm_set_select_handler(fd, COMM_SELECT_CLOSE, ! (PF) icpStateFree, (void *) astm); icpRead(fd, FALSE, *************** *** 1466,1472 **** astm->inbufsize - 1, /* size */ 30, /* timeout */ 1, /* handle immed */ ! asciiProcessInput, (void *) astm); comm_set_select_handler(sock, COMM_SELECT_READ, --- 1477,1483 ---- astm->inbufsize - 1, /* size */ 30, /* timeout */ 1, /* handle immed */ ! (complete_handler) asciiProcessInput, (void *) astm); comm_set_select_handler(sock, COMM_SELECT_READ, *************** *** 1494,1506 **** static void CheckQuickAbort(astm) icpStateData *astm; { - if (!getQuickAbort()) - return; if (astm->entry == NULL) return; if (astm->entry->lock_count != 1) return; if (astm->entry->store_status == STORE_OK) return; BIT_SET(astm->entry->flag, CLIENT_ABORT_REQUEST); storeReleaseRequest(astm->entry); --- 1505,1519 ---- static void CheckQuickAbort(astm) icpStateData *astm; { if (astm->entry == NULL) return; if (astm->entry->lock_count != 1) return; if (astm->entry->store_status == STORE_OK) + return; + if (!getQuickAbort() && + BIT_TEST(astm->flags, REQ_CACHABLE) && + !BIT_TEST(astm->entry->flag, KEY_PRIVATE)) return; BIT_SET(astm->entry->flag, CLIENT_ABORT_REQUEST); storeReleaseRequest(astm->entry); diff -rc squid-1.0.beta5/src/ipcache.c squid-1.0.beta6/src/ipcache.c *** squid-1.0.beta5/src/ipcache.c Thu Apr 25 09:34:59 1996 --- squid-1.0.beta6/src/ipcache.c Thu May 02 18:52:32 1996 *************** *** 1,4 **** ! /* $Id: ipcache.c,v 1.26.2.2 1996/04/25 16:34:59 wessels Exp $ */ /* * DEBUG: Section 14 ipcache: IP Cache --- 1,4 ---- ! /* $Id: ipcache.c,v 1.26.2.7 1996/05/03 01:52:32 wessels Exp $ */ /* * DEBUG: Section 14 ipcache: IP Cache *************** *** 106,112 **** int pid; struct sockaddr_un addr; static int n_dnsserver = 0; ! char socketname[256]; int cfd; /* socket for child (dnsserver) */ int sfd; /* socket for server (squid) */ int fd; --- 106,112 ---- int pid; struct sockaddr_un addr; static int n_dnsserver = 0; ! char *socketname = NULL; int cfd; /* socket for child (dnsserver) */ int sfd; /* socket for server (squid) */ int fd; *************** *** 119,125 **** fd_note(cfd, "socket to dnsserver"); memset(&addr, '\0', sizeof(addr)); addr.sun_family = AF_UNIX; ! sprintf(socketname, "dns/dns%d.%d", (int) getpid(), n_dnsserver++); strcpy(addr.sun_path, socketname); debug(14, 4, "ipcache_create_dnsserver: path is %s\n", addr.sun_path); --- 119,126 ---- fd_note(cfd, "socket to dnsserver"); memset(&addr, '\0', sizeof(addr)); addr.sun_family = AF_UNIX; ! socketname = tempnam(NULL, "dns"); ! /* sprintf(socketname, "dns/dns%d.%d", (int) getpid(), n_dnsserver++); */ strcpy(addr.sun_path, socketname); debug(14, 4, "ipcache_create_dnsserver: path is %s\n", addr.sun_path); *************** *** 126,131 **** --- 127,133 ---- if (bind(cfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(cfd); debug(14, 0, "ipcache_create_dnsserver: bind: %s\n", xstrerror()); + xfree(socketname); return -1; } debug(14, 4, "ipcache_create_dnsserver: bind to local host.\n"); *************** *** 134,139 **** --- 136,142 ---- if ((pid = fork()) < 0) { debug(14, 0, "ipcache_create_dnsserver: fork: %s\n", xstrerror()); close(cfd); + xfree(socketname); return -1; } if (pid > 0) { /* parent */ *************** *** 142,147 **** --- 145,151 ---- /* open new socket for parent process */ if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { debug(14, 0, "ipcache_create_dnsserver: socket: %s\n", xstrerror()); + xfree(socketname); return -1; } fcntl(sfd, F_SETFD, 1); /* set close-on-exec */ *************** *** 148,153 **** --- 152,158 ---- memset(&addr, '\0', sizeof(addr)); addr.sun_family = AF_UNIX; strcpy(addr.sun_path, socketname); + xfree(socketname); if (connect(sfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { close(sfd); debug(14, 0, "ipcache_create_dnsserver: connect: %s\n", xstrerror()); *************** *** 826,832 **** break; } e->entry.h_addr_list[i] = (char *) xcalloc(1, e->entry.h_length); ! *((unsigned long *) e->entry.h_addr_list[i]) = inet_addr(line_cur->line); line_cur = line_cur->next; i++; } --- 831,837 ---- break; } e->entry.h_addr_list[i] = (char *) xcalloc(1, e->entry.h_length); ! *((unsigned long *) (void *) e->entry.h_addr_list[i]) = inet_addr(line_cur->line); line_cur = line_cur->next; i++; } *************** *** 1059,1071 **** int i; int dnssocket; static char fd_note_buf[FD_ASCII_NOTE_SZ]; ! if (mkdir("dns", 0755) < 0 && errno != EEXIST) ! debug(14, 0, "ipcacheOpenServers: mkdir %s\n", xstrerror()); ! ! /* start up companion process */ ! safe_free(dns_child_table); dns_child_table = (dnsserver_entry **) xcalloc(N, sizeof(dnsserver_entry)); dns_child_alive = 0; debug(14, 1, "ipcacheOpenServers: Starting %d 'dns_server' processes\n", N); for (i = 0; i < N; i++) { --- 1064,1079 ---- int i; int dnssocket; static char fd_note_buf[FD_ASCII_NOTE_SZ]; + static int NChildrenAlloc = 0; ! /* free old structures if present */ ! if (dns_child_table) { ! for (i = 0; i < NChildrenAlloc; i++) ! safe_free(dns_child_table[i]->ip_inbuf); ! safe_free(dns_child_table); ! } dns_child_table = (dnsserver_entry **) xcalloc(N, sizeof(dnsserver_entry)); + NChildrenAlloc = N; dns_child_alive = 0; debug(14, 1, "ipcacheOpenServers: Starting %d 'dns_server' processes\n", N); for (i = 0; i < N; i++) { *************** *** 1231,1237 **** } /* check if it's already a IP address in text form. */ if (sscanf(name, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) == 4) { ! *((unsigned long *) static_result->h_addr_list[0]) = inet_addr(name); strncpy(static_result->h_name, name, MAX_HOST_NAME); return static_result; } else { --- 1239,1245 ---- } /* check if it's already a IP address in text form. */ if (sscanf(name, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) == 4) { ! *((unsigned long *) (void *) static_result->h_addr_list[0]) = inet_addr(name); strncpy(static_result->h_name, name, MAX_HOST_NAME); return static_result; } else { diff -rc squid-1.0.beta5/src/main.c squid-1.0.beta6/src/main.c *** squid-1.0.beta5/src/main.c Thu Apr 25 15:06:54 1996 --- squid-1.0.beta6/src/main.c Wed May 01 16:46:55 1996 *************** *** 1,4 **** ! /* $Id: main.c,v 1.44.4.10 1996/04/25 22:06:54 wessels Exp $ */ /* DEBUG: Section 1 main: startup and main loop */ --- 1,4 ---- ! /* $Id: main.c,v 1.44.4.11 1996/05/01 23:46:55 wessels Exp $ */ /* DEBUG: Section 1 main: startup and main loop */ *************** *** 41,47 **** %s\n\ -a port Specify ASCII port number (default: %d).\n\ -u port Specify UDP port number (default: %d).\n", ! appname, DEFAULT_CONFIG_FILE, CACHE_HTTP_PORT, CACHE_ICP_PORT); exit(1); } --- 41,47 ---- %s\n\ -a port Specify ASCII port number (default: %d).\n\ -u port Specify UDP port number (default: %d).\n", ! appname, DefaultConfigFile, CACHE_HTTP_PORT, CACHE_ICP_PORT); exit(1); } *************** *** 73,79 **** case 's': syslog_enable = 0; break; - break; case 'R': do_reuse = 0; break; --- 73,78 ---- *************** *** 322,328 **** /* main loop */ if (getCleanRate() > 0) next_cleaning = time(NULL) + getCleanRate(); ! while (1) { loop_delay = (time_t) 60; /* maintain cache storage */ if (squid_curtime > last_maintain) { --- 321,327 ---- /* main loop */ if (getCleanRate() > 0) next_cleaning = time(NULL) + getCleanRate(); ! for (;;) { loop_delay = (time_t) 60; /* maintain cache storage */ if (squid_curtime > last_maintain) { *************** *** 382,385 **** --- 381,385 ---- } /* NOTREACHED */ exit(0); + return 0; } diff -rc squid-1.0.beta5/src/neighbors.c squid-1.0.beta6/src/neighbors.c *** squid-1.0.beta5/src/neighbors.c Tue Apr 23 12:49:31 1996 --- squid-1.0.beta6/src/neighbors.c Wed May 01 12:18:29 1996 *************** *** 1,4 **** ! /* $Id: neighbors.c,v 1.22.2.1 1996/04/23 19:49:31 wessels Exp $ */ /* TODO: * - change 'neighbor' to 'sibling' --- 1,4 ---- ! /* $Id: neighbors.c,v 1.22.2.2 1996/05/01 19:18:29 wessels Exp $ */ /* TODO: * - change 'neighbor' to 'sibling' *************** *** 104,118 **** } } else { if (cache_host) { ! fprintf(cache_hierarchy_log, "%d %s %s%s %s\n", ! (int) squid_curtime, url, timeout ? "TIMEOUT_" : "", hier_strings[code], cache_host); } else { ! fprintf(cache_hierarchy_log, "%d %s %s%s\n", ! (int) squid_curtime, url, timeout ? "TIMEOUT_" : "", hier_strings[code]); --- 104,120 ---- } } else { if (cache_host) { ! fprintf(cache_hierarchy_log, "%d.%03d %s %s%s %s\n", ! (int) current_time.tv_sec, ! (int) current_time.tv_usec / 1000, url, timeout ? "TIMEOUT_" : "", hier_strings[code], cache_host); } else { ! fprintf(cache_hierarchy_log, "%d.%03d %s %s%s\n", ! (int) current_time.tv_sec, ! (int) current_time.tv_usec / 1000, url, timeout ? "TIMEOUT_" : "", hier_strings[code]); diff -rc squid-1.0.beta5/src/proto.c squid-1.0.beta6/src/proto.c *** squid-1.0.beta5/src/proto.c Tue Apr 23 22:52:52 1996 --- squid-1.0.beta6/src/proto.c Thu May 02 18:58:39 1996 *************** *** 1,4 **** ! /* $Id: proto.c,v 1.27.2.3 1996/04/24 05:52:52 wessels Exp $ */ /* * DEBUG: Section 17 proto: --- 1,4 ---- ! /* $Id: proto.c,v 1.27.2.7 1996/05/03 01:58:39 wessels Exp $ */ /* * DEBUG: Section 17 proto: *************** *** 295,300 **** --- 295,301 ---- protoDNSError(fd, entry); return 1; } + /* NOTREACHED */ return 0; } *************** *** 411,421 **** } else if (request->protocol == PROTO_GOPHER) { return gopherStart(fd, url, entry); } else if (request->protocol == PROTO_FTP) { ! return ftpStart(fd, url, entry); } else if (request->protocol == PROTO_WAIS) { return waisStart(fd, url, entry->method, request_hdr, entry); } else if (entry->method == METHOD_CONNECT) { ! return connectStart(fd, url, request, request_hdr, entry); } else { return protoNotImplemented(fd, url, entry); } --- 412,423 ---- } else if (request->protocol == PROTO_GOPHER) { return gopherStart(fd, url, entry); } else if (request->protocol == PROTO_FTP) { ! return ftpStart(fd, url, request, entry); } else if (request->protocol == PROTO_WAIS) { return waisStart(fd, url, entry->method, request_hdr, entry); } else if (entry->method == METHOD_CONNECT) { ! fatal_dump("getFromCache() should not be handling CONNECT"); ! return 0; } else { return protoNotImplemented(fd, url, entry); } Only in squid-1.0.beta5/src: squid.conf.in Only in squid-1.0.beta6/src: squid.conf.pre.in diff -rc squid-1.0.beta5/src/squid.h squid-1.0.beta6/src/squid.h *** squid-1.0.beta5/src/squid.h Thu Apr 25 15:06:35 1996 --- squid-1.0.beta6/src/squid.h Thu May 02 18:52:32 1996 *************** *** 1,8 **** ! /* $Id: squid.h,v 1.19.4.3 1996/04/25 22:06:35 wessels Exp $ */ #include "config.h" #include "autoconf.h" #if SQUID_FD_SETSIZE > 256 #define FD_SETSIZE SQUID_FD_SETSIZE --- 1,9 ---- ! /* $Id: squid.h,v 1.19.4.8 1996/05/03 01:52:32 wessels Exp $ */ #include "config.h" #include "autoconf.h" + #include "version.h" #if SQUID_FD_SETSIZE > 256 #define FD_SETSIZE SQUID_FD_SETSIZE *************** *** 16,22 **** --- 17,25 ---- #include #include #include + #ifndef _SQUID_FREEBSD_ /* "Obsolete" Markus Stumpf */ #include + #endif #include #include #include *************** *** 73,78 **** --- 76,85 ---- #define SQUIDHOSTNAMELEN MAXHOSTNAMELEN #endif + #ifndef BUFSIZ + #define BUFSIZ 4096 /* make reasonable guess */ + #endif + typedef struct sentry StoreEntry; typedef struct mem_hdr *mem_ptr; typedef struct _edge edge; *************** *** 120,126 **** #include "ftp.h" #include "gopher.h" #include "wais.h" ! #include "connect.h" #include "objcache.h" #include "send-announce.h" #include "acl.h" --- 127,133 ---- #include "ftp.h" #include "gopher.h" #include "wais.h" ! #include "ssl.h" #include "objcache.h" #include "send-announce.h" #include "acl.h" Only in squid-1.0.beta6/src: ssl.c Only in squid-1.0.beta6/src: ssl.h diff -rc squid-1.0.beta5/src/stat.c squid-1.0.beta6/src/stat.c *** squid-1.0.beta5/src/stat.c Thu Apr 25 22:36:19 1996 --- squid-1.0.beta6/src/stat.c Wed May 01 12:15:34 1996 *************** *** 1,4 **** ! /* $Id: stat.c,v 1.28.4.10 1996/04/26 05:36:19 wessels Exp $ */ /* * DEBUG: Section 18 stat --- 1,4 ---- ! /* $Id: stat.c,v 1.28.4.11 1996/05/01 19:15:34 wessels Exp $ */ /* * DEBUG: Section 18 stat *************** *** 983,990 **** memcpy(obj->logfilename, logfilename, (int) (strlen(logfilename) + 1) % 256); obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT); if (obj->logfile_fd == DISK_ERROR) { ! debug(18, 0, "Cannot open logfile: %s\n", obj->logfilename); ! obj->logfile_status = LOG_DISABLE; fatal("Cannot open logfile."); } obj->logfile_access = file_write_lock(obj->logfile_fd); --- 983,989 ---- memcpy(obj->logfilename, logfilename, (int) (strlen(logfilename) + 1) % 256); obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT); if (obj->logfile_fd == DISK_ERROR) { ! debug(18, 0, "%s: %s\n", obj->logfilename, xstrerror()); fatal("Cannot open logfile."); } obj->logfile_access = file_write_lock(obj->logfile_fd); diff -rc squid-1.0.beta5/src/store.c squid-1.0.beta6/src/store.c *** squid-1.0.beta5/src/store.c Thu Apr 25 15:05:16 1996 --- squid-1.0.beta6/src/store.c Thu May 02 09:55:51 1996 *************** *** 1,5 **** ! /* $Id: store.c,v 1.61.4.8 1996/04/25 22:05:16 wessels Exp $ */ /* * DEBUG: Section 20 store --- 1,5 ---- ! /* $Id: store.c,v 1.61.4.12 1996/05/02 16:55:51 wessels Exp $ */ /* * DEBUG: Section 20 store *************** *** 435,441 **** { int e_lock_count; - debug(20, 3, "storeUnlockObject: key '%s' count=%d\n", e->key, e->lock_count); if ((int) e->lock_count > 0) e->lock_count--; --- 435,440 ---- *************** *** 442,447 **** --- 441,448 ---- else if (e->lock_count == 0) { debug(20, 0, "Entry lock count %d is out-of-whack\n", e->lock_count); } + debug(20, 3, "storeUnlockObject: key '%s' count=%d\n", e->key, e->lock_count); + /* Prevent UMR if we end up freeing the entry */ e_lock_count = (int) e->lock_count; *************** *** 512,529 **** --- 513,534 ---- switch (method) { case METHOD_GET: return url; + /* NOTREACHED */ break; case METHOD_POST: sprintf(key_temp_buffer, "/post/%s", url); return key_temp_buffer; + /* NOTREACHED */ break; case METHOD_HEAD: sprintf(key_temp_buffer, "/head/%s", url); return key_temp_buffer; + /* NOTREACHED */ break; case METHOD_CONNECT: sprintf(key_temp_buffer, "/connect/%s", url); return key_temp_buffer; + /* NOTREACHED */ break; default: fatal_dump("storeGeneratePublicKey: Unsupported request method"); *************** *** 567,572 **** --- 572,578 ---- StoreEntry *e2 = NULL; hash_link *table_entry = NULL; char *newkey = NULL; + int loop_detect = 0; if (e->key && !BIT_TEST(e->flag, KEY_PRIVATE)) return; /* is already public */ *************** *** 577,582 **** --- 583,591 ---- e2 = (StoreEntry *) table_entry; storeSetPrivateKey(e2); storeReleaseRequest(e2); + if (loop_detect++ == 10) + fatal_dump("storeSetPublicKey() is looping!!"); + newkey = storeGeneratePublicKey(e->url, e->method); } if (e->key) storeHashDelete(e); *************** *** 1462,1470 **** /* Start reading the log file */ runInBackground("storeRebuild", ! storeDoRebuildFromDisk, data, ! storeRebuiltFromDisk); } /* return current swap size in kilo-bytes */ --- 1471,1479 ---- /* Start reading the log file */ runInBackground("storeRebuild", ! (int (*)(void *)) storeDoRebuildFromDisk, data, ! (void (*)(void *)) storeRebuiltFromDisk); } /* return current swap size in kilo-bytes */ diff -rc squid-1.0.beta5/src/url.c squid-1.0.beta6/src/url.c *** squid-1.0.beta5/src/url.c Wed Apr 24 08:16:55 1996 --- squid-1.0.beta6/src/url.c Thu May 02 18:58:39 1996 *************** *** 1,4 **** ! /* $Id: url.c,v 1.19.2.4 1996/04/24 15:16:55 wessels Exp $ */ /* * DEBUG: Section 23 url --- 1,4 ---- ! /* $Id: url.c,v 1.19.2.6 1996/05/03 01:58:39 wessels Exp $ */ /* * DEBUG: Section 23 url *************** *** 161,166 **** --- 161,167 ---- char *url; { static char proto[MAX_URL + 1]; + static char login[MAX_URL + 1]; static char host[MAX_URL + 1]; static char urlpath[MAX_URL + 1]; request_t *request = NULL; *************** *** 167,185 **** char *t = NULL; int port; protocol_t protocol = PROTO_NONE; ! proto[0] = host[0] = urlpath[0] = '\0'; if (method == METHOD_CONNECT) { port = CONNECT_PORT; if (sscanf(url, "%[^:]:%d", host, &port) < 1) return NULL; - if (!aclMatchInteger(connect_port_list, port)) - return NULL; } else { if (sscanf(url, "%[^:]://%[^/]%s", proto, host, urlpath) < 2) return NULL; protocol = urlParseProtocol(proto); port = urlDefaultPort(protocol); if ((t = strrchr(host, ':')) && *(t + 1) != '\0') { *t = '\0'; port = atoi(t + 1); --- 168,191 ---- char *t = NULL; int port; protocol_t protocol = PROTO_NONE; ! proto[0] = host[0] = urlpath[0] = login[0] = '\0'; if (method == METHOD_CONNECT) { port = CONNECT_PORT; if (sscanf(url, "%[^:]:%d", host, &port) < 1) return NULL; } else { if (sscanf(url, "%[^:]://%[^/]%s", proto, host, urlpath) < 2) return NULL; protocol = urlParseProtocol(proto); port = urlDefaultPort(protocol); + /* Is there any login informaiton? */ + if ((t = strrchr(host, '@'))) { + strcpy(login, host); + t = strrchr(login, '@'); + *t = 0; + strcpy(host, t + 1); + } if ((t = strrchr(host, ':')) && *(t + 1) != '\0') { *t = '\0'; port = atoi(t + 1); *************** *** 195,200 **** --- 201,207 ---- request->method = method; request->protocol = protocol; strncpy(request->host, host, SQUIDHOSTNAMELEN); + strncpy(request->login, login, MAX_LOGIN_SZ); request->port = port; strncpy(request->urlpath, urlpath, MAX_URL); return request; *************** *** 216,223 **** portbuf[0] = '\0'; if (request->port != urlDefaultPort(request->protocol)) sprintf(portbuf, ":%d", request->port); ! sprintf(buf, "%s://%s%s%s", ProtocolStr[request->protocol], request->host, portbuf, request->urlpath); --- 223,232 ---- portbuf[0] = '\0'; if (request->port != urlDefaultPort(request->protocol)) sprintf(portbuf, ":%d", request->port); ! sprintf(buf, "%s://%s%s%s%s%s", ProtocolStr[request->protocol], + request->login, + *request->login ? "@" : "", request->host, portbuf, request->urlpath); diff -rc squid-1.0.beta5/src/url.h squid-1.0.beta6/src/url.h *** squid-1.0.beta5/src/url.h Fri Apr 19 09:46:58 1996 --- squid-1.0.beta6/src/url.h Thu May 02 18:58:40 1996 *************** *** 1,9 **** ! /* $Id: url.h,v 1.11.2.1 1996/04/19 16:46:58 wessels Exp $ */ #ifndef _URL_HEADER_ #define _URL_HEADER_ #define MAX_URL 4096 typedef enum { METHOD_NONE, --- 1,10 ---- ! /* $Id: url.h,v 1.11.2.2 1996/05/03 01:58:40 wessels Exp $ */ #ifndef _URL_HEADER_ #define _URL_HEADER_ #define MAX_URL 4096 + #define MAX_LOGIN_SZ 128 typedef enum { METHOD_NONE, *************** *** 30,35 **** --- 31,37 ---- typedef struct _request { method_t method; protocol_t protocol; + char login[MAX_LOGIN_SZ + 1]; char host[SQUIDHOSTNAMELEN + 1]; int port; char urlpath[MAX_URL + 1]; diff -rc squid-1.0.beta5/src/wais.c squid-1.0.beta6/src/wais.c *** squid-1.0.beta5/src/wais.c Tue Apr 23 22:52:55 1996 --- squid-1.0.beta6/src/wais.c Wed May 01 16:46:57 1996 *************** *** 1,4 **** ! /* $Id: wais.c,v 1.28.4.2 1996/04/24 05:52:55 wessels Exp $ */ /* * DEBUG: Section 24 wais --- 1,4 ---- ! /* $Id: wais.c,v 1.28.4.3 1996/05/01 23:46:57 wessels Exp $ */ /* * DEBUG: Section 24 wais *************** *** 258,264 **** data->mime_hdr = mime_hdr; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! waisStateFree, (void *) data); /* check if IP is already in cache. It must be. --- 258,264 ---- data->mime_hdr = mime_hdr; comm_set_select_handler(sock, COMM_SELECT_CLOSE, ! (PF) waisStateFree, (void *) data); /* check if IP is already in cache. It must be.