From e818fa96b302696ac141d562baab5a538cc58329 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 23 Apr 2020 21:43:33 +0200 Subject: [PATCH 1/2] Stop trying to start a scheduled task if permission was denied This prevents the schedular from failing to start the task every 10 seconds forever, when the user does not have permission to run the task. This can happen, for example, if the task uses someone else's target, and permission to access the target is revoked. --- src/manage.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/manage.c b/src/manage.c index 7d1c4b725..f9ecbba1a 100644 --- a/src/manage.c +++ b/src/manage.c @@ -7105,14 +7105,28 @@ scheduled_task_start (scheduled_task_t *scheduled_task, scheduled_task->task_uuid, NULL)) { - if (gmp_start_task_report_c (&connection, - scheduled_task->task_uuid, - NULL)) + gmp_start_task_opts_t opts; + + opts = gmp_start_task_opts_defaults; + opts.task_id = scheduled_task->task_uuid; + + switch (gmp_start_task_ext_c (&connection, opts)) { - g_warning ("%s: gmp_start_task and gmp_resume_task failed", __func__); - scheduled_task_free (scheduled_task); - gvm_connection_free (&connection); - exit (EXIT_FAILURE); + case 0: + break; + + case 99: + g_warning ("%s: user denied permission to start task", __func__); + scheduled_task_free (scheduled_task); + gvm_connection_free (&connection); + /* Return success, so that parent stops trying to start the task. */ + exit (EXIT_SUCCESS); + + default: + g_warning ("%s: gmp_start_task and gmp_resume_task failed", __func__); + scheduled_task_free (scheduled_task); + gvm_connection_free (&connection); + exit (EXIT_FAILURE); } } From a61cef31158d1e4bd5875abf3ea3a8e486ef43c5 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Thu, 23 Apr 2020 21:50:53 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe1975be..cd98340c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Perform integrity check of VTs after updates [#1024](https://github.com/greenbone/gvmd/pull/1024) [#1035](https://github.com/greenbone/gvmd/pull/1035) - Ensure path of listening UNIX socket exists [#1040](https://github.com/greenbone/gvmd/pull/1040) - Add --rebuild-scap option [#1051](https://github.com/greenbone/gvmd/pull/1051) +- Stop current scheduling of task when permission denied [#1058](https://github.com/greenbone/gvmd/pull/1058) ### Changed - Update SCAP and CERT feed info in sync scripts [#810](https://github.com/greenbone/gvmd/pull/810)