On Mon, May 03, 2004 at 07:55:05PM +1200, Russell Fulton wrote: > I have been looking at using some plugins (currently smb_kb835732.nasl) > from the command line nasl tool.
A potential problem with this approach in general is that the commandline nasl tool can't read KBs at present. Many plugins need to be able to do so to run properly. > Any hints on how to set the exit code for nasl would be appreciated. I took at look at the source and developed some patches (see attached) that *seem* to do this. This seems like a useful feature and would be nice if Renaud / Michel (1) find that they work correctly and (2) choose to integrate them into the source. They modify libnasl/exec.c to use the return code from the script itself when executing a NASL script as well as libnasl/nasl.c to keep track of the return code from running each NASL script and to exit with the most recent. Use at your own risk. Note that I haven't done anything more than use them to modify the standalone NASL interpreter and verify that I can set the return code with a simple NASL plugin. George -- [EMAIL PROTECTED]
--- libnasl/nasl/exec.c.orig 2004-01-19 16:38:32.000000000 -0500
+++ libnasl/nasl/exec.c 2004-05-05 15:26:29.023772808 -0400
@@ -1739,8 +1739,10 @@
truc = (lex_ctxt*)ctx.tree;
if ((ret = nasl_exec(lexic, ctx.tree)) == NULL)
err = -1;
- else
+ else {
+ err = cell2int(lexic, ret);
deref_cell(ret);
+ }
if ((pf = get_func_ref_by_name(lexic, "on_exit")) != NULL)
nasl_func_call(lexic, pf, NULL);
--- libnasl/nasl/nasl.c.orig 2003-07-17 14:05:36.000000000 -0400
+++ libnasl/nasl/nasl.c 2004-05-05 14:48:00.725687456 -0400
@@ -132,6 +132,7 @@
int start, n;
char hostname[1024];
int mode = 0;
+ int rc;
/*--------------------------------------------
Command-line options
@@ -221,10 +222,10 @@
n = start;
while(argv[n])
{
- execute_nasl_script(script_infos, argv[n], mode);
+ rc = execute_nasl_script(script_infos, argv[n], mode);
n++;
}
}
hg_cleanup(hg_globals);
- return(0);
+ return(rc);
}
pgptAoNW7bmrw.pgp
Description: PGP signature
_______________________________________________ Nessus mailing list [EMAIL PROTECTED] http://mail.nessus.org/mailman/listinfo/nessus
