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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 16 17:19:25 CEST 2009


Author: mattm
Date: 2009-10-16 17:19:24 +0200 (Fri, 16 Oct 2009)
New Revision: 5581

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/tasks_sql.h
Log:
	Include report ID in OMP START_TASK response.

	* src/tasks_sql.h (create_report): Add report_id output arg.

	* src/manage.c (start_task): Add report_id output arg.  Pass to
	create_report.
	* src/manage.h: Update header.

	* src/omp.c (omp_xml_handle_end_element): In CLIENT_START_TASK add report
	ID to OK response.

Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog	2009-10-16 13:32:54 UTC (rev 5580)
+++ trunk/openvas-manager/ChangeLog	2009-10-16 15:19:24 UTC (rev 5581)
@@ -1,3 +1,16 @@
+2009-10-16  Matthew Mundell <matthew.mundell at intevation.de>
+
+	Include report ID in OMP START_TASK response.
+
+	* src/tasks_sql.h (create_report): Add report_id output arg.
+
+	* src/manage.c (start_task): Add report_id output arg.  Pass to
+	create_report.
+	* src/manage.h: Update header.
+
+	* src/omp.c (omp_xml_handle_end_element): In CLIENT_START_TASK add report
+	ID to OK response.
+
 2009-10-15  Matthew Mundell <matthew.mundell at intevation.de>
 
 	* src/tasks_sql.h (set_task_parameter): Remove all task files when

Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c	2009-10-16 13:32:54 UTC (rev 5580)
+++ trunk/openvas-manager/src/manage.c	2009-10-16 15:19:24 UTC (rev 5581)
@@ -673,7 +673,8 @@
  *
  * Only one task can run at a time in a process.
  *
- * @param[in]  task  A pointer to the task.
+ * @param[in]   task       The task.
+ * @param[out]  report_id  The report ID.
  *
  * @return 0 on success, 1 task is active already,
  *         -1 if out of space in scanner output buffer, -2 if the
@@ -682,7 +683,7 @@
  *         running in this process.
  */
 int
-start_task (task_t task)
+start_task (task_t task, char **report_id)
 {
   char *hosts, *target, *config, *selector;
   gchar *plugins;
@@ -719,7 +720,7 @@
 
   /* Create the report. */
 
-  if (create_report (task)) return -3;
+  if (create_report (task, report_id)) return -3;
 
   /* Reset any running information. */
 

Modified: trunk/openvas-manager/src/manage.h
===================================================================
--- trunk/openvas-manager/src/manage.h	2009-10-16 13:32:54 UTC (rev 5580)
+++ trunk/openvas-manager/src/manage.h	2009-10-16 15:19:24 UTC (rev 5581)
@@ -357,7 +357,7 @@
 task_run_status_name (task_t task);
 
 int
-start_task (task_t);
+start_task (task_t, char**);
 
 int
 stop_task (task_t);

Modified: trunk/openvas-manager/src/omp.c
===================================================================
--- trunk/openvas-manager/src/omp.c	2009-10-16 13:32:54 UTC (rev 5580)
+++ trunk/openvas-manager/src/omp.c	2009-10-16 15:19:24 UTC (rev 5581)
@@ -4369,47 +4369,69 @@
                   }
               }
             else
-              switch (start_task (task))
-                {
-                  case 0:
-                    SEND_TO_CLIENT_OR_FAIL (XML_OK_REQUESTED ("start_task"));
-                    break;
-                  case 1:
-                    SEND_TO_CLIENT_OR_FAIL
-                     (XML_ERROR_SYNTAX ("start_task",
-                                        "Task is active already"));
-                    break;
-                  case -1:
-                    /* to_scanner is full. */
-                    // FIX or other error
-                    // FIX revert parsing for retry
-                    // process_omp_client_input must return -2
-                    abort ();
-                    break;
-                  case -6:
-                    SEND_TO_CLIENT_OR_FAIL
-                     (XML_ERROR_SYNTAX ("start_task",
-                                        "There is already a task running in"
-                                        " this process"));
-                    break;
-                  case -2:
-                    /* Task target lacks hosts.  This is checked when the
-                     * target is created. */
-                    assert (0);
-                    /*@fallthrough@*/
-                  case -4:
-                    /* Task lacks target.  This is checked when the task is
-                     * created anyway. */
-                    assert (0);
-                    /*@fallthrough@*/
-                  case -3: /* Failed to create report. */
-                    SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("start_task"));
-                    break;
-                  default: /* Programming error. */
-                    assert (0);
-                    SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("start_task"));
-                    break;
-                }
+              {
+                char *report_id;
+                switch (start_task (task, &report_id))
+                  {
+                    case 0:
+                      {
+                        gchar *msg;
+                        msg = g_strdup_printf
+                               ("<start_task_response"
+                                " status=\"" STATUS_OK_REQUESTED "\""
+                                " status_text=\""
+                                STATUS_OK_REQUESTED_TEXT
+                                "\">"
+                                "<report_id>%s</report_id>"
+                                "</start_task_response>",
+                                report_id);
+                        free (report_id);
+                        if (send_to_client (msg))
+                          {
+                            g_free (msg);
+                            error_send_to_client (error);
+                            return;
+                          }
+                        g_free (msg);
+                      }
+                      break;
+                    case 1:
+                      SEND_TO_CLIENT_OR_FAIL
+                       (XML_ERROR_SYNTAX ("start_task",
+                                          "Task is active already"));
+                      break;
+                    case -1:
+                      /* to_scanner is full. */
+                      // FIX or other error
+                      // FIX revert parsing for retry
+                      // process_omp_client_input must return -2
+                      abort ();
+                      break;
+                    case -6:
+                      SEND_TO_CLIENT_OR_FAIL
+                       (XML_ERROR_SYNTAX ("start_task",
+                                          "There is already a task running in"
+                                          " this process"));
+                      break;
+                    case -2:
+                      /* Task target lacks hosts.  This is checked when the
+                       * target is created. */
+                      assert (0);
+                      /*@fallthrough@*/
+                    case -4:
+                      /* Task lacks target.  This is checked when the task is
+                       * created anyway. */
+                      assert (0);
+                      /*@fallthrough@*/
+                    case -3: /* Failed to create report. */
+                      SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("start_task"));
+                      break;
+                    default: /* Programming error. */
+                      assert (0);
+                      SEND_TO_CLIENT_OR_FAIL (XML_INTERNAL_ERROR ("start_task"));
+                      break;
+                  }
+              }
             openvas_free_string_var (&current_uuid);
           }
         else

Modified: trunk/openvas-manager/src/tasks_sql.h
===================================================================
--- trunk/openvas-manager/src/tasks_sql.h	2009-10-16 13:32:54 UTC (rev 5580)
+++ trunk/openvas-manager/src/tasks_sql.h	2009-10-16 15:19:24 UTC (rev 5581)
@@ -1835,26 +1835,27 @@
 /**
  * @brief Create the current report for a task.
  *
- * @param[in]  task   The task.
+ * @param[in]   task       The task.
+ * @param[out]  report_id  Report ID.
  *
  * @return 0 success, -1 current_report is already set, -2 failed to generate ID.
  */
 static int
-create_report (task_t task)
+create_report (task_t task, char **report_id)
 {
-  char* report_id;
-
   assert (current_report == (report_t) 0);
   if (current_report) return -1;
 
+  if (report_id == NULL) return -1;
+
   /* Generate report UUID. */
 
-  report_id = make_report_uuid ();
-  if (report_id == NULL) return -2;
+  *report_id = make_report_uuid ();
+  if (*report_id == NULL) return -2;
 
   /* Create the report. */
 
-  current_report = make_report (task, report_id);
+  current_report = make_report (task, *report_id);
 
   return 0;
 }



More information about the Openvas-commits mailing list