28 #include "../misc/network.h" 29 #include "../misc/nvt_categories.h" 38 #include <gvm/base/prefs.h> 39 #include <gvm/util/nvticache.h> 52 #define G_LOG_DOMAIN "sd main" 57 #define MAX_PROCESSES 32 86 int log_whole = prefs_get_bool (
"log_whole_attack");
91 gettimeofday (&now, NULL);
97 int ret_terminate = 0;
112 g_message (
"%s (pid %d) is slow to finish - killing it",
116 "ERRMSG||| |||general/tcp|||%s|||" 117 "NVT timed out after %d seconds.",
119 kb_item_push_str (kb,
"internal/results", msg);
122 if (ret_terminate == 0)
137 now.tv_usec += 1000000;
141 char *
name = nvticache_get_filename (
oid);
143 "%s (%s) [%d] finished its job in %ld.%.3ld seconds",
155 while (e < 0 && errno == EINTR);
170 if (!list1 || !list2)
178 if (!strcmp (list1->data, tmp->data))
190 GSList *common_ports = NULL;
191 char **array, *ports;
196 ports = nvticache_get_required_ports (
oid);
199 array = g_strsplit (ports,
", ", 0);
204 for (i = 0; array[i]; i++)
209 if (!strcmp (tmp->data, array[i]))
210 common_ports = g_slist_prepend (common_ports, g_strdup (tmp->data));
223 GSList *common_ports1 = NULL, *common_ports2 = NULL;
228 if (common_ports1 && common_ports2 &&
common (common_ports1, common_ports2))
230 g_slist_free_full (common_ports1, g_free);
231 g_slist_free_full (common_ports2, g_free);
269 char **split = g_strsplit (prefs_get (
"non_simult_ports"),
", ", 0);
270 for (i = 0; split[i]; i++)
279 g_debug (
"max_checks (%d) > MAX_PROCESSES (%d) - modify " 280 "openvas/openvas/pluginlaunch.c",
324 timeout = prefs_nvt_timeout (nvti_oid (nvti));
326 timeout = nvti_timeout (nvti);
331 atoi (prefs_get (
"scanner_plugins_timeout")) ?: SCANNER_NVT_TIMEOUT;
333 timeout = atoi (prefs_get (
"plugins_timeout")) ?: NVT_TIMEOUT;
344 struct in6_addr *ip, GSList *vhosts, kb_t kb, nvti_t *nvti)
355 gettimeofday (&(
processes[p].start), NULL);
376 waitpid (-1, NULL, 0);
392 if (!timeout ||
processes[i].timeout < timeout)
413 struct timespec ts = {0, 0};
418 sigaddset (&mask, SIGCHLD);
419 if (sigtimedwait (&mask, NULL, &ts) < 0 && errno != EAGAIN)
420 g_warning (
"%s: %s", __FUNCTION__, strerror (errno));
static int plugin_timeout(nvti_t *nvti)
int process_alive(pid_t pid)
static GSList * required_ports_in_list(const char *oid, GSList *list)
static struct running processes[MAX_PROCESSES]
static int old_max_running_processes
static int common(GSList *list1, GSList *list2)
struct scheduler_plugin * plugin
headerfile for sighand.c.
#define MAX_PROCESSES
'Hard' limit of the max. number of concurrent plugins per host.
static GSList * non_simult_ports
static int next_free_process(kb_t kb, struct scheduler_plugin *upcoming)
void pluginlaunch_disable_parallel_checks(void)
void pluginlaunch_wait_for_free_process(kb_t kb)
Waits and 'pushes' processes until the number of running processes has changed.
Host information, implemented as doubly linked list.
void pluginlaunch_wait(kb_t kb)
Waits and 'pushes' processes until num_running_processes is 0.
static int num_running_processes
static int timeout_running_processes()
Return shortest timeout of the running processes.
void pluginlaunch_enable_parallel_checks(void)
static int max_running_processes
struct timeval timeval(unsigned long val)
Structure to represent a process in the sense of a running NVT.
enum plugin_status running_state
int nasl_plugin_launch(struct scan_globals *globals, struct in6_addr *ip, GSList *vhosts, kb_t kb, const char *oid)
Launch a NASL plugin.
static void update_running_processes(kb_t kb)
static int simult_ports(const char *oid, const char *next_oid)
int terminate_process(pid_t pid)
Send SIGTERM to the pid process. Try to wait the the process. In case of the process has still not ch...
header for pluginscheduler.c
int get_max_checks_number(void)
void pluginlaunch_init(const char *host)
int plugin_launch(struct scan_globals *globals, struct scheduler_plugin *plugin, struct in6_addr *ip, GSList *vhosts, kb_t kb, nvti_t *nvti)