From ff71f8fc9a973b15bfa81523e83724859e0d4578 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 29 Jun 2020 16:43:50 +0200 Subject: [PATCH 1/3] Remove user from tags when deleting user --- src/manage_sql.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/manage_sql.c b/src/manage_sql.c index 29ee57907..08c35b528 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -52111,10 +52111,16 @@ delete_user (const char *user_id_arg, const char *name_arg, int ultimate, sql ("DELETE FROM overrides_trash WHERE owner = %llu;", user); /* Tags. */ + sql ("DELETE FROM tag_resources" + " WHERE resource_type = 'user' AND resource = %llu;", + user); sql ("DELETE FROM tag_resources" " WHERE tag IN (SELECT id FROM tags WHERE owner = %llu);", user); sql ("DELETE FROM tags WHERE owner = %llu;", user); + sql ("DELETE FROM tag_resources_trash" + " WHERE resource_type = 'user' AND resource = %llu;", + user); sql ("DELETE FROM tag_resources_trash" " WHERE tag IN (SELECT id FROM tags_trash WHERE owner = %llu);", user); From ab3382f40ee9594710f0fe3b590fb945eaf79211 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 29 Jun 2020 17:01:50 +0200 Subject: [PATCH 2/3] Remove user from tags when inheriting user --- src/manage_sql.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/manage_sql.c b/src/manage_sql.c index 08c35b528..8149ce16e 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -52053,8 +52053,14 @@ delete_user (const char *user_id_arg, const char *name_arg, int ultimate, inheritor, user); sql ("UPDATE settings SET owner = %llu WHERE owner = %llu;", inheritor, user); + sql ("DELETE FROM tag_resources" + " WHERE resource_type = 'user' AND resource = %llu;", + user); sql ("UPDATE tags SET owner = %llu WHERE owner = %llu;", inheritor, user); + sql ("DELETE FROM tag_resources_trash" + " WHERE resource_type = 'user' AND resource = %llu;", + user); sql ("UPDATE tags_trash SET owner = %llu WHERE owner = %llu;", inheritor, user); sql ("UPDATE targets SET owner = %llu WHERE owner = %llu;", From 3ce2d7e467f9d2246d42bcc520d46b8730962529 Mon Sep 17 00:00:00 2001 From: Matt Mundell Date: Mon, 29 Jun 2020 17:03:44 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36543fdef..2434845d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,6 +123,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix and simplify parse_iso_time and add tests [#1129](https://github.com/greenbone/gvmd/pull/1129) - Fix gvm-manage-certs. [#1140](https://github.com/greenbone/gvmd/pull/1140) - Fix CVE scanner and results handling [#1141](https://github.com/greenbone/gvmd/pull/1141) +- Remove user from tags when deleting user [#1161](https://github.com/greenbone/gvmd/pull/1161) ### Removed - Remove support for "All SecInfo": removal of "allinfo" for type in get_info [#790](https://github.com/greenbone/gvmd/pull/790)