22#include <bsd/unistd.h>
25#include <gvm/base/drop_privileges.h>
26#include <gvm/base/networking.h>
27#include <gvm/base/prefs.h>
28#include <gvm/util/nvticache.h>
40#define G_LOG_DOMAIN "sd main"
58 g_warning (
"%s: Missing OID", filename);
61 else if (!nvti_name (nvt))
63 g_warning (
"%s: Missing name", filename);
66 else if (!nvti_family (nvt))
68 g_warning (
"%s: Missing family", filename);
85 char fullname[PATH_MAX + 1];
89 snprintf (fullname,
sizeof (fullname),
"%s/%s", folder, filename);
91 if (prefs_get_bool (
"nasl_no_signature_check"))
95 args->
key = nvticache_get_kb ();
97 args->
name = fullname;
100 g_debug (
"%s: Checksum check failed", fullname);
122 char fullname[PATH_MAX + 1];
127 struct utimbuf updated_timestamp;
129 snprintf (fullname,
sizeof (fullname),
"%s/%s", folder, filename);
131 if (prefs_get_bool (
"nasl_no_signature_check"))
135 args->
key = nvticache_get_kb ();
136 new_nvti = nvti_new ();
137 args->
nvti = new_nvti;
138 args->
name = fullname;
141 g_debug (
"%s: Could not be loaded", fullname);
147 now = time (NULL) - 1;
148 updated_timestamp.actime = now;
149 updated_timestamp.modtime = now;
150 utime (fullname, &updated_timestamp);
153 nvticache_add (new_nvti, filename);
154 nvti_free (new_nvti);
167 GSList *vhosts, kb_t kb,
const char *
oid)
172 memset (&infos,
'\0',
sizeof (infos));
179 infos.
name = nvticache_get_src (
oid);
182 module = create_ipc_process ((ipc_process_func) nasl_thread, &infos);
190 char ip_str[INET6_ADDRSTRLEN];
193 GError *error = NULL;
203 addr6_to_str (args->
ip, ip_str);
206 setproctitle (
"openvas: testing %s (%s)", ip_str,
207 g_path_get_basename (args->
name));
209 if (prefs_get_bool (
"nasl_no_signature_check"))
212 if (prefs_get_bool (
"drop_privileges"))
214 int drop_priv_res = drop_privileges (NULL, &error);
215 if (drop_priv_res != GVM_DROP_PRIVILEGES_OK)
217 if (drop_priv_res != GVM_DROP_PRIVILEGES_FAIL_NOT_ROOT)
218 g_debug (
"Failed to drop privileges for %s", args->
name);
219 g_error_free (error);
224 g_debug (
"exec_nasl_script: %s error", args->
name);
int exec_nasl_script(struct script_infos *script_infos, int mode)
Execute a NASL script.
kb_t get_main_kb(void)
gets the main_kb. @description returns the previously set main_kb; when asserts are enabled it will a...
Header file to cache main_kb.
#define NASL_ALWAYS_SIGNED
static void nasl_thread(struct ipc_context *, struct script_infos *)
int nasl_file_check(const char *folder, const char *filename)
Check a single .nasl/.inc file.
int nasl_plugin_add(const char *folder, char *filename)
Add one .nasl plugin to the plugin list.
static int check_nvti(const char *filename, nvti_t *nvt)
Check that the nvt's data is valid.
int nasl_plugin_launch(struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts, kb_t kb, const char *oid)
Launch a NASL plugin.
Header file for module network.
header for pluginscheduler.c
Header file for module plugutils.
static struct ipc_contexts * ipcc
struct ipc_context * ipc_context
struct scan_globals * globals