]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
SSL->HTTP gatewaying support by Benno Rice
authorhno <>
Sat, 14 Apr 2001 06:03:19 +0000 (06:03 +0000)
committerhno <>
Sat, 14 Apr 2001 06:03:19 +0000 (06:03 +0000)
Allows Squid in accelerator mode to listen for https requests
as well as http requests.

31 files changed:
configure.in
helpers/digest_auth/password/Makefile.in
include/md5.h
include/rfc2617.h
lib/md5.c
lib/rfc2617.c
src/Makefile.in
src/cf.data.pre
src/client_side.cc
src/comm.cc
src/disk.cc
src/errorpage.cc
src/fd.cc
src/ftp.cc
src/gopher.cc
src/helper.cc
src/http.cc
src/ident.cc
src/main.cc
src/mime.cc
src/pconn.cc
src/send-announce.cc
src/squid.h
src/ssl.cc
src/structs.h
src/tools.cc
src/tunnel.cc
src/typedefs.h
src/url.cc
src/wais.cc
src/whois.cc

index 83805aa1fab31a18049dbe8f510ca56f7676e1f8..d9b2da2db12908923492e511b44b8bf19b240164 100644 (file)
@@ -3,13 +3,13 @@ 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.222 2001/03/10 00:55:35 hno Exp $
+dnl  $Id: configure.in,v 1.223 2001/04/14 00:03:19 hno Exp $
 dnl
 dnl
 dnl
 AC_INIT(src/main.c)
 AC_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.222 $)dnl
+AC_REVISION($Revision: 1.223 $)dnl
 AC_PREFIX_DEFAULT(/usr/local/squid)
 AC_CONFIG_AUX_DIR(cfgaux)
 
@@ -501,6 +501,53 @@ AC_ARG_ENABLE(htcp,
 ])
 AC_SUBST(HTCP_OBJS)
 
+AC_ARG_ENABLE(ssl,
+[  --enable-ssl            Enable ssl gatewaying support using OpenSSL],
+[ if test "$enableval" != "no"; then
+    echo "SSL gatewaying enabled"
+    AC_DEFINE(USE_SSL)
+    SSL_OBJS='$(SSL_OBJS)'
+    SSLLIB='-lssl -lcrypto'
+    USE_OPENSSL=1
+  fi
+])
+
+AC_ARG_WITH(openssl,
+[  --with-openssl[=prefix]
+                          Compile with the OpenSSL libraries. The path to
+                         the OpenSSL development libraries and headers
+                         installation can be specified if outside of the
+                         system standard directories],
+[ 
+  case "$with_ssl" in
+  yes)
+    USE_OPENSSL=1
+    ;;
+  no)
+    USE_OPENSSL=
+    ;;
+  *)
+    SSLLIBDIR="$with_ssl/lib"
+    SSLINC="-I$with_ssl/include"
+    USE_OPENSSL=1
+  esac
+])
+
+if test -n "$USE_OPENSSL"; then
+  AC_DEFINE(USE_OPENSSL)
+  if test -z "$SSLLIB"; then
+    SSLLIB="-lcrypto" # for MD5 routines
+  fi
+fi
+if test -n "$SSLLIBDIR"; then
+  SSLLIB="-L$SSLLIBDIR $SSLLIB"
+fi
+if test -n "$SSLINC"; then
+  CFLAGS="$CFLAGS $SSLINC"
+fi
+AC_SUBST(SSL_OBJS)
+AC_SUBST(SSLLIB)
+
 AC_ARG_ENABLE(forw-via-db,
 [  --enable-forw-via-db    Enable Forw/Via database],
 [ if test "$enableval" = "yes" ; then
@@ -952,6 +999,9 @@ AC_CHECK_HEADERS( \
        netinet/ip_fil_compat.h \
        netinet/ip_fil.h \
        netinet/ip_nat.h \
+       openssl/err.h \
+       openssl/md5.h \
+       openssl/ssl.h \
        poll.h \
        pwd.h \
        regex.h \
index ec9b4b868fee9b1d7dbf8587298ca1a3d097c8bf..66b83d6aa79d0551e8b9992efd865990c5237b9e 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.1 2001/01/31 22:16:42 hno Exp $
+#  $Id: Makefile.in,v 1.2 2001/04/14 00:03:25 hno Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -45,11 +45,11 @@ XTRA_OBJS   = @XTRA_OBJS@
 MV             = @MV@
 RM             = @RM@
 SHELL          = /bin/sh
-
+SSLLIB         = @SSLLIB@
 
 INCLUDE                = -I. -I../../../../../include -I$(top_srcdir)/include
 CFLAGS                 = $(AC_CFLAGS) $(INCLUDE) $(DEFINES)
-AUTH_LIBS      = -L../../../../../lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS)
+AUTH_LIBS      = -L../../../../../lib -lmiscutil $(CRYPTLIB) $(XTRA_LIBS) $(SSLLIB)
 
 PROGS           = $(DIGEST_PW_AUTH_EXE)
 OBJS           = digest_pw_auth.o
index e8e323dde3f4c76f9176aef4f5f9b56f60be9bfa..ab8d072e619c96fa6b325ff4d026851c827d8ca1 100644 (file)
@@ -1,9 +1,27 @@
 /*
- * $Id: md5.h,v 1.8 2001/03/11 21:55:20 hno Exp $
+ * $Id: md5.h,v 1.9 2001/04/14 00:03:20 hno Exp $
  */
 
 #ifndef MD5_H
 #define MD5_H
+
+#if USE_OPENSSL
+
+#if HAVE_OPENSSL_MD5_H
+#include <openssl/md5.h>
+#else
+#error Cannot find OpenSSL headers
+#endif
+
+/* Hack to adopt Squid to the OpenSSL syntax */
+#define MD5_DIGEST_CHARS MD5_DIGEST_LENGTH
+
+#define MD5Init MD5_Init
+#define MD5Update MD5_Update
+#define MD5Final MD5_Final
+
+#else /* USE_OPENSSL */
+
 /* MD5.H - header file for MD5C.C
  */
 
@@ -44,4 +62,5 @@ void MD5Final(unsigned char[16], MD5_CTX *);
 
 #define MD5_DIGEST_CHARS         16
 
+#endif /* USE_OPENSSL */
 #endif /* MD5_H */
index 189ec88a02ef451d160488a09c3dcd9f4cdffab4..bdeac3faa202a89f93e5a02a2e1be9e5e3543c48 100644 (file)
@@ -14,7 +14,7 @@
 
 
 /*
- * $Id: rfc2617.h,v 1.1 2001/01/31 22:16:36 hno Exp $
+ * $Id: rfc2617.h,v 1.2 2001/04/14 00:03:20 hno Exp $
  *
  * DEBUG:
  * AUTHOR: RFC 2617 & Robert Collins
@@ -49,7 +49,6 @@
 
 #ifndef RFC2617_H
 #define RFC2617_H
-#include "md5.h"
 
 #define HASHLEN 16
 typedef char HASH[HASHLEN];
index 4aa10a1e6d80b73d3f2b6591acc48225d8a3ff68..2ae975669884bf73c88d41ade9b8fa9ebfae6f98 100644 (file)
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -1,5 +1,5 @@
 /*
- * $Id: md5.c,v 1.11 2001/03/11 21:55:20 hno Exp $
+ * $Id: md5.c,v 1.12 2001/04/14 00:03:20 hno Exp $
  */
 
 /* taken from RFC-1321/Appendix A.3 */
@@ -32,6 +32,7 @@
 
 #include "config.h"
 
+#if !USE_OPENSSL
 /*
  * Only compile md5.c if we need it.  Its needed for MD5 store keys
  * and by the SNMP routines.
@@ -360,3 +361,5 @@ MD5_memset(char *output, int value, unsigned int len)
 }
 
 #endif
+
+#endif /* USE_OPENSSL */
index 7bf15833e01311afce2c6ad16eee766f273b2830..bb93686d19d3588ab075887ba0b73255a57ae6af 100644 (file)
@@ -13,7 +13,7 @@
 
 
 /*
- * $Id: rfc2617.c,v 1.2 2001/02/01 18:49:06 hno Exp $
+ * $Id: rfc2617.c,v 1.3 2001/04/14 00:03:20 hno Exp $
  *
  * DEBUG:
  * AUTHOR: RFC 2617 & Robert Collins
@@ -49,6 +49,7 @@
 #include "config.h"
 #include <string.h>
 #include "rfc2617.h"
+#include "md5.h"
 
 void 
 CvtHex(const HASH Bin, HASHHEX Hex)
index ac0f50a2fcebd364c810090dfa9979de62431a1f..8d9b372b5b73daf8c53c68586d277f44662b0281 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.200 2001/04/03 20:22:10 adrian Exp $
+#  $Id: Makefile.in,v 1.201 2001/04/14 00:03:21 hno Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -65,6 +65,7 @@ REGEXLIB      = @REGEXLIB@
 PTHREADLIB     = @PTHREADLIB@
 SNMPLIB                = @SNMPLIB@
 MALLOCLIB      = @LIB_MALLOC@
+SSLLIB         = @SSLLIB@
 AC_CFLAGS      = @CFLAGS@
 LDFLAGS                = @LDFLAGS@
 XTRA_LIBS      = @XTRA_LIBS@
@@ -80,7 +81,7 @@ SHELL         = /bin/sh
 INCLUDE                = -I. -I../include -I$(top_srcdir)/include
 CFLAGS                 = $(AC_CFLAGS) $(INCLUDE) $(DEFINES)
 SQUID_LIBS     = -L../lib $(CRYPTLIB) $(REGEXLIB) @SQUID_PTHREAD_LIB@ \
-                 $(SNMPLIB) $(MALLOCLIB) -lmiscutil $(XTRA_LIBS)
+                 $(SNMPLIB) $(MALLOCLIB) $(SSLLIB) -lmiscutil $(XTRA_LIBS)
 CLIENT_LIBS    = -L../lib -lmiscutil $(XTRA_LIBS)
 DNSSERVER_LIBS = -L../lib -lmiscutil $(XTRA_LIBS)
 PINGER_LIBS    = -L../lib -lmiscutil $(XTRA_LIBS)
@@ -160,6 +161,7 @@ OBJS                = \
                send-announce.o \
                @SNMP_OBJS@ \
                ssl.o \
+               @SSL_OBJS@ \
                stat.o \
                StatHist.o \
                String.o \
@@ -198,6 +200,8 @@ DELAY_OBJS  = delay_pools.o
 LEAKFINDER_OBJS        = \
                leakfinder.o
 
+SSL_OBJS       = ssl_support.o
+
 DEFAULTS        = \
        -DDEFAULT_CONFIG_FILE=\"$(DEFAULT_CONFIG_FILE)\"
 
index 32badc31edb41b98f7ea5ae9a45feb81e247c9b4..5d8357e7e20e3babb3075a0bbc6262f42d82d582 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.216 2001/04/03 20:22:10 adrian Exp $
+# $Id: cf.data.pre,v 1.217 2001/04/14 00:03:21 hno Exp $
 #
 #
 # SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -84,6 +84,57 @@ DOC_START
        You may specify multiple socket addresses on multiple lines.
 DOC_END
 
+NAME: https_port
+IFDEF: USE_SSL
+TYPE: sockaddr_in_list
+DEFAULT: none
+LOC: Config.Sockaddr.https
+DOC_START
+        Usage:  port
+                hostname:port
+                1.2.3.4:port
+
+        The socket addresses where Squid will listen for HTTPS client
+        requests.  You may specify multiple socket addresses.
+
+        This is really only useful for situations where you are running
+        squid in accelerator mode and you want to do the SSL work at the
+        accelerator level.
+DOC_END
+
+NAME: ssl_certificate
+IFDEF: USE_SSL
+TYPE: string
+DEFAULT: none
+LOC: Config.SSL.certificate
+COMMENT: /path/to/certificate
+DOC_START
+        Certificate for use with SSL acceleration.
+DOC_END
+
+NAME: ssl_key
+IFDEF: USE_SSL
+TYPE: string
+DEFAULT: none
+LOC: Config.SSL.key
+COMMENT: /path/to/key
+DOC_START
+        Key for SSL certificate defined in ssl_certificate.
+DOC_END
+
+NAME: ssl_version
+IFDEF: USE_SSL
+TYPE: int
+DEFAULT: 1
+LOC: Config.SSL.version
+DOC_START
+        Determines the version of SSL/TLS used.
+        1:      SSLv2/SSLv3
+        2:      SSLv2 only
+        3:      SSLv3 only
+        4:      TLSv1
+DOC_END
+
 
 NAME: icp_port udp_port
 TYPE: ushort
@@ -447,7 +498,6 @@ DOC_START
        be handled directly by this cache.  In other words, use this
        to not query neighbor caches for certain objects.  You may
        list this option multiple times.
-
 NOCOMMENT_START
 #We recommend you to use at least the following line.
 hierarchy_stoplist cgi-bin ?
@@ -685,6 +735,8 @@ DOC_START
        
        cache_dir Type Directory-Name Fs-specific-data [options]
 
+       cache_dir diskd Maxobjsize Directory-Name MB L1 L2 Q1 Q2
+
        You can specify multiple cache_dir lines to spread the
        cache among different disk partitions.
 
index fa10dcc2806e19867626299ff17c46dbee535696..b3caf3a94b449cc4f80a095794979b749dffae33 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.533 2001/04/13 14:59:11 hno Exp $
+ * $Id: client_side.cc,v 1.534 2001/04/14 00:03:21 hno Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -831,7 +831,7 @@ connStateFree(int fd, void *data)
     /* prevent those nasty RST packets */
     {
        char buf[SQUID_TCP_SO_RCVBUF];
-       while (read(fd, buf, SQUID_TCP_SO_RCVBUF) > 0);
+       while (FD_READ_METHOD(fd, buf, SQUID_TCP_SO_RCVBUF) > 0);
     }
 #endif
 }
@@ -2472,6 +2472,7 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
        if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
            int vport;
            char *q;
+           char *protocol_name = "http";
            if (vport_mode)
                vport = (int) ntohs(http->conn->me.sin_port);
            else
@@ -2494,8 +2495,15 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
            url_sz = strlen(url) + 32 + Config.appendDomainLen +
                strlen(t);
            http->uri = xcalloc(url_sz, 1);
-           snprintf(http->uri, url_sz, "http://%s:%d%s",
-               t, vport, url);
+
+#if SSL_FORWARDING_NOT_YET_DONE
+           if (Config.Sockaddr.https->s.sin_port == http->conn->me.sin_port) {
+               protocol_name = "https";
+               vport = ntohs(http->conn->me.sin_port);
+           }
+#endif
+           snprintf(http->uri, url_sz, "%s://%s:%d%s",
+               protocol_name, t, vport, url);
        } else if (vhost_mode) {
            int vport;
            /* Put the local socket IP address as the hostname */
@@ -2611,7 +2619,7 @@ clientReadRequest(int fd, void *data)
     int len = conn->in.size - conn->in.offset - 1;
     debug(33, 4) ("clientReadRequest: FD %d: reading request...\n", fd);
     statCounter.syscalls.sock.reads++;
-    size = read(fd, conn->in.buf + conn->in.offset, len);
+    size = FD_READ_METHOD(fd, conn->in.buf + conn->in.offset, len);
     if (size > 0) {
        fd_bytes(fd, size, FD_READ);
        kb_incr(&statCounter.client_http.kbytes_in, size);
@@ -3105,6 +3113,112 @@ httpAccept(int sock, void *data)
     }
 }
 
+#if USE_SSL
+
+/* negotiate an SSL connection */
+static void
+clientNegotiateSSL(int fd, void *data)
+{
+    ConnStateData *conn = data;
+    X509 *client_cert;
+    int ret;
+
+    if ((ret = SSL_accept(fd_table[fd].ssl)) <= 0) {
+       if (BIO_sock_should_retry(ret)) {
+           commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, conn, 0);
+           return;
+       }
+       ret = ERR_get_error();
+       debug(81, 1) ("clientNegotiateSSL: Error negotiating SSL connection on FD %d: %s\n",
+           fd, ERR_error_string(ret, NULL));
+       comm_close(fd);
+       return;
+    }
+    debug(81, 5) ("clientNegotiateSSL: FD %d negotiated cipher %s\n", fd,
+       SSL_get_cipher(fd_table[fd].ssl));
+
+    client_cert = SSL_get_peer_certificate(fd_table[fd].ssl);
+    if (client_cert != NULL) {
+       debug(81, 5) ("clientNegotiateSSL: FD %d client certificate: subject: %s\n", fd,
+           X509_NAME_oneline(X509_get_subject_name(client_cert), 0, 0));
+
+       debug(81, 5) ("clientNegotiateSSL: FD %d client certificate: issuer: %s\n", fd,
+           X509_NAME_oneline(X509_get_issuer_name(client_cert), 0, 0));
+
+       X509_free(client_cert);
+    } else {
+       debug(81, 5) ("clientNegotiateSSL: FD %d has no certificate.\n", fd);
+    }
+
+    commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, conn, 0);
+}
+
+/* handle a new HTTPS connection */
+static void
+httpsAccept(int sock, void *data)
+{
+    int *N = data;
+    int fd = -1;
+    ConnStateData *connState = NULL;
+    struct sockaddr_in peer;
+    struct sockaddr_in me;
+    int max = INCOMING_HTTP_MAX;
+    SSL *ssl;
+    int ssl_error;
+#if USE_IDENT
+    static aclCheck_t identChecklist;
+#endif
+    commSetSelect(sock, COMM_SELECT_READ, httpsAccept, NULL, 0);
+    while (max-- && !httpAcceptDefer(sock, NULL)) {
+       memset(&peer, '\0', sizeof(struct sockaddr_in));
+       memset(&me, '\0', sizeof(struct sockaddr_in));
+       if ((fd = comm_accept(sock, &peer, &me)) < 0) {
+           if (!ignoreErrno(errno))
+               debug(50, 1) ("httpsAccept: FD %d: accept failure: %s\n",
+                   sock, xstrerror());
+           break;
+       }
+       if ((ssl = SSL_new(sslContext)) == NULL) {
+           ssl_error = ERR_get_error();
+           debug(81, 1) ("httpsAccept: Error allocating handle: %s\n",
+               ERR_error_string(ssl_error, NULL));
+           break;
+       }
+       SSL_set_fd(ssl, fd);
+       fd_table[fd].ssl = ssl;
+       fd_table[fd].read_method = &ssl_read_method;
+       fd_table[fd].write_method = &ssl_write_method;
+       debug(50, 5) ("httpsAccept: FD %d accepted, starting SSL negotiation.\n", fd);
+
+       connState = cbdataAlloc(ConnStateData);
+       connState->peer = peer;
+       connState->log_addr = peer.sin_addr;
+       connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
+       connState->me = me;
+       connState->fd = fd;
+       connState->in.size = CLIENT_REQ_BUF_SZ;
+       connState->in.buf = memAllocate(MEM_CLIENT_REQ_BUF);
+       /* XXX account connState->in.buf */
+       comm_add_close_handler(fd, connStateFree, connState);
+       if (Config.onoff.log_fqdn)
+           fqdncache_gethostbyaddr(peer.sin_addr, FQDN_LOOKUP_IF_MISS);
+       commSetTimeout(fd, Config.Timeout.request, requestTimeout, connState);
+#if USE_IDENT
+       identChecklist.src_addr = peer.sin_addr;
+       identChecklist.my_addr = me.sin_addr;
+       identChecklist.my_port = ntohs(me.sin_port);
+       if (aclCheckFast(Config.accessList.identLookup, &identChecklist))
+           identStart(&me, &peer, clientIdentDone, connState);
+#endif
+       commSetSelect(fd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
+       commSetDefer(fd, clientReadDefer, connState);
+       clientdbEstablished(peer.sin_addr, 1);
+       (*N)++;
+    }
+}
+
+#endif /* USE_SSL */
+
 #define SENDING_BODY 0
 #define SENDING_HDRSONLY 1
 static int
@@ -3263,6 +3377,28 @@ clientHttpConnectionsOpen(void)
            fd);
        HttpSockets[NHttpSockets++] = fd;
     }
+#ifdef USE_SSL
+    for (s = Config.Sockaddr.https; s; s = s->next) {
+       enter_suid();
+       fd = comm_open(SOCK_STREAM,
+           0,
+           s->s.sin_addr,
+           ntohs(s->s.sin_port),
+           COMM_NONBLOCKING,
+           "HTTPS Socket");
+       leave_suid();
+       if (fd < 0)
+           continue;
+       comm_listen(fd);
+       commSetSelect(fd, COMM_SELECT_READ, httpsAccept, NULL, 0);
+       /*commSetDefer(fd, httpAcceptDefer, NULL); */
+       debug(1, 1) ("Accepting HTTPS connections at %s, port %d, FD %d.\n",
+           inet_ntoa(s->s.sin_addr),
+           (int) ntohs(s->s.sin_port),
+           fd);
+       HttpSockets[NHttpSockets++] = fd;
+    }
+#endif
     if (NHttpSockets < 1)
        fatal("Cannot open HTTP Port");
 }
index 76a092da581b56b36a26976a3172fffde712b089..fd8f1cf28f87c3b16c544e92b3322c54ddf8b0b3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.317 2001/03/03 10:39:31 hno Exp $
+ * $Id: comm.cc,v 1.318 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -537,7 +537,7 @@ commLingerClose(int fd, void *unused)
 {
     LOCAL_ARRAY(char, buf, 1024);
     int n;
-    n = read(fd, buf, 1024);
+    n = FD_READ_METHOD(fd, buf, 1024);
     if (n < 0)
        debug(5, 3) ("commLingerClose: FD %d read: %s\n", fd, xstrerror());
     comm_close(fd);
@@ -570,10 +570,12 @@ void
 comm_close(int fd)
 {
     fde *F = NULL;
+
     debug(5, 5) ("comm_close: FD %d\n", fd);
     assert(fd >= 0);
     assert(fd < Squid_MaxFD);
     F = &fd_table[fd];
+
     if (F->flags.closing)
        return;
     if (shutting_down && (!F->flags.open || F->type == FD_FILE))
@@ -807,7 +809,7 @@ commHandleWrite(int fd, void *data)
        fd, (int) state->offset, state->size);
 
     nleft = state->size - state->offset;
-    len = write(fd, state->buf + state->offset, nleft);
+    len = FD_WRITE_METHOD(fd, state->buf + state->offset, nleft);
     debug(5, 5) ("commHandleWrite: write() returns %d\n", len);
     fd_bytes(fd, len, FD_WRITE);
     statCounter.syscalls.sock.writes++;
index 27a23f45d9f3f0cf05d2ee798222830259d3eb14..9ddf0821a3b5e8fd1af6991ff8e7ee2d7d32f667 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: disk.cc,v 1.154 2001/01/12 00:37:17 wessels Exp $
+ * $Id: disk.cc,v 1.155 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 6     Disk I/O Routines
  * AUTHOR: Harvest Derived
@@ -192,7 +192,7 @@ diskHandleWrite(int fd, void *notused)
     errno = 0;
     if (fdd->write_q->file_offset != -1)
        lseek(fd, fdd->write_q->file_offset, SEEK_SET);
-    len = write(fd,
+    len = FD_WRITE_METHOD(fd,
        fdd->write_q->buf + fdd->write_q->buf_offset,
        fdd->write_q->len - fdd->write_q->buf_offset);
     debug(6, 3) ("diskHandleWrite: FD %d len = %d\n", fd, len);
@@ -361,7 +361,7 @@ diskHandleRead(int fd, void *data)
        F->disk.offset = ctrl_dat->offset;
     }
     errno = 0;
-    len = read(fd, ctrl_dat->buf, ctrl_dat->req_len);
+    len = FD_READ_METHOD(fd, ctrl_dat->buf, ctrl_dat->req_len);
     if (len > 0)
        F->disk.offset += len;
     statCounter.syscalls.disk.reads++;
index 2c64294997748285a75a5cca81018b4167efe08e..43511f77fc03fd8c895b48d58481ba422755bd2e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.163 2001/03/03 10:39:31 hno Exp $
+ * $Id: errorpage.cc,v 1.164 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -177,7 +177,7 @@ errorTryLoadText(const char *page_name, const char *dir)
        return NULL;
     }
     text = xcalloc(sb.st_size + 2 + 1, 1);     /* 2 == space for %S */
-    if (read(fd, text, sb.st_size) != sb.st_size) {
+    if (FD_READ_METHOD(fd, text, sb.st_size) != sb.st_size) {
        debug(4, 0) ("errorTryLoadText: failed to fully read: '%s': %s\n",
            path, xstrerror());
        xfree(text);
index 22b1c307da9609eb89117e986477646ca30c1ef6..99225b6378e0063f82038dabb25e97ef750ee9fa 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fd.cc,v 1.41 2001/01/12 00:37:17 wessels Exp $
+ * $Id: fd.cc,v 1.42 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 51    Filedescriptor Functions
  * AUTHOR: Duane Wessels
@@ -35,6 +35,9 @@
 
 #include "squid.h"
 
+int default_read_method(int, char *, int);
+int default_write_method(int, const char *, int);
+
 const char *fdTypeStr[] =
 {
     "None",
@@ -80,6 +83,12 @@ fd_close(int fd)
        assert(F->read_handler == NULL);
        assert(F->write_handler == NULL);
     }
+    F->read_method = &default_read_method;
+    F->write_method = &default_write_method;
+#if USE_SSL
+    safe_free(F->ssl);
+    F->ssl = NULL;
+#endif
     debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc);
     F->flags.open = 0;
     fdUpdateBiggest(fd, 0);
@@ -90,6 +99,18 @@ fd_close(int fd)
     F->timeout = 0;
 }
 
+int
+default_read_method(int fd, char *buf, int len)
+{
+    return (read(fd, buf, len));
+}
+
+int
+default_write_method(int fd, const char *buf, int len)
+{
+    return (write(fd, buf, len));
+}
+
 void
 fd_open(int fd, unsigned int type, const char *desc)
 {
@@ -104,6 +125,8 @@ fd_open(int fd, unsigned int type, const char *desc)
     debug(51, 3) ("fd_open FD %d %s\n", fd, desc);
     F->type = type;
     F->flags.open = 1;
+    F->read_method = &default_read_method;
+    F->write_method = &default_write_method;
     fdUpdateBiggest(fd, 1);
     if (desc)
        xstrncpy(F->desc, desc, FD_DESC_SZ);
index 60717dc3786bac4761c42c69eb3cb019e4c0be7f..f75e519ab5e5ba7c67994cd14523c6a8fedc2d41 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.308 2001/03/03 10:39:32 hno Exp $
+ * $Id: ftp.cc,v 1.309 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -883,7 +883,7 @@ ftpDataRead(int fd, void *data)
 #endif
     memset(ftpState->data.buf + ftpState->data.offset, '\0', read_sz);
     statCounter.syscalls.sock.reads++;
-    len = read(fd, ftpState->data.buf + ftpState->data.offset, read_sz);
+    len = FD_READ_METHOD(fd, ftpState->data.buf + ftpState->data.offset, read_sz);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
@@ -1244,7 +1244,7 @@ ftpReadControlReply(int fd, void *data)
     }
     assert(ftpState->ctrl.offset < ftpState->ctrl.size);
     statCounter.syscalls.sock.reads++;
-    len = read(fd,
+    len = FD_READ_METHOD(fd,
        ftpState->ctrl.buf + ftpState->ctrl.offset,
        ftpState->ctrl.size - ftpState->ctrl.offset);
     if (len > 0) {
index 76d3c8f6f52c6e12f85bba1d4fcc53f192b41b0e..7bfe50a615947a6b4c137ff1768f11a1207e0917 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.160 2001/03/03 10:39:32 hno Exp $
+ * $Id: gopher.cc,v 1.161 2001/04/14 00:03:22 hno Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -612,7 +612,7 @@ gopherReadReply(int fd, void *data)
 #endif
     /* leave one space for \0 in gopherToHTML */
     statCounter.syscalls.sock.reads++;
-    len = read(fd, buf, read_sz);
+    len = FD_READ_METHOD(fd, buf, read_sz);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
index ccb5528a15f6b6b5f68a3674163639a9bad05e78..2a858c687130d2a125513ab47b027a28338aab5d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.cc,v 1.26 2001/03/03 10:39:32 hno Exp $
+ * $Id: helper.cc,v 1.27 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 29    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -659,7 +659,7 @@ helperHandleRead(int fd, void *data)
     assert(fd == srv->rfd);
     assert(cbdataValid(data));
     statCounter.syscalls.sock.reads++;
-    len = read(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset);
+    len = FD_READ_METHOD(fd, srv->buf + srv->offset, srv->buf_sz - srv->offset);
     fd_bytes(fd, len, FD_READ);
     debug(29, 5) ("helperHandleRead: %d bytes from %s #%d.\n",
        len, hlp->id_name, srv->index + 1);
index ae0dabaecea1e0a0d6497fc18381e00493584881..a79316d871bc1ee4140aa305b6e6b2a1486998d2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.378 2001/03/03 10:39:32 hno Exp $
+ * $Id: http.cc,v 1.379 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -482,7 +482,7 @@ httpReadReply(int fd, void *data)
     read_sz = delayBytesWanted(delay_id, 1, read_sz);
 #endif
     statCounter.syscalls.sock.reads++;
-    len = read(fd, buf, read_sz);
+    len = FD_READ_METHOD(fd, buf, read_sz);
     debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, len);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
index ca4e335e827fa6f4346ca45ce36116dc282afe3f..086f217ea59c7a31125dbb8feb59f687fb97b4d6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ident.cc,v 1.57 2001/03/03 10:39:32 hno Exp $
+ * $Id: ident.cc,v 1.58 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 30    Ident (RFC 931)
  * AUTHOR: Duane Wessels
@@ -139,7 +139,7 @@ identReadReply(int fd, void *data)
     int len = -1;
     buf[0] = '\0';
     statCounter.syscalls.sock.reads++;
-    len = read(fd, buf, BUFSIZ - 1);
+    len = FD_READ_METHOD(fd, buf, BUFSIZ - 1);
     fd_bytes(fd, len, FD_READ);
     if (len <= 0) {
        comm_close(fd);
index 9f6a1208bbdec5fd9dce11de3d6efc8ac9cf5959..1e664e3b383f5469242664ca36d9b1fe38aa951d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.334 2001/03/28 23:24:18 wessels Exp $
+ * $Id: main.cc,v 1.335 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -518,6 +518,10 @@ mainInitialize(void)
     }
 #if USE_WCCP
     wccpInit();
+#endif
+#if USE_SSL
+    if (Config.Sockaddr.https)
+       sslInit(Config.SSL.certificate, Config.SSL.key);
 #endif
     serverConnectionsOpen();
     if (theOutIcpConnection >= 0) {
index 26376f2e99522236616ed2f4514e0580efaa1955..73570f866c84ea00248a1931f997b72484ef2d55 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.99 2001/01/12 00:37:19 wessels Exp $
+ * $Id: mime.cc,v 1.100 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -439,7 +439,7 @@ mimeLoadIconFile(const char *icon)
     reply->hdr_sz = e->mem_obj->inmem_hi;      /* yuk */
     /* read the file into the buffer and append it to store */
     buf = memAllocate(MEM_4K_BUF);
-    while ((n = read(fd, buf, 4096)) > 0)
+    while ((n = FD_READ_METHOD(fd, buf, 4096)) > 0)
        storeAppend(e, buf, n);
     file_close(fd);
     EBIT_SET(e->flags, ENTRY_SPECIAL);
index dcb749f31027afa6b2cbc2a69cc64d8c6142488e..11a52e67120ea7b45e29b04f5c09b9642e42df29 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pconn.cc,v 1.30 2001/01/12 00:37:20 wessels Exp $
+ * $Id: pconn.cc,v 1.31 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 48    Persistent Connections
  * AUTHOR: Duane Wessels
@@ -125,7 +125,7 @@ pconnRead(int fd, void *data)
     int n;
     assert(table != NULL);
     statCounter.syscalls.sock.reads++;
-    n = read(fd, buf, 256);
+    n = FD_READ_METHOD(fd, buf, 256);
     debug(48, 3) ("pconnRead: %d bytes from FD %d, %s\n", n, fd,
        hashKeyStr(&p->hash));
     pconnRemoveFD(p, fd);
index 96a635c7d049eec2901f8b352ab851adc3088ddd..7fda259b75680acff07ceb6461b35d9b1d7f943b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: send-announce.cc,v 1.61 2001/01/12 00:37:20 wessels Exp $
+ * $Id: send-announce.cc,v 1.62 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 27    Cache Announcer
  * AUTHOR: Duane Wessels
@@ -86,7 +86,7 @@ send_announce(const ipcache_addrs * ia, void *junk)
     l = strlen(sndbuf);
     if ((file = Config.Announce.file) != NULL) {
        fd = file_open(file, O_RDONLY | O_TEXT);
-       if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
+       if (fd > -1 && (n = FD_READ_METHOD(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
            fd_bytes(fd, n, FD_READ);
            l += n;
            sndbuf[l] = '\0';
index d72250d6c5889d27bb3ac415d0497b15baa5cbdb..12edf7551721df1dfc25086617c2350346c574e9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.214 2001/03/11 21:55:20 hno Exp $
+ * $Id: squid.h,v 1.215 2001/04/14 00:03:23 hno Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -368,6 +368,20 @@ struct rusage {
 #endif
 
 #include "md5.h"
+
+#if USE_SSL
+#include "ssl_support.h"
+/* This is an ugly hack, but necessary.
+ *
+ * Squid's md5 conflicts with OpenSSL's md5, but they're more or less
+ * interchangable.
+ * Free is defined in include/radix.h and also in OpenSSL, but we don't need
+ * OpenSSL's, so it can be undef'd and then appear from radix.h later.
+ * It's dangerous and ugly, but I can't see any other way to get around it.
+ */
+#undef Free
+#endif
+
 #include "Stack.h"
 
 /* Needed for poll() on Linux at least */
@@ -464,7 +478,9 @@ struct rusage {
 /*
  * I'm sick of having to keep doing this ..
  */
-
 #define INDEXSD(i)   (&Config.cacheSwap.swapDirs[(i)])
 
+#define FD_READ_METHOD(fd, buf, len) (*fd_table[fd].read_method)(fd, buf, len)
+#define FD_WRITE_METHOD(fd, buf, len) (*fd_table[fd].write_method)(fd, buf, len)
+
 #endif /* SQUID_H */
index 8c155f0834129ebe7311d5b969e7c3c51211c034..8614625f3fe657eedf9c6dc11dd6bfc94bc3d579 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
+ * $Id: ssl.cc,v 1.113 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -200,7 +200,7 @@ sslReadServer(int fd, void *data)
     read_sz = delayBytesWanted(sslState->delay_id, 1, read_sz);
 #endif
     statCounter.syscalls.sock.reads++;
-    len = read(fd, sslState->server.buf + sslState->server.len, read_sz);
+    len = FD_READ_METHOD(fd, sslState->server.buf + sslState->server.len, read_sz);
     debug(26, 3) ("sslReadServer: FD %d, read   %d bytes\n", fd, len);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
@@ -236,7 +236,7 @@ sslReadClient(int fd, void *data)
        fd, SQUID_TCP_SO_RCVBUF - sslState->client.len,
        sslState->client.len);
     statCounter.syscalls.sock.reads++;
-    len = read(fd,
+    len = FD_READ_METHOD(fd,
        sslState->client.buf + sslState->client.len,
        SQUID_TCP_SO_RCVBUF - sslState->client.len);
     debug(26, 3) ("sslReadClient: FD %d, read   %d bytes\n", fd, len);
@@ -276,7 +276,7 @@ sslWriteServer(int fd, void *data)
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes to write\n",
        fd, sslState->client.len);
     statCounter.syscalls.sock.writes++;
-    len = write(fd,
+    len = FD_WRITE_METHOD(fd,
        sslState->client.buf,
        sslState->client.len);
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes written\n", fd, len);
@@ -315,7 +315,7 @@ sslWriteClient(int fd, void *data)
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes to write\n",
        fd, sslState->server.len);
     statCounter.syscalls.sock.writes++;
-    len = write(fd,
+    len = FD_WRITE_METHOD(fd,
        sslState->server.buf,
        sslState->server.len);
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes written\n", fd, len);
index aba260fa49a986f770912b0a185ac14a564dc6e9..eac05625e4c5da7f52d781fd7c8b2f528cf133e8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.385 2001/04/03 20:22:10 adrian Exp $
+ * $Id: structs.h,v 1.386 2001/04/14 00:03:23 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -381,6 +381,9 @@ struct _SquidConfig {
     } Port;
     struct {
        sockaddr_in_list *http;
+#if USE_SSL
+       sockaddr_in_list *https;
+#endif
     } Sockaddr;
 #if SQUID_SNMP
     struct {
@@ -620,6 +623,13 @@ struct _SquidConfig {
        size_t swapout_chunk_size;
        int rebuild_chunk_percentage;
     } digest;
+#endif
+#if USE_SSL
+    struct {
+       char *certificate;
+       char *key;
+       int version;
+    } SSL;
 #endif
     wordlist *ext_methods;
     struct {
@@ -734,6 +744,11 @@ struct _fde {
     DEFER *defer_check;                /* check if we should defer read */
     void *defer_data;
     CommWriteStateData *rwstate;       /* State data for comm_write */
+    READ_HANDLER *read_method;
+    WRITE_HANDLER *write_method;
+#if USE_SSL
+    SSL *ssl;
+#endif
 };
 
 struct _fileMap {
index 3901a0dfc909f65f8c4c297df74478eb9ba55824..c9303a850e2fb5690972282eb8ad80d28e523299 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.205 2001/02/15 11:11:54 adrian Exp $
+ * $Id: tools.cc,v 1.206 2001/04/14 00:03:24 hno Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -589,7 +589,7 @@ writePidFile(void)
        return;
     }
     snprintf(buf, 32, "%d\n", (int) getpid());
-    write(fd, buf, strlen(buf));
+    FD_WRITE_METHOD(fd, buf, strlen(buf));
     file_close(fd);
 }
 
index 54e54c54117a4f4632a5348693cdaaeaa6a5e6d2..eb04b78bbc10cc824850fa45f5c0bedd41f8fc3c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.112 2001/03/03 10:39:33 hno Exp $
+ * $Id: tunnel.cc,v 1.113 2001/04/14 00:03:23 hno Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -200,7 +200,7 @@ sslReadServer(int fd, void *data)
     read_sz = delayBytesWanted(sslState->delay_id, 1, read_sz);
 #endif
     statCounter.syscalls.sock.reads++;
-    len = read(fd, sslState->server.buf + sslState->server.len, read_sz);
+    len = FD_READ_METHOD(fd, sslState->server.buf + sslState->server.len, read_sz);
     debug(26, 3) ("sslReadServer: FD %d, read   %d bytes\n", fd, len);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
@@ -236,7 +236,7 @@ sslReadClient(int fd, void *data)
        fd, SQUID_TCP_SO_RCVBUF - sslState->client.len,
        sslState->client.len);
     statCounter.syscalls.sock.reads++;
-    len = read(fd,
+    len = FD_READ_METHOD(fd,
        sslState->client.buf + sslState->client.len,
        SQUID_TCP_SO_RCVBUF - sslState->client.len);
     debug(26, 3) ("sslReadClient: FD %d, read   %d bytes\n", fd, len);
@@ -276,7 +276,7 @@ sslWriteServer(int fd, void *data)
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes to write\n",
        fd, sslState->client.len);
     statCounter.syscalls.sock.writes++;
-    len = write(fd,
+    len = FD_WRITE_METHOD(fd,
        sslState->client.buf,
        sslState->client.len);
     debug(26, 3) ("sslWriteServer: FD %d, %d bytes written\n", fd, len);
@@ -315,7 +315,7 @@ sslWriteClient(int fd, void *data)
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes to write\n",
        fd, sslState->server.len);
     statCounter.syscalls.sock.writes++;
-    len = write(fd,
+    len = FD_WRITE_METHOD(fd,
        sslState->server.buf,
        sslState->server.len);
     debug(26, 3) ("sslWriteClient: FD %d, %d bytes written\n", fd, len);
index 77d7b1cd071438831f047590f3334d7bc6e47c85..e22d11d59760d19ceb6ca56e8a4485ec745dfef1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.124 2001/03/01 03:27:54 hno Exp $
+ * $Id: typedefs.h,v 1.125 2001/04/14 00:03:24 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -227,6 +227,8 @@ typedef void PSC(FwdServer *, void *);
 typedef void RH(void *data, char *);
 typedef void UH(void *data, wordlist *);
 typedef int DEFER(int fd, void *data);
+typedef int READ_HANDLER(int, char *, int);
+typedef int WRITE_HANDLER(int, const char *, int);
 typedef void CBCB(char *buf, size_t size, void *data);
 
 typedef void STIOCB(void *their_data, int errflag, storeIOState *);
index b5fb1a8d7afb6b93261116b39b0cf70aa840cbf5..d5645d4a1705bef3a3a5879491edf317f9ade987 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.129 2001/01/12 00:37:23 wessels Exp $
+ * $Id: url.cc,v 1.130 2001/04/14 00:03:24 hno Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -550,12 +550,17 @@ urlCheckRequest(const request_t * r)
            rc = 1;
        break;
     case PROTO_HTTPS:
+#ifdef USE_SSL
+       rc = 1;
+       break;
+#else
        /*
         * Squid can't originate an SSL connection, so it should
         * never receive an "https:" URL.  It should always be
         * CONNECT instead.
         */
        rc = 0;
+#endif
     default:
        break;
     }
index c3b429a825f9a60f061aae11742f02e2246998ef..72b7aa5a16a82cdd26970dfe1c20feb7babb2e70 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.136 2001/03/03 10:39:34 hno Exp $
+ * $Id: wais.cc,v 1.137 2001/04/14 00:03:24 hno Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -103,7 +103,7 @@ waisReadReply(int fd, void *data)
     read_sz = delayBytesWanted(delay_id, 1, read_sz);
 #endif
     statCounter.syscalls.sock.reads++;
-    len = read(fd, buf, read_sz);
+    len = FD_READ_METHOD(fd, buf, read_sz);
     if (len > 0) {
        fd_bytes(fd, len, FD_READ);
 #if DELAY_POOLS
index 9797c627b9118e0687679151e2a8f92339cf3fac..fdd95885825ccd32bb8aae98641d2227a82781ea 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: whois.cc,v 1.15 2001/03/03 10:39:34 hno Exp $
+ * $Id: whois.cc,v 1.16 2001/04/14 00:03:24 hno Exp $
  *
  * DEBUG: section 75    WHOIS protocol
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -92,7 +92,7 @@ whoisReadReply(int fd, void *data)
     MemObject *mem = entry->mem_obj;
     int len;
     statCounter.syscalls.sock.reads++;
-    len = read(fd, buf, 4095);
+    len = FD_READ_METHOD(fd, buf, 4095);
     buf[len] = '\0';
     debug(75, 3) ("whoisReadReply: FD %d read %d bytes\n", fd, len);
     debug(75, 5) ("{%s}\n", buf);