[Openvas-commits] r3320 - in trunk/openvas-manager: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 11 12:03:33 CEST 2009


Author: mattm
Date: 2009-05-11 12:03:32 +0200 (Mon, 11 May 2009)
New Revision: 3320

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/otpd.c
Log:
	* src/otpd.c (serve_otp): Connect to server initially.


Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-05-11 09:19:54 UTC (rev 3319)
+++ trunk/openvas-manager/ChangeLog	2009-05-11 10:03:32 UTC (rev 3320)
@@ -1,5 +1,9 @@
 2009-05-11  Matthew Mundell <mmundell at intevation.de>
 
+	* src/otpd.c (serve_otp): Connect to server initially.
+
+2009-05-11  Matthew Mundell <mmundell at intevation.de>
+
 	* src/manage.c (task_plugins): Separate plugins with semicolons.
 
 2009-05-11  Matthew Mundell <mmundell at intevation.de>

Modified: trunk/openvas-manager/src/otpd.c
===================================================================
--- trunk/openvas-manager/src/otpd.c	2009-05-11 09:19:54 UTC (rev 3319)
+++ trunk/openvas-manager/src/otpd.c	2009-05-11 10:03:32 UTC (rev 3320)
@@ -38,7 +38,9 @@
  */
 
 #include "types.h"
+#include "ovas-mngr-comm.h"
 #include "otpd.h"
+#include "ompd.h"  /* FIX for server_address */
 #include "logf.h"
 #include "tracef.h"
 
@@ -95,10 +97,10 @@
            gnutls_session_t* server_session,
            int client_socket, int server_socket)
 {
-  int nfds;
+  int nfds, interrupted = 0;
   fd_set readfds, exceptfds, writefds;
 
-  /* Handle the first client input, which was read by `read_protocol'. */
+  /* Log the first client input, which was read by `read_protocol'. */
 #if TRACE || LOG
   logf ("<= %.*s\n", from_client_end, from_client);
 #if TRACE_TEXT
@@ -109,6 +111,50 @@
 #endif
 #endif /* TRACE || LOG */
 
+  /* Connect to the server. */
+  nfds = 1 + server_socket;
+  while (1)
+    {
+      int ret;
+
+      /* Setup for select. */
+      FD_ZERO (&exceptfds);
+      FD_ZERO (&writefds);
+      FD_SET (server_socket, &exceptfds);
+      FD_SET (server_socket, &writefds);
+
+      /* Select, then handle result. */
+      ret = select (nfds, NULL, &writefds, &exceptfds, NULL);
+      if (ret < 0)
+        {
+          if (errno == EINTR) continue;
+          perror ("Child connect select failed");
+          return -1;
+        }
+      if (ret > 0)
+        {
+          if (FD_ISSET (server_socket, &exceptfds))
+            {
+              fprintf (stderr,
+                       "Exception on server in child connect select.\n");
+              return -1;
+            }
+          if (FD_ISSET (server_socket, &writefds))
+            {
+              ret = connect_to_server (server_socket,
+                                       &server_address,
+                                       server_session,
+                                       interrupted);
+              if (ret == 0)
+                break;
+              if (ret == -2)
+                interrupted = 1;
+              else
+                return -1;
+            }
+        }
+    }
+
   /* Loop handling input from the sockets. */
   nfds = 1 + (client_socket > server_socket
               ? client_socket : server_socket);



More information about the Openvas-commits mailing list