Skip to content

Commit

Permalink
Fix: Set preference components when modifying config
Browse files Browse the repository at this point in the history
When modifying a config, the database fields containing the
VT id, preference id, type and name are now set for all types.

This fixes the preferences not working correctly after modifying them.
  • Loading branch information
timopollmeier authored and a-h-abdelsalam committed Mar 11, 2024
1 parent 3e37dd7 commit 57a6d05
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/manage_sql_configs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3627,6 +3627,13 @@ modify_config_preference (config_t config, const char* nvt,
g_free (quoted_name);
quoted_name = sql_quote (splits[3]);
}
else
{
quoted_pref_nvt = sql_quote (splits[0]);
pref_id = atoi (splits[1]);
quoted_pref_type = sql_quote (splits[2]);
quoted_pref_name = sql_quote (splits[3]);
}
}
g_strfreev (splits);

Expand All @@ -3639,12 +3646,25 @@ modify_config_preference (config_t config, const char* nvt,
config,
nvt ? "= 'PLUGINS_PREFS'" : "= 'SERVER_PREFS'",
quoted_name);
sql ("INSERT INTO config_preferences"
" (config, type, name, value, pref_nvt, pref_id, pref_type, pref_name)"
" VALUES (%llu, %s, '%s', '%s', '%s', %i, '%s', '%s');",
config, nvt ? "'PLUGINS_PREFS'" : "'SERVER_PREFS'", quoted_name,
quoted_value, quoted_pref_nvt, pref_id, quoted_pref_type,
quoted_pref_name);
if (nvt)
{
sql ("INSERT INTO config_preferences"
" (config, type, name, value,"
" pref_nvt, pref_id, pref_type, pref_name)"
" VALUES (%llu, 'PLUGINS_PREFS', '%s', '%s',"
" '%s', %i, '%s', '%s');",
config, quoted_name, quoted_value,
quoted_pref_nvt, pref_id, quoted_pref_type, quoted_pref_name);
}
else
{
sql ("INSERT INTO config_preferences"
" (config, type, name, value,"
" pref_nvt, pref_id, pref_type, pref_name)"
" VALUES (%llu, 'SERVER_PREFS', '%s', '%s',"
" NULL, NULL, NULL, NULL);",
config, quoted_name, quoted_value);
}

g_free (quoted_value);
g_free (quoted_name);
Expand Down

0 comments on commit 57a6d05

Please sign in to comment.