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));