Mailing List Archive

Re: Making user plugins override main plugins directory
On Mon, Nov 25, 2002 at 04:10:02PM +0000, Paul Johnston wrote:
> >Use arg_set_value() to change the value if it exists already, and that
> >should be sufficient. You should also call arg_free() on the value
> >you're replacing.
> >
> Problem is, if I take that approach, then I'll need to make changes to
> nasl_plugins, nes_plugins and perl_plugins. It struck me that adding
> arg_remove_value() would be a cleaner way.
>
> I'm easy though - what do you reckon?

I think it would be cleaner to edit {nasl,nes}_plugins.c. As the way the
arglists are used is a bit messy (to say the least), arg_rm_value()
would cause more harm than good (as the location of the begining of the
list might change).


-- Renaud

ps: please continue this discussion to nessus-devel@list.nessus.org
please
Re: Making user plugins override main plugins directory [ In reply to ]
Hi,

>I think it would be cleaner to edit {nasl,nes}_plugins.c. As the way the
>arglists are used is a bit messy (to say the least), arg_rm_value()
>would cause more harm than good (as the location of the begining of the
>list might change).
>
Ok, I have now made the changes and they work fine for me. I've attached
a patch file.
BTW, I didn't change perl_plugins.c as it seemed that this file is not
actually in use.

Paul




diff -bu /project/nessus/nessus-core/nessusd/nasl_plugins.c /home/users/paul/nessus/nessus-core/nessusd/nasl_plugins.c
--- /project/nessus/nessus-core/nessusd/nasl_plugins.c Thu Nov 21 09:39:59 2002
+++ /home/users/paul/nessus/nessus-core/nessusd/nasl_plugins.c Mon Nov 25 17:09:39 2002
@@ -91,7 +91,12 @@
arg_add_value(plugin, "plugin_args", ARG_ARGLIST, -1, (void *)plugin_args);
arg_add_value(plugin, "full_name", ARG_STRING, -1, fullname);
plug_set_launch(plugin_args, 0);
+
+ if(!arg_get_value(plugins, name))
arg_add_value(plugins, name, ARG_ARGLIST, -1, (void *)plugin);
+ else
+ arg_set_value(plugins, name, -1, (void *)plugin);
+
nasl_exit(nasl);
return(plugin);
}
diff -bu /project/nessus/nessus-core/nessusd/nes_plugins.c /home/users/paul/nessus/nessus-core/nessusd/nes_plugins.c
--- /project/nessus/nessus-core/nessusd/nes_plugins.c Thu Nov 21 09:39:59 2002
+++ /home/users/paul/nessus/nessus-core/nessusd/nes_plugins.c Mon Nov 25 17:10:03 2002
@@ -183,7 +183,11 @@
arg_add_value(plugin, "plugin_args", ARG_ARGLIST, -1, (void *)args);
arg_add_value(plugin, "full_name", ARG_STRING, -1, fullname);
plug_set_launch(args, 0);
+
+ if(!arg_get_value(plugins, name))
arg_add_value(plugins, name, ARG_ARGLIST, -1, (void *)plugin);
+ else
+ arg_set_value(plugins, name, -1, (void *)plugin);
}
}
else log_write("Couldn't find the entry point in %s [%s]\n", name,LIB_LAST_ERROR());
diff -bu /project/nessus/nessus-core/nessusd/pluginload.c /home/users/paul/nessus/nessus-core/nessusd/pluginload.c
--- /project/nessus/nessus-core/nessusd/pluginload.c Thu Nov 21 09:39:59 2002
+++ /home/users/paul/nessus/nessus-core/nessusd/pluginload.c Mon Nov 25 17:12:31 2002
@@ -135,8 +135,6 @@
pl_class_t * cl_ptr = plugin_classes;


- if(!arg_get_value(plugins, name))
- {
if(preferences_log_plugins_at_load(preferences))
log_write("Loading %s\n", name);
while(cl_ptr) {
@@ -153,7 +151,6 @@
cl_ptr = cl_ptr->pl_next;
}
}
- }
#ifdef NESSUSNT
while(FinNextFile(search, &filedata));
FindClose(search);