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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 19 13:12:40 CEST 2012


Author: mattm
Date: 2012-07-19 13:12:40 +0200 (Thu, 19 Jul 2012)
New Revision: 13750

Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/ompd.c
   trunk/openvas-manager/src/otp.c
   trunk/openvas-manager/src/oxpd.c
Log:
	Add OTP 1.1 handling.

	* src/ompd.c (write_to_scanner): Send OTP/1.1 for normal mode, OTP/1.0 for
	NVT cache mode.  In normal mode go to DONE state after sending password.

	* src/otp.c (process_otp_scanner_input): Also check for OTP/1.1.

	* src/oxpd.c (OTP_INIT_STRING_2): New define.
	(read_protocol): Also compare OTP 1.1 string.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2012-07-19 11:08:32 UTC (rev 13749)
+++ trunk/openvas-manager/ChangeLog	2012-07-19 11:12:40 UTC (rev 13750)
@@ -1,3 +1,15 @@
+2012-07-19  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Add OTP 1.1 handling.
+
+	* src/ompd.c (write_to_scanner): Send OTP/1.1 for normal mode, OTP/1.0 for
+	NVT cache mode.  In normal mode go to DONE state after sending password.
+
+	* src/otp.c (process_otp_scanner_input): Also check for OTP/1.1.
+
+	* src/oxpd.c (OTP_INIT_STRING_2): New define.
+	(read_protocol): Also compare OTP 1.1 string.
+
 2012-07-09  Michael Wiegand <michael.wiegand at greenbone.net>
 
 	* src/manage.c (manage_read_info): Replace g_strcasecmp with

Modified: trunk/openvas-manager/src/ompd.c
===================================================================
--- trunk/openvas-manager/src/ompd.c	2012-07-19 11:08:32 UTC (rev 13749)
+++ trunk/openvas-manager/src/ompd.c	2012-07-19 11:12:40 UTC (rev 13750)
@@ -342,7 +342,18 @@
         /*@fallthrough@*/
       case SCANNER_INIT_CONNECTED:
         {
-          char* string = "< OTP/1.0 >\n";
+          char* string;
+
+          if (ompd_nvt_cache_mode)
+            /* Request OTP 1.0 only in cache mode, because in this case Scanner
+             * sends extra info that we use, like plugins MD5 sum and
+             * preferences. */
+            string = "< OTP/1.0 >\n";
+          else
+            /* Normal mode, request OTP 1.1, to skip extra info, for faster
+             * init with Scanner. */
+            string = "< OTP/1.1 >\n";
+
           scanner_init_offset = write_string_to_server (scanner_session,
                                                         string
                                                         + scanner_init_offset);
@@ -387,8 +398,13 @@
           scanner_init_offset = write_string_to_server (scanner_session,
                                                         password + scanner_init_offset);
           if (scanner_init_offset == 0)
-            set_scanner_init_state (SCANNER_INIT_SENT_PASSWORD);
-            /* Fall through to send any available output. */
+            {
+              if (ompd_nvt_cache_mode)
+                set_scanner_init_state (SCANNER_INIT_SENT_PASSWORD);
+              else
+                set_scanner_init_state (SCANNER_INIT_DONE);
+              /* Fall through to send any available output. */
+            }
           else if (scanner_init_offset == -1)
             {
               scanner_init_offset = 0;

Modified: trunk/openvas-manager/src/otp.c
===================================================================
--- trunk/openvas-manager/src/otp.c	2012-07-19 11:08:32 UTC (rev 13749)
+++ trunk/openvas-manager/src/otp.c	2012-07-19 11:12:40 UTC (rev 13750)
@@ -1344,9 +1344,11 @@
             if (sync_buffer ()) return -1;
             return 0;
           }
-        if (strncasecmp ("< OTP/1.0 >\n", messages, 12))
+        if (strncasecmp ("< OTP/1.0 >\n", messages, 12)
+            && strncasecmp ("< OTP/1.1 >\n", messages, 12))
           {
-            tracef ("   scanner fail: expected \"< OTP/1.0 >, got \"%.12s\"\n\"\n",
+            tracef ("   scanner fail: expected \"< OTP/1.0 >\""
+                    " or \"< OTP/1.1 >\", got \"%.12s\"\n\n",
                     messages);
             return -1;
           }

Modified: trunk/openvas-manager/src/oxpd.c
===================================================================
--- trunk/openvas-manager/src/oxpd.c	2012-07-19 11:08:32 UTC (rev 13749)
+++ trunk/openvas-manager/src/oxpd.c	2012-07-19 11:12:40 UTC (rev 13750)
@@ -91,6 +91,11 @@
 #define OTP_INIT_STRING "< OTP/1.0 >\n"
 
 /**
+ * @brief The OTP initialisation string.
+ */
+#define OTP_INIT_STRING_2 "< OTP/1.1 >\n"
+
+/**
  * @brief Read and return the type of protocol from the client.
  *
  * For OMP, this may read in OMP commands while determining the protocol,
@@ -263,6 +268,8 @@
                 {
                   if (strstr (from_client, OTP_INIT_STRING))
                     ret = PROTOCOL_OTP;
+                  else if (strstr (from_client, OTP_INIT_STRING_2))
+                    ret = PROTOCOL_OTP;
                   else
                     ret = PROTOCOL_OMP;
                   break;



More information about the Openvas-commits mailing list