OpenVAS Scanner  21.4.1
Macros | Functions | Variables
utils.c File Reference

A bunch of miscellaneous functions, mostly file conversions. More...

#include "../misc/scanneraux.h"
#include <errno.h>
#include <gvm/base/prefs.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/wait.h>

Macros

#define G_LOG_DOMAIN   "sd main"
 GLib log domain. More...
 

Functions

static void files_add_translation (struct scan_globals *globals, const char *file_hash, char *contents)
 Adds a 'translation' entry for a file sent by the client. More...
 
static void files_add_size_translation (struct scan_globals *globals, const char *file_hash, const long filesize)
 Adds a 'content size' entry for a file sent by the client. More...
 
int store_file (struct scan_globals *globals, const char *file, const char *file_hash)
 Stores a file type preference in a hash table. More...
 
int get_max_hosts_number (void)
 
int get_max_checks_number (void)
 
int process_alive (pid_t pid)
 
int data_left (int soc)
 
void wait_for_children1 (void)
 
int is_scanner_only_pref (const char *pref)
 

Variables

int global_max_hosts
 
int global_max_checks
 

Detailed Description

A bunch of miscellaneous functions, mostly file conversions.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "sd main"

GLib log domain.

Function Documentation

◆ data_left()

int data_left ( int  soc)

◆ files_add_size_translation()

static void files_add_size_translation ( struct scan_globals globals,
const char *  file_hash,
const long  filesize 
)
static

Adds a 'content size' entry for a file sent by the client.

Files sent by the client are stored in memory on the server side. Because they may be binary we need to store the size of the uploaded file as well. This function sets up a mapping from the original name sent by the client to the file size.

Parameters
globalsGlobal struct.
file_hashhash to reference the file.
filesizeSize of the file in bytes.

◆ files_add_translation()

static void files_add_translation ( struct scan_globals globals,
const char *  file_hash,
char *  contents 
)
static

Adds a 'translation' entry for a file sent by the client.

Files sent by the client are stored in memory on the server side. In order to access these files, their original name ('local' to the client) can be 'translated' into the file contents of the in-memory copy of the file on the server side.

Parameters
globalsGlobal struct.
file_hashhash to reference the file.
contentsContents of the file.

◆ 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

◆ get_max_hosts_number()

int get_max_hosts_number ( void  )

Get the max number of hosts to test at the same time.

◆ is_scanner_only_pref()

int is_scanner_only_pref ( const char *  pref)

◆ process_alive()

int process_alive ( pid_t  pid)

Determines if a process is alive - as reliably as we can

◆ 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
globalsGlobal struct.
fileFile content.
file_hashhash to reference the file.
Returns
0 if successful, -1 in case of errors.

◆ wait_for_children1()

void wait_for_children1 ( void  )

Variable Documentation

◆ global_max_checks

int global_max_checks
extern

◆ global_max_hosts

int global_max_hosts
extern

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