]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Enabled the RFC1413 ident functionality for Win32 and NetWare. Also introduced
authorBradley Nicholes <bnicholes@apache.org>
Thu, 18 Sep 2003 18:54:26 +0000 (18:54 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Thu, 18 Sep 2003 18:54:26 +0000 (18:54 +0000)
a thread-safe socket timeout alternative that can be adapted for other non-winsock
platforms

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@101283 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/main/rfc1413.c

index 7115a108b440312c57a0821d815647bde15f5bb3..e4aafd98bb2ad0e2f7c779a41451ca765f8f4d19 100644 (file)
@@ -1,5 +1,11 @@
 Changes with Apache 1.3.29
 
+  *) Enabled RFC1413 ident functionality for both Win32 and
+     NetWare platforms.  This also included an alternate thread safe
+     implementation of the socket timout functionality when querying
+     the identd daemon.
+     [Brad Nicholes, William Rowe]
+     
   *) Prevent creation of subprocess Zombies when using CGI wrappers
      such as suExec and cgiwrap. PR 21737. [Numerous]
 
index ebef8be6886dd0d780f897728e434c5076aa1c9b..4df40403f0794d6f3a87619ddd39c5c7a86444df 100644 (file)
 
 int ap_rfc1413_timeout = RFC1413_TIMEOUT;      /* Global so it can be changed */
 
+#if (defined (NETWARE) || defined (WIN32))
+#define write(a,b,c) send(a,b,c,0)
+#define read(a,b,c) recv(a,b,c,0)
+#endif
+
+#ifdef MULTITHREAD
+#define RFC_USER_STATIC 
+
+static int setsocktimeout (int sock, int timeout)
+{
+#if (defined (NETWARE) || defined (WIN32))
+    u_long msec = 0;
+
+    /* Make sure that we are in blocking mode */
+    if (ioctlsocket(sock, FIONBIO, &msec) == SOCKET_ERROR) {
+        return h_errno;
+    }
+
+    /* Win32 timeouts are in msec, represented as int */
+    msec = timeout * 1000;
+    setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, 
+               (char *) &msec, sizeof(msec));
+    setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, 
+               (char *) &msec, sizeof(msec));
+#else
+    //XXX Needs to be implemented for non-winsock platforms
+#endif
+    return 0;
+}
+#else /* MULTITHREAD */
+
+#define RFC_USER_STATIC static
 static JMP_BUF timebuf;
 
 /* ident_timeout - handle timeouts */
@@ -106,6 +138,7 @@ static void ident_timeout(int sig)
 {
     ap_longjmp(timebuf, sig);
 }
+#endif
 
 /* bind_connect - bind both ends of a socket */
 /* Ambarish fix this. Very broken */
@@ -237,22 +270,28 @@ static int get_rfc1413(int sock, const struct sockaddr_in *our_sin,
 /* rfc1413 - return remote user name, given socket structures */
 API_EXPORT(char *) ap_rfc1413(conn_rec *conn, server_rec *srv)
 {
-    static char user[RFC1413_USERLEN + 1];     /* XXX */
-    static char *result;
-    static int sock;
+    RFC_USER_STATIC char user[RFC1413_USERLEN + 1];    /* XXX */
+    RFC_USER_STATIC char *result;
+    RFC_USER_STATIC int sock;
 
     result = FROM_UNKNOWN;
 
     sock = ap_psocket_ex(conn->pool, AF_INET, SOCK_STREAM, IPPROTO_TCP, 1);
     if (sock < 0) {
-       ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
-                   "socket: rfc1413: error creating socket");
-       conn->remote_logname = result;
+       ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
+                   "socket: rfc1413: error creating socket");
+       conn->remote_logname = result;
     }
 
     /*
      * Set up a timer so we won't get stuck while waiting for the server.
      */
+#ifdef MULTITHREAD
+    if (setsocktimeout(sock, ap_rfc1413_timeout) == 0) {
+        if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user, srv) >= 0)
+            result = ap_pstrdup (conn->pool, user);
+    }
+#else
     if (ap_setjmp(timebuf) == 0) {
        ap_set_callback_and_alarm(ident_timeout, ap_rfc1413_timeout);
 
@@ -260,8 +299,10 @@ API_EXPORT(char *) ap_rfc1413(conn_rec *conn, server_rec *srv)
            result = user;
     }
     ap_set_callback_and_alarm(NULL, 0);
+#endif
     ap_pclosesocket(conn->pool, sock);
     conn->remote_logname = result;
 
     return conn->remote_logname;
 }
+