OpenVAS Scanner 23.23.1
openvas.c File Reference
#include "openvas.h"
#include "../misc/kb_cache.h"
#include "../misc/plugutils.h"
#include "../misc/scan_id.h"
#include "../misc/vendorversion.h"
#include "../nasl/nasl_krb5.h"
#include "attack.h"
#include "debug_utils.h"
#include "pluginlaunch.h"
#include "processes.h"
#include "sighand.h"
#include "utils.h"
#include <bsd/unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <gcrypt.h>
#include <glib.h>
#include <gnutls/gnutls.h>
#include <grp.h>
#include <gvm/base/logging.h>
#include <gvm/base/nvti.h>
#include <gvm/base/prefs.h>
#include <gvm/base/version.h>
#include <gvm/util/kb.h>
#include <gvm/util/mqtt.h>
#include <gvm/util/nvticache.h>
#include <gvm/util/uuidutils.h>
#include <netdb.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>
#include "../misc/network.h"

Data Structures

struct  openvas_option

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain.
#define PROCTITLE_WAITING   "openvas: Waiting for incoming connections"
#define PROCTITLE_LOADING   "openvas: Loading Handler"
#define PROCTITLE_RELOADING   "openvas: Reloading"
#define PROCTITLE_SERVING   "openvas: Serving %s"

Functions

static void set_default_openvas_prefs ()
 Set the prefs from the openvas_defaults array.
static void my_gnutls_log_func (int level, const char *text)
static void set_globals_from_preferences (void)
static void handle_termination_signal (int sig)
static void init_signal_handlers (void)
 Initializes main scanner process' signal handlers.
static int overwrite_openvas_prefs_with_prefs_from_client (struct scan_globals *globals)
 Read the scan preferences from redis.
static int init_logging ()
 Init logging.
static void gcrypt_init (void)
static void check_tls ()
 Check TLS.
static void openvas_print_start_msg ()
 Print start message.
static int stop_single_task_scan (void)
 Search in redis the process ID of a running scan and sends it the kill signal SIGUSR1, which will stop the scan. To find the process ID, it uses the scan_id passed with the –scan-stop option.
static void send_message_to_client_and_finish_scan (const char *msg)
 Send a failure message and set the scan as finished.
static int attack_network_init (struct scan_globals *globals, const gchar *config_file)
 Set up data needed for attack_network().
int openvas (int argc, char *argv[], char *env[])
 openvas.

Variables

int global_max_hosts = 15
int global_max_checks = 10
int global_min_memory = 0
int global_max_sysload = 0
GSList * log_config = NULL
 Logging parameters, as passed to setup_log_handlers.
static volatile int termination_signal = 0
static openvas_option openvas_defaults []
 Default values for scanner options. Must be NULL terminated.

Detailed Description

OpenVAS main module, runs the scanner.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

◆ PROCTITLE_LOADING

#define PROCTITLE_LOADING   "openvas: Loading Handler"

◆ PROCTITLE_RELOADING

#define PROCTITLE_RELOADING   "openvas: Reloading"

◆ PROCTITLE_SERVING

#define PROCTITLE_SERVING   "openvas: Serving %s"

◆ PROCTITLE_WAITING

#define PROCTITLE_WAITING   "openvas: Waiting for incoming connections"

Function Documentation

◆ attack_network_init()

int attack_network_init ( struct scan_globals * globals,
const gchar * config_file )
static

Set up data needed for attack_network().

Parameters
globalsscan_globals needed for client preference handling.
config_fileUsed for config preference handling.
Returns
0 on success, 1 otherwise.

◆ check_tls()

void check_tls ( )
static

Check TLS.

◆ gcrypt_init()

void gcrypt_init ( void )
static

◆ handle_termination_signal()

void handle_termination_signal ( int sig)
static

◆ init_logging()

int init_logging ( )
static

Init logging.

Returns
0 on success, -1 on error.

◆ init_signal_handlers()

void init_signal_handlers ( void )
static

Initializes main scanner process' signal handlers.

◆ my_gnutls_log_func()

void my_gnutls_log_func ( int level,
const char * text )
static

◆ openvas()

int openvas ( int argc,
char * argv[],
char * env[] )

openvas.

Parameters
argcArgument count.
argvArgument vector.

◆ openvas_print_start_msg()

void openvas_print_start_msg ( )
static

Print start message.

◆ overwrite_openvas_prefs_with_prefs_from_client()

int overwrite_openvas_prefs_with_prefs_from_client ( struct scan_globals * globals)
static

Read the scan preferences from redis.

Adds preferences to the global_prefs. If preference already exists in global_prefs they will be overwritten by prefs from client.

Parameters
globalsScan ID of globals used as key to find the corresponding KB where to take the preferences from. Globals also used for file upload.
Returns
0 on success, -1 if the kb is not found or no prefs are found in the kb.

◆ send_message_to_client_and_finish_scan()

void send_message_to_client_and_finish_scan ( const char * msg)
static

Send a failure message and set the scan as finished.

Parameters
msgMessage to send to the client.

◆ set_default_openvas_prefs()

void set_default_openvas_prefs ( )
static

Set the prefs from the openvas_defaults array.

◆ set_globals_from_preferences()

void set_globals_from_preferences ( void )
static

◆ stop_single_task_scan()

int stop_single_task_scan ( void )
static

Search in redis the process ID of a running scan and sends it the kill signal SIGUSR1, which will stop the scan. To find the process ID, it uses the scan_id passed with the –scan-stop option.

Returns
0 on success, 1 otherwise.

Variable Documentation

◆ global_max_checks

int global_max_checks = 10

◆ global_max_hosts

int global_max_hosts = 15

Globals that should not be touched (used in utils module).

◆ global_max_sysload

int global_max_sysload = 0

◆ global_min_memory

int global_min_memory = 0

◆ log_config

GSList* log_config = NULL

Logging parameters, as passed to setup_log_handlers.

◆ openvas_defaults

openvas_option openvas_defaults[]
static
Initial value:
= {
{"plugins_folder", OPENVAS_NVT_DIR},
{"include_folders", OPENVAS_NVT_DIR},
{"plugins_timeout", G_STRINGIFY (NVT_TIMEOUT)},
{"scanner_plugins_timeout", G_STRINGIFY (SCANNER_NVT_TIMEOUT)},
{"db_address", KB_PATH_DEFAULT},
{NULL, NULL}}

Default values for scanner options. Must be NULL terminated.

Only include options which are dependent on CMake variables. Empty options must be "\0", not NULL, to match the behavior of prefs_init.

◆ termination_signal

volatile int termination_signal = 0
static