Greenbone Vulnerability Manager  22.4.0~dev1
Macros | Functions
manage_configs.c File Reference

GVM manage layer: Configs. More...

#include "gmp_configs.h"
#include "manage_configs.h"
#include "manage_sql.h"
#include "manage_sql_configs.h"
#include "utils.h"
#include <errno.h>
#include <glib.h>
#include <gvm/util/fileutils.h>
#include <stdlib.h>
#include <string.h>

Macros

#define G_LOG_DOMAIN   "md manage"
 GLib log domain.
 

Functions

int config_predefined_uuid (const gchar *config_id)
 Return whether a config is predefined. More...
 
static const gchar * feed_dir_configs ()
 Get path to configs in feed. More...
 
static void create_feed_config_permissions (const gchar *config_id)
 Grant 'Feed Import Roles' access to a config. More...
 
static int update_config_from_file (config_t config, const gchar *path)
 Create a config from an XML file. More...
 
static int create_config_from_file (const gchar *path)
 Create a config from an XML file. More...
 
static int should_sync_config_from_path (const char *path, gboolean rebuild, config_t *config)
 Gets if a config must be synced a file path in the feed. More...
 
static void sync_config_with_feed (const gchar *path, gboolean rebuild)
 Sync a single config with the feed. More...
 
static int try_open_configs_feed_dir (GDir **dir, gboolean set_current_user)
 Open the configs feed directory if it is available and the feed owner is set. Optionally set the current user to the feed owner on success. More...
 
int sync_configs_with_feed (gboolean rebuild)
 Sync all configs with the feed. More...
 
gboolean configs_feed_dir_exists ()
 Tests if the configs feed directory exists. More...
 
void manage_sync_configs ()
 Sync configs with the feed.
 
int manage_rebuild_configs ()
 Rebuild configs from the feed. More...
 
gboolean should_sync_configs ()
 Checks if the configs should be synced with the feed. More...
 

Detailed Description

GVM manage layer: Configs.

General functions for managing scan configs.

Function Documentation

◆ config_predefined_uuid()

int config_predefined_uuid ( const gchar *  config_id)

Return whether a config is predefined.

Parameters
[in]config_idUUID of config.
Returns
1 if predefined, else 0.

◆ configs_feed_dir_exists()

gboolean configs_feed_dir_exists ( )

Tests if the configs feed directory exists.

Returns
TRUE if the directory exists.

◆ create_config_from_file()

static int create_config_from_file ( const gchar *  path)
static

Create a config from an XML file.

Parameters
[in]pathPath to config XML.
Returns
0 success, -1 error.

◆ create_feed_config_permissions()

static void create_feed_config_permissions ( const gchar *  config_id)
static

Grant 'Feed Import Roles' access to a config.

Parameters
[in]config_idUUID of config.

◆ feed_dir_configs()

static const gchar* feed_dir_configs ( )
static

Get path to configs in feed.

Returns
Path to configs in feed.

◆ manage_rebuild_configs()

int manage_rebuild_configs ( )

Rebuild configs from the feed.

Returns
0 success, 1 no feed directory, 2 no feed owner, 3 NVTs missing, -1 error.

◆ should_sync_config_from_path()

static int should_sync_config_from_path ( const char *  path,
gboolean  rebuild,
config_t *  config 
)
static

Gets if a config must be synced a file path in the feed.

Parameters
[in]pathPath to config XML in feed.
[in]rebuildWhether ignore timestamps to force a rebuild.
[out]configConfig row id if it already exists, 0 if config is new.
Returns
1 if config should be synced, 0 otherwise

◆ should_sync_configs()

gboolean should_sync_configs ( )

Checks if the configs should be synced with the feed.

Returns
1 if configs should be synced, 0 otherwise

◆ sync_config_with_feed()

static void sync_config_with_feed ( const gchar *  path,
gboolean  rebuild 
)
static

Sync a single config with the feed.

Parameters
[in]pathPath to config XML in feed.
[in]rebuildWhether ignore timestamps to force a rebuild.

◆ sync_configs_with_feed()

int sync_configs_with_feed ( gboolean  rebuild)

Sync all configs with the feed.

Create configs that exists in the feed but not in the db. Update configs in the db that have changed on the feed. Do nothing to configs in db that have been removed from the feed.

Parameters
[in]rebuildWhether ignore timestamps to force a rebuild.
Returns
0 success, 1 no feed directory, 2 no feed owner, 3 NVTs missing, -1 error.

◆ try_open_configs_feed_dir()

static int try_open_configs_feed_dir ( GDir **  dir,
gboolean  set_current_user 
)
static

Open the configs feed directory if it is available and the feed owner is set. Optionally set the current user to the feed owner on success.

The sync will be skipped if the feed directory does not exist or the feed owner is not set. For configs the NVTs also have to exist.

Parameters
[out]dirThe directory as GDir if available and feed owner is set, NULL otherwise.
[in]set_current_userWhether to set current user to feed owner.
Returns
0 success, 1 no feed directory, 2 no feed owner, 3 NVTs missing, -1 error.

◆ update_config_from_file()

static int update_config_from_file ( config_t  config,
const gchar *  path 
)
static

Create a config from an XML file.

Parameters
[in]configExisting config.
[in]pathFull path to config XML.
Returns
0 success, -1 error.