-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53312: server,pgwire: make more log message bits non-redactable r=spaskob,irfansharif a=knz Commit prefix from #53764 see individual commits for details Release justification: low risk, high benefit changes to existing functionality 53650: sql: allow non-admins to perform some RESTOREs r=solongordon a=solongordon Release justification: Low risk, high reward change to existing functionality Release note (sql change): Non-admin users are now permitted to execute RESTORE statements as long as the restore does not depend on implicit credentials and the user has the appropriate privileges to create all of the resulting database objects. For database restores, this means the user must have the CREATEDB role privilege. For table restores, the user must have CREATE privileges on the parent database. Full cluster restores still require admin privileges. Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Solon Gordon <[email protected]>
- Loading branch information
Showing
28 changed files
with
418 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Test permissions checks for non-admin users running RESTORE. | ||
new-server name=s1 | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE d; | ||
CREATE TABLE d.t (x INT); | ||
INSERT INTO d.t VALUES (1), (2), (3); | ||
---- | ||
|
||
exec-sql | ||
BACKUP TO 'nodelocal://0/test/' | ||
---- | ||
|
||
# Start a new cluster with the same IO dir. | ||
new-server name=s2 share-io-dir=s1 allow-implicit-access | ||
---- | ||
|
||
exec-sql server=s2 | ||
CREATE USER testuser | ||
---- | ||
|
||
# Restore into the new cluster. | ||
exec-sql server=s2 user=testuser | ||
RESTORE FROM 'nodelocal://0/test/' | ||
---- | ||
pq: only users with the admin role are allowed to restore full cluster backups | ||
|
||
exec-sql server=s2 user=testuser | ||
RESTORE DATABASE d FROM 'nodelocal://0/test/' | ||
---- | ||
pq: only users with the CREATEDB privilege can restore databases | ||
|
||
exec-sql server=s2 | ||
CREATE DATABASE d | ||
---- | ||
|
||
exec-sql server=s2 user=testuser | ||
RESTORE TABLE d.t FROM 'nodelocal://0/test/' | ||
---- | ||
pq: user testuser does not have CREATE privilege on database d | ||
|
||
exec-sql server=s2 | ||
GRANT CREATE ON DATABASE d TO testuser | ||
---- | ||
|
||
exec-sql server=s2 user=testuser | ||
RESTORE TABLE d.t FROM 'nodelocal://0/test/' | ||
---- | ||
|
||
query-sql server=s2 | ||
SELECT x FROM d.t ORDER BY x | ||
---- | ||
1 | ||
2 | ||
3 | ||
|
||
exec-sql server=s2 | ||
DROP DATABASE d | ||
---- | ||
|
||
exec-sql server=s2 | ||
ALTER USER testuser CREATEDB | ||
---- | ||
|
||
exec-sql server=s2 user=testuser | ||
RESTORE DATABASE d FROM 'nodelocal://0/test/' | ||
---- | ||
|
||
query-sql server=s2 | ||
SELECT x FROM d.t ORDER BY x | ||
---- | ||
1 | ||
2 | ||
3 | ||
|
||
# Test that implicit access is disallowed when the testing knob isn't set. | ||
new-server name=s3 share-io-dir=s1 | ||
---- | ||
|
||
exec-sql server=s3 | ||
CREATE USER testuser | ||
---- | ||
|
||
exec-sql server=s3 user=testuser | ||
RESTORE TABLE d.t FROM 'nodelocal://0/test/' | ||
---- | ||
pq: only users with the admin role are allowed to RESTORE from the specified nodelocal URI |
Oops, something went wrong.