Skip to content

Commit 9ad00d9

Browse files
ozgengreenbonebot
authored andcommitted
Fix: include update_to_latest only when provided in modify_agent
1 parent f4017ee commit 9ad00d9

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/gsad_gmp.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19316,7 +19316,7 @@ char *
1931619316
modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1931719317
params_t *params, cmd_response_data_t *response_data)
1931819318
{
19319-
gchar *xml, *response, *format;
19319+
gchar *xml, *response, *format, *update_to_latest_tag;
1932019320
const char *authorized, *attempts, *delay_in_seconds, *bulk_size;
1932119321
const char *max_jitter_in_seconds, *bulk_throttle_time_in_ms,
1932219322
*indexer_dir_depth, *update_to_latest;
@@ -19356,7 +19356,6 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1935619356
if (has_config)
1935719357
{
1935819358
CHECK_VARIABLE_INVALID (authorized, "Save Agent List");
19359-
CHECK_VARIABLE_INVALID (update_to_latest, "Save Agent List");
1936019359
CHECK_VARIABLE_INVALID (attempts, "Save Agent List");
1936119360
CHECK_VARIABLE_INVALID (delay_in_seconds, "Save Agent List");
1936219361
CHECK_VARIABLE_INVALID (bulk_size, "Save Agent List");
@@ -19380,6 +19379,16 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1938019379
response_data);
1938119380
}
1938219381

19382+
if (params_given (params, "update_to_latest"))
19383+
{
19384+
CHECK_VARIABLE_INVALID (update_to_latest, "Save Agent List");
19385+
update_to_latest_tag =
19386+
g_strdup_printf ("<update_to_latest>%d</update_to_latest>",
19387+
update_to_latest ? strcmp (update_to_latest, "0") : 0);
19388+
}
19389+
else
19390+
update_to_latest_tag = g_strdup ("");
19391+
1938319392
agents_element = g_string_new ("<agents>");
1938419393

1938519394
char *name;
@@ -19415,7 +19424,7 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1941519424
"<modify_agent>"
1941619425
"%s" /* agents */
1941719426
"<authorized>%d</authorized>"
19418-
"<update_to_latest>%d</update_to_latest>"
19427+
"%s" /* update_to_latest_tag */
1941919428
"<config>"
1942019429
"<agent_control>"
1942119430
"<retry>"
@@ -19440,7 +19449,7 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1944019449
"<comment>%%s</comment>"
1944119450
"</modify_agent>",
1944219451
agents_element->str, authorized ? strcmp (authorized, "0") : 0,
19443-
update_to_latest ? strcmp (update_to_latest, "0") : 0, items_xml->str);
19452+
update_to_latest_tag, items_xml->str);
1944419453

1944519454
response = NULL;
1944619455
entity = NULL;
@@ -19456,10 +19465,12 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1945619465
format = g_strdup_printf ("<modify_agent>"
1945719466
"%s" /* agents */
1945819467
"<authorized>%d</authorized>"
19468+
"%s" /* update_to_latest*/
1945919469
"<comment>%%s</comment>"
1946019470
"</modify_agent>",
1946119471
agents_element->str,
19462-
authorized ? strcmp (authorized, "0") : 0);
19472+
authorized ? strcmp (authorized, "0") : 0,
19473+
update_to_latest_tag);
1946319474

1946419475
response = NULL;
1946519476
entity = NULL;
@@ -19469,6 +19480,7 @@ modify_agent_gmp (gvm_connection_t *connection, credentials_t *credentials,
1946919480
}
1947019481

1947119482
g_free (format);
19483+
g_free (update_to_latest_tag);
1947219484
g_string_free (items_xml, TRUE);
1947319485
g_string_free (agents_element, TRUE);
1947419486

0 commit comments

Comments
 (0)