[Openvas-commits] r5469 - in trunk/openvas-client: . openvas
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 9 22:47:47 CEST 2009
Author: mattm
Date: 2009-10-09 22:47:47 +0200 (Fri, 09 Oct 2009)
New Revision: 5469
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/openvas/attack.c
Log:
* openvas/attack.c [USE_OMP] (send_ssh_credential_files): New header.
(attack_host) [USE_OMP]: Sync context plugin prefs before saving
context. Free GError. Send files after sending RC. Add error
dialog to omp_start_task failure.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-10-09 20:42:43 UTC (rev 5468)
+++ trunk/openvas-client/ChangeLog 2009-10-09 20:47:47 UTC (rev 5469)
@@ -1,5 +1,12 @@
2009-10-09 Matthew Mundell <matthew.mundell at intevation.de>
+ * openvas/attack.c [USE_OMP] (send_ssh_credential_files): New header.
+ (attack_host) [USE_OMP]: Sync context plugin prefs before saving
+ context. Free GError. Send files after sending RC. Add error
+ dialog to omp_start_task failure.
+
+2009-10-09 Matthew Mundell <matthew.mundell at intevation.de>
+
* openvas/comm.c (send_ssh_credential_files): Correct doc typo.
(gui_comm_send_preferences): Add free query.
Modified: trunk/openvas-client/openvas/attack.c
===================================================================
--- trunk/openvas-client/openvas/attack.c 2009-10-09 20:42:43 UTC (rev 5468)
+++ trunk/openvas-client/openvas/attack.c 2009-10-09 20:47:47 UTC (rev 5469)
@@ -87,6 +87,9 @@
}
#endif
+#ifdef USE_OMP
+GSList* send_ssh_credential_files (GSList*);
+#endif
/**
* @brief Sends the order to start a new attack to the scanner (openvassd).
@@ -113,6 +116,9 @@
const char *hostname, *login, *password;
struct context* manager;
+ /* Ensure the RC file is up to date. */
+
+ context_sync_plugin_prefs (context);
preferences_save (context);
/* Connect. */
@@ -148,6 +154,7 @@
g_file_get_contents (rcfile, &rc, &rc_len, &error);
if (error)
{
+ g_error_free (error);
openvas_server_close (socket, session);
return 0;
}
@@ -160,10 +167,91 @@
}
}
+ /* Send files, in case they are newer. */
+
+ {
+ GSList *files = NULL;
+ struct openvas_plugin *plugins[2];
+ int i;
+
+ /* Collect the files. */
+
+ plugins[0] = context->plugins;
+ plugins[1] = context->scanners;
+
+ for (i = 0; i < 2; i++)
+ {
+ struct openvas_plugin *plugs = plugins[i];
+
+ while (plugs != NULL)
+ {
+ struct arglist *plugin_prefs = plugs->plugin_prefs;
+ while (plugin_prefs && plugin_prefs->next)
+ {
+ char *type = arg_get_value (plugin_prefs->value, "type");
+ char *value = arg_get_value (plugin_prefs->value, "value");
+
+ if (strcmp (type, PREF_FILE) == 0)
+ files = g_slist_append (files, value);
+
+ if (strcmp(type, PREF_SSH_CREDENTIALS) == 0)
+ files = send_ssh_credential_files (files);
+
+ plugin_prefs = plugin_prefs->next;
+ }
+ plugs = plugs->next;
+ }
+ }
+
+ /* Send the files. */
+
+ while (files)
+ {
+ GSList *last = files;
+ gchar *content;
+ gsize content_len;
+ GError *error;
+
+ if (files->data && strlen (files->data))
+ {
+ error = NULL;
+ g_file_get_contents (files->data, &content, &content_len, &error);
+ if (error)
+ {
+ show_error (_("Error getting contents of '%s': %s"),
+ files->data,
+ error->message);
+ g_error_free (error);
+ openvas_server_close (socket, session);
+ // FIX free list incl data
+ return 0;
+ }
+
+ if (omp_modify_task_file (&session,
+ prefs_get_string (context, "id"),
+ files->data,
+ content))
+ {
+ show_error (_("Failed to set file on task: '%s'"), files->data);
+ g_free (content);
+ openvas_server_close (socket, session);
+ // FIX free list incl data
+ return 0;
+ }
+ g_free (content);
+ }
+
+ files = g_slist_next (files);
+ g_free (last->data);
+ g_slist_free_1 (last);
+ }
+ }
+
/* Start the task. */
if (omp_start_task (&session, prefs_get_string (context, "id")))
{
+ show_error (_("Failed to start task: %s"));
openvas_server_close (socket, session);
return 0;
}
More information about the Openvas-commits
mailing list