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

Send dedicated error message to the create ticket dialogue if create permission permission is missing. (backport #1686) #1688

Merged
merged 3 commits into from
Sep 16, 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed
### Fixed
- Fix resume task. [#1679](https://github.com/greenbone/gvmd/pull/1679)

-Added a dedicated error message for the create ticket dialogue when the create permission permission is missing [#1686](https://github.com/greenbone/gvmd/pull/1686)

[Unreleased]: https://github.com/greenbone/gvmd/compare/v21.4.3...HEAD

Expand Down
6 changes: 6 additions & 0 deletions src/gmp_tickets.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ create_ticket_run (gmp_parser_t *gmp_parser, GError **error)
return;
}
break;
case 98:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_ticket",
"Permission to create permission denied"));
log_event_fail ("ticket", "Ticket", NULL, "created");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_ticket",
Expand Down
40 changes: 21 additions & 19 deletions src/manage_sql_tickets.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,8 @@ restore_ticket (const char *ticket_id)
* @param[out] ticket Created ticket.
*
* @return 0 success, 1 failed to find user, 2 failed to find result,
* 99 permission denied, -1 error.
* 99 permission to create ticket denied, 98 permission to
* create permission denied, -1 error.
*/
int
create_ticket (const char *comment, const char *result_id,
Expand All @@ -920,6 +921,7 @@ create_ticket (const char *comment, const char *result_id,
gchar *quoted_location, *quoted_solution, *quoted_uuid, *quoted_open_note;
char *new_ticket_id, *task_id;
task_t task;
int ret;

assert (current_credentials.uuid);
assert (result_id);
Expand Down Expand Up @@ -1041,32 +1043,32 @@ create_ticket (const char *comment, const char *result_id,

/* Give assigned user permission to access ticket and ticket's task. */

if (create_permission_internal (1,
"modify_ticket",
"Automatically created for ticket",
NULL,
new_ticket_id,
"user",
user_id,
&permission))
if ((ret = create_permission_internal (1,
"modify_ticket",
"Automatically created for ticket",
NULL,
new_ticket_id,
"user",
user_id,
&permission)))
{
sql_rollback ();
return -1;
return (ret == 99 ? 98 : -1);
}

task_uuid (task, &task_id);
if (create_permission_internal (1,
"get_tasks",
"Automatically created for ticket",
NULL,
task_id,
"user",
user_id,
&permission))
if ((ret = create_permission_internal (1,
"get_tasks",
"Automatically created for ticket",
NULL,
task_id,
"user",
user_id,
&permission)))
{
free (task_id);
sql_rollback ();
return -1;
return (ret == 99 ? 98 : -1);
}
free (task_id);

Expand Down