OpenVAS Scanner  6.0.0~git
Data Structures | Macros | Functions | Variables
openvassd.c File Reference
#include "../misc/plugutils.h"
#include "../misc/vendorversion.h"
#include "attack.h"
#include "comm.h"
#include "ntp.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 <grp.h>
#include <gvm/base/logging.h>
#include <gvm/base/nvti.h>
#include <gvm/base/pidfile.h>
#include <gvm/base/prefs.h>
#include <gvm/base/proctitle.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  openvassd_option
 

Macros

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

Functions

static void start_daemon_mode (void)
 
static void end_daemon_mode (void)
 
static void set_globals_from_preferences (void)
 
static void reload_openvassd (void)
 
static void handle_reload_signal (int sig)
 
static void handle_termination_signal (int sig)
 
static void loading_client_handle (int soc)
 
static void handle_loading_stop_signal (int sig)
 
static void remove_pidfile ()
 
static pid_t loading_handler_start ()
 
void loading_handler_stop (pid_t handler_pid)
 
static void init_signal_handlers ()
 Initializes main scanner process' signal handlers. More...
 
static int load_scan_preferences (const char *scan_id)
 Read the scan preferences from redis scan_id Scan ID used as key to find the corresponding KB where to take the preferences from. More...
 
static void handle_client (struct scan_globals *globals)
 
static void scanner_thread (struct scan_globals *globals)
 
static void log_config_free ()
 Free logging configuration. More...
 
static void check_termination ()
 
static void check_reload ()
 
static void stop_all_scans (void)
 Get the pid and ppid from /proc to find the running scan pids. Send SIGUSR2 kill signal to all running scans to stop them. More...
 
void check_kb_status ()
 Check if Redis Server is up and if the KB exists. If KB does not exist,force a reload and stop all the running scans. More...
 
static void main_loop ()
 
static int init_unix_network (int *sock, const char *owner, const char *group, const char *mode)
 
static int init_openvassd (const char *config_file)
 Initialize everything. More...
 
static void set_daemon_mode ()
 
static int flush_all_kbs ()
 
static void gcrypt_init ()
 
void start_single_task_scan ()
 
int main (int argc, char *argv[])
 openvassd. More...
 

Variables

int global_max_hosts = 15
 
int global_max_checks = 10
 
GSList * log_config = NULL
 Logging parameters, as passed to setup_log_handlers. More...
 
static int global_iana_socket = -1
 
static volatile int loading_stop_signal = 0
 
static volatile int termination_signal = 0
 
static char * global_scan_id = NULL
 
static openvassd_option openvassd_defaults []
 Default values for scanner options. Must be NULL terminated. More...
 
gchar * unix_socket_path = NULL
 

Detailed Description

OpenVAS Scanner 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   "openvassd: Loading Handler"

◆ PROCTITLE_RELOADING

#define PROCTITLE_RELOADING   "openvassd: Reloading"

◆ PROCTITLE_SERVING

#define PROCTITLE_SERVING   "openvassd: Serving %s"

◆ PROCTITLE_WAITING

#define PROCTITLE_WAITING   "openvassd: Waiting for incoming connections"

Function Documentation

◆ check_kb_status()

void check_kb_status ( )

Check if Redis Server is up and if the KB exists. If KB does not exist,force a reload and stop all the running scans.

◆ check_reload()

static void check_reload ( )
static

◆ check_termination()

static void check_termination ( )
static

◆ end_daemon_mode()

static void end_daemon_mode ( void  )
static

◆ flush_all_kbs()

static int flush_all_kbs ( )
static

◆ gcrypt_init()

static void gcrypt_init ( )
static

◆ handle_client()

static void handle_client ( struct scan_globals globals)
static

◆ handle_loading_stop_signal()

static void handle_loading_stop_signal ( int  sig)
static

◆ handle_reload_signal()

static void handle_reload_signal ( int  sig)
static

◆ handle_termination_signal()

static void handle_termination_signal ( int  sig)
static

◆ init_openvassd()

static int init_openvassd ( const char *  config_file)
static

Initialize everything.

Parameters
config_filePath to config file for initialization

◆ init_signal_handlers()

static void init_signal_handlers ( )
static

Initializes main scanner process' signal handlers.

◆ init_unix_network()

static int init_unix_network ( int *  sock,
const char *  owner,
const char *  group,
const char *  mode 
)
static

Initialization of the network in unix socket case: we setup the socket that will listen for incoming connections on unix_socket_path.

Parameters
[out]sockSocket to be initialized.
Returns
0 on success. -1 on failure.

◆ load_scan_preferences()

static int load_scan_preferences ( const char *  scan_id)
static

Read the scan preferences from redis 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.

◆ loading_client_handle()

static void loading_client_handle ( int  soc)
static

◆ loading_handler_start()

static pid_t loading_handler_start ( )
static

◆ loading_handler_stop()

void loading_handler_stop ( pid_t  handler_pid)

◆ log_config_free()

static void log_config_free ( )
static

Free logging configuration.

◆ main()

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

openvassd.

Parameters
argcArgument count.
argvArgument vector.

◆ main_loop()

static void main_loop ( )
static

◆ reload_openvassd()

static void reload_openvassd ( void  )
static

◆ remove_pidfile()

static void remove_pidfile ( )
static

◆ scanner_thread()

static void scanner_thread ( struct scan_globals globals)
static

◆ set_daemon_mode()

static void set_daemon_mode ( )
static

◆ set_globals_from_preferences()

static void set_globals_from_preferences ( void  )
static

◆ start_daemon_mode()

static void start_daemon_mode ( void  )
static

◆ start_single_task_scan()

void start_single_task_scan ( )

◆ stop_all_scans()

static void stop_all_scans ( void  )
static

Get the pid and ppid from /proc to find the running scan pids. Send SIGUSR2 kill signal to all running scans to stop them.

Variable Documentation

◆ global_iana_socket

int global_iana_socket = -1
static

◆ 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_scan_id

char* global_scan_id = NULL
static

◆ loading_stop_signal

volatile int loading_stop_signal = 0
static

◆ log_config

GSList* log_config = NULL

Logging parameters, as passed to setup_log_handlers.

◆ openvassd_defaults

openvassd_option openvassd_defaults[]
static
Initial value:
= {
{"plugins_folder", OPENVAS_NVT_DIR},
{"include_folders", OPENVAS_NVT_DIR},
{"max_hosts", "30"},
{"max_checks", "10"},
{"be_nice", "no"},
{"log_whole_attack", "no"},
{"log_plugins_name_at_load", "no"},
{"optimize_test", "yes"},
{"network_scan", "no"},
{"non_simult_ports", "139, 445, 3389, Services/irc"},
{"plugins_timeout", G_STRINGIFY (NVT_TIMEOUT)},
{"scanner_plugins_timeout", G_STRINGIFY (SCANNER_NVT_TIMEOUT)},
{"safe_checks", "yes"},
{"auto_enable_dependencies", "yes"},
{"drop_privileges", "no"},
{"report_host_details", "yes"},
{"db_address", KB_PATH_DEFAULT},
{NULL, NULL}}

Default values for scanner options. Must be NULL terminated.

◆ termination_signal

volatile int termination_signal = 0
static

◆ unix_socket_path

gchar* unix_socket_path = NULL