Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8545482

Browse files
committed
When a superuser does GRANT or REVOKE on an object he doesn't own,
process the command as though it were issued by the object owner. This prevents creating weird scenarios in which the same privileges may appear to flow from different sources, and ensures that a superuser can in fact revoke all privileges if he wants to. In particular this means that the regression tests work when run by a superuser other than the original bootstrap userid. Per report from Larry Rosenman.
1 parent 19554ed commit 8545482

File tree

3 files changed

+135
-67
lines changed

3 files changed

+135
-67
lines changed

doc/src/sgml/ref/grant.sgml

+20-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/grant.sgml,v 1.36 2003/09/20 20:12:05 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/grant.sgml,v 1.37 2003/10/31 20:00:48 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -66,19 +66,21 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
6666
</para>
6767

6868
<para>
69-
There is no need to grant privileges to the owner of an object (usually the user that created it),
70-
as the owner has all privileges by default. (The owner could,
71-
however, choose to revoke some of his own privileges for safety.)
72-
The right to drop an object, or to alter it in any way is
73-
not described by a grantable right; it is inherent in the owner,
74-
and cannot be granted or revoked.
69+
If <literal>WITH GRANT OPTION</literal> is specified, the recipient
70+
of the privilege may in turn grant it to others. By default this
71+
is not allowed. Grant options can only be granted to individual
72+
users, not to groups or <literal>PUBLIC</literal>.
7573
</para>
7674

7775
<para>
78-
If <literal>WITH GRANT OPTION</literal> is specified, the recipient
79-
of the privilege may in turn grant it to others. By default this
80-
is not possible. Grant options can only be granted to individual
81-
users, not groups or <literal>PUBLIC</literal>.
76+
There is no need to grant privileges to the owner of an object
77+
(usually the user that created it),
78+
as the owner has all privileges by default. (The owner could,
79+
however, choose to revoke some of his own privileges for safety.)
80+
The right to drop an object, or to alter its definition in any way is
81+
not described by a grantable privilege; it is inherent in the owner,
82+
and cannot be granted or revoked. It is not possible for the owner's
83+
grant options to be revoked, either.
8284
</para>
8385

8486
<para>
@@ -263,6 +265,13 @@ GRANT { { CREATE | USAGE } [,...] | ALL [ PRIVILEGES ] }
263265
except when absolutely necessary.
264266
</para>
265267

268+
<para>
269+
If a superuser chooses to issue a <command>GRANT</> or <command>REVOKE</>
270+
command, the command is performed as though it were issued by the
271+
owner of the affected object. In particular, privileges granted via
272+
such a command will appear to have been granted by the object owner.
273+
</para>
274+
266275
<para>
267276
Currently, to grant privileges in <productname>PostgreSQL</productname>
268277
to only a few columns, you must

doc/src/sgml/ref/revoke.sgml

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/revoke.sgml,v 1.27 2003/08/31 17:32:24 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/revoke.sgml,v 1.28 2003/10/31 20:00:48 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -63,6 +63,11 @@ REVOKE [ GRANT OPTION FOR ]
6363
all users.
6464
</para>
6565

66+
<para>
67+
See the description of the <xref linkend="sql-grant" endterm="sql-grant-title"> command for
68+
the meaning of the privilege types.
69+
</para>
70+
6671
<para>
6772
Note that any particular user will have the sum
6873
of privileges granted directly to him, privileges granted to any group he
@@ -73,11 +78,6 @@ REVOKE [ GRANT OPTION FOR ]
7378
directly or via a group will still have it.
7479
</para>
7580

76-
<para>
77-
See the description of the <xref linkend="sql-grant" endterm="sql-grant-title"> command for
78-
the meaning of the privilege types.
79-
</para>
80-
8181
<para>
8282
If <literal>GRANT OPTION FOR</literal> is specified, only the grant
8383
option for the privilege is revoked, not the privilege itself.
@@ -116,6 +116,15 @@ REVOKE [ GRANT OPTION FOR ]
116116
the <literal>CASCADE</literal> option so that the privilege is
117117
automatically revoked from user C.
118118
</para>
119+
120+
<para>
121+
If a superuser chooses to issue a <command>GRANT</> or <command>REVOKE</>
122+
command, the command is performed as though it were issued by the
123+
owner of the affected object. Since all privileges ultimately come
124+
from the object owner (possibly indirectly via chains of grant options),
125+
it is possible for a superuser to revoke all privileges, but this may
126+
require use of <literal>CASCADE</literal> as stated above.
127+
</para>
119128
</refsect1>
120129

121130
<refsect1 id="SQL-REVOKE-examples">
@@ -153,7 +162,8 @@ REVOKE [ GRANT OPTION FOR ] <replaceable class="PARAMETER">privileges</replaceab
153162
{ RESTRICT | CASCADE }
154163
</synopsis>
155164
One of <literal>RESTRICT</literal> or <literal>CASCADE</literal>
156-
is required.
165+
is required according to the standard, but <productname>PostgreSQL</>
166+
assumes <literal>RESTRICT</literal> by default.
157167
</para>
158168
</refsect1>
159169

0 commit comments

Comments
 (0)