utils.c headerfile.
More...
#include "../misc/scanneraux.h"
#include <sys/types.h>
Go to the source code of this file.
utils.c headerfile.
Definition in file utils.h.
◆ check_host_still_alive()
| int check_host_still_alive |
( |
kb_t |
kb, |
|
|
const char * |
hostname |
|
) |
| |
Check if the hosts is still alive and set it as dead if not.
- Parameters
-
| kb | Host kb where the host is set as dead. |
- Returns
- 1 if considered alive, 0 if it is dead. -1 on error or option disabled.
Definition at line 33 of file heartbeat.c.
36 boreas_error_t alive_err;
40 if (prefs_get_bool (
"test_alive_hosts_only"))
42 const gchar *alive_test_str = prefs_get (
"ALIVE_TEST");
47 && atoi (alive_test_str) >= ALIVE_TEST_TCP_ACK_SERVICE
48 && atoi (alive_test_str) < 32
49 && !((atoi (alive_test_str)) & ALIVE_TEST_CONSIDER_ALIVE)))
54 g_warning (
"%s: Trying to perform an alive test, but Boreas is not "
55 "enabled. Heartbeat check for %s will not be performed",
60 alive_err = is_host_alive (
hostname, &is_alive);
63 g_warning (
"%s: Heartbeat check failed for %s with error %d.", __func__,
70 g_message (
"%s: Heartbeat check was not successful. The host %s has"
Referenced by nasl_end_denial(), and update_running_processes().
◆ data_left()
Definition at line 208 of file utils.c.
211 ioctl (soc, FIONREAD, &data);
◆ get_max_checks_number()
| int get_max_checks_number |
( |
void |
| ) |
|
Get the max number of plugins to launch against the remote host at the same time
Definition at line 165 of file utils.c.
168 if (prefs_get (
"max_checks"))
170 max_checks = atoi (prefs_get (
"max_checks"));
173 g_debug (
"Error ! max_hosts = %d -- check %s", max_checks,
174 (
char *) prefs_get (
"config_file"));
179 g_debug (
"Client tried to raise the maximum checks number - %d."
180 " Using %d. Change 'max_checks' in openvas.conf if you"
181 " believe this is incorrect",
References global_max_checks.
Referenced by attack_network(), and pluginlaunch_init().
◆ get_max_hosts_number()
| int get_max_hosts_number |
( |
void |
| ) |
|
Get the max number of hosts to test at the same time.
Definition at line 134 of file utils.c.
137 if (prefs_get (
"max_hosts"))
139 max_hosts = atoi (prefs_get (
"max_hosts"));
142 g_debug (
"Error ! max_hosts = %d -- check %s", max_hosts,
143 (
char *) prefs_get (
"config_file"));
148 g_debug (
"Client tried to raise the maximum hosts number - %d."
149 " Using %d. Change 'max_hosts' in openvas.conf if you"
150 " believe this is incorrect",
References global_max_hosts.
Referenced by attack_network().
◆ is_scanner_only_pref()
| int is_scanner_only_pref |
( |
const char * |
| ) |
|
Definition at line 235 of file utils.c.
239 if (!strcmp (pref,
"config_file") || !strcmp (pref,
"plugins_folder")
243 || !strcmp (pref,
"db_address") || !strcmp (pref,
"negot_timeout")
244 || !strcmp (pref,
"force_pubkey_auth")
245 || !strcmp (pref,
"log_whole_attack")
246 || !strcmp (pref,
"log_plugins_name_at_load")
247 || !strcmp (pref,
"nasl_no_signature_check")
248 || !strcmp (pref,
"vendor_version") || !strcmp (pref,
"drop_privileges")
249 || !strcmp (pref,
"nasl_drop_privileges_user")
250 || !strcmp (pref,
"debug_tls") || !strcmp (pref,
"min_free_mem")
251 || !strcmp (pref,
"max_sysload")
253 || !strncmp (pref,
"sys_", 4))
Referenced by overwrite_openvas_prefs_with_prefs_from_client().
◆ process_alive()
| int process_alive |
( |
pid_t |
pid | ) |
|
◆ store_file()
| int store_file |
( |
struct scan_globals * |
globals, |
|
|
const char * |
file, |
|
|
const char * |
file_hash |
|
) |
| |
Stores a file type preference in a hash table.
- Parameters
-
| globals | Global struct. |
| file | File content. |
| file_hash | hash to reference the file. |
- Returns
- 0 if successful, -1 in case of errors.
Definition at line 101 of file utils.c.
105 gchar *contents = NULL;
109 if (!file_hash || *file_hash ==
'\0')
112 origname = g_strdup (file_hash);
114 contents = (gchar *) g_base64_decode (file, &bytes);
116 if (contents == NULL)
118 g_debug (
"store_file: Failed to allocate memory for uploaded file.");
References files_add_size_translation(), and files_add_translation().
Referenced by overwrite_openvas_prefs_with_prefs_from_client().
◆ wait_for_children1()
| void wait_for_children1 |
( |
void |
| ) |
|
Definition at line 216 of file utils.c.
222 e = waitpid (-1, NULL, WNOHANG);
225 while ((e > 0 || errno == EINTR) && n < 20);