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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 29 19:25:07 CEST 2009


Author: mattm
Date: 2009-05-29 19:25:06 +0200 (Fri, 29 May 2009)
New Revision: 3542

Added:
   trunk/openvas-manager/src/tests/omp_get_certificates_0.c
   trunk/openvas-manager/src/tests/omp_get_certificates_1.c
Modified:
   trunk/openvas-manager/ChangeLog
   trunk/openvas-manager/src/manage.c
   trunk/openvas-manager/src/manage.h
   trunk/openvas-manager/src/omp.c
   trunk/openvas-manager/src/otp.c
   trunk/openvas-manager/src/otp.h
   trunk/openvas-manager/src/tests/CMakeLists.txt
   trunk/openvas-manager/src/tests/omp_help_0.c
Log:
	Add OTP CERTIFICATES handling and OMP GET_CERTIFICATES.

	* src/manage.c (request_certificates): New function.
	* src/manage.h: Update headers.

	* src/omp.c (help_text, client_state_t): Add GET_CERTIFICATES entries.
	(send_certificate): New function.
	(omp_xml_handle_start_element, omp_xml_handle_end_element): Add
	GET_CERTIFICATES handling.

	* src/otp.h (server_t): Add certificates.

	* src/otp.c (init_otp_data): Init server certificates.
	(server_state_t): Add CERTIFICATES states.
	(current_certificates, current_certificate): New variables.
	(parse_server_certificate_public_key): New function.
	(parse_server_server, process_otp_server_input): Add CERTIFICATES
	handling.

	* src/tests/omp_help_0.c (help_text): Add GET_CERTIFICATES entry.

	* src/tests/omp_get_certificates_0.c,
	src/tests/omp_get_certificates_1.c: New files.

	* src/tests/CMakeLists.txt: Add omp_get_certificates_0 and
	omp_get_certificates_1.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/ChangeLog	2009-05-29 17:25:06 UTC (rev 3542)
@@ -1,3 +1,32 @@
+2009-05-29  Matthew Mundell <mmundell at intevation.de>
+
+	Add OTP CERTIFICATES handling and OMP GET_CERTIFICATES.
+
+	* src/manage.c (request_certificates): New function.
+	* src/manage.h: Update headers.
+
+	* src/omp.c (help_text, client_state_t): Add GET_CERTIFICATES entries.
+	(send_certificate): New function.
+	(omp_xml_handle_start_element, omp_xml_handle_end_element): Add
+	GET_CERTIFICATES handling.
+
+	* src/otp.h (server_t): Add certificates.
+
+	* src/otp.c (init_otp_data): Init server certificates.
+	(server_state_t): Add CERTIFICATES states.
+	(current_certificates, current_certificate): New variables.
+	(parse_server_certificate_public_key): New function.
+	(parse_server_server, process_otp_server_input): Add CERTIFICATES
+	handling.
+
+	* src/tests/omp_help_0.c (help_text): Add GET_CERTIFICATES entry.
+
+	* src/tests/omp_get_certificates_0.c,
+	src/tests/omp_get_certificates_1.c: New files.
+
+	* src/tests/CMakeLists.txt: Add omp_get_certificates_0 and
+	omp_get_certificates_1.
+
 2009-05-28  Matthew Mundell <mmundell at intevation.de>
 
 	* src/tests/CMakeLists.txt: Sort rules.

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/manage.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -1175,7 +1175,7 @@
 }
 
 
-/* Plugins. */
+/* Server requests. */
 
 /**
  * @brief Request the list of plugins from the server.
@@ -1189,3 +1189,16 @@
     return -1;
   return 0;
 }
+
+/**
+ * @brief Request the list of certificates from the server.
+ *
+ * @return 0 on success, -1 if out of space in \ref to_server buffer.
+ */
+int
+request_certificates ()
+{
+  if (send_to_server ("CLIENT <|> CERTIFICATES <|> CLIENT\n"))
+    return -1;
+  return 0;
+}

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/manage.h	2009-05-29 17:25:06 UTC (rev 3542)
@@ -347,9 +347,12 @@
 set_report_parameter (char*, const char*, char*);
 
 
-/* Plugins. */
+/* Server requests. */
 
 int
 request_plugin_list ();
 
+int
+request_certificates ();
+
 #endif

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/omp.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -47,6 +47,7 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include <openvas/certificate.h>
 #include <openvas/nvti.h>
 
 #ifdef S_SPLINT_S
@@ -69,6 +70,7 @@
 "    CREATE_TASK            Create a new task.\n"
 "    DELETE_REPORT          Delete an existing report.\n"
 "    DELETE_TASK            Delete an existing task.\n"
+"    GET_CERTIFICATES       Get all available certificates.\n"
 "    GET_DEPENDENCIES       Get dependencies for all available NVTs.\n"
 "    GET_NVT_ALL            Get IDs and names of all available NVTs.\n"
 "    GET_NVT_DETAILS        Get all details for all available NVTs.\n"
@@ -188,6 +190,7 @@
   CLIENT_DELETE_REPORT_ID,
   CLIENT_DELETE_TASK,
   CLIENT_DELETE_TASK_TASK_ID,
+  CLIENT_GET_CERTIFICATES,
   CLIENT_GET_DEPENDENCIES,
   CLIENT_GET_NVT_ALL,
   CLIENT_GET_NVT_DETAILS,
@@ -349,6 +352,8 @@
             append_text (&current_uuid, "", 0);
             set_client_state (CLIENT_DELETE_TASK);
           }
+        else if (strncasecmp ("GET_CERTIFICATES", element_name, 16) == 0)
+          set_client_state (CLIENT_GET_CERTIFICATES);
         else if (strncasecmp ("GET_DEPENDENCIES", element_name, 16) == 0)
           set_client_state (CLIENT_GET_DEPENDENCIES);
         else if (strncasecmp ("GET_NVT_ALL", element_name, 11) == 0)
@@ -497,6 +502,23 @@
           }
         break;
 
+      case CLIENT_GET_CERTIFICATES:
+          {
+            if (send_to_client ("<get_certificates_response>"
+                                "<status>" STATUS_ERROR_SYNTAX "</status>"
+                                "</get_certificates_response>"))
+              {
+                error_send_to_client (error);
+                return;
+              }
+            set_client_state (CLIENT_AUTHENTIC);
+            g_set_error (error,
+                         G_MARKUP_ERROR,
+                         G_MARKUP_ERROR_UNKNOWN_ELEMENT,
+                         "Error");
+          }
+        break;
+
       case CLIENT_GET_DEPENDENCIES:
           {
             if (send_to_client ("<get_dependencies_response>"
@@ -789,6 +811,55 @@
 }
 
 /**
+ * @brief Send XML for a certificate.
+ *
+ * @param[in]  cert_gp  The certificate.
+ * @param[in]  dummy    Dummy variable, for certificate_find.
+ *
+ * @return 0 if out of space in to_client buffer, else 1.
+ */
+static gint
+send_certificate (gpointer cert_gp, gpointer dummy)
+{
+  certificate_t* cert = (certificate_t*) cert_gp;
+  gchar* msg;
+  gsize size_dummy;
+
+  const char* public_key = certificate_public_key (cert);
+  const char* owner = certificate_owner (cert);
+  /* FIX The g_convert is a temp hack. */
+  gchar* owner_utf8 = owner ? g_convert (owner, strlen (owner),
+                                         "UTF-8", "ISO_8859-1",
+                                         NULL, &size_dummy, NULL)
+                            : NULL;
+  gchar* owner_text = owner_utf8
+                      ? g_markup_escape_text (owner_utf8, -1)
+                      : g_strdup ("");
+  g_free (owner_utf8);
+
+  msg = g_strdup_printf ("<certificate>"
+                         "<fingerprint>%s</fingerprint>"
+                         "<owner>%s</owner>"
+                         "<trust_level>%s</trust_level>"
+                         "<length>%u</length>"
+                         "<public_key>%s</public_key>"
+                         "</certificate>",
+                         certificate_fingerprint (cert),
+                         owner_utf8,
+                         certificate_trusted (cert) ? "trusted" : "notrust",
+                         strlen (public_key),
+                         public_key);
+  g_free (owner_text);
+  if (send_to_client (msg))
+    {
+      g_free (msg);
+      return 0;
+    }
+  g_free (msg);
+  return 1;
+}
+
+/**
  * @brief Send XML for a requirement of a plugin.
  *
  * @param[in]  element  The required plugin.
@@ -1309,6 +1380,37 @@
         set_client_state (CLIENT_AUTHENTIC);
         break;
 
+      case CLIENT_GET_CERTIFICATES:
+        if (server.certificates)
+          {
+            SEND_TO_CLIENT_OR_FAIL ("<get_certificates_response>"
+                                    "<status>" STATUS_OK "</status>");
+            if (certificates_find (server.certificates,
+                                   send_certificate,
+                                   NULL))
+              {
+                error_send_to_client (error);
+                return;
+              }
+            SEND_TO_CLIENT_OR_FAIL ("</get_certificates_response>");
+          }
+        else
+          {
+            SEND_TO_CLIENT_OR_FAIL ("<get_certificates_response>"
+                                    "<status>" STATUS_SERVICE_DOWN "</status>"
+                                    "</get_certificates_response>");
+            /* \todo TODO Sort out a proactive mechanism for this. */
+            if (request_certificates ())
+              {
+                /* to_server is full. */
+                // FIX ~ revert parsing for retry
+                // process_omp_client_input must return -2
+                abort ();
+              }
+          }
+        set_client_state (CLIENT_AUTHENTIC);
+        break;
+
       case CLIENT_GET_DEPENDENCIES:
         if (server.plugins_dependencies)
           {

Modified: trunk/openvas-manager/src/otp.c
===================================================================
--- trunk/openvas-manager/src/otp.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/otp.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -646,6 +646,7 @@
 void
 init_otp_data ()
 {
+  server.certificates = NULL;
   server.preferences = NULL;
   server.rules = NULL;
   server.plugins = NULL;
@@ -658,6 +659,11 @@
 typedef enum
 {
   SERVER_BYE,
+  SERVER_CERTIFICATE_FINGERPRINT,
+  SERVER_CERTIFICATE_LENGTH,
+  SERVER_CERTIFICATE_OWNER,
+  SERVER_CERTIFICATE_PUBLIC_KEY,
+  SERVER_CERTIFICATE_TRUST_LEVEL,
   SERVER_DONE,
   SERVER_DEBUG_DESCRIPTION,
   SERVER_DEBUG_HOST,
@@ -751,6 +757,21 @@
 }
 
 
+/* Server certificates. */
+
+/**
+ * @brief The current certificates, during reading of server certificates.
+ */
+/*@only@*/
+static certificates_t* current_certificates = NULL;
+
+/**
+ * @brief The current certificate, during reading of server certificates.
+ */
+/*@only@*/
+static certificate_t* current_certificate = NULL;
+
+
 /* OTP input processor. */
 
 // FIX probably should pass to process_omp_client_input
@@ -759,6 +780,41 @@
 extern buffer_size_t from_server_end;
 
 /**
+ * @brief Parse the final field of a certificate in a certificate list.
+ *
+ * @param  messages  A pointer into the OTP input buffer.
+ *
+ * @return 0 success, -2 too few characters (need more input).
+ */
+static int
+parse_server_certificate_public_key (char** messages)
+{
+  char *value, *end, *match;
+  assert (current_certificate != NULL);
+  end = *messages + from_server_end - from_server_start;
+  while (*messages < end && ((*messages)[0] == ' '))
+    { (*messages)++; from_server_start++; }
+  if ((match = memchr (*messages,
+                       (int) '\n',
+                       from_server_end - from_server_start)))
+    {
+      match[0] = '\0';
+      value = g_strdup (*messages);
+      if (current_certificates && current_certificate)
+        {
+          certificate_set_public_key (current_certificate, value);
+          certificates_add (current_certificates, current_certificate);
+          current_certificate = NULL;
+        }
+      set_server_state (SERVER_CERTIFICATE_FINGERPRINT);
+      from_server_start += match + 1 - *messages;
+      *messages = match + 1;
+      return 0;
+    }
+  return -2;
+}
+
+/**
  * @brief Parse the final SERVER field of an OTP message.
  *
  * @param  messages  A pointer into the OTP input buffer.
@@ -981,6 +1037,24 @@
           set_server_state (SERVER_PLUGIN_DEPENDENCY_NAME);
           return 0;
         }
+      // FIX 12 available?
+      if (strncasecmp ("CERTIFICATES", *messages, 12) == 0)
+        {
+          from_server_start += match + 1 - *messages;
+          *messages = match + 1;
+          /* current_certificates may be allocated already due to a
+           * request for the list before the end of the previous
+           * request.  In this case just let the responses mix.
+           * FIX depends what server does on multiple requests
+           */
+          if (current_certificates == NULL)
+            {
+              current_certificates = certificates_create ();
+              if (current_certificates == NULL) abort (); // FIX
+            }
+          set_server_state (SERVER_CERTIFICATE_FINGERPRINT);
+          return 0;
+        }
       newline = match;
       newline[0] = '\n';
       /* Check for a <|>. */
@@ -1163,7 +1237,15 @@
         return -1;
       case SERVER_INIT_DONE:
       case SERVER_INIT_TOP:
-        if (server_state == SERVER_DONE)
+        if (server_state == SERVER_CERTIFICATE_PUBLIC_KEY)
+          switch (parse_server_certificate_public_key (&messages))
+            {
+              case -2:
+                /* Need more input. */
+                if (sync_buffer ()) return -1;
+                return 0;
+            }
+        else if (server_state == SERVER_DONE)
           switch (parse_server_done (&messages))
             {
               case -1: return -1;
@@ -1284,6 +1366,59 @@
                       return 0;
                   }
                 break;
+              case SERVER_CERTIFICATE_FINGERPRINT:
+                {
+                  if (strlen (field) == 0)
+                    {
+                      certificates_free (server.certificates);
+                      server.certificates = current_certificates;
+                      current_certificates = NULL;
+                      set_server_state (SERVER_DONE);
+                      switch (parse_server_done (&messages))
+                        {
+                          case -1: return -1;
+                          case -2:
+                            /* Need more input. */
+                            if (sync_buffer ()) return -1;
+                            return 0;
+                        }
+                      break;
+                    }
+                  current_certificate = certificate_create ();
+                  if (current_certificate == NULL) abort (); // FIX
+                  if (certificate_set_fingerprint (current_certificate, field))
+                    abort (); // FIX
+                  set_server_state (SERVER_CERTIFICATE_OWNER);
+                  break;
+                }
+              case SERVER_CERTIFICATE_LENGTH:
+                {
+                  /* Read over the length. */
+                  // \todo TODO consider using this to read next field
+                  set_server_state (SERVER_CERTIFICATE_PUBLIC_KEY);
+                  switch (parse_server_certificate_public_key (&messages))
+                    {
+                      case -2:
+                        /* Need more input. */
+                        if (sync_buffer ()) return -1;
+                        return 0;
+                    }
+                  break;
+                }
+              case SERVER_CERTIFICATE_OWNER:
+                {
+                  if (certificate_set_owner (current_certificate, field))
+                    abort ();
+                  set_server_state (SERVER_CERTIFICATE_TRUST_LEVEL);
+                  break;
+                }
+              case SERVER_CERTIFICATE_TRUST_LEVEL:
+                {
+                  certificate_set_trusted (current_certificate,
+                                           strcasecmp (field, "trusted") == 0);
+                  set_server_state (SERVER_CERTIFICATE_LENGTH);
+                  break;
+                }
               case SERVER_DEBUG_DESCRIPTION:
                 {
                   if (current_message)

Modified: trunk/openvas-manager/src/otp.h
===================================================================
--- trunk/openvas-manager/src/otp.h	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/otp.h	2009-05-29 17:25:06 UTC (rev 3542)
@@ -29,6 +29,7 @@
 #include "manage.h"
 #include <glib.h>
 
+#include <openvas/certificate.h>
 #include <openvas/nvti.h>
 
 void
@@ -70,6 +71,7 @@
  */
 typedef struct
 {
+  certificates_t* certificates;      ///< List of certificates.
   char* plugins_md5;                 ///< MD5 sum over all tests.
   GHashTable* plugins_dependencies;  ///< Dependencies between plugins.
   nvtis_t* plugins;                  ///< Plugin meta-information.

Modified: trunk/openvas-manager/src/tests/CMakeLists.txt
===================================================================
--- trunk/openvas-manager/src/tests/CMakeLists.txt	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/tests/CMakeLists.txt	2009-05-29 17:25:06 UTC (rev 3542)
@@ -174,6 +174,20 @@
 target_link_libraries (omp_delete_task_2 common)
 ADD_TEST (omp_delete_task_2 omp_delete_task_2)
 
+add_executable (omp_get_certificates_0 omp_get_certificates_0.c)
+target_link_libraries (omp_get_certificates_0 string)
+set_target_properties (omp_get_certificates_0 PROPERTIES COMPILE_FLAGS "-I .. ${GLIB_CFLAGS}")
+set_target_properties (omp_get_certificates_0 PROPERTIES LINK_FLAGS "${OVAS_LDFLAG} ${GLIB_LDFLAGS}")
+target_link_libraries (omp_get_certificates_0 common)
+ADD_TEST (omp_get_certificates_0 omp_get_certificates_0)
+
+add_executable (omp_get_certificates_1 omp_get_certificates_1.c)
+target_link_libraries (omp_get_certificates_1 string)
+set_target_properties (omp_get_certificates_1 PROPERTIES COMPILE_FLAGS "-I .. ${GLIB_CFLAGS}")
+set_target_properties (omp_get_certificates_1 PROPERTIES LINK_FLAGS "${OVAS_LDFLAG} ${GLIB_LDFLAGS}")
+target_link_libraries (omp_get_certificates_1 common)
+ADD_TEST (omp_get_certificates_1 omp_get_certificates_1)
+
 add_executable (omp_get_dependencies_0 omp_get_dependencies_0.c)
 target_link_libraries (omp_get_dependencies_0 string)
 set_target_properties (omp_get_dependencies_0 PROPERTIES COMPILE_FLAGS "-I .. ${GLIB_CFLAGS}")

Added: trunk/openvas-manager/src/tests/omp_get_certificates_0.c
===================================================================
--- trunk/openvas-manager/src/tests/omp_get_certificates_0.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/tests/omp_get_certificates_0.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -0,0 +1,84 @@
+/* Test 0 of OMP GET_CERTIFICATES.
+ * $Id$
+ * Description: Test the OMP GET_CERTIFICATES command before a task runs.
+ *
+ * Authors:
+ * Matthew Mundell <matt at mundell.ukfsn.org>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Greenbone Networks GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define TRACE 1
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "../tracef.h"
+
+int
+main ()
+{
+  int socket;
+  gnutls_session_t session;
+
+  setup_test ();
+
+  socket = connect_to_manager (&session);
+  if (socket == -1) return EXIT_FAILURE;
+
+  /* Request the certificates. */
+
+  if (env_authenticate (&session))
+    {
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+
+  if (send_to_manager (&session, "<get_certificates/>") == -1)
+    {
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+
+  /* Read the response. */
+
+  entity_t entity = NULL;
+  read_entity (&session, &entity);
+
+  /* Compare to expected response. */
+
+  entity_t expected = add_entity (NULL, "get_certificates_response", NULL);
+  add_entity (&expected->entities, "status", "503");
+
+  if (compare_entities (entity, expected))
+    {
+      free_entity (entity);
+      free_entity (expected);
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+
+  free_entity (expected);
+  free_entity (entity);
+  close_manager_connection (socket, session);
+  return EXIT_SUCCESS;
+}

Added: trunk/openvas-manager/src/tests/omp_get_certificates_1.c
===================================================================
--- trunk/openvas-manager/src/tests/omp_get_certificates_1.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/tests/omp_get_certificates_1.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -0,0 +1,110 @@
+/* Test 1 of OMP GET_CERTIFICATES.
+ * $Id$
+ * Description: Test the OMP GET_CERTIFICATES command after a task runs.
+ *
+ * Authors:
+ * Matthew Mundell <matt at mundell.ukfsn.org>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Greenbone Networks GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define TRACE 1
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "common.h"
+#include "../tracef.h"
+
+int
+main ()
+{
+  int socket;
+  gnutls_session_t session;
+  entity_t entity, status;
+
+  setup_test ();
+
+  socket = connect_to_manager (&session);
+  if (socket == -1) return EXIT_FAILURE;
+
+  if (env_authenticate (&session))
+    {
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+
+  /* Request certificates, and give the server some time to send other
+   * cruft first. */
+
+  if (send_to_manager (&session, "<get_certificates/>") == -1)
+    {
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+  entity = NULL;
+  if (read_entity (&session, &entity))
+    {
+      close_manager_connection (socket, session);
+      return EXIT_FAILURE;
+    }
+
+  sleep (10);
+
+  /* Request certificates until the manager responds with OK or an error. */
+
+  while (1)
+    {
+      if (send_to_manager (&session, "<get_certificates/>") == -1)
+        {
+          close_manager_connection (socket, session);
+          return EXIT_FAILURE;
+        }
+      entity = NULL;
+      if (read_entity (&session, &entity))
+        {
+          close_manager_connection (socket, session);
+          return EXIT_FAILURE;
+        }
+
+      if (entity == NULL
+          || strcmp (entity_name (entity), "get_certificates_response")
+          || (status = entity_child (entity, "status")) == NULL
+          || (strcmp (entity_text (status), "200")
+              && strcmp (entity_text (status), "503")))
+        {
+          free_entity (entity);
+          close_manager_connection (socket, session);
+          return EXIT_FAILURE;
+        }
+      if (strcmp (entity_text (status), "200") == 0)
+        {
+          free_entity (entity);
+          close_manager_connection (socket, session);
+          return EXIT_SUCCESS;
+        }
+      free_entity (entity);
+      sleep (0.25);
+    }
+
+  close_manager_connection (socket, session);
+  return EXIT_FAILURE;
+}

Modified: trunk/openvas-manager/src/tests/omp_help_0.c
===================================================================
--- trunk/openvas-manager/src/tests/omp_help_0.c	2009-05-29 17:09:54 UTC (rev 3541)
+++ trunk/openvas-manager/src/tests/omp_help_0.c	2009-05-29 17:25:06 UTC (rev 3542)
@@ -38,6 +38,7 @@
 "    CREATE_TASK            Create a new task.\n"
 "    DELETE_REPORT          Delete an existing report.\n"
 "    DELETE_TASK            Delete an existing task.\n"
+"    GET_CERTIFICATES       Get all available certificates.\n"
 "    GET_DEPENDENCIES       Get dependencies for all available NVTs.\n"
 "    GET_NVT_ALL            Get IDs and names of all available NVTs.\n"
 "    GET_NVT_DETAILS        Get all details for all available NVTs.\n"



More information about the Openvas-commits mailing list