[Openvas-commits] r3276 - in trunk/openvas-manager: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri May 8 14:57:54 CEST 2009
Author: mattm
Date: 2009-05-08 14:57:52 +0200 (Fri, 08 May 2009)
New Revision: 3276
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/manage.c
Log:
* src/manage.c (task_plugins): New function.
(start_task): Request plugins listed in RC file instead of always
requesting all plugins.
(task_preference): Correct parsing.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2009-05-08 09:47:18 UTC (rev 3275)
+++ trunk/openvas-manager/ChangeLog 2009-05-08 12:57:52 UTC (rev 3276)
@@ -1,5 +1,12 @@
2009-05-08 Matthew Mundell <matt at mundell.ukfsn.org>
+ * src/manage.c (task_plugins): New function.
+ (start_task): Request plugins listed in RC file instead of always
+ requesting all plugins.
+ (task_preference): Correct parsing.
+
+2009-05-08 Matthew Mundell <matt at mundell.ukfsn.org>
+
Ensure that the memory allocated in sql_string is always freed.
* src/manage.h (task_name, task_comment, task_description)
Modified: trunk/openvas-manager/src/manage.c
===================================================================
--- trunk/openvas-manager/src/manage.c 2009-05-08 09:47:18 UTC (rev 3275)
+++ trunk/openvas-manager/src/manage.c 2009-05-08 12:57:52 UTC (rev 3276)
@@ -631,30 +631,31 @@
if (eq)
{
#if 0
- tracef ("found: %.*s\n",
+ tracef (" 1 found: %.*s\n",
seek ? seek - desc : strlen (seek),
desc);
#endif
if (strncmp (desc, name, eq - desc - 1) == 0)
{
free (orig_desc);
- return g_strndup (eq + 1, seek ? seek - eq + 1 : strlen (seek));
+ return g_strndup (eq + 2,
+ seek ? seek - (eq + 2) : strlen (seek));
}
}
else if ((seek ? seek - desc > 7 : 1)
&& strncmp (desc, "begin(", 6) == 0)
{
/* Read over the section. */
- desc = seek;
+ desc = seek + 1;
while ((seek = strchr (desc, '\n')))
{
if ((seek ? seek - desc > 5 : 1)
- && strncmp (desc, "end(", 4))
+ && strncmp (desc, "end(", 4) == 0)
{
break;
}
#if 0
- tracef ("skip: %.*s\n",
+ tracef (" 1 skip: %.*s\n",
seek ? seek - desc : strlen (seek),
desc);
#endif
@@ -668,6 +669,86 @@
return NULL;
}
+static char*
+task_plugins (task_t task)
+{
+ char* desc = task_description (task);
+ char* orig_desc = desc;
+ char* seek;
+ GString* plugins = g_string_new ("");
+ while ((seek = strchr (desc, '\n')))
+ {
+ char* eq = seek
+ ? memchr (desc, '=', seek - desc)
+ : strchr (desc, '=');
+ if (eq)
+ {
+#if 0
+ tracef (" skip: %.*s\n",
+ seek ? seek - desc : strlen (seek),
+ desc);
+#endif
+ }
+ else if ((seek ? seek - desc >= 17 : 1)
+ && (strncmp (desc, "begin(PLUGIN_SET)", 17) == 0
+ || strncmp (desc, "begin(SCANNER_SET)", 18) == 0))
+ {
+ /* Read in the plugins. */
+ desc = seek + 1;
+ while ((seek = strchr (desc, '\n')))
+ {
+ char* eq2;
+
+ if ((seek ? seek - desc > 5 : 1)
+ && strncmp (desc, "end(", 4) == 0)
+ {
+ break;
+ }
+
+ eq2 = memchr (desc, '=', seek - desc);
+ if (eq2)
+ {
+ if (strncasecmp (eq2 + 2, "yes", 3) == 0)
+ {
+ g_string_append_len (plugins, desc, eq2 - desc - 1);
+#if 0
+ tracef (" plugin: %.*s\n",
+ eq2 - desc - 1,
+ desc);
+#endif
+ }
+ }
+
+ desc = seek + 1;
+ }
+ }
+ else if ((seek ? seek - desc > 7 : 1)
+ && strncmp (desc, "begin(", 6) == 0)
+ {
+ /* Read over the section. */
+ desc = seek + 1;
+ while ((seek = strchr (desc, '\n')))
+ {
+ if ((seek ? seek - desc > 5 : 1)
+ && strncmp (desc, "end(", 4) == 0)
+ {
+ break;
+ }
+#if 0
+ tracef ("skip s: %.*s\n",
+ seek ? seek - desc : strlen (seek),
+ desc);
+#endif
+ desc = seek + 1;
+ }
+ }
+ if (seek == NULL) break;
+ desc = seek + 1;
+ }
+ free (orig_desc);
+ return g_string_free (plugins, FALSE);
+}
+
/**
* @brief Start a task.
*
@@ -705,12 +786,9 @@
// FIX still getting FINISHED msgs
if (send_to_server ("ntp_opt_show_end <|> no\n")) return -1;
//if (send_to_server ("ntp_short_status <|> yes\n")) return -1;
- if (send_to_server ("plugin_set <|> \n")) return -1;
+ if (sendf_to_server ("plugin_set <|> %s\n", task_plugins (task))) return -1;
// FIX
if (send_to_server ("port_range <|> 21\n")) return -1;
-#if 0
- if (send_to_server (task_plugins (task))) return -1;
-#endif
if (send_to_server ("\n")) return -1;
#if 0
queue_task_preferences (task);
More information about the Openvas-commits
mailing list