|
OpenVAS Scanner 23.40.3
|
Manages the launching of plugins within processes. More...
#include "pluginlaunch.h"#include "../misc/heartbeat.h"#include "../misc/network.h"#include "../misc/nvt_categories.h"#include "../misc/plugutils.h"#include "pluginload.h"#include "pluginscheduler.h"#include "plugs_req.h"#include "processes.h"#include "sighand.h"#include "utils.h"#include <errno.h>#include <gvm/base/prefs.h>#include <gvm/util/nvticache.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>#include <sys/time.h>#include <sys/wait.h>#include <unistd.h>
Go to the source code of this file.
Data Structures | |
| struct | running |
| Structure to represent a process in the sense of a running NVT. More... | |
Macros | |
| #define | G_LOG_DOMAIN "sd main" |
| GLib log domain. | |
| #define | MAX_PROCESSES 32 |
| 'Hard' limit of the max. number of concurrent plugins per host. | |
Functions | |
| static int | max_nvt_timeouts_reached (void) |
| Check if max_nvt_timeouts is set and if has been reached. | |
| static void | update_running_processes (kb_t main_kb, kb_t kb) |
| static int | common (GSList *list1, GSList *list2) |
| static GSList * | required_ports_in_list (const char *oid, GSList *list) |
| static int | simult_ports (const char *oid, const char *next_oid) |
| static int | next_free_process (kb_t main_kb, kb_t kb, struct scheduler_plugin *upcoming) |
| void | pluginlaunch_init (const char *host) |
| void | pluginlaunch_disable_parallel_checks (void) |
| void | pluginlaunch_enable_parallel_checks (void) |
| void | pluginlaunch_stop (void) |
| static int | plugin_timeout (nvti_t *nvti) |
| static int | get_available_memory () |
| static int | check_memory () |
| static int | check_sysload () |
| int | plugin_launch (struct scan_globals *globals, struct scheduler_plugin *plugin, struct in6_addr *ip, GSList *vhosts, kb_t kb, kb_t main_kb, nvti_t *nvti, int *error) |
| Start a plugin. | |
| void | pluginlaunch_wait (kb_t main_kb, kb_t kb) |
| Waits and 'pushes' processes until num_running_processes is 0. | |
| static int | timeout_running_processes (void) |
| Return shortest timeout of the running processes. | |
| void | pluginlaunch_wait_for_free_process (kb_t main_kb, kb_t kb) |
| Waits and 'pushes' processes until the number of running processes has changed. | |
Variables | |
| int | global_min_memory |
| int | global_max_sysload |
| static struct running | processes [MAX_PROCESSES] |
| static int | num_running_processes |
| static int | max_running_processes |
| static int | old_max_running_processes |
| static GSList * | non_simult_ports = NULL |
| const char * | hostname = NULL |
Manages the launching of plugins within processes.
Definition in file pluginlaunch.c.
| #define G_LOG_DOMAIN "sd main" |
GLib log domain.
Definition at line 41 of file pluginlaunch.c.
| #define MAX_PROCESSES 32 |
'Hard' limit of the max. number of concurrent plugins per host.
Definition at line 46 of file pluginlaunch.c.
Referenced by next_free_process(), pluginlaunch_init(), pluginlaunch_stop(), timeout_running_processes(), and update_running_processes().
|
static |
Definition at line 443 of file pluginlaunch.c.
References get_available_memory(), and global_min_memory.
Referenced by pluginlaunch_wait_for_free_process().


|
static |
Definition at line 457 of file pluginlaunch.c.
References global_max_sysload.
Referenced by pluginlaunch_wait_for_free_process().

|
static |
Definition at line 227 of file pluginlaunch.c.
Referenced by simult_ports().

|
static |
Definition at line 410 of file pluginlaunch.c.
References len.
Referenced by check_memory().

|
static |
Check if max_nvt_timeouts is set and if has been reached.
Definition at line 76 of file pluginlaunch.c.
Referenced by update_running_processes().

|
static |
If another NVT with same port requirements is running, wait.
Definition at line 301 of file pluginlaunch.c.
References ERR_NO_FREE_SLOT, main_kb, MAX_PROCESSES, scheduler_plugin::oid, pid, process_alive(), processes, simult_ports(), and update_running_processes().
Referenced by plugin_launch().


| int plugin_launch | ( | struct scan_globals * | globals, |
| struct scheduler_plugin * | plugin, | ||
| struct in6_addr * | ip, | ||
| GSList * | vhosts, | ||
| kb_t | kb, | ||
| kb_t | main_kb, | ||
| nvti_t * | nvti, | ||
| int * | error ) |
Start a plugin.
Check for free slots available in the process table. Set error with ERR_NO_FREE_SLOT if the process table is full. Set error with ERR_CANT_FORK if was not possible to fork() a new child.
Definition at line 480 of file pluginlaunch.c.
References ERR_CANT_FORK, ERR_NO_FREE_SLOT, main_kb, nasl_plugin_launch(), next_free_process(), num_running_processes, scheduler_plugin::oid, pid, PLUGIN_STATUS_UNRUN, plugin_timeout(), pluginlaunch_wait_for_free_process(), and processes.
Referenced by launch_plugin().


|
static |
Definition at line 383 of file pluginlaunch.c.
References ACT_SCANNER, and get_plugin_preference().
Referenced by plugin_launch().


| void pluginlaunch_disable_parallel_checks | ( | void | ) |
Definition at line 351 of file pluginlaunch.c.
References max_running_processes.
Referenced by get_next_in_range().

| void pluginlaunch_enable_parallel_checks | ( | void | ) |
Definition at line 357 of file pluginlaunch.c.
References max_running_processes, and old_max_running_processes.
Referenced by get_next_in_range().

| void pluginlaunch_init | ( | const char * | host | ) |
Definition at line 324 of file pluginlaunch.c.
References get_max_checks_number(), hostname, init_kb_usage(), MAX_PROCESSES, max_running_processes, non_simult_ports, num_running_processes, old_max_running_processes, and processes.
Referenced by attack_host().


| void pluginlaunch_stop | ( | void | ) |
Definition at line 363 of file pluginlaunch.c.
References MAX_PROCESSES, num_running_processes, pid, PLUGIN_STATUS_DONE, processes, and terminate_process().
Referenced by attack_host(), launch_plugin(), pluginlaunch_wait_for_free_process(), and scan_stop_cleanup().


| void pluginlaunch_wait | ( | kb_t | main_kb, |
| kb_t | kb ) |
Waits and 'pushes' processes until num_running_processes is 0.
Definition at line 517 of file pluginlaunch.c.
References main_kb, num_running_processes, and update_running_processes().
Referenced by attack_host().


| void pluginlaunch_wait_for_free_process | ( | kb_t | main_kb, |
| kb_t | kb ) |
Waits and 'pushes' processes until the number of running processes has changed.
Definition at line 550 of file pluginlaunch.c.
References check_memory(), check_sysload(), main_kb, max_running_processes, num_running_processes, pluginlaunch_stop(), procs_cleanup_children(), timeout_running_processes(), and update_running_processes().
Referenced by attack_host(), and plugin_launch().


|
static |
Definition at line 247 of file pluginlaunch.c.
References oid.
Referenced by simult_ports().

|
static |
Definition at line 279 of file pluginlaunch.c.
References common(), non_simult_ports, oid, and required_ports_in_list().
Referenced by next_free_process().


|
static |
Return shortest timeout of the running processes.
Definition at line 531 of file pluginlaunch.c.
References MAX_PROCESSES, pid, and processes.
Referenced by pluginlaunch_wait_for_free_process().

|
static |
Definition at line 109 of file pluginlaunch.c.
References check_host_still_alive(), hostname, kb_item_push_str_with_main_kb_check(), main_kb, max_nvt_timeouts_reached(), MAX_PROCESSES, name, num_running_processes, oid, pid, PLUGIN_STATUS_DONE, process_alive(), processes, terminate_process(), and timeval().
Referenced by next_free_process(), pluginlaunch_wait(), and pluginlaunch_wait_for_free_process().


|
extern |
Definition at line 88 of file openvas.c.
Referenced by check_sysload(), and set_globals_from_preferences().
|
extern |
Definition at line 87 of file openvas.c.
Referenced by check_memory(), and set_globals_from_preferences().
| const char* hostname = NULL |
Definition at line 68 of file pluginlaunch.c.
Referenced by _http2_req(), _http_req(), call_rs_notus(), check_duplicated_vhost(), check_host_still_alive(), get_hostname(), ipc_data_type_from_hostname(), ipc_get_lsc_os_release_from_data(), make_table_driven_lsc_info_json_str(), nasl_open_sock_kdc(), nasl_this_host(), nasl_this_host_name(), open_sock_opt_hn(), open_SSL_connection(), open_stream_connection_ext(), plug_add_host_fqdn(), plug_get_host_source(), pluginlaunch_init(), proto_post_wrapped(), run_table_driven_lsc(), socket_negotiate_ssl(), update_running_processes(), and v6_openbpf().
|
static |
Definition at line 65 of file pluginlaunch.c.
Referenced by pluginlaunch_disable_parallel_checks(), pluginlaunch_enable_parallel_checks(), pluginlaunch_init(), and pluginlaunch_wait_for_free_process().
|
static |
Definition at line 67 of file pluginlaunch.c.
Referenced by pluginlaunch_init(), and simult_ports().
|
static |
Definition at line 64 of file pluginlaunch.c.
Referenced by plugin_launch(), pluginlaunch_init(), pluginlaunch_stop(), pluginlaunch_wait(), pluginlaunch_wait_for_free_process(), and update_running_processes().
|
static |
Definition at line 66 of file pluginlaunch.c.
Referenced by pluginlaunch_enable_parallel_checks(), and pluginlaunch_init().
|
static |
Definition at line 63 of file pluginlaunch.c.
Referenced by next_free_process(), plugin_launch(), pluginlaunch_init(), pluginlaunch_stop(), timeout_running_processes(), and update_running_processes().