#include "manage.h"
#include "manage_sql.h"
#include "sql.h"
#include <assert.h>
Go to the source code of this file.
◆ G_LOG_DOMAIN
#define G_LOG_DOMAIN "md main" |
◆ NAME
#define NAME "Global variable settings[checkbox]:Strictly unauthenticated" |
◆ check_config_host_discovery()
int check_config_host_discovery |
( |
const char * |
uuid | ) |
|
Ensure the Host Discovery config is up to date.
- Parameters
-
- Returns
- 0 success, -1 error.
Definition at line 118 of file manage_config_host_discovery.c.
References NAME, NVT_SELECTOR_TYPE_NVT, sql(), sql_int(), and update_config_cache_init().
126 if (
sql_int (
"SELECT count (*) FROM config_preferences" 127 " WHERE config = (SELECT id FROM configs WHERE uuid = '%s')" 128 " AND type = 'PLUGINS_PREFS'" 129 " AND name = '" NAME "';",
133 sql (
"INSERT INTO config_preferences (config, type, name, value)" 134 " VALUES ((SELECT id FROM configs WHERE uuid = '%s')," 144 if (
sql_int (
"SELECT count (*) FROM nvt_selectors" 145 " WHERE name = (SELECT nvt_selector FROM configs" 146 " WHERE uuid = '%s')" 147 " AND family_or_nvt = '1.3.6.1.4.1.25623.1.0.12288';",
151 sql (
"INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)" 152 " VALUES ((SELECT nvt_selector FROM configs WHERE uuid = '%s'), 0," 154 " '1.3.6.1.4.1.25623.1.0.12288', 'Settings');",
int sql_int(char *sql,...)
Get a particular cell from a SQL query, as an int.
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
#define NAME
Preference name.
void update_config_cache_init(const char *uuid)
Update count and growing info in config, without checking user.
◆ make_config_host_discovery()
void make_config_host_discovery |
( |
char *const |
uuid, |
|
|
char *const |
selector_name |
|
) |
| |
Make Host Discovery Scan Config.
Caller must lock the db.
- Parameters
-
[in] | uuid | UUID for new scan config. |
[in] | selector_name | Name of NVT selector to use. |
Definition at line 47 of file manage_config_host_discovery.c.
References nvt_selector_family_count(), nvt_selector_nvt_count(), NVT_SELECTOR_TYPE_NVT, sql(), and sql_last_insert_id().
53 sql (
"INSERT into configs (uuid, name, owner, nvt_selector, comment," 54 " family_count, nvt_count, nvts_growing, families_growing," 55 " type, creation_time, modification_time)" 56 " VALUES ('%s', 'Host Discovery', NULL," 57 " '%s', 'Network Host Discovery scan configuration.'," 58 " 0, 0, 0, 0, 0, m_now (), m_now ());",
66 sql (
"INSERT INTO nvt_selectors (name, exclude, type, family_or_nvt, family)" 68 " '1.3.6.1.4.1.25623.1.0.100315', 'Port scanners');",
74 " SET family_count = %i, nvt_count = %i," 75 " modification_time = m_now ()" 83 sql (
"INSERT INTO config_preferences (config, type, name, value)" 86 " 'Ping Host[checkbox]:Mark unrechable Hosts as dead (not scanning)'," 90 sql (
"INSERT INTO config_preferences (config, type, name, value)" 93 " 'Ping Host[checkbox]:Report about reachable Hosts'," 97 sql (
"INSERT INTO config_preferences (config, type, name, value)" 100 " 'Ping Host[checkbox]:Report about unrechable Hosts',"
resource_t sql_last_insert_id()
Get the ID of the last inserted row.
void sql(char *sql,...)
Perform an SQL statement, retrying if database is busy or locked.
#define NVT_SELECTOR_TYPE_NVT
NVT selector type for "NVT" rule.
int nvt_selector_nvt_count(const char *, const char *, int)
Get the number of NVTs selected by an NVT selector.
int nvt_selector_family_count(const char *, int)
Get the number of families selected by an NVT selector.