OpenVAS Libraries
4.0+rc3.SVN
|
#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"
#include "nvticache.h"
Functions | |
void | _add_plugin_preference (struct arglist *prefs, const char *p_name, const char *name, const char *type, const char *defaul) |
int | store_init (const char *dir, const char *src) |
Initializes the global NVTI Cache. | |
struct arglist * | store_load_plugin (const char *file, struct arglist *prefs) |
Returns a (plugin) arglist assembled from the cached description file. | |
void | store_plugin (struct arglist *plugin, char *file) |
Creates an entry in the store for data of "plugin" into cache 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:
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 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 (store_plugin).
int store_init | ( | const char * | dir, |
const char * | src | ||
) |
Initializes the global NVTI Cache.
dir | Path to the cache-directory. It must exist. |
src | Path to the plugin-directory. It must exist. |
struct arglist* store_load_plugin | ( | const char * | file, |
struct arglist * | prefs | ||
) | [read] |
Returns a (plugin) arglist assembled from the cached description file.
file | Filename of the plugin (e.g. "scriptname1.nasl" or "subdir1/subdir2/scriptname2.nasl" ). |
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)).
void store_plugin | ( | struct arglist * | plugin, |
char * | file | ||
) |
Creates an entry in the store for data of "plugin" into cache file.
"file" which is placed in the cache directory.
plugin | Data structure that contains a plugin description |
file | Name of corresponding plugin file (e.g. "x.nasl", "x.nes" or "x.oval". It can also be something like "subdir1/subdir2/scriptname.nasl"). |