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

Remove OVAL case from --rebuild-scap #1127

Merged
merged 2 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 6 additions & 7 deletions src/gvmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,7 @@ gvmd (int argc, char** argv)
static gchar *rc_name = NULL;
static gchar *relay_mapper = NULL;
static gboolean rebuild = FALSE;
static gchar *rebuild_scap = NULL;
static gboolean rebuild_scap = FALSE;
static gchar *role = NULL;
static gchar *disable = NULL;
static gchar *value = NULL;
Expand Down Expand Up @@ -1807,15 +1807,14 @@ gvmd (int argc, char** argv)
&manager_port_string_2,
"Use port number <number> for address 2.",
"<number>" },
{ "rebuild", 'm', 0, G_OPTION_ARG_NONE,
{ "rebuild", '\0', 0, G_OPTION_ARG_NONE,
&rebuild,
"Remove NVT db, and rebuild it from the scanner.",
NULL },
{ "rebuild-scap", '\0', 0, G_OPTION_ARG_STRING,
{ "rebuild-scap", '\0', 0, G_OPTION_ARG_NONE,
&rebuild_scap,
"Rebuild SCAP data of type <type>"
" (currently supports 'ovaldefs' and 'all').",
"<type>" },
"Rebuild all SCAP data.",
NULL },
{ "relay-mapper", '\0', 0, G_OPTION_ARG_FILENAME,
&relay_mapper,
"Executable for mapping scanner hosts to relays."
Expand Down Expand Up @@ -2277,7 +2276,7 @@ gvmd (int argc, char** argv)
if (option_lock (&lockfile_checking))
return EXIT_FAILURE;

ret = manage_rebuild_scap (log_config, database, rebuild_scap);
ret = manage_rebuild_scap (log_config, database);
log_config_free ();
if (ret)
{
Expand Down
38 changes: 11 additions & 27 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -4882,14 +4882,12 @@ manage_sync_scap (sigset_t *sigmask_current)
}

/**
* @brief Rebuild part of the SCAP DB.
*
* @param[in] type The type of SCAP info to rebuild.
* @brief Rebuild the entire SCAP DB.
*
* @return 0 success, 1 invalid type, 2 sync running, -1 error
* @return 0 success, 2 sync running, -1 error
*/
static int
rebuild_scap (const char *type)
rebuild_scap ()
{
int ret = -1;
lockfile_t lockfile;
Expand All @@ -4900,16 +4898,9 @@ rebuild_scap (const char *type)
else if (ret)
return -1;

if (strcasecmp (type, "all") == 0
|| strcasecmp (type, "ovaldefs") == 0
|| strcasecmp (type, "ovaldef") == 0)
{
ret = update_scap (TRUE);
if (ret == 1)
ret = 2;
}
else
ret = 1;
ret = update_scap (TRUE);
if (ret == 1)
ret = 2;

if (feed_lockfile_unlock (&lockfile))
{
Expand All @@ -4926,29 +4917,22 @@ rebuild_scap (const char *type)
*
* @param[in] log_config Log configuration.
* @param[in] database Location of manage database.
* @param[in] type The type of SCAP info to rebuild.

*
* @return 0 success, -1 error.
*/
int
manage_rebuild_scap (GSList *log_config, const gchar *database,
const char *type)
manage_rebuild_scap (GSList *log_config, const gchar *database)
{
int ret;

g_info (" Rebuilding SCAP data (%s).", type);
g_info (" Rebuilding SCAP data");

ret = manage_option_setup (log_config, database);
if (ret)
return -1;

ret = rebuild_scap (type);
if (ret == 1)
{
printf ("Type must be 'ovaldefs' or 'all'.\n");
goto fail;
}
else if (ret == 2)
ret = rebuild_scap ();
if (ret == 2)
{
printf ("SCAP sync is currently running.\n");
goto fail;
Expand Down
2 changes: 1 addition & 1 deletion src/manage_sql_secinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void
manage_sync_scap (sigset_t *);

int
manage_rebuild_scap (GSList *, const gchar *, const char *);
manage_rebuild_scap (GSList *, const gchar *);

void
manage_sync_cert (sigset_t *);
Expand Down