[Openvas-commits] r1319 - in trunk/openvas-client: . nessus
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Sep 10 12:42:39 CEST 2008
Author: jan
Date: 2008-09-10 12:42:39 +0200 (Wed, 10 Sep 2008)
New Revision: 1319
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/nessus/preferences.c
Log:
Migrate preferences to use OID instead of ID. This includes
migration from "nessusrc" to "openvasrc" filename.
* nessus/preferences.c (pluginset_reload): Change hash search from
ID to OID.
(struct hash): Changed type of name from int to char * as it is now OID.
(hash_get): Changed parameter id to OID (and type from int to char *).
The hash value is now the last element of the OID. The hash name is now OID.
(new_pluginset): print OID instead of ID.
(preferences_get_filename): Change filename from "nessusrc" to
"openvasrc". ANSI C declaration. Renamed internal variables accordingly.
(preferences_new): Initial settings use full OID now.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2008-09-10 09:15:36 UTC (rev 1318)
+++ trunk/openvas-client/ChangeLog 2008-09-10 10:42:39 UTC (rev 1319)
@@ -1,5 +1,20 @@
2008-09-10 Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
+ Migrate preferences to use OID instead of ID. This includes
+ migration from "nessusrc" to "openvasrc" filename.
+
+ * nessus/preferences.c (pluginset_reload): Change hash search from
+ ID to OID.
+ (struct hash): Changed type of name from int to char * as it is now OID.
+ (hash_get): Changed parameter id to OID (and type from int to char *).
+ The hash value is now the last element of the OID. The hash name is now OID.
+ (new_pluginset): print OID instead of ID.
+ (preferences_get_filename): Change filename from "nessusrc" to
+ "openvasrc". ANSI C declaration. Renamed internal variables accordingly.
+ (preferences_new): Initial settings use full OID now.
+
+2008-09-10 Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
+
Migrate timout settings handling as well as SQL dumping to OID.
* nessus/cli.c (_cli_sql_dump_plugins): Use OID for INSERT command
Modified: trunk/openvas-client/nessus/preferences.c
===================================================================
--- trunk/openvas-client/nessus/preferences.c 2008-09-10 09:15:36 UTC (rev 1318)
+++ trunk/openvas-client/nessus/preferences.c 2008-09-10 10:42:39 UTC (rev 1319)
@@ -26,7 +26,7 @@
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*
- * Preferences -- maps the content of the nessusrc file to memory
+ * Preferences -- maps the content of the openvasrc file to memory
*
*/
@@ -71,29 +71,28 @@
*/
char *
-preferences_get_filename(context)
- struct context *context;
+preferences_get_filename(struct context * context)
{
- char *nessusrc;
+ char * openvasrc;
if(context->dir)
{
- nessusrc = emalloc(strlen(context->dir) + strlen("/nessusrc") + 1);
- sprintf(nessusrc, "%s/nessusrc", context->dir);
+ openvasrc = emalloc(strlen(context->dir) + strlen("/openvasrc") + 1);
+ sprintf(openvasrc, "%s/openvasrc", context->dir);
}
else
{
if(Alt_rcfile)
- nessusrc = estrdup(Alt_rcfile);
+ openvasrc = estrdup(Alt_rcfile);
else
{
char *home = prefs_get_nessushome();
- nessusrc = emalloc(strlen(home) + strlen("/.openvasrc") + 1);
- sprintf(nessusrc, "%s/.openvasrc", home);
+ openvasrc = emalloc(strlen(home) + strlen("/.openvasrc") + 1);
+ sprintf(openvasrc, "%s/.openvasrc", home);
}
}
- return nessusrc;
+ return openvasrc;
}
char *
@@ -138,18 +137,18 @@
fprintf(f, _("# OpenVAS-Client Preferences File\n\n"));
fprintf(f, "trusted_ca = cacert.pem\n");
fprintf(f, "begin(SCANNER_SET)\n");
- fprintf(f, "10180 = yes\n");
- fprintf(f, "10278 = no\n");
- fprintf(f, "10331 = no\n");
- fprintf(f, "10335 = yes\n");
- fprintf(f, "10841 = no\n");
- fprintf(f, "10336 = no\n");
- fprintf(f, "10796 = no\n");
- fprintf(f, "11219 = no\n");
- fprintf(f, "14259 = no\n");
- fprintf(f, "14272 = no\n");
- fprintf(f, "14274 = no\n");
- fprintf(f, "14663 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10180 = yes\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10278 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10331 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10335 = yes\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10841 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10336 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.10796 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.11219 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.14259 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.14272 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.14274 = no\n");
+ fprintf(f, " 1.3.6.1.4.1.25623.1.0.14663 = no\n");
fprintf(f, "end(SCANNER_SET)\n\n");
fprintf(f, "begin(SERVER_PREFS)\n");
@@ -374,9 +373,9 @@
{
while(plugins != NULL )
{
- char name[32];
+ char name[40];
- snprintf(name, sizeof(name), "%d", plugins->id);
+ snprintf(name, sizeof(name), "%s", plugins->oid);
arg_add_value(pluginset, name, ARG_INT, sizeof(int), (void*)(plugins->enabled != 0) );
plugins = plugins->next;
}
@@ -399,24 +398,34 @@
return plugin_set;
}
+/*
+ * TODO: This whole private hash implementation should be replaced by
+ * a adequate fast search method from glib or a least be consolidated
+ * with other hash implementation that occur in OpenVAS.
+ * XXX: This hashing is probably less performant since it was migrated from
+ * integer names to string names.
+ */
#define MAGIC 8197
struct hash
{
- int name;
+ char * name;
struct arglist *v;
struct hash *next;
};
static struct arglist *
-hash_get(struct hash **hash, int id)
+hash_get(struct hash **hash, const char * oid)
{
- int idx = id % MAGIC;
- struct hash *h = hash[idx];
+ int id, dummy;
+ struct hash *h;
+ sscanf(oid, "1.3.6.1.4.1.25623.1.%d.%d", &dummy, &id);
+ h = hash[id % MAGIC];
+
while(h != NULL)
{
- if(h->name == id)
+ if(!strcmp(h->name, oid))
return h->v;
h = h->next;
}
@@ -446,21 +455,21 @@
while(pluginset->next)
{
- int id = atoi(pluginset->name);
- int idx = id % MAGIC;
+ int dummy, id;
+ sscanf(pluginset->name, "1.3.6.1.4.1.25623.1.%d.%d", &dummy, &id);
+
h = emalloc(sizeof(struct hash));
- h->name = id;
+ h->name = pluginset->name;
h->v = pluginset;
- h->next = hash[idx];
- hash[idx] = h;
+ h->next = hash[id % MAGIC];
+ hash[id % MAGIC] = h;
pluginset = pluginset->next;
}
while(plugins != NULL )
{
- int id = plugins->id;
- struct arglist *pluginset_entry = hash_get(hash, id);
+ struct arglist *pluginset_entry = hash_get(hash, plugins->oid);
if(pluginset_entry != NULL )
pluginset_entry->value = (void *)(plugins->enabled != 0 );
More information about the Openvas-commits
mailing list