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

Remove user from tags when deleting user #1161

Merged
merged 6 commits into from
Jun 30, 2020
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 @@ -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
Expand Down
12 changes: 12 additions & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;",
Expand Down Expand Up @@ -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);
Expand Down