Mailing List Archive

NessusClient/nessus context.h,1.14,1.15 context.c,1.14,1.15
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv36225

Modified Files:
context.h context.c
Log Message:
Factored out the sync routine for plugin prefs from
comm.c:gui_comm_send_preferences()
to context.c:context_sync_plugin_prefs()


Index: context.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- context.h 28 Apr 2006 17:42:33 -0000 1.14
+++ context.h 18 May 2006 14:42:03 -0000 1.15
@@ -88,6 +88,18 @@
void context_load_plugin_cache(struct context *context);
void context_set_plugins_md5sum(struct context *context, const char *md5sum);
void context_reset_plugins(struct context *context);
+
+/* This function sync the plugin preferences (for plugins and scanners)
+ * for the given context.
+ * In fact, the plugin preferences are copied from
+ * context->plugins[plugin][plugin-pref]
+ * and
+ * context->scanners->[plugin][plugin-pref]
+ * to
+ * context->prefs["PLUGINS_PREFS"][plugin]
+ */
+void context_sync_plugin_prefs(struct context *);
+
#ifdef USE_GTK
void context_collect(struct context*);
void context_rename(struct context*, const char*);

Index: context.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- context.c 3 May 2006 10:18:32 -0000 1.14
+++ context.c 18 May 2006 14:42:03 -0000 1.15
@@ -602,6 +602,80 @@
}
}

+/* This function sync the plugin preferences (for plugins and scanners)
+ * for the given context.
+ * In fact, the plugin preferences are copied from
+ * context->plugins[plugin][plugin-pref]
+ * and
+ * context->scanners->[plugin][plugin-pref]
+ * to
+ * context->prefs["PLUGINS_PREFS"][plugin]
+ */
+void
+context_sync_plugin_prefs(context)
+ struct context * context;
+{
+ struct arglist * plugins_prefs = arg_get_value(context->prefs, "PLUGINS_PREFS");
+ struct nessus_plugin * plugins[2];
+ int i;
+
+ /* If there is yet no entry "PLUGINS_PREFS", add it now */
+ if(!plugins_prefs)
+ {
+ plugins_prefs = emalloc(sizeof(struct arglist));
+ arg_add_value(context->prefs, "PLUGINS_PREFS", ARG_ARGLIST, -1, plugins_prefs);
+ }
+
+ plugins[0] = context->plugins;
+ plugins[1] = context->scanners;
+
+ /* iterate over the two plugin sets */
+ for (i = 0; i < 2; i++)
+ {
+ struct nessus_plugin * plugin = plugins[i];
+
+ /* iterate over plugins */
+ while (plugin != NULL)
+ {
+ struct arglist * plugin_prefs = plugin->plugin_prefs;
+
+ /* iterate over the prefs of the plugin */
+ while (plugin_prefs && plugin_prefs->next)
+ {
+ char * value = arg_get_value(plugin_prefs->value, "value");
+ char * fullname = arg_get_value(plugin_prefs->value, "fullname");
+
+ /* is this pref already in the plugins_prefs? */
+ if ((arg_get_type(plugins_prefs, fullname)) >= 0)
+ { /* yes, then just copy the value */
+ if ((arg_get_type(plugins_prefs, fullname)) == ARG_INT)
+ {
+ if (!strcmp(value, "yes"))
+ arg_set_value(plugins_prefs, fullname, sizeof(int), (void *)1);
+ else
+ arg_set_value(plugins_prefs, fullname, sizeof(int), NULL);
+ }
+ else
+ arg_set_value(plugins_prefs, fullname, strlen(value), strdup(value));
+ }
+ else
+ { /* no, then create a new pref */
+ if (!strcmp(value, "yes"))
+ arg_add_value(plugins_prefs, fullname, ARG_INT, sizeof(int), (void *)1);
+ else if (!strcmp(value, "no"))
+ arg_add_value(plugins_prefs, fullname, ARG_INT, sizeof(int), NULL);
+ else
+ arg_add_value(plugins_prefs, fullname, ARG_STRING, strlen(value),
+ strdup(value));
+ }
+
+ plugin_prefs = plugin_prefs->next;
+ }
+ plugin = plugin->next;
+ }
+ }
+}
+

/*
* replacements for g_file_test which is unreliable on windows

_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs