[Openvas-commits] r5560 - in trunk/openvas-client: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Oct 15 16:18:16 CEST 2009


Author: mattm
Date: 2009-10-15 16:18:13 +0200 (Thu, 15 Oct 2009)
New Revision: 5560

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/src/omp-cli.c
Log:
	* src/omp-cli.c (main): Add --delete-report.

Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-10-15 14:08:58 UTC (rev 5559)
+++ trunk/openvas-client/ChangeLog	2009-10-15 14:18:13 UTC (rev 5560)
@@ -1,5 +1,9 @@
 2009-10-15  Matthew Mundell <matthew.mundell at intevation.de>
 
+	* src/omp-cli.c (main): Add --delete-report.
+
+2009-10-15  Matthew Mundell <matthew.mundell at intevation.de>
+
 	* src/omp-cli.c (print_tasks): Add extra space before report ID.
 	(main): Pass content_length to omp_modify_task_file.
 

Modified: trunk/openvas-client/src/omp-cli.c
===================================================================
--- trunk/openvas-client/src/omp-cli.c	2009-10-15 14:08:58 UTC (rev 5559)
+++ trunk/openvas-client/src/omp-cli.c	2009-10-15 14:18:13 UTC (rev 5560)
@@ -173,6 +173,8 @@
   static gchar *config = NULL;
   static gboolean rc = FALSE;
   static gchar *target = NULL;
+  /* Command delete-report. */
+  static gboolean cmd_delete_report = FALSE;
   /* Command delete-task. */
   static gboolean cmd_delete_task = FALSE;
   /* Command get-report. */
@@ -228,9 +230,12 @@
         { "target", 't', 0, G_OPTION_ARG_STRING, &target,
           "Target for create-task.",
           "<target>" },
+        /* Command delete-report. */
+        { "delete-report", 'E', 0, G_OPTION_ARG_NONE, &cmd_delete_report,
+          "Delete one or more reports.", NULL },
         /* Command delete-task. */
         { "delete-task", 'D', 0, G_OPTION_ARG_NONE, &cmd_delete_task,
-          "Delete a task.", NULL },
+          "Delete one or more tasks.", NULL },
         /* Command get-report. */
         { "get-report", 'R', 0, G_OPTION_ARG_NONE, &cmd_get_report,
           "Get report of one task.", NULL },
@@ -444,6 +449,47 @@
       exit (EXIT_SUCCESS);
     }
 
+  if (cmd_delete_report)
+    {
+      gchar **point = rest;
+
+      if (point == NULL || *point == NULL)
+        {
+          fprintf (stderr, "delete-report requires at least one argument.\n");
+          exit (EXIT_FAILURE);
+        }
+
+      socket = openvas_server_open (&session, manager_host_string, manager_port);
+      if (socket == -1)
+        {
+          fprintf (stderr, "Failed to acquire socket.\n");
+          exit (EXIT_FAILURE);
+        }
+
+      if (omp_authenticate (&session, omp_username, omp_password))
+        {
+          openvas_server_close (socket, session);
+          fprintf (stderr, "Failed to authenticate.\n");
+          exit (EXIT_FAILURE);
+        }
+
+      while (*point)
+        {
+          if (omp_delete_report (&session, *point))
+            {
+              fprintf (stderr,
+                       "Failed to delete report %s, exiting.\n",
+                       *point);
+              openvas_server_close (socket, session);
+              exit (EXIT_FAILURE);
+            }
+          point++;
+        }
+
+      openvas_server_close (socket, session);
+      exit (EXIT_SUCCESS);
+    }
+
   if (cmd_delete_task)
     {
       gchar **point = rest;



More information about the Openvas-commits mailing list