Mailing List Archive

NessusClient/nessus plugin_cache.c,1.6,1.7
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv70128

Modified Files:
plugin_cache.c
Log Message:
Added support for caching the dependency information.


Index: plugin_cache.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/plugin_cache.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- plugin_cache.c 3 May 2006 10:17:43 -0000 1.6
+++ plugin_cache.c 15 May 2007 21:35:10 -0000 1.7
@@ -99,6 +99,7 @@
#define HEADER_MAGIC "NessusClientPluginCache"
#define FILE_FORMAT_VERSION 0
#define PLUGIN_KEYWORD "plugin"
+#define DEP_KEYWORD "dependency"
#define END_KEYWORD "end"

/* Determine the cache file to use for the context.
@@ -249,6 +250,27 @@
}


+/* Write a dependency to the cache file
+ *
+ * The parameter DEP is the dependency to write and FILE is be the stream
+ * to be used to write to the cache file. The dependency is written as a
+ * single record as described in the file format description.
+ *
+ * The return value is 0 on success and != 0 otherwise.
+ */
+static int
+write_dep(struct arglist *dep, FILE *file)
+{
+ struct arglist * lst = dep->value;
+ while (lst && lst->next) {
+ if (write_record(file, "kss", DEP_KEYWORD, dep->name, lst->name))
+ return 1;
+ lst = lst->next;
+ }
+ return 0;
+}
+
+
/* Write all plugins in the linked list PLUGINS
*
* The parameter PLUGINS is the first plugin in the list of plugins to
@@ -270,6 +292,26 @@
return 0;
}

+/* Write all dependencies in the linked list DEPS
+ *
+ * The parameter DEPS is the first dependency in the list of dependencies to
+ * write and FILE is be the stream to be used to write to the cache
+ * file. Each dependency is written with write_dep.
+ *
+ * The return value is 0 on success and != 0 otherwise.
+ */
+static int
+write_deps_list(struct arglist *deps, FILE *file)
+{
+ while (deps && deps->next)
+ {
+ if (write_dep(deps, file) != 0)
+ return -1;
+ deps = deps->next;
+ }
+
+ return 0;
+}

/* Write the plugins in CONTEXT to a cache
*
@@ -314,6 +356,7 @@
server_md5sum)
|| write_plugin_list(context->scanners, file)
|| write_plugin_list(context->plugins, file)
+ || write_deps_list(context->dependencies, file)
|| write_record(file, "k", END_KEYWORD));

if (fclose(file) != 0)
@@ -686,6 +729,22 @@
nessus_plugin_set_md5sum(plugin, items[2]);

context_add_plugin(context, plugin);
+ }
+ else if (nitems == 3 && strcmp(items[0], DEP_KEYWORD) == 0)
+ {
+ struct arglist *deps = arg_get_value(context->dependencies, items[1]);
+ if (!deps) {
+ deps = emalloc(sizeof(struct arglist));
+ arg_add_value(deps, items[2], ARG_INT,
+ (sizeof(int)), (void *)1);
+ if (! context->dependencies)
+ context->dependencies = emalloc(sizeof(struct arglist));
+ arg_add_value(context->dependencies, items[1],
+ ARG_ARGLIST, -1, deps);
+ } else {
+ arg_add_value(deps, items[2], ARG_INT,
+ (sizeof(int)), (void *)1);
+ }
}
else if (nitems == 1 && strcmp(items[0], END_KEYWORD) == 0)
{

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