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

Backport "alterable" fix for cloned tasks to 20.08 #1574

Merged
merged 3 commits into from
Jun 22, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Free alert get data in report_content_for_alert [#1526](https://github.com/greenbone/gvmd/pull/1526)
- Fix erroneous freeing of ical timezone component [#1530](https://github.com/greenbone/gvmd/pull/1530)
- Fixed the sorting / filter by username functionality for remediation tickets [#1546](https://github.com/greenbone/gvmd/pull/1546)
- The alterable indicator is now copied when cloning a task [#1553](https://github.com/greenbone/gvmd/pull/1553)
- Fix stop resume feature. [#1568](https://github.com/greenbone/gvmd/pull/1568)

### Removed
Expand Down
13 changes: 9 additions & 4 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21962,17 +21962,22 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
int ret;
gchar *name, *comment;
task_t new_task;
int alterable;

name = task_name (create_task_data->task);
comment = task_comment (create_task_data->task);

if(create_task_data->alterable)
alterable = strcmp (create_task_data->alterable, "0") ? 1 : 0;
else
alterable = -1;

ret = copy_task (name,
comment,
create_task_data->copy,
(create_task_data->alterable
&& strcmp (create_task_data->alterable, "0"))
? 1
: 0,
alterable,
&new_task);

g_free (name);
g_free (comment);
/* Remove the task that was created while parsing elements. */
Expand Down
15 changes: 10 additions & 5 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -29709,7 +29709,8 @@ set_task_comment (task_t task, const char *comment)
* @param[in] name Name of new task. NULL to copy from existing.
* @param[in] comment Comment on new task. NULL to copy from existing.
* @param[in] task_id UUID of existing task.
* @param[in] alterable Whether the new task will be alterable.
* @param[in] alterable Whether the new task will be alterable. < 0 to
* to copy from existing.
* @param[out] new_task New task.
*
* @return 0 success, 2 failed to find existing task, 99 permission denied,
Expand All @@ -29735,17 +29736,21 @@ copy_task (const char* name, const char* comment, const char *task_id,
" scanner, schedule_next_time,"
" config_location, target_location,"
" schedule_location, scanner_location,"
" hosts_ordering, usage_type",
" hosts_ordering, usage_type, alterable",
1, &new, &old);
if (ret)
{
sql_rollback ();
return ret;
}

sql ("UPDATE tasks SET alterable = %i, hidden = 0 WHERE id = %llu;",
alterable,
new);
if (alterable >= 0)
sql ("UPDATE tasks SET alterable = %i, hidden = 0 WHERE id = %llu;",
alterable,
new);
else
sql ("UPDATE tasks SET hidden = 0 WHERE id = %llu;",
new);

set_task_run_status (new, TASK_STATUS_NEW);
sql ("INSERT INTO task_preferences (task, name, value)"
Expand Down