|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.137 2007/02/14 01:58:56 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.138 2007/03/26 16:58:38 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * NOTES
|
14 | 14 | * See acl.h.
|
@@ -1003,11 +1003,8 @@ ExecGrant_Language(InternalGrant *istmt)
|
1003 | 1003 | /*
|
1004 | 1004 | * Get owner ID and working copy of existing ACL. If there's no ACL,
|
1005 | 1005 | * substitute the proper default.
|
1006 |
| - * |
1007 |
| - * Note: for now, languages are treated as owned by the bootstrap |
1008 |
| - * user. We should add an owner column to pg_language instead. |
1009 | 1006 | */
|
1010 |
| - ownerId = BOOTSTRAP_SUPERUSERID; |
| 1007 | + ownerId = pg_language_tuple->lanowner; |
1011 | 1008 | aclDatum = SysCacheGetAttr(LANGNAME, tuple, Anum_pg_language_lanacl,
|
1012 | 1009 | &isNull);
|
1013 | 1010 | if (isNull)
|
@@ -1770,8 +1767,7 @@ pg_language_aclmask(Oid lang_oid, Oid roleid,
|
1770 | 1767 | (errcode(ERRCODE_UNDEFINED_OBJECT),
|
1771 | 1768 | errmsg("language with OID %u does not exist", lang_oid)));
|
1772 | 1769 |
|
1773 |
| - /* XXX pg_language should have an owner column, but doesn't */ |
1774 |
| - ownerId = BOOTSTRAP_SUPERUSERID; |
| 1770 | + ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner; |
1775 | 1771 |
|
1776 | 1772 | aclDatum = SysCacheGetAttr(LANGOID, tuple, Anum_pg_language_lanacl,
|
1777 | 1773 | &isNull);
|
@@ -2147,6 +2143,34 @@ pg_proc_ownercheck(Oid proc_oid, Oid roleid)
|
2147 | 2143 | return has_privs_of_role(roleid, ownerId);
|
2148 | 2144 | }
|
2149 | 2145 |
|
| 2146 | +/* |
| 2147 | + * Ownership check for a procedural language (specified by OID) |
| 2148 | + */ |
| 2149 | +bool |
| 2150 | +pg_language_ownercheck(Oid lan_oid, Oid roleid) |
| 2151 | +{ |
| 2152 | + HeapTuple tuple; |
| 2153 | + Oid ownerId; |
| 2154 | + |
| 2155 | + /* Superusers bypass all permission checking. */ |
| 2156 | + if (superuser_arg(roleid)) |
| 2157 | + return true; |
| 2158 | + |
| 2159 | + tuple = SearchSysCache(LANGOID, |
| 2160 | + ObjectIdGetDatum(lan_oid), |
| 2161 | + 0, 0, 0); |
| 2162 | + if (!HeapTupleIsValid(tuple)) |
| 2163 | + ereport(ERROR, |
| 2164 | + (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 2165 | + errmsg("language with OID %u does not exist", lan_oid))); |
| 2166 | + |
| 2167 | + ownerId = ((Form_pg_language) GETSTRUCT(tuple))->lanowner; |
| 2168 | + |
| 2169 | + ReleaseSysCache(tuple); |
| 2170 | + |
| 2171 | + return has_privs_of_role(roleid, ownerId); |
| 2172 | +} |
| 2173 | + |
2150 | 2174 | /*
|
2151 | 2175 | * Ownership check for a namespace (specified by OID).
|
2152 | 2176 | */
|
|
0 commit comments