Greenbone Vulnerability Manager
8.0.1~git
|
GVM management layer: Scanner connection handling. More...
#include "scanner.h"
#include "comm.h"
#include "gmpd.h"
#include "otp.h"
#include "utils.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <gvm/util/serverutils.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
Macros | |
#define | G_LOG_DOMAIN "md main" |
GLib log domain. | |
Functions | |
static int | write_string_to_server (char *const string) |
Write as much as possible from a string to the server. More... | |
static int | write_to_server_buffer () |
Write as much as possible from the internal buffer to the server. More... | |
int | openvas_scanner_read () |
Read as much from the server as the from_scanner buffer will. More... | |
int | openvas_scanner_full () |
Check whether the buffer for data from Scanner is full. More... | |
int | openvas_scanner_realloc () |
Reallocates the from_scanner buffer to a higher size. More... | |
int | openvas_scanner_write (int nvt_cache_mode) |
Write as much as possible from the to_scanner buffer to the scanner. More... | |
static int | openvas_scanner_wait () |
Wait for the scanner socket to be writable. More... | |
static int | load_cas (gnutls_certificate_credentials_t *scanner_credentials) |
Load certificates from the CA directory. More... | |
int | openvas_scanner_close () |
Finish the connection to the Scanner and free internal buffers. More... | |
void | openvas_scanner_fork () |
Reset Scanner variables after a fork. More... | |
static int | openvas_scanner_connect_unix () |
Create a new connection to the scanner and set it as current scanner. More... | |
int | openvas_scanner_connect () |
Create a new connection to the scanner and set it as current scanner. More... | |
void | openvas_scanner_free () |
Free the scanner allocated data. Doesn't close socket and terminate the session. | |
int | openvas_scanner_fd_isset (fd_set *fd) |
Check if connected to Scanner is set in an fd_set. More... | |
void | openvas_scanner_fd_set (fd_set *fd) |
Add connected to Scanner's socket to an fd_set. More... | |
int | openvas_scanner_peek () |
Check if there is any data to receive from connected Scanner socket. More... | |
int | openvas_scanner_get_nfds (int socket) |
Get the nfds value to use for a select() call. More... | |
int | openvas_scanner_session_peek () |
Check if there is any data to receive from connected Scanner session. More... | |
int | openvas_scanner_connected () |
Whether we have started a connection to the Scanner using openvas_scanner_connect(). More... | |
int | openvas_scanner_init (int cache_mode) |
Initializes the already setup connection with the Scanner. More... | |
int | openvas_scanner_set_address (const char *addr, int port) |
Set the scanner's address and port. Will try to resolve addr if it is a hostname. More... | |
int | openvas_scanner_set_unix (const char *path) |
Set the scanner's unix socket path. More... | |
void | openvas_scanner_set_certs (const char *ca_pub, const char *key_pub, const char *key_priv) |
Set the scanner's CA Certificate, and public/private key pair. More... | |
int | openvas_scanner_is_loading () |
Checks whether the connected to OpenVAS Scanner is still loading plugins. To be called right after openvas_scanner_init(). More... | |
Variables | |
static gnutls_session_t | openvas_scanner_session = NULL |
Current OpenVAS Scanner session. | |
static gnutls_certificate_credentials_t | openvas_scanner_credentials = NULL |
Current OpenVAS Scanner credentials. | |
static int | openvas_scanner_socket = -1 |
Current OpenVAS Scanner socket. | |
static struct sockaddr_in | openvas_scanner_address |
Current OpenVAS Scanner address. | |
static char * | openvas_scanner_ca_pub = NULL |
Current OpenVAS Scanner CA Cert. | |
static char * | openvas_scanner_key_pub = NULL |
Current OpenVAS Scanner public key. | |
static char * | openvas_scanner_key_priv = NULL |
Current OpenVAS Scanner private key. | |
static char * | openvas_scanner_unix_path = NULL |
Current OpenVAS Scanner UNIX path. | |
char * | from_scanner = NULL |
Buffer of input from the scanner. More... | |
buffer_size_t | from_scanner_start = 0 |
The start of the data in the from_scanner buffer. | |
buffer_size_t | from_scanner_end = 0 |
The end of the data in the from_scanner buffer. | |
static buffer_size_t | from_scanner_size = 1048576 |
The current size of the from_scanner buffer. | |
static buffer_size_t | from_scanner_max_size = 1073741824 |
The max size of the from_scanner buffer. | |
GVM management layer: Scanner connection handling.
This file provides facilities for working with scanner connections.
|
static |
Load certificates from the CA directory.
[in] | scanner_credentials | Scanner credentials. |
int openvas_scanner_close | ( | ) |
Finish the connection to the Scanner and free internal buffers.
int openvas_scanner_connect | ( | ) |
Create a new connection to the scanner and set it as current scanner.
|
static |
Create a new connection to the scanner and set it as current scanner.
Use a UNIX socket for the connection.
int openvas_scanner_connected | ( | ) |
Whether we have started a connection to the Scanner using openvas_scanner_connect().
int openvas_scanner_fd_isset | ( | fd_set * | fd | ) |
Check if connected to Scanner is set in an fd_set.
[in] | fd | File descriptor set. |
void openvas_scanner_fd_set | ( | fd_set * | fd | ) |
Add connected to Scanner's socket to an fd_set.
[in] | fd | File Descriptor set. |
void openvas_scanner_fork | ( | ) |
Reset Scanner variables after a fork.
This other side of the fork will do the actual cleanup.
int openvas_scanner_full | ( | ) |
Check whether the buffer for data from Scanner is full.
int openvas_scanner_get_nfds | ( | int | socket | ) |
Get the nfds value to use for a select() call.
[in] | socket | Socket to compare to. |
int openvas_scanner_init | ( | int | cache_mode | ) |
Initializes the already setup connection with the Scanner.
[in] | cache_mode | NVT Cache mode if true, which means sending NVT_INFO command to scanner in initial negotiation. |
int openvas_scanner_is_loading | ( | ) |
Checks whether the connected to OpenVAS Scanner is still loading plugins. To be called right after openvas_scanner_init().
int openvas_scanner_peek | ( | ) |
Check if there is any data to receive from connected Scanner socket.
int openvas_scanner_read | ( | ) |
Read as much from the server as the from_scanner buffer will.
hold.
int openvas_scanner_realloc | ( | ) |
Reallocates the from_scanner buffer to a higher size.
int openvas_scanner_session_peek | ( | ) |
Check if there is any data to receive from connected Scanner session.
int openvas_scanner_set_address | ( | const char * | addr, |
int | port | ||
) |
Set the scanner's address and port. Will try to resolve addr if it is a hostname.
[in] | addr | Scanner address string. |
[in] | port | Scanner port. |
void openvas_scanner_set_certs | ( | const char * | ca_pub, |
const char * | key_pub, | ||
const char * | key_priv | ||
) |
Set the scanner's CA Certificate, and public/private key pair.
[in] | ca_pub | CA Certificate. |
[in] | key_pub | Scanner Certificate. |
[in] | key_priv | Scanner private key. |
int openvas_scanner_set_unix | ( | const char * | path | ) |
Set the scanner's unix socket path.
[in] | path | Path to scanner unix socket. |
|
static |
Wait for the scanner socket to be writable.
int openvas_scanner_write | ( | int | nvt_cache_mode | ) |
Write as much as possible from the to_scanner buffer to the scanner.
[in] | nvt_cache_mode | NVT cache mode. |
|
static |
Write as much as possible from a string to the server.
[in] | string | The string. |
|
static |
Write as much as possible from the internal buffer to the server.
char* from_scanner = NULL |
Buffer of input from the scanner.