Skip to content
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
14 changes: 14 additions & 0 deletions database_admin/migrations/145_update_manager_privileges.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
REVOKE UPDATE ON system_inventory FROM manager;
GRANT UPDATE ON system_inventory (stale) TO manager;

REVOKE UPDATE ON system_patch FROM manager;
GRANT UPDATE ON system_patch (
installable_advisory_count_cache,
installable_advisory_enh_count_cache,
installable_advisory_bug_count_cache,
installable_advisory_sec_count_cache,
applicable_advisory_count_cache,
applicable_advisory_enh_count_cache,
applicable_advisory_bug_count_cache,
applicable_advisory_sec_count_cache,
template_id) TO manager;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GRANT UPDATE ON system_inventory TO manager;
GRANT UPDATE ON system_patch TO manager;
4 changes: 3 additions & 1 deletion database_admin/schema/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS schema_migrations


INSERT INTO schema_migrations
VALUES (144, false);
VALUES (145, false);

-- ---------------------------------------------------------------------------
-- Functions
Expand Down Expand Up @@ -698,6 +698,7 @@ SELECT create_table_partitions('system_inventory', 16,
GRANT SELECT, INSERT, UPDATE ON system_inventory TO listener;
GRANT SELECT, UPDATE, DELETE ON system_inventory TO vmaas_sync; -- vmaas_sync performs system culling
GRANT SELECT, UPDATE (stale) ON system_inventory TO manager; -- manager needs to be able to update opt_out column
GRANT SELECT, UPDATE ON system_inventory TO manager; -- manager needs to be able to update opt_out column
GRANT SELECT, UPDATE ON system_inventory TO evaluator;

SELECT create_table_partition_triggers('system_inventory_set_last_updated',
Expand Down Expand Up @@ -1063,6 +1064,7 @@ GRANT SELECT, UPDATE (installable_advisory_count_cache,
applicable_advisory_bug_count_cache,
applicable_advisory_sec_count_cache,
template_id) ON system_patch TO manager;
GRANT SELECT, UPDATE ON system_patch TO manager;
GRANT SELECT, UPDATE, DELETE ON system_patch to vmaas_sync; -- vmaas_sync performs system culling

-- system_platform
Expand Down
3 changes: 3 additions & 0 deletions manager/controllers/template_systems_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ func assignTemplateSystems(c *gin.Context, db *gorm.DB, accountID int, template
templateID = &template.ID
}

// TODO: once SystemPlatform model is removed, revoke unnecessary manager privileges to system_inventory and
// system_patch tables. They were granted in migration 145 as a temporary fix to solve system_platform view instead
// of update trigger issues. Hint: have a look at 145_update_manager_privileges.down.sql
tx = tx.Model(models.SystemPlatform{}).
Where("rh_account_id = ? AND inventory_id IN (?::uuid)",
accountID, inventoryIDs).
Expand Down
Loading