diff --git a/CHANGELOG.md b/CHANGELOG.md index 8864aed5c..9a090419c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -125,6 +125,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) - Handle INTERRUPTED scans [#1146](https://github.com/greenbone/gvmd/pull/1146) ### Removed diff --git a/src/manage_sql.c b/src/manage_sql.c index d332b6bda..6064e8443 100644 --- a/src/manage_sql.c +++ b/src/manage_sql.c @@ -52078,8 +52078,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;", @@ -52136,10 +52142,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);