[Openvas-commits] r13728 - in trunk/openvas-libraries: . misc
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Thu Jul 12 22:41:54 CEST 2012
Author: jan
Date: 2012-07-12 22:41:53 +0200 (Thu, 12 Jul 2012)
New Revision: 13728
Removed:
trunk/openvas-libraries/misc/store.c
trunk/openvas-libraries/misc/store.h
Modified:
trunk/openvas-libraries/COPYING
trunk/openvas-libraries/ChangeLog
trunk/openvas-libraries/misc/CMakeLists.txt
trunk/openvas-libraries/misc/plugutils.c
trunk/openvas-libraries/misc/plugutils.h
Log:
* misc/plugutils.c (_add_plugin_preference): New. Moved here from store.c.
(plug_create_from_nvti_and_prefs): New. A reduced version of
store_load_plugin from store.c.
* misc/plugutils.h: Added proto accordingly.
* misc/store.c, misc/store.h: Removed no unneeded module.
* COPYING: Removed entry for removed module.
* misc/CMakeLists.txt: Removed handling of module store.
Modified: trunk/openvas-libraries/COPYING
===================================================================
--- trunk/openvas-libraries/COPYING 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/COPYING 2012-07-12 20:41:53 UTC (rev 13728)
@@ -81,7 +81,6 @@
misc/services.[c|h]: LGPLv2+
misc/share_fd.c: BSD2
misc/share_fd.h: LGPLv2+
-misc/store.[c|h]: LGPLv2+
misc/support.h: GPLv2+
misc/system.[c|h]: LGPLv2+
misc/system_internal.h: LGPLv2+
Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/ChangeLog 2012-07-12 20:41:53 UTC (rev 13728)
@@ -1,3 +1,17 @@
+2012-07-12 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+ * misc/plugutils.c (_add_plugin_preference): New. Moved here from store.c.
+ (plug_create_from_nvti_and_prefs): New. A reduced version of
+ store_load_plugin from store.c.
+
+ * misc/plugutils.h: Added proto accordingly.
+
+ * misc/store.c, misc/store.h: Removed no unneeded module.
+
+ * COPYING: Removed entry for removed module.
+
+ * misc/CMakeLists.txt: Removed handling of module store.
+
2012-07-11 Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
* misc/store.c (store_init): Removed. The initialization is
Modified: trunk/openvas-libraries/misc/CMakeLists.txt
===================================================================
--- trunk/openvas-libraries/misc/CMakeLists.txt 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/misc/CMakeLists.txt 2012-07-12 20:41:53 UTC (rev 13728)
@@ -65,7 +65,7 @@
popen.c proctitle.c
rand.c resolve.c resource_request.c scanners_utils.c services1.c
services.c share_fd.c
- store.c system.c www_funcs.c pcap.c)
+ system.c www_funcs.c pcap.c)
set (HEADERS arglists.h bpf_share.h ftp_funcs.h hash_table_file.h kb.h
network.h otp.h pcap_openvas.h plugutils.h popen.h proctitle.h
@@ -73,7 +73,7 @@
openvas_server.h openvas_ssh_login.h openvas_uuid.h
resource_request.h nvt_categories.h internal_com.h
scanners_utils.h services1.h services.h
- share_fd.h store.h system.h www_funcs.h)
+ share_fd.h system.h www_funcs.h)
endif (MINGW)
if (BUILD_WITH_LDAP)
Modified: trunk/openvas-libraries/misc/plugutils.c
===================================================================
--- trunk/openvas-libraries/misc/plugutils.c 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/misc/plugutils.c 2012-07-12 20:41:53 UTC (rev 13728)
@@ -319,7 +319,75 @@
arg_set_value (desc, "HOSTNAME", sizeof (hostname), hostname);
}
+void
+_add_plugin_preference (struct arglist *prefs, const char *p_name,
+ const char *name, const char *type, const char *defaul)
+{
+ char *pref;
+ char *cname;
+ int len;
+ cname = estrdup (name);
+ len = strlen (cname);
+ // Terminate string before last trailing space
+ while (cname[len - 1] == ' ')
+ {
+ cname[len - 1] = '\0';
+ len--;
+ }
+ if (!prefs || !p_name)
+ {
+ efree (&cname);
+ return;
+ }
+
+
+ pref = emalloc (strlen (p_name) + 10 + strlen (type) + strlen (cname));
+ // RATS: ignore
+ snprintf (pref, strlen (p_name) + 10 + strlen (type) + strlen (cname),
+ "%s[%s]:%s", p_name, type, cname);
+ if (arg_get_value (prefs, pref) == NULL)
+ arg_add_value (prefs, pref, ARG_STRING, strlen (defaul), estrdup (defaul));
+
+ efree (&cname);
+ efree (&pref);
+}
+
+/**
+ * @brief Returns a (plugin) arglist assembled from the nvti.
+ *
+ * @param nvti NVT Information to be used for the creation.
+ *
+ * @param prefs Plugin preference arglist that is added to
+ * new arglist and where all preferences of the NVTI
+ * are copied to as single entries.
+ *
+ * @return Pointer to plugin as arglist or NULL.
+ */
+struct arglist *
+plug_create_from_nvti_and_prefs (nvti_t * nvti, struct arglist *prefs)
+{
+ struct arglist *ret;
+ int i;
+
+ if (!nvti)
+ return NULL;
+
+ ret = emalloc (sizeof (struct arglist));
+
+ arg_add_value (ret, "NVTI", ARG_PTR, -1, nvti);
+ arg_add_value (ret, "preferences", ARG_ARGLIST, -1, prefs);
+
+ for (i = 0; i < nvti_pref_len (nvti); i++)
+ {
+ nvtpref_t *np = nvti_pref (nvti, i);
+ _add_plugin_preference (prefs, nvti_name (nvti), nvtpref_name (np),
+ nvtpref_type (np), nvtpref_default (np));
+ }
+
+ return ret;
+}
+
void
host_add_port_proto (struct arglist *args, int portnum, int state, char *proto)
{
Modified: trunk/openvas-libraries/misc/plugutils.h
===================================================================
--- trunk/openvas-libraries/misc/plugutils.h 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/misc/plugutils.h 2012-07-12 20:41:53 UTC (rev 13728)
@@ -70,6 +70,8 @@
int plug_get_port_transport (struct arglist *, int);
+struct arglist * plug_create_from_nvti_and_prefs (nvti_t *, struct arglist *);
+
/*
* Reporting functions
*/
Deleted: trunk/openvas-libraries/misc/store.c
===================================================================
--- trunk/openvas-libraries/misc/store.c 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/misc/store.c 2012-07-12 20:41:53 UTC (rev 13728)
@@ -1,155 +0,0 @@
-/* OpenVAS
- * $Id$
- * Description: Functions related to plugin cache and.
- *
- * Authors:
- * Renaud Deraison <deraison at nessus.org> (Original pre-fork development)
- *
- * Copyright:
- * Based on work Copyright (C) 1998 - 2003 Renaud Deraison
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-/** @file
- * OpenVAS-Scanner employs a plugin cache to avoid parsing all known nvts at
- * start-up.
- *
- * The cache consists of a .desc file for each script (e.g. cache file of
- * nvts/xyz.nasl is nvts/xyz.nas.desc), which contains a memory dump of the
- * corresponding plugin struct.
- *
- * The cache is used as followed:
- *
- * 1. Init the store with store_init.
- *
- * 2. Add nvts by calling store_plugin or
- *
- * 3. Give the store a file path (store_load_plugin)
- * and receive the plugin as arglist. Under nice conditions the information
- * contained in the cache file can be used. Under not so nice conditions, the
- * store returns NULL (cache is either outdated, contains error or an error
- * occurred).
- *
- * The store is updated at each openvassd start up. There the plugin loader
- * iterates over plugin files and tries to retrieve the cached version.
- * If there is no cached version (or @ref store_load_plugin returns Null for
- * another reason, e.g.because the script file seems to have been modified in
- * between) the plugin is added to the store (@ref store_plugin).
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <time.h>
-#include <sys/param.h>
-
-#include <glib.h>
-
-#include "share_fd.h"
-#include "system.h"
-#include "plugutils.h"
-
-#include "nvti.h"
-
-/* for nvticache_get */
-#include "nvticache.h"
-
-void
-_add_plugin_preference (struct arglist *prefs, const char *p_name,
- const char *name, const char *type, const char *defaul)
-{
- char *pref;
- char *cname;
- int len;
-
- cname = estrdup (name);
- len = strlen (cname);
- // Terminate string before last trailing space
- while (cname[len - 1] == ' ')
- {
- cname[len - 1] = '\0';
- len--;
- }
- if (!prefs || !p_name)
- {
- efree (&cname);
- return;
- }
-
-
- pref = emalloc (strlen (p_name) + 10 + strlen (type) + strlen (cname));
- // RATS: ignore
- snprintf (pref, strlen (p_name) + 10 + strlen (type) + strlen (cname),
- "%s[%s]:%s", p_name, type, cname);
- if (arg_get_value (prefs, pref) == NULL)
- arg_add_value (prefs, pref, ARG_STRING, strlen (defaul), estrdup (defaul));
-
- efree (&cname);
- efree (&pref);
-}
-
-/**
- * @brief Returns a (plugin) arglist assembled from the cached description file
- *
- * @param file Filename of the plugin (e.g. "scriptname1.nasl"
- * or "subdir1/subdir2/scriptname2.nasl" ).
- *
- * @param prefs Plugin preference arglist.
- *
- * NULL is returned in either of these cases:
- * 1) The .NVT definition or .desc file does not exist.
- * 2) NVT definition file (e.g. xyz.nasl) or nvt signature (xyz.asc) file is
- * newer than the .desc file.
- * 3) The NVT definition files (e.g. xyz.nasl) or nvt signature (xyz.asc) files
- * timestamp is in the future.
- * 4) The magic number test failed (other file format expected).
- * 5) An internal error occured.
- *
- * Point 4) is necessary because the cache will not create .desc files with
- * timestamps in the future. Thus, when creating a new cache file for the given
- * NVT, it would not be able to become loaded from the cache (point 2)).
- *
- * @return Pointer to plugin as arglist or NULL.
- */
-struct arglist *
-store_load_plugin (const char *file, struct arglist *prefs)
-{
- struct arglist *ret;
- int i;
-
- nvti_t *n = nvticache_get (arg_get_value(prefs, "nvticache"), file);
- if (!n)
- return NULL;
-
- ret = emalloc (sizeof (struct arglist));
-
- arg_add_value (ret, "NVTI", ARG_PTR, -1, n);
- arg_add_value (ret, "preferences", ARG_ARGLIST, -1, prefs);
-
- for (i = 0; i < nvti_pref_len (n); i++)
- {
- nvtpref_t *np = nvti_pref (n, i);
- _add_plugin_preference (prefs, nvti_name (n), nvtpref_name (np),
- nvtpref_type (np), nvtpref_default (np));
- }
-
- return ret;
-}
Deleted: trunk/openvas-libraries/misc/store.h
===================================================================
--- trunk/openvas-libraries/misc/store.h 2012-07-12 17:01:43 UTC (rev 13727)
+++ trunk/openvas-libraries/misc/store.h 2012-07-12 20:41:53 UTC (rev 13728)
@@ -1,31 +0,0 @@
-/* OpenVAS
- * $Id$
- * Description: Header file for module store.
- *
- * Authors:
- * Renaud Deraison <deraison at nessus.org> (Original pre-fork development)
- *
- * Copyright:
- * Based on work Copyright (C) 1998 - 2007 Tenable Network Security, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef OPENVAS_STORE_H
-#define OPENVAS_STORE_H
-
-struct arglist *store_load_plugin (char *, struct arglist *);
-
-#endif
More information about the Openvas-commits
mailing list