OpenVAS Scanner  21.4.1
Data Structures | Macros | Functions | Variables
openvas.c File Reference
#include "../misc/plugutils.h"
#include "../misc/vendorversion.h"
#include "attack.h"
#include "pluginlaunch.h"
#include "processes.h"
#include "sighand.h"
#include "utils.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/proctitle.h>
#include <gvm/base/version.h>
#include <gvm/util/kb.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. More...
 
#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 my_gnutls_log_func (int level, const char *text)
 
static void set_globals_from_preferences (void)
 
static void reload_openvas (void)
 
static void handle_reload_signal (int sig)
 
static void handle_termination_signal (int sig)
 
static void init_signal_handlers (void)
 Initializes main scanner process' signal handlers. More...
 
static int load_scan_preferences (struct scan_globals *globals)
 Read the scan preferences from redis @input scan_id Scan ID used as key to find the corresponding KB where to take the preferences from. More...
 
static void scanner_thread (struct scan_globals *globals)
 
static int init_openvas (const char *config_file)
 Initialize everything. More...
 
static void gcrypt_init (void)
 
void start_single_task_scan (void)
 
static void 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. More...
 
int openvas (int argc, char *argv[])
 openvas. More...
 

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. More...
 
static volatile int termination_signal = 0
 
static char * global_scan_id = NULL
 
static openvas_option openvas_defaults []
 Default values for scanner options. Must be NULL terminated. More...
 

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

◆ gcrypt_init()

static void gcrypt_init ( void  )
static

◆ handle_reload_signal()

static void handle_reload_signal ( int  sig)
static

◆ handle_termination_signal()

static void handle_termination_signal ( int  sig)
static

◆ init_openvas()

static int init_openvas ( const char *  config_file)
static

Initialize everything.

Parameters
config_filePath to config file for initialization

◆ init_signal_handlers()

static void init_signal_handlers ( void  )
static

Initializes main scanner process' signal handlers.

◆ load_scan_preferences()

static int load_scan_preferences ( struct scan_globals globals)
static

Read the scan preferences from redis @input scan_id Scan ID used as key to find the corresponding KB where to take the preferences from.

Returns
0 on success, -1 if the kb is not found or no prefs are found in the kb.

◆ my_gnutls_log_func()

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

◆ openvas()

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

openvas.

Parameters
argcArgument count.
argvArgument vector.

◆ reload_openvas()

static void reload_openvas ( void  )
static

◆ scanner_thread()

static void scanner_thread ( struct scan_globals globals)
static

◆ set_globals_from_preferences()

static void set_globals_from_preferences ( void  )
static

◆ start_single_task_scan()

void start_single_task_scan ( void  )

◆ stop_single_task_scan()

static void 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.

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

◆ global_scan_id

char* global_scan_id = NULL
static

◆ 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