Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Replace CPE xml_split with XML iterator #2142

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3449,6 +3449,9 @@ setting_iterator_comment (iterator_t*);
const char*
setting_iterator_value (iterator_t*);

int
setting_value_int (const char *, int *);

int
modify_setting (const gchar *, const gchar *, const gchar *, gchar **);

Expand Down
48 changes: 41 additions & 7 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ static void
set_credential_snmp_secret (credential_t, const char *, const char *,
const char *);

static int
setting_value_int (const char *, int *);

static int
setting_auto_cache_rebuild_int ();

Expand Down Expand Up @@ -16005,6 +16002,19 @@ check_db_settings ()
" 'Delta Reports Version',"
" 'Version of the generation of the Delta Reports.',"
" '2' );");

if (sql_int ("SELECT count(*) FROM settings"
" WHERE uuid = '" SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD "'"
" AND " ACL_IS_GLOBAL () ";")
== 0)
sql ("INSERT into settings (uuid, owner, name, comment, value)"
" VALUES"
" ('" SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD "', NULL,"
" 'SecInfo SQL Buffer Threshold',"
" 'Buffer size threshold in MiB for running buffered SQL statements'"
" || ' in SecInfo updates before the end of the file'"
" || ' being processed.',"
" '100' );");
}

/**
Expand Down Expand Up @@ -51978,7 +51988,7 @@ setting_value (const char *uuid, char **value)
*
* @return 0 success, -1 error.
*/
static int
int
setting_value_int (const char *uuid, int *value)
{
gchar *quoted_uuid;
Expand Down Expand Up @@ -52683,6 +52693,8 @@ setting_name (const gchar *uuid)
return "Feed Import Roles";
if (strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION) == 0)
return "Delta Reports Version";
if (strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD) == 0)
return "SecInfo SQL Buffer Threshold";

return NULL;
}
Expand Down Expand Up @@ -52722,12 +52734,15 @@ setting_description (const gchar *uuid)
return "Roles given access to new resources from feed.";
if (strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION) == 0)
return "Version of the generation of the Delta Reports.";
if (strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD) == 0)
return "Buffer size threshold in MiB for running buffered SQL statements"
" in SecInfo updates before the end of the file being processed.";

return NULL;
}

/**
* @brief Get the name of a setting.
* @brief Verify the value of a setting.
*
* @param[in] uuid UUID of setting.
* @param[in] value Value of setting, to verify.
Expand Down Expand Up @@ -52815,6 +52830,14 @@ setting_verify (const gchar *uuid, const gchar *value, const gchar *user)
return 1;
}

if (strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD))
{
int threshold;
threshold = atoi (value);
if (threshold < 0 || threshold > (INT_MAX / 1048576))
return 1;
}

return 0;
}

Expand Down Expand Up @@ -52870,6 +52893,15 @@ setting_normalise (const gchar *uuid, const gchar *value)
return g_string_free (normalised, FALSE);
}

if (strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD) == 0)
{
int threshold;
threshold = atoi (value);
if (threshold < 0)
return NULL;
return g_strdup_printf ("%i", threshold);
}

return g_strdup (value);
}

Expand Down Expand Up @@ -52900,7 +52932,8 @@ manage_modify_setting (GSList *log_config, const db_conn_info_t *database,
&& strcmp (uuid, SETTING_UUID_LSC_DEB_MAINTAINER)
&& strcmp (uuid, SETTING_UUID_FEED_IMPORT_OWNER)
&& strcmp (uuid, SETTING_UUID_FEED_IMPORT_ROLES)
&& strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION))
&& strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION)
&& strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD))
{
fprintf (stderr, "Error in setting UUID.\n");
return 3;
Expand All @@ -52927,7 +52960,8 @@ manage_modify_setting (GSList *log_config, const db_conn_info_t *database,
if ((strcmp (uuid, SETTING_UUID_DEFAULT_CA_CERT) == 0)
|| (strcmp (uuid, SETTING_UUID_FEED_IMPORT_OWNER) == 0)
|| (strcmp (uuid, SETTING_UUID_FEED_IMPORT_ROLES) == 0)
|| (strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION) == 0))
|| (strcmp (uuid, SETTING_UUID_DELTA_REPORTS_VERSION) == 0)
|| (strcmp (uuid, SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD) == 0))
{
sql_rollback ();
fprintf (stderr,
Expand Down
4 changes: 4 additions & 0 deletions src/manage_sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
*/
#define SETTING_UUID_DELTA_REPORTS_VERSION "985a0c05-2140-4e66-9989-ce9a0906a5a9"

/**
* @brief UUID of 'SecInfo SQL Buffer Threshold' setting.
*/
#define SETTING_UUID_SECINFO_SQL_BUFFER_THRESHOLD "316275a9-3629-49ad-9cea-5b3ab155b93f"

/**
* @brief Trust constant for error.
Expand Down
Loading
Loading