-
Notifications
You must be signed in to change notification settings - Fork 187
Grant minimum required permissions for non-superuser usage #475
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
base: master
Are you sure you want to change the base?
Conversation
|
Thank you @ardentperf, Would it make sense to grant permissions only to Moreover we could allow in |
|
There is a relevant PR #451 |
|
this patch #451 offers a more secure and maintainable solution by leveraging PostgreSQL's native trusted extension mechanism (available in PostgreSQL 13+). the approach uses the Also, we don't need to modify any test cases as the patch is backward compatible. let me know if this looks good, appreciate any reviews on the PR and waiting for inclusion of the patch in future releases. Thanks. |
|
@za-arthur pg_repack is effectively a substitute for
Version 1.5.2 of pg_repack allowed non-superusers to repack their own tables (but not other people's tables) by updating privilege checks in several backend functions. Importantly, table ownership permissions still prevent users from accessing intermediate repack data and log tables of other users. This proposed PR does not grant access to The third regression test verifies that the |
|
@harinath001 #451 won't work since it grants privileges to a user who installed the extension, which is a superuser currently, because pg_repack isn't marked as trusted extension. @ardentperf 's idea is to allow owners of tables to execute pg_repack and #451 doesn't help with that.
@ardentperf still they are implemented differently and might require different permission model. The least difference from the user point of view is the additional
There are might be environments and users who might need to have more tight and strict permissions. And if we merge this PR they might need to execute additional REVOKE/GRANT script to narrow down access to I think another approach to address the issue might be to allow to create temporary objects on a same schema where is the original table. This at least doesn't require granting CREATE permissions on the |
@za-arthur the intention of the patch is to make the change backward compatible (and not to modify the default value of BTW, I also tested the patch by modifying the As Postgres is giving more freedom for admins to modify the |
|
@za-arthur thanks, you're right - I missed the fact that |
|
Thinking about this some more - it seems to me that it's ok to grant USAGE, EXECUTE ON ALL FUNCTIONS, and SELECT ON ALL TABLES to public for the repack schema. The only question I see is around The background of revoking However, I do see another consideration - since the default behavior now is that newly created users can't create tables anywhere by default, if pg_repack has a different default behavior then users might just start putting all kind of stuff in the repack schema as a workaround to admins not granting them the right privs after creating the new roles. I think it would be a good idea for pg_repack to match the default behavior of postgres for newly create roles, and not grant default privs to create tables. This does mean that users will need to manually grant the I see the For this reason I'd actually propose that the best solution here is keeping intermediate objects in the repack schema, granting the CREATE privilege to the something else to consider is whether we still need a i'm going to go ahead and make an initial update to this PR to switch the on a side note - i found that pg_repack is compatible with https://github.com/nektos/act to locally run the full test matrix from https://github.com/reorg/pg_repack/actions which can test all major versions of PG back to 9.5 in parallel. I found it useful and a bit quicker than running the tests locally or in my personal github for this many different major versions. or (need the bridge network to avoid listening port conflicts) |
|
granting privs to |
This covers all grants except for CREATE on the repack schema to allow table owners to use pg_repack with --no-superuser-check. Importantly, table ownership permissions still prevent users from accessing intermediate repack data and log tables of other users, or attempting to repack tables they do not own - similar to VACUUM FULL. CREATE on the repack schema is not included to match the default behavior of postgres v15+ of not allowing new roles to create tables without an explicit grant. We also add a successful non-superuser test case by replacing the repack schema permission grants with a test that creates a user-owned table and verifies pg_repack works for non-superuser with --no-superuser-check flag.
18133f7 to
d948fc9
Compare
|
i don't see any path to allowing users with
After ruling out |
|
@ardentperf thanks for checking
Indeed, that is the reason
Good point! That is definitely is a good reason to stick with the default Postgres behavior.
Yeah, I think I could try this option. We would need to add an additional option, like This could add a little bit of understanding for a user what are these tables for. And we would need to acquire ACCESS SHARE lock on these tables to restrict accidental dropping by a user. |
I originally left it for backwards compatibility since if we remove it |
Alternatively, could make it a no-op argument that doesn't do anything but leave it around so that we don't break scripts. Either option could work here |
Version 1.5.2 of pg_repack allowed non-superusers to repack their own tables by updating privilege checks in several backend functions (PR #431). This capability is important for environments where platform teams manage postgres installation and upgrades, but non-superusers directly manage their own schemas and tables including repacks. However version 1.5.2 did not grant the actual privileges to run pg_repack to non-superusers. This change adds the missing grants and allows table owners to use pg_repack with
--no-superuser-check. This also adds a successful non-superuser test case, which was missing before.Importantly, table ownership permissions still prevent users from accessing intermediate repack data and log tables of other users. (cf https://github.com/ardentperf/pg_repack_isolation/blob/main/test_multiuser_isolation.log )