PostgreSQL Source Code git master
Loading...
Searching...
No Matches
acl.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "access/htup_details.h"
#include "bootstrap/bootstrap.h"
#include "catalog/catalog.h"
#include "catalog/namespace.h"
#include "catalog/pg_auth_members.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_class.h"
#include "catalog/pg_database.h"
#include "catalog/pg_foreign_data_wrapper.h"
#include "catalog/pg_foreign_server.h"
#include "catalog/pg_language.h"
#include "catalog/pg_largeobject.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "commands/proclang.h"
#include "commands/tablespace.h"
#include "common/hashfn.h"
#include "foreign/foreign.h"
#include "funcapi.h"
#include "lib/bloomfilter.h"
#include "lib/qunique.h"
#include "miscadmin.h"
#include "storage/large_object.h"
#include "utils/acl.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
#include "utils/varlena.h"
Include dependency graph for acl.c:

Go to the source code of this file.

Data Structures

struct  priv_map
 

Macros

#define ROLES_LIST_BLOOM_THRESHOLD   1024
 

Enumerations

enum  RoleRecurseType { ROLERECURSE_MEMBERS = 0 , ROLERECURSE_PRIVS = 1 , ROLERECURSE_SETROLE = 2 }
 

Functions

static const chargetid (const char *s, char *n, Node *escontext)
 
static void putid (char *p, const char *s)
 
static Aclallocacl (int n)
 
static void check_acl (const Acl *acl)
 
static const characlparse (const char *s, AclItem *aip, Node *escontext)
 
static bool aclitem_match (const AclItem *a1, const AclItem *a2)
 
static int aclitemComparator (const void *arg1, const void *arg2)
 
static void check_circularity (const Acl *old_acl, const AclItem *mod_aip, Oid ownerId)
 
static Aclrecursive_revoke (Acl *acl, Oid grantee, AclMode revoke_privs, Oid ownerId, DropBehavior behavior)
 
static AclMode convert_any_priv_string (text *priv_type_text, const priv_map *privileges)
 
static Oid convert_table_name (text *tablename)
 
static AclMode convert_table_priv_string (text *priv_type_text)
 
static AclMode convert_sequence_priv_string (text *priv_type_text)
 
static AttrNumber convert_column_name (Oid tableoid, text *column)
 
static AclMode convert_column_priv_string (text *priv_type_text)
 
static Oid convert_database_name (text *databasename)
 
static AclMode convert_database_priv_string (text *priv_type_text)
 
static Oid convert_foreign_data_wrapper_name (text *fdwname)
 
static AclMode convert_foreign_data_wrapper_priv_string (text *priv_type_text)
 
static Oid convert_function_name (text *functionname)
 
static AclMode convert_function_priv_string (text *priv_type_text)
 
static Oid convert_language_name (text *languagename)
 
static AclMode convert_language_priv_string (text *priv_type_text)
 
static Oid convert_schema_name (text *schemaname)
 
static AclMode convert_schema_priv_string (text *priv_type_text)
 
static Oid convert_server_name (text *servername)
 
static AclMode convert_server_priv_string (text *priv_type_text)
 
static Oid convert_tablespace_name (text *tablespacename)
 
static AclMode convert_tablespace_priv_string (text *priv_type_text)
 
static Oid convert_type_name (text *typename)
 
static AclMode convert_type_priv_string (text *priv_type_text)
 
static AclMode convert_parameter_priv_string (text *priv_text)
 
static AclMode convert_largeobject_priv_string (text *priv_type_text)
 
static AclMode convert_role_priv_string (text *priv_type_text)
 
static AclResult pg_role_aclcheck (Oid role_oid, Oid roleid, AclMode mode)
 
static void RoleMembershipCacheCallback (Datum arg, SysCacheIdentifier cacheid, uint32 hashvalue)
 
static bool is_safe_acl_char (unsigned char c, bool is_getid)
 
Aclmake_empty_acl (void)
 
Aclaclcopy (const Acl *orig_acl)
 
Aclaclconcat (const Acl *left_acl, const Acl *right_acl)
 
Aclaclmerge (const Acl *left_acl, const Acl *right_acl, Oid ownerId)
 
void aclitemsort (Acl *acl)
 
bool aclequal (const Acl *left_acl, const Acl *right_acl)
 
Datum aclitemin (PG_FUNCTION_ARGS)
 
Datum aclitemout (PG_FUNCTION_ARGS)
 
Datum aclitem_eq (PG_FUNCTION_ARGS)
 
Datum hash_aclitem (PG_FUNCTION_ARGS)
 
Datum hash_aclitem_extended (PG_FUNCTION_ARGS)
 
Aclacldefault (ObjectType objtype, Oid ownerId)
 
Datum acldefault_sql (PG_FUNCTION_ARGS)
 
Aclaclupdate (const Acl *old_acl, const AclItem *mod_aip, int modechg, Oid ownerId, DropBehavior behavior)
 
Aclaclnewowner (const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
 
AclMode aclmask (const Acl *acl, Oid roleid, Oid ownerId, AclMode mask, AclMaskHow how)
 
static AclMode aclmask_direct (const Acl *acl, Oid roleid, Oid ownerId, AclMode mask, AclMaskHow how)
 
int aclmembers (const Acl *acl, Oid **roleids)
 
Datum aclinsert (PG_FUNCTION_ARGS)
 
Datum aclremove (PG_FUNCTION_ARGS)
 
Datum aclcontains (PG_FUNCTION_ARGS)
 
Datum makeaclitem (PG_FUNCTION_ARGS)
 
static const charconvert_aclright_to_string (int aclright)
 
Datum aclexplode (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_table_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_sequence_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_any_column_privilege_id_id (PG_FUNCTION_ARGS)
 
static int column_privilege_check (Oid tableoid, AttrNumber attnum, Oid roleid, AclMode mode)
 
Datum has_column_privilege_name_name_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_name_name_attnum (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_name_id_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_name_id_attnum (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_name_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_name_attnum (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_id_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_id_attnum (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_name_attnum (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_column_privilege_id_attnum (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_database_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_foreign_data_wrapper_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_function_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_language_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_schema_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_server_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_tablespace_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_id_name (PG_FUNCTION_ARGS)
 
Datum has_type_privilege_id_id (PG_FUNCTION_ARGS)
 
static bool has_param_priv_byname (Oid roleid, const text *parameter, AclMode priv)
 
Datum has_parameter_privilege_name_name (PG_FUNCTION_ARGS)
 
Datum has_parameter_privilege_name (PG_FUNCTION_ARGS)
 
Datum has_parameter_privilege_id_name (PG_FUNCTION_ARGS)
 
static bool has_lo_priv_byid (Oid roleid, Oid lobjId, AclMode priv, bool *is_missing)
 
Datum has_largeobject_privilege_name_id (PG_FUNCTION_ARGS)
 
Datum has_largeobject_privilege_id (PG_FUNCTION_ARGS)
 
Datum has_largeobject_privilege_id_id (PG_FUNCTION_ARGS)
 
Datum pg_has_role_name_name (PG_FUNCTION_ARGS)
 
Datum pg_has_role_name (PG_FUNCTION_ARGS)
 
Datum pg_has_role_name_id (PG_FUNCTION_ARGS)
 
Datum pg_has_role_id (PG_FUNCTION_ARGS)
 
Datum pg_has_role_id_name (PG_FUNCTION_ARGS)
 
Datum pg_has_role_id_id (PG_FUNCTION_ARGS)
 
void initialize_acl (void)
 
static Listroles_list_append (List *roles_list, bloom_filter **bf, Oid role)
 
static Listroles_is_member_of (Oid roleid, enum RoleRecurseType type, Oid admin_of, Oid *admin_role)
 
bool has_privs_of_role (Oid member, Oid role)
 
bool member_can_set_role (Oid member, Oid role)
 
void check_can_set_role (Oid member, Oid role)
 
bool is_member_of_role (Oid member, Oid role)
 
bool is_member_of_role_nosuper (Oid member, Oid role)
 
bool is_admin_of_role (Oid member, Oid role)
 
Oid select_best_admin (Oid member, Oid role)
 
void select_best_grantor (Oid roleId, AclMode privileges, const Acl *acl, Oid ownerId, Oid *grantorId, AclMode *grantOptions)
 
Oid get_role_oid (const char *rolname, bool missing_ok)
 
Oid get_role_oid_or_public (const char *rolname)
 
Oid get_rolespec_oid (const RoleSpec *role, bool missing_ok)
 
HeapTuple get_rolespec_tuple (const RoleSpec *role)
 
charget_rolespec_name (const RoleSpec *role)
 
void check_rolespec_name (const RoleSpec *role, const char *detail_msg)
 

Variables

static Oid cached_role [] = {InvalidOid, InvalidOid, InvalidOid}
 
static Listcached_roles [] = {NIL, NIL, NIL}
 
static uint32 cached_db_hash
 

Macro Definition Documentation

◆ ROLES_LIST_BLOOM_THRESHOLD

#define ROLES_LIST_BLOOM_THRESHOLD   1024

Definition at line 91 of file acl.c.

Enumeration Type Documentation

◆ RoleRecurseType

Enumerator
ROLERECURSE_MEMBERS 
ROLERECURSE_PRIVS 
ROLERECURSE_SETROLE 

Definition at line 75 of file acl.c.

76{
77 ROLERECURSE_MEMBERS = 0, /* recurse unconditionally */
78 ROLERECURSE_PRIVS = 1, /* recurse through inheritable grants */
79 ROLERECURSE_SETROLE = 2 /* recurse through grants with set_option */
80};
@ ROLERECURSE_PRIVS
Definition acl.c:78
@ ROLERECURSE_MEMBERS
Definition acl.c:77
@ ROLERECURSE_SETROLE
Definition acl.c:79

Function Documentation

◆ aclconcat()

Acl * aclconcat ( const Acl left_acl,
const Acl right_acl 
)

Definition at line 490 of file acl.c.

491{
493
495
498 ACL_NUM(left_acl) * sizeof(AclItem));
499
502 ACL_NUM(right_acl) * sizeof(AclItem));
503
504 return result_acl;
505}
static Acl * allocacl(int n)
Definition acl.c:439
#define ACL_DAT(ACL)
Definition acl.h:109
#define ACL_NUM(ACL)
Definition acl.h:108
static int fb(int x)
Definition acl.h:55

References ACL_DAT, ACL_NUM, allocacl(), and fb().

Referenced by ExecGrant_Attribute().

◆ aclcontains()

Datum aclcontains ( PG_FUNCTION_ARGS  )

Definition at line 1625 of file acl.c.

1626{
1627 Acl *acl = PG_GETARG_ACL_P(0);
1629 AclItem *aidat;
1630 int i,
1631 num;
1632
1633 check_acl(acl);
1634 num = ACL_NUM(acl);
1635 aidat = ACL_DAT(acl);
1636 for (i = 0; i < num; ++i)
1637 {
1638 if (aip->ai_grantee == aidat[i].ai_grantee &&
1639 aip->ai_grantor == aidat[i].ai_grantor &&
1641 PG_RETURN_BOOL(true);
1642 }
1643 PG_RETURN_BOOL(false);
1644}
static void check_acl(const Acl *acl)
Definition acl.c:603
#define PG_GETARG_ACLITEM_P(n)
Definition acl.h:117
#define PG_GETARG_ACL_P(n)
Definition acl.h:122
#define ACLITEM_GET_RIGHTS(item)
Definition acl.h:68
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
int i
Definition isn.c:77

References ACL_DAT, ACL_NUM, ACLITEM_GET_RIGHTS, check_acl(), fb(), i, PG_GETARG_ACL_P, PG_GETARG_ACLITEM_P, and PG_RETURN_BOOL.

◆ aclcopy()

Acl * aclcopy ( const Acl orig_acl)

Definition at line 470 of file acl.c.

471{
473
475
478 ACL_NUM(orig_acl) * sizeof(AclItem));
479
480 return result_acl;
481}

References ACL_DAT, ACL_NUM, allocacl(), and fb().

Referenced by aclmerge(), ExecGrant_Relation(), and SetDefaultACL().

◆ acldefault()

Acl * acldefault ( ObjectType  objtype,
Oid  ownerId 
)

Definition at line 816 of file acl.c.

817{
820 int nacl;
821 Acl *acl;
822 AclItem *aip;
823
824 switch (objtype)
825 {
826 case OBJECT_COLUMN:
827 /* by default, columns have no extra privileges */
830 break;
831 case OBJECT_TABLE:
834 break;
835 case OBJECT_SEQUENCE:
838 break;
839 case OBJECT_DATABASE:
840 /* for backwards compatibility, grant some rights by default */
843 break;
844 case OBJECT_FUNCTION:
845 /* Grant EXECUTE by default, for now */
848 break;
849 case OBJECT_LANGUAGE:
850 /* Grant USAGE by default, for now */
853 break;
857 break;
858 case OBJECT_SCHEMA:
861 break;
865 break;
866 case OBJECT_FDW:
869 break;
873 break;
874 case OBJECT_DOMAIN:
875 case OBJECT_TYPE:
878 break;
882 break;
883 default:
884 elog(ERROR, "unrecognized object type: %d", (int) objtype);
885 world_default = ACL_NO_RIGHTS; /* keep compiler quiet */
887 break;
888 }
889
890 nacl = 0;
892 nacl++;
894 nacl++;
895
896 acl = allocacl(nacl);
897 aip = ACL_DAT(acl);
898
900 {
901 aip->ai_grantee = ACL_ID_PUBLIC;
902 aip->ai_grantor = ownerId;
904 aip++;
905 }
906
907 /*
908 * Note that the owner's entry shows all ordinary privileges but no grant
909 * options. This is because his grant options come "from the system" and
910 * not from his own efforts. (The SQL spec says that the owner's rights
911 * come from a "_SYSTEM" authid.) However, we do consider that the
912 * owner's ordinary privileges are self-granted; this lets him revoke
913 * them. We implement the owner's grant options without any explicit
914 * "_SYSTEM"-like ACL entry, by internally special-casing the owner
915 * wherever we are testing grant options.
916 */
918 {
919 aip->ai_grantee = ownerId;
920 aip->ai_grantor = ownerId;
922 }
923
924 return acl;
925}
#define ACL_ALL_RIGHTS_FOREIGN_SERVER
Definition acl.h:164
#define ACL_ALL_RIGHTS_TABLESPACE
Definition acl.h:170
#define ACL_ALL_RIGHTS_PARAMETER_ACL
Definition acl.h:168
#define ACL_ALL_RIGHTS_SCHEMA
Definition acl.h:169
#define ACL_ALL_RIGHTS_SEQUENCE
Definition acl.h:161
#define ACL_ALL_RIGHTS_DATABASE
Definition acl.h:162
#define ACL_ALL_RIGHTS_FUNCTION
Definition acl.h:165
#define ACL_ALL_RIGHTS_LANGUAGE
Definition acl.h:166
#define ACL_ALL_RIGHTS_TYPE
Definition acl.h:171
#define ACL_ALL_RIGHTS_FDW
Definition acl.h:163
#define ACLITEM_SET_PRIVS_GOPTIONS(item, privs, goptions)
Definition acl.h:82
#define ACL_ALL_RIGHTS_RELATION
Definition acl.h:160
#define ACL_ID_PUBLIC
Definition acl.h:46
#define ACL_ALL_RIGHTS_LARGEOBJECT
Definition acl.h:167
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
#define ACL_CREATE_TEMP
Definition parsenodes.h:86
uint64 AclMode
Definition parsenodes.h:74
#define ACL_USAGE
Definition parsenodes.h:84
#define ACL_NO_RIGHTS
Definition parsenodes.h:92
@ OBJECT_FDW
@ OBJECT_SCHEMA
@ OBJECT_DOMAIN
@ OBJECT_COLUMN
@ OBJECT_TABLESPACE
@ OBJECT_LARGEOBJECT
@ OBJECT_DATABASE
@ OBJECT_SEQUENCE
@ OBJECT_LANGUAGE
@ OBJECT_FOREIGN_SERVER
@ OBJECT_TABLE
@ OBJECT_PARAMETER_ACL
@ OBJECT_TYPE
@ OBJECT_FUNCTION
#define ACL_CONNECT
Definition parsenodes.h:87
#define ACL_EXECUTE
Definition parsenodes.h:83

References ACL_ALL_RIGHTS_DATABASE, ACL_ALL_RIGHTS_FDW, ACL_ALL_RIGHTS_FOREIGN_SERVER, ACL_ALL_RIGHTS_FUNCTION, ACL_ALL_RIGHTS_LANGUAGE, ACL_ALL_RIGHTS_LARGEOBJECT, ACL_ALL_RIGHTS_PARAMETER_ACL, ACL_ALL_RIGHTS_RELATION, ACL_ALL_RIGHTS_SCHEMA, ACL_ALL_RIGHTS_SEQUENCE, ACL_ALL_RIGHTS_TABLESPACE, ACL_ALL_RIGHTS_TYPE, ACL_CONNECT, ACL_CREATE_TEMP, ACL_DAT, ACL_EXECUTE, ACL_ID_PUBLIC, ACL_NO_RIGHTS, ACL_USAGE, ACLITEM_SET_PRIVS_GOPTIONS, allocacl(), elog, ERROR, fb(), OBJECT_COLUMN, OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FUNCTION, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_PARAMETER_ACL, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_TABLE, OBJECT_TABLESPACE, and OBJECT_TYPE.

Referenced by acldefault_sql(), buildDefaultACLCommands(), dumpACL(), dumpRoleGUCPrivs(), dumpTable(), dumpTablespaces(), ExecGrant_Attribute(), ExecGrant_common(), ExecGrant_Largeobject(), ExecGrant_Parameter(), ExecGrant_Relation(), get_user_default_acl(), object_aclmask_ext(), pg_class_aclmask_ext(), pg_largeobject_aclmask_snapshot(), pg_namespace_aclmask_ext(), pg_parameter_acl_aclmask(), pg_parameter_aclmask(), pg_type_aclmask_ext(), and SetDefaultACL().

◆ acldefault_sql()

Datum acldefault_sql ( PG_FUNCTION_ARGS  )

Definition at line 933 of file acl.c.

934{
935 char objtypec = PG_GETARG_CHAR(0);
936 Oid owner = PG_GETARG_OID(1);
937 ObjectType objtype = 0;
938
939 switch (objtypec)
940 {
941 case 'c':
942 objtype = OBJECT_COLUMN;
943 break;
944 case 'r':
945 objtype = OBJECT_TABLE;
946 break;
947 case 's':
948 objtype = OBJECT_SEQUENCE;
949 break;
950 case 'd':
951 objtype = OBJECT_DATABASE;
952 break;
953 case 'f':
954 objtype = OBJECT_FUNCTION;
955 break;
956 case 'l':
957 objtype = OBJECT_LANGUAGE;
958 break;
959 case 'L':
960 objtype = OBJECT_LARGEOBJECT;
961 break;
962 case 'n':
963 objtype = OBJECT_SCHEMA;
964 break;
965 case 'p':
966 objtype = OBJECT_PARAMETER_ACL;
967 break;
968 case 't':
969 objtype = OBJECT_TABLESPACE;
970 break;
971 case 'F':
972 objtype = OBJECT_FDW;
973 break;
974 case 'S':
975 objtype = OBJECT_FOREIGN_SERVER;
976 break;
977 case 'T':
978 objtype = OBJECT_TYPE;
979 break;
980 default:
981 elog(ERROR, "unrecognized object type abbreviation: %c", objtypec);
982 }
983
984 PG_RETURN_ACL_P(acldefault(objtype, owner));
985}
Acl * acldefault(ObjectType objtype, Oid ownerId)
Definition acl.c:816
#define PG_RETURN_ACL_P(x)
Definition acl.h:124
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_GETARG_CHAR(n)
Definition fmgr.h:273
ObjectType
unsigned int Oid

References acldefault(), elog, ERROR, fb(), OBJECT_COLUMN, OBJECT_DATABASE, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FUNCTION, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_PARAMETER_ACL, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TYPE, PG_GETARG_CHAR, PG_GETARG_OID, and PG_RETURN_ACL_P.

◆ aclequal()

bool aclequal ( const Acl left_acl,
const Acl right_acl 
)

Definition at line 572 of file acl.c.

573{
574 /* Check for cases where one or both are empty/null */
575 if (left_acl == NULL || ACL_NUM(left_acl) == 0)
576 {
577 if (right_acl == NULL || ACL_NUM(right_acl) == 0)
578 return true;
579 else
580 return false;
581 }
582 else
583 {
584 if (right_acl == NULL || ACL_NUM(right_acl) == 0)
585 return false;
586 }
587
589 return false;
590
593 ACL_NUM(left_acl) * sizeof(AclItem)) == 0)
594 return true;
595
596 return false;
597}

References ACL_DAT, ACL_NUM, and fb().

Referenced by ExecGrant_Parameter(), get_user_default_acl(), and SetDefaultACL().

◆ aclexplode()

Datum aclexplode ( PG_FUNCTION_ARGS  )

Definition at line 1803 of file acl.c.

1804{
1805 Acl *acl = PG_GETARG_ACL_P(0);
1807 int *idx;
1808 AclItem *aidat;
1809
1810 if (SRF_IS_FIRSTCALL())
1811 {
1812 TupleDesc tupdesc;
1813 MemoryContext oldcontext;
1814
1815 check_acl(acl);
1816
1818 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
1819
1820 /*
1821 * build tupdesc for result tuples (matches out parameters in pg_proc
1822 * entry)
1823 */
1824 tupdesc = CreateTemplateTupleDesc(4);
1825 TupleDescInitEntry(tupdesc, (AttrNumber) 1, "grantor",
1826 OIDOID, -1, 0);
1827 TupleDescInitEntry(tupdesc, (AttrNumber) 2, "grantee",
1828 OIDOID, -1, 0);
1829 TupleDescInitEntry(tupdesc, (AttrNumber) 3, "privilege_type",
1830 TEXTOID, -1, 0);
1831 TupleDescInitEntry(tupdesc, (AttrNumber) 4, "is_grantable",
1832 BOOLOID, -1, 0);
1833
1834 funcctx->tuple_desc = BlessTupleDesc(tupdesc);
1835
1836 /* allocate memory for user context */
1837 idx = palloc_array(int, 2);
1838 idx[0] = 0; /* ACL array item index */
1839 idx[1] = -1; /* privilege type counter */
1840 funcctx->user_fctx = idx;
1841
1842 MemoryContextSwitchTo(oldcontext);
1843 }
1844
1846 idx = (int *) funcctx->user_fctx;
1847 aidat = ACL_DAT(acl);
1848
1849 /* need test here in case acl has no items */
1850 while (idx[0] < ACL_NUM(acl))
1851 {
1852 AclItem *aidata;
1854
1855 idx[1]++;
1856 if (idx[1] == N_ACL_RIGHTS)
1857 {
1858 idx[1] = 0;
1859 idx[0]++;
1860 if (idx[0] >= ACL_NUM(acl)) /* done */
1861 break;
1862 }
1863 aidata = &aidat[idx[0]];
1864 priv_bit = UINT64CONST(1) << idx[1];
1865
1867 {
1868 Datum result;
1869 Datum values[4];
1870 bool nulls[4] = {0};
1871 HeapTuple tuple;
1872
1873 values[0] = ObjectIdGetDatum(aidata->ai_grantor);
1874 values[1] = ObjectIdGetDatum(aidata->ai_grantee);
1877
1878 tuple = heap_form_tuple(funcctx->tuple_desc, values, nulls);
1879 result = HeapTupleGetDatum(tuple);
1880
1881 SRF_RETURN_NEXT(funcctx, result);
1882 }
1883 }
1884
1886}
Datum idx(PG_FUNCTION_ARGS)
Definition _int_op.c:262
static const char * convert_aclright_to_string(int aclright)
Definition acl.c:1747
#define ACLITEM_GET_PRIVS(item)
Definition acl.h:66
#define ACLITEM_GET_GOPTIONS(item)
Definition acl.h:67
int16 AttrNumber
Definition attnum.h:21
static Datum values[MAXATTR]
Definition bootstrap.c:187
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define UINT64CONST(x)
Definition c.h:594
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
#define palloc_array(type, count)
Definition fe_memutils.h:76
#define SRF_IS_FIRSTCALL()
Definition funcapi.h:304
#define SRF_PERCALL_SETUP()
Definition funcapi.h:308
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition funcapi.h:310
#define SRF_FIRSTCALL_INIT()
Definition funcapi.h:306
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
Definition funcapi.h:230
#define SRF_RETURN_DONE(_funcctx)
Definition funcapi.h:328
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1117
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
#define N_ACL_RIGHTS
Definition parsenodes.h:91
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
TupleDesc CreateTemplateTupleDesc(int natts)
Definition tupdesc.c:165
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition tupdesc.c:825

References ACL_DAT, ACL_NUM, ACLITEM_GET_GOPTIONS, ACLITEM_GET_PRIVS, BlessTupleDesc(), BoolGetDatum(), check_acl(), convert_aclright_to_string(), CreateTemplateTupleDesc(), CStringGetTextDatum, fb(), heap_form_tuple(), HeapTupleGetDatum(), idx(), MemoryContextSwitchTo(), N_ACL_RIGHTS, ObjectIdGetDatum(), palloc_array, PG_GETARG_ACL_P, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, TupleDescInitEntry(), UINT64CONST, and values.

◆ aclinsert()

Datum aclinsert ( PG_FUNCTION_ARGS  )

Definition at line 1605 of file acl.c.

1606{
1607 ereport(ERROR,
1609 errmsg("aclinsert is no longer supported")));
1610
1611 PG_RETURN_NULL(); /* keep compiler quiet */
1612}
int errcode(int sqlerrcode)
Definition elog.c:874
#define ereport(elevel,...)
Definition elog.h:150
#define PG_RETURN_NULL()
Definition fmgr.h:346
static char * errmsg

References ereport, errcode(), errmsg, ERROR, fb(), and PG_RETURN_NULL.

◆ aclitem_eq()

Datum aclitem_eq ( PG_FUNCTION_ARGS  )

Definition at line 761 of file acl.c.

762{
765 bool result;
766
767 result = a1->ai_privs == a2->ai_privs &&
768 a1->ai_grantee == a2->ai_grantee &&
769 a1->ai_grantor == a2->ai_grantor;
770 PG_RETURN_BOOL(result);
771}
static const FormData_pg_attribute a1
Definition heap.c:144
static const FormData_pg_attribute a2
Definition heap.c:157

References a1, a2, PG_GETARG_ACLITEM_P, and PG_RETURN_BOOL.

◆ aclitem_match()

static bool aclitem_match ( const AclItem a1,
const AclItem a2 
)
static

Definition at line 726 of file acl.c.

727{
728 return a1->ai_grantee == a2->ai_grantee &&
729 a1->ai_grantor == a2->ai_grantor;
730}

References a1, and a2.

Referenced by aclnewowner(), and aclupdate().

◆ aclitemComparator()

static int aclitemComparator ( const void arg1,
const void arg2 
)
static

Definition at line 737 of file acl.c.

738{
739 const AclItem *a1 = (const AclItem *) arg1;
740 const AclItem *a2 = (const AclItem *) arg2;
741
742 if (a1->ai_grantee > a2->ai_grantee)
743 return 1;
744 if (a1->ai_grantee < a2->ai_grantee)
745 return -1;
746 if (a1->ai_grantor > a2->ai_grantor)
747 return 1;
748 if (a1->ai_grantor < a2->ai_grantor)
749 return -1;
750 if (a1->ai_privs > a2->ai_privs)
751 return 1;
752 if (a1->ai_privs < a2->ai_privs)
753 return -1;
754 return 0;
755}

References a1, a2, and fb().

Referenced by aclitemsort().

◆ aclitemin()

Datum aclitemin ( PG_FUNCTION_ARGS  )

Definition at line 628 of file acl.c.

629{
630 const char *s = PG_GETARG_CSTRING(0);
631 Node *escontext = fcinfo->context;
632 AclItem *aip;
633
635
636 s = aclparse(s, aip, escontext);
637 if (s == NULL)
639
640 while (isspace((unsigned char) *s))
641 ++s;
642 if (*s)
643 ereturn(escontext, (Datum) 0,
645 errmsg("extra garbage at the end of the ACL specification")));
646
648}
static const char * aclparse(const char *s, AclItem *aip, Node *escontext)
Definition acl.c:278
#define PG_RETURN_ACLITEM_P(x)
Definition acl.h:118
#define ereturn(context, dummy_value,...)
Definition elog.h:278
#define palloc_object(type)
Definition fe_memutils.h:74
#define PG_GETARG_CSTRING(n)
Definition fmgr.h:278
Definition nodes.h:135

References aclparse(), ereturn, errcode(), errmsg, fb(), palloc_object, PG_GETARG_CSTRING, PG_RETURN_ACLITEM_P, and PG_RETURN_NULL.

◆ aclitemout()

Datum aclitemout ( PG_FUNCTION_ARGS  )

Definition at line 659 of file acl.c.

660{
662 char *p;
663 char *out;
664 HeapTuple htup;
665 unsigned i;
666
667 out = palloc(strlen("=/") +
668 2 * N_ACL_RIGHTS +
669 2 * (2 * NAMEDATALEN + 2) +
670 1);
671
672 p = out;
673 *p = '\0';
674
675 if (aip->ai_grantee != ACL_ID_PUBLIC)
676 {
677 htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantee));
678 if (HeapTupleIsValid(htup))
679 {
681 ReleaseSysCache(htup);
682 }
683 else
684 {
685 /* Generate numeric OID if we don't find an entry */
686 sprintf(p, "%u", aip->ai_grantee);
687 }
688 }
689 while (*p)
690 ++p;
691
692 *p++ = '=';
693
694 for (i = 0; i < N_ACL_RIGHTS; ++i)
695 {
696 if (ACLITEM_GET_PRIVS(*aip) & (UINT64CONST(1) << i))
697 *p++ = ACL_ALL_RIGHTS_STR[i];
698 if (ACLITEM_GET_GOPTIONS(*aip) & (UINT64CONST(1) << i))
699 *p++ = '*';
700 }
701
702 *p++ = '/';
703 *p = '\0';
704
705 htup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(aip->ai_grantor));
706 if (HeapTupleIsValid(htup))
707 {
709 ReleaseSysCache(htup);
710 }
711 else
712 {
713 /* Generate numeric OID if we don't find an entry */
714 sprintf(p, "%u", aip->ai_grantor);
715 }
716
718}
static void putid(char *p, const char *s)
Definition acl.c:223
#define ACL_ALL_RIGHTS_STR
Definition acl.h:154
#define NameStr(name)
Definition c.h:798
#define PG_RETURN_CSTRING(x)
Definition fmgr.h:364
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
void * palloc(Size size)
Definition mcxt.c:1387
NameData rolname
Definition pg_authid.h:36
END_CATALOG_STRUCT typedef FormData_pg_authid * Form_pg_authid
Definition pg_authid.h:60
#define NAMEDATALEN
#define sprintf
Definition port.h:262
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:220

References ACL_ALL_RIGHTS_STR, ACL_ID_PUBLIC, ACLITEM_GET_GOPTIONS, ACLITEM_GET_PRIVS, fb(), Form_pg_authid, GETSTRUCT(), HeapTupleIsValid, i, N_ACL_RIGHTS, NAMEDATALEN, NameStr, ObjectIdGetDatum(), palloc(), PG_GETARG_ACLITEM_P, PG_RETURN_CSTRING, putid(), ReleaseSysCache(), rolname, SearchSysCache1(), sprintf, and UINT64CONST.

◆ aclitemsort()

void aclitemsort ( Acl acl)

Definition at line 558 of file acl.c.

559{
560 if (acl != NULL && ACL_NUM(acl) > 1)
561 qsort(ACL_DAT(acl), ACL_NUM(acl), sizeof(AclItem), aclitemComparator);
562}
static int aclitemComparator(const void *arg1, const void *arg2)
Definition acl.c:737
#define qsort(a, b, c, d)
Definition port.h:495

References ACL_DAT, ACL_NUM, aclitemComparator(), fb(), and qsort.

Referenced by get_user_default_acl(), and SetDefaultACL().

◆ aclmask()

AclMode aclmask ( const Acl acl,
Oid  roleid,
Oid  ownerId,
AclMode  mask,
AclMaskHow  how 
)

Definition at line 1401 of file acl.c.

1403{
1404 AclMode result;
1406 AclItem *aidat;
1407 int i,
1408 num;
1409
1410 /*
1411 * Null ACL should not happen, since caller should have inserted
1412 * appropriate default
1413 */
1414 if (acl == NULL)
1415 elog(ERROR, "null ACL");
1416
1417 check_acl(acl);
1418
1419 /* Quick exit for mask == 0 */
1420 if (mask == 0)
1421 return 0;
1422
1423 result = 0;
1424
1425 /* Owner always implicitly has all grant options */
1426 if ((mask & ACLITEM_ALL_GOPTION_BITS) &&
1427 has_privs_of_role(roleid, ownerId))
1428 {
1429 result = mask & ACLITEM_ALL_GOPTION_BITS;
1430 if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
1431 return result;
1432 }
1433
1434 num = ACL_NUM(acl);
1435 aidat = ACL_DAT(acl);
1436
1437 /*
1438 * Check privileges granted directly to roleid or to public
1439 */
1440 for (i = 0; i < num; i++)
1441 {
1442 AclItem *aidata = &aidat[i];
1443
1444 if (aidata->ai_grantee == ACL_ID_PUBLIC ||
1445 aidata->ai_grantee == roleid)
1446 {
1447 result |= aidata->ai_privs & mask;
1448 if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
1449 return result;
1450 }
1451 }
1452
1453 /*
1454 * Check privileges granted indirectly via role memberships. We do this in
1455 * a separate pass to minimize expensive indirect membership tests. In
1456 * particular, it's worth testing whether a given ACL entry grants any
1457 * privileges still of interest before we perform the has_privs_of_role
1458 * test.
1459 */
1460 remaining = mask & ~result;
1461 for (i = 0; i < num; i++)
1462 {
1463 AclItem *aidata = &aidat[i];
1464
1465 if (aidata->ai_grantee == ACL_ID_PUBLIC ||
1466 aidata->ai_grantee == roleid)
1467 continue; /* already checked it */
1468
1469 if ((aidata->ai_privs & remaining) &&
1470 has_privs_of_role(roleid, aidata->ai_grantee))
1471 {
1472 result |= aidata->ai_privs & mask;
1473 if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
1474 return result;
1475 remaining = mask & ~result;
1476 }
1477 }
1478
1479 return result;
1480}
bool has_privs_of_role(Oid member, Oid role)
Definition acl.c:5298
#define ACLITEM_ALL_GOPTION_BITS
Definition acl.h:88
@ ACLMASK_ALL
Definition acl.h:176
int remaining
Definition informix.c:692
AclMode ai_privs
Definition acl.h:58

References ACL_DAT, ACL_ID_PUBLIC, ACL_NUM, ACLITEM_ALL_GOPTION_BITS, ACLMASK_ALL, AclItem::ai_privs, check_acl(), elog, ERROR, fb(), has_privs_of_role(), i, and remaining.

Referenced by check_circularity(), LockTableAclCheck(), object_aclmask_ext(), pg_attribute_aclcheck_all_ext(), pg_attribute_aclmask_ext(), pg_class_aclmask_ext(), pg_largeobject_aclmask_snapshot(), pg_namespace_aclmask_ext(), pg_parameter_acl_aclmask(), pg_parameter_aclmask(), pg_type_aclmask_ext(), and recursive_revoke().

◆ aclmask_direct()

static AclMode aclmask_direct ( const Acl acl,
Oid  roleid,
Oid  ownerId,
AclMode  mask,
AclMaskHow  how 
)
static

Definition at line 1490 of file acl.c.

1492{
1493 AclMode result;
1494 AclItem *aidat;
1495 int i,
1496 num;
1497
1498 /*
1499 * Null ACL should not happen, since caller should have inserted
1500 * appropriate default
1501 */
1502 if (acl == NULL)
1503 elog(ERROR, "null ACL");
1504
1505 check_acl(acl);
1506
1507 /* Quick exit for mask == 0 */
1508 if (mask == 0)
1509 return 0;
1510
1511 result = 0;
1512
1513 /* Owner always implicitly has all grant options */
1514 if ((mask & ACLITEM_ALL_GOPTION_BITS) &&
1515 roleid == ownerId)
1516 {
1517 result = mask & ACLITEM_ALL_GOPTION_BITS;
1518 if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
1519 return result;
1520 }
1521
1522 num = ACL_NUM(acl);
1523 aidat = ACL_DAT(acl);
1524
1525 /*
1526 * Check privileges granted directly to roleid (and not to public)
1527 */
1528 for (i = 0; i < num; i++)
1529 {
1530 AclItem *aidata = &aidat[i];
1531
1532 if (aidata->ai_grantee == roleid)
1533 {
1534 result |= aidata->ai_privs & mask;
1535 if ((how == ACLMASK_ALL) ? (result == mask) : (result != 0))
1536 return result;
1537 }
1538 }
1539
1540 return result;
1541}

References ACL_DAT, ACL_NUM, ACLITEM_ALL_GOPTION_BITS, ACLMASK_ALL, AclItem::ai_privs, check_acl(), elog, ERROR, fb(), and i.

Referenced by select_best_grantor().

◆ aclmembers()

int aclmembers ( const Acl acl,
Oid **  roleids 
)

Definition at line 1553 of file acl.c.

1554{
1555 Oid *list;
1556 const AclItem *acldat;
1557 int i,
1558 j;
1559
1560 if (acl == NULL || ACL_NUM(acl) == 0)
1561 {
1562 *roleids = NULL;
1563 return 0;
1564 }
1565
1566 check_acl(acl);
1567
1568 /* Allocate the worst-case space requirement */
1569 list = palloc(ACL_NUM(acl) * 2 * sizeof(Oid));
1570 acldat = ACL_DAT(acl);
1571
1572 /*
1573 * Walk the ACL collecting mentioned RoleIds.
1574 */
1575 j = 0;
1576 for (i = 0; i < ACL_NUM(acl); i++)
1577 {
1578 const AclItem *ai = &acldat[i];
1579
1580 if (ai->ai_grantee != ACL_ID_PUBLIC)
1581 list[j++] = ai->ai_grantee;
1582 /* grantor is currently never PUBLIC, but let's check anyway */
1583 if (ai->ai_grantor != ACL_ID_PUBLIC)
1584 list[j++] = ai->ai_grantor;
1585 }
1586
1587 /* Sort the array */
1588 qsort(list, j, sizeof(Oid), oid_cmp);
1589
1590 /*
1591 * We could repalloc the array down to minimum size, but it's hardly worth
1592 * it since it's only transient memory.
1593 */
1594 *roleids = list;
1595
1596 /* Remove duplicates from the array */
1597 return qunique(list, j, sizeof(Oid), oid_cmp);
1598}
int j
Definition isn.c:78
int oid_cmp(const void *p1, const void *p2)
Definition oid.c:287
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
Definition qunique.h:21

References ACL_DAT, ACL_ID_PUBLIC, ACL_NUM, check_acl(), fb(), i, j, oid_cmp(), palloc(), qsort, and qunique().

Referenced by ExecGrant_Attribute(), ExecGrant_common(), ExecGrant_Largeobject(), ExecGrant_Parameter(), ExecGrant_Relation(), recordDependencyOnNewAcl(), recordExtensionInitPrivWorker(), RemoveRoleFromInitPriv(), ReplaceRoleInInitPriv(), and SetDefaultACL().

◆ aclmerge()

Acl * aclmerge ( const Acl left_acl,
const Acl right_acl,
Oid  ownerId 
)

Definition at line 514 of file acl.c.

515{
517 AclItem *aip;
518 int i,
519 num;
520
521 /* Check for cases where one or both are empty/null */
522 if (left_acl == NULL || ACL_NUM(left_acl) == 0)
523 {
524 if (right_acl == NULL || ACL_NUM(right_acl) == 0)
525 return NULL;
526 else
527 return aclcopy(right_acl);
528 }
529 else
530 {
531 if (right_acl == NULL || ACL_NUM(right_acl) == 0)
532 return aclcopy(left_acl);
533 }
534
535 /* Merge them the hard way, one item at a time */
537
539 num = ACL_NUM(right_acl);
540
541 for (i = 0; i < num; i++, aip++)
542 {
543 Acl *tmp_acl;
544
546 ownerId, DROP_RESTRICT);
549 }
550
551 return result_acl;
552}
Acl * aclupdate(const Acl *old_acl, const AclItem *mod_aip, int modechg, Oid ownerId, DropBehavior behavior)
Definition acl.c:1005
Acl * aclcopy(const Acl *orig_acl)
Definition acl.c:470
#define ACL_MODECHG_ADD
Definition acl.h:129
void pfree(void *pointer)
Definition mcxt.c:1616
@ DROP_RESTRICT

References ACL_DAT, ACL_MODECHG_ADD, ACL_NUM, aclcopy(), aclupdate(), DROP_RESTRICT, fb(), i, and pfree().

Referenced by get_user_default_acl().

◆ aclnewowner()

Acl * aclnewowner ( const Acl old_acl,
Oid  oldOwnerId,
Oid  newOwnerId 
)

Definition at line 1132 of file acl.c.

1133{
1134 Acl *new_acl;
1140 bool newpresent = false;
1141 int dst,
1142 src,
1143 targ,
1144 num;
1145
1147
1148 /*
1149 * Make a copy of the given ACL, substituting new owner ID for old
1150 * wherever it appears as either grantor or grantee. Also note if the new
1151 * owner ID is already present.
1152 */
1153 num = ACL_NUM(old_acl);
1155 new_acl = allocacl(num);
1157 memcpy(new_aip, old_aip, num * sizeof(AclItem));
1158 for (dst = 0, dst_aip = new_aip; dst < num; dst++, dst_aip++)
1159 {
1160 if (dst_aip->ai_grantor == oldOwnerId)
1161 dst_aip->ai_grantor = newOwnerId;
1162 else if (dst_aip->ai_grantor == newOwnerId)
1163 newpresent = true;
1164 if (dst_aip->ai_grantee == oldOwnerId)
1165 dst_aip->ai_grantee = newOwnerId;
1166 else if (dst_aip->ai_grantee == newOwnerId)
1167 newpresent = true;
1168 }
1169
1170 /*
1171 * If the old ACL contained any references to the new owner, then we may
1172 * now have generated an ACL containing duplicate entries. Find them and
1173 * merge them so that there are not duplicates. (This is relatively
1174 * expensive since we use a stupid O(N^2) algorithm, but it's unlikely to
1175 * be the normal case.)
1176 *
1177 * To simplify deletion of duplicate entries, we temporarily leave them in
1178 * the array but set their privilege masks to zero; when we reach such an
1179 * entry it's just skipped. (Thus, a side effect of this code will be to
1180 * remove privilege-free entries, should there be any in the input.) dst
1181 * is the next output slot, targ is the currently considered input slot
1182 * (always >= dst), and src scans entries to the right of targ looking for
1183 * duplicates. Once an entry has been emitted to dst it is known
1184 * duplicate-free and need not be considered anymore.
1185 */
1186 if (newpresent)
1187 {
1188 dst = 0;
1189 for (targ = 0, targ_aip = new_aip; targ < num; targ++, targ_aip++)
1190 {
1191 /* ignore if deleted in an earlier pass */
1193 continue;
1194 /* find and merge any duplicates */
1195 for (src = targ + 1, src_aip = targ_aip + 1; src < num;
1196 src++, src_aip++)
1197 {
1199 continue;
1201 {
1205 /* mark the duplicate deleted */
1207 }
1208 }
1209 /* and emit to output */
1210 new_aip[dst] = *targ_aip;
1211 dst++;
1212 }
1213 /* Adjust array size to be 'dst' items */
1214 ARR_DIMS(new_acl)[0] = dst;
1216 }
1217
1218 return new_acl;
1219}
static bool aclitem_match(const AclItem *a1, const AclItem *a2)
Definition acl.c:726
#define ACL_N_SIZE(N)
Definition acl.h:110
#define ACLITEM_SET_RIGHTS(item, rights)
Definition acl.h:79
#define ARR_DIMS(a)
Definition array.h:294
static void SET_VARSIZE(void *PTR, Size len)
Definition varatt.h:432

References ACL_DAT, ACL_N_SIZE, ACL_NO_RIGHTS, ACL_NUM, ACLITEM_GET_RIGHTS, aclitem_match(), ACLITEM_SET_RIGHTS, allocacl(), ARR_DIMS, check_acl(), fb(), and SET_VARSIZE().

Referenced by AlterDatabaseOwner(), AlterForeignDataWrapperOwner_internal(), AlterForeignServerOwner_internal(), AlterObjectOwner_internal(), AlterSchemaOwner_internal(), AlterTypeOwnerInternal(), ATExecChangeOwner(), change_owner_fix_column_acls(), and ReplaceRoleInInitPriv().

◆ aclparse()

static const char * aclparse ( const char s,
AclItem aip,
Node escontext 
)
static

Definition at line 278 of file acl.c.

279{
281 goption,
282 read;
283 char name[NAMEDATALEN];
284 char name2[NAMEDATALEN];
285
286 Assert(s && aip);
287
288 s = getid(s, name, escontext);
289 if (s == NULL)
290 return NULL;
291 if (*s != '=')
292 {
293 /* we just read a keyword, not a name */
294 if (strcmp(name, "group") != 0 && strcmp(name, "user") != 0)
295 ereturn(escontext, NULL,
297 errmsg("unrecognized key word: \"%s\"", name),
298 errhint("ACL key word must be \"group\" or \"user\".")));
299 /* move s to the name beyond the keyword */
300 s = getid(s, name, escontext);
301 if (s == NULL)
302 return NULL;
303 if (name[0] == '\0')
304 ereturn(escontext, NULL,
306 errmsg("missing name"),
307 errhint("A name must follow the \"group\" or \"user\" key word.")));
308 }
309
310 if (*s != '=')
311 ereturn(escontext, NULL,
313 errmsg("missing \"=\" sign")));
314
316
317 for (++s, read = 0; isalpha((unsigned char) *s) || *s == '*'; s++)
318 {
319 switch (*s)
320 {
321 case '*':
322 goption |= read;
323 break;
324 case ACL_INSERT_CHR:
326 break;
327 case ACL_SELECT_CHR:
329 break;
330 case ACL_UPDATE_CHR:
332 break;
333 case ACL_DELETE_CHR:
335 break;
336 case ACL_TRUNCATE_CHR:
338 break;
341 break;
342 case ACL_TRIGGER_CHR:
344 break;
345 case ACL_EXECUTE_CHR:
347 break;
348 case ACL_USAGE_CHR:
349 read = ACL_USAGE;
350 break;
351 case ACL_CREATE_CHR:
353 break;
356 break;
357 case ACL_CONNECT_CHR:
359 break;
360 case ACL_SET_CHR:
361 read = ACL_SET;
362 break;
365 break;
366 case ACL_MAINTAIN_CHR:
368 break;
369 default:
370 ereturn(escontext, NULL,
372 errmsg("invalid mode character: must be one of \"%s\"",
374 }
375
376 privs |= read;
377 }
378
379 if (name[0] == '\0')
380 aip->ai_grantee = ACL_ID_PUBLIC;
381 else
382 {
384 aip->ai_grantee = boot_get_role_oid(name);
385 else
386 aip->ai_grantee = get_role_oid(name, true);
387 if (!OidIsValid(aip->ai_grantee))
388 ereturn(escontext, NULL,
390 errmsg("role \"%s\" does not exist", name)));
391 }
392
393 /*
394 * XXX Allow a degree of backward compatibility by defaulting the grantor
395 * to the superuser. We condone that practice in the catalog .dat files
396 * (i.e., in bootstrap mode) for brevity; otherwise, issue a warning.
397 */
398 if (*s == '/')
399 {
400 s = getid(s + 1, name2, escontext);
401 if (s == NULL)
402 return NULL;
403 if (name2[0] == '\0')
404 ereturn(escontext, NULL,
406 errmsg("a name must follow the \"/\" sign")));
408 aip->ai_grantor = boot_get_role_oid(name2);
409 else
410 aip->ai_grantor = get_role_oid(name2, true);
411 if (!OidIsValid(aip->ai_grantor))
412 ereturn(escontext, NULL,
414 errmsg("role \"%s\" does not exist", name2)));
415 }
416 else
417 {
418 aip->ai_grantor = BOOTSTRAP_SUPERUSERID;
422 errmsg("defaulting grantor to user ID %u",
424 }
425
427
428 return s;
429}
static const char * getid(const char *s, char *n, Node *escontext)
Definition acl.c:170
Oid get_role_oid(const char *rolname, bool missing_ok)
Definition acl.c:5566
#define ACL_CREATE_CHR
Definition acl.h:146
#define ACL_SET_CHR
Definition acl.h:149
#define ACL_REFERENCES_CHR
Definition acl.h:142
#define ACL_TRUNCATE_CHR
Definition acl.h:141
#define ACL_SELECT_CHR
Definition acl.h:138
#define ACL_EXECUTE_CHR
Definition acl.h:144
#define ACL_DELETE_CHR
Definition acl.h:140
#define ACL_INSERT_CHR
Definition acl.h:137
#define ACL_UPDATE_CHR
Definition acl.h:139
#define ACL_ALTER_SYSTEM_CHR
Definition acl.h:150
#define ACL_USAGE_CHR
Definition acl.h:145
#define ACL_CONNECT_CHR
Definition acl.h:148
#define ACL_TRIGGER_CHR
Definition acl.h:143
#define ACL_CREATE_TEMP_CHR
Definition acl.h:147
#define ACL_MAINTAIN_CHR
Definition acl.h:151
Oid boot_get_role_oid(const char *rolname)
Definition bootstrap.c:1086
#define Assert(condition)
Definition c.h:906
#define OidIsValid(objectId)
Definition c.h:821
int errhint(const char *fmt,...) pg_attribute_printf(1
#define WARNING
Definition elog.h:36
#define read(a, b, c)
Definition win32.h:13
#define IsBootstrapProcessingMode()
Definition miscadmin.h:477
#define ACL_SET
Definition parsenodes.h:88
#define ACL_DELETE
Definition parsenodes.h:79
#define ACL_MAINTAIN
Definition parsenodes.h:90
#define ACL_INSERT
Definition parsenodes.h:76
#define ACL_UPDATE
Definition parsenodes.h:78
#define ACL_ALTER_SYSTEM
Definition parsenodes.h:89
#define ACL_REFERENCES
Definition parsenodes.h:81
#define ACL_SELECT
Definition parsenodes.h:77
#define ACL_TRUNCATE
Definition parsenodes.h:80
#define ACL_CREATE
Definition parsenodes.h:85
#define ACL_TRIGGER
Definition parsenodes.h:82
const char * name

References ACL_ALL_RIGHTS_STR, ACL_ALTER_SYSTEM, ACL_ALTER_SYSTEM_CHR, ACL_CONNECT, ACL_CONNECT_CHR, ACL_CREATE, ACL_CREATE_CHR, ACL_CREATE_TEMP, ACL_CREATE_TEMP_CHR, ACL_DELETE, ACL_DELETE_CHR, ACL_EXECUTE, ACL_EXECUTE_CHR, ACL_ID_PUBLIC, ACL_INSERT, ACL_INSERT_CHR, ACL_MAINTAIN, ACL_MAINTAIN_CHR, ACL_NO_RIGHTS, ACL_REFERENCES, ACL_REFERENCES_CHR, ACL_SELECT, ACL_SELECT_CHR, ACL_SET, ACL_SET_CHR, ACL_TRIGGER, ACL_TRIGGER_CHR, ACL_TRUNCATE, ACL_TRUNCATE_CHR, ACL_UPDATE, ACL_UPDATE_CHR, ACL_USAGE, ACL_USAGE_CHR, ACLITEM_SET_PRIVS_GOPTIONS, Assert, boot_get_role_oid(), ereport, ereturn, errcode(), errhint(), errmsg, fb(), get_role_oid(), getid(), IsBootstrapProcessingMode, name, NAMEDATALEN, OidIsValid, read, and WARNING.

Referenced by aclitemin().

◆ aclremove()

Datum aclremove ( PG_FUNCTION_ARGS  )

Definition at line 1615 of file acl.c.

1616{
1617 ereport(ERROR,
1619 errmsg("aclremove is no longer supported")));
1620
1621 PG_RETURN_NULL(); /* keep compiler quiet */
1622}

References ereport, errcode(), errmsg, ERROR, fb(), and PG_RETURN_NULL.

◆ aclupdate()

Acl * aclupdate ( const Acl old_acl,
const AclItem mod_aip,
int  modechg,
Oid  ownerId,
DropBehavior  behavior 
)

Definition at line 1005 of file acl.c.

1007{
1008 Acl *new_acl = NULL;
1010 *new_aip = NULL;
1013 new_rights,
1015 int dst,
1016 num;
1017
1018 /* Caller probably already checked old_acl, but be safe */
1020
1021 /* If granting grant options, check for circularity */
1022 if (modechg != ACL_MODECHG_DEL &&
1025
1026 num = ACL_NUM(old_acl);
1028
1029 /*
1030 * Search the ACL for an existing entry for this grantee and grantor. If
1031 * one exists, just modify the entry in-place (well, in the same position,
1032 * since we actually return a copy); otherwise, insert the new entry at
1033 * the end.
1034 */
1035
1036 for (dst = 0; dst < num; ++dst)
1037 {
1039 {
1040 /* found a match, so modify existing item */
1041 new_acl = allocacl(num);
1044 break;
1045 }
1046 }
1047
1048 if (dst == num)
1049 {
1050 /* need to append a new item */
1051 new_acl = allocacl(num + 1);
1053 memcpy(new_aip, old_aip, num * sizeof(AclItem));
1054
1055 /* initialize the new entry with no permissions */
1056 new_aip[dst].ai_grantee = mod_aip->ai_grantee;
1057 new_aip[dst].ai_grantor = mod_aip->ai_grantor;
1060 num++; /* set num to the size of new_acl */
1061 }
1062
1065
1066 /* apply the specified permissions change */
1067 switch (modechg)
1068 {
1069 case ACL_MODECHG_ADD:
1072 break;
1073 case ACL_MODECHG_DEL:
1076 break;
1077 case ACL_MODECHG_EQL:
1080 break;
1081 }
1082
1085
1086 /*
1087 * If the adjusted entry has no permissions, delete it from the list.
1088 */
1090 {
1092 new_aip + dst + 1,
1093 (num - dst - 1) * sizeof(AclItem));
1094 /* Adjust array size to be 'num - 1' items */
1095 ARR_DIMS(new_acl)[0] = num - 1;
1096 SET_VARSIZE(new_acl, ACL_N_SIZE(num - 1));
1097 }
1098
1099 /*
1100 * Remove abandoned privileges (cascading revoke). Currently we can only
1101 * handle this when the grantee is not PUBLIC.
1102 */
1103 if ((old_goptions & ~new_goptions) != 0)
1104 {
1105 Assert(mod_aip->ai_grantee != ACL_ID_PUBLIC);
1106 new_acl = recursive_revoke(new_acl, mod_aip->ai_grantee,
1108 ownerId, behavior);
1109 }
1110
1111 return new_acl;
1112}
static Acl * recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs, Oid ownerId, DropBehavior behavior)
Definition acl.c:1315
static void check_circularity(const Acl *old_acl, const AclItem *mod_aip, Oid ownerId)
Definition acl.c:1235
#define ACL_SIZE(ACL)
Definition acl.h:111
#define ACL_MODECHG_DEL
Definition acl.h:130
#define ACL_MODECHG_EQL
Definition acl.h:131

References ACL_DAT, ACL_ID_PUBLIC, ACL_MODECHG_ADD, ACL_MODECHG_DEL, ACL_MODECHG_EQL, ACL_N_SIZE, ACL_NO_RIGHTS, ACL_NUM, ACL_SIZE, ACLITEM_GET_GOPTIONS, ACLITEM_GET_RIGHTS, aclitem_match(), ACLITEM_SET_PRIVS_GOPTIONS, ACLITEM_SET_RIGHTS, allocacl(), ARR_DIMS, Assert, check_acl(), check_circularity(), fb(), recursive_revoke(), and SET_VARSIZE().

Referenced by aclmerge(), check_circularity(), merge_acl_with_grant(), and recursive_revoke().

◆ allocacl()

static Acl * allocacl ( int  n)
static

Definition at line 439 of file acl.c.

440{
441 Acl *new_acl;
442 Size size;
443
444 if (n < 0)
445 elog(ERROR, "invalid size: %d", n);
446 size = ACL_N_SIZE(n);
447 new_acl = (Acl *) palloc0(size);
448 SET_VARSIZE(new_acl, size);
449 new_acl->ndim = 1;
450 new_acl->dataoffset = 0; /* we never put in any nulls */
451 new_acl->elemtype = ACLITEMOID;
452 ARR_LBOUND(new_acl)[0] = 1;
453 ARR_DIMS(new_acl)[0] = n;
454 return new_acl;
455}
#define ARR_LBOUND(a)
Definition array.h:296
size_t Size
Definition c.h:652
void * palloc0(Size size)
Definition mcxt.c:1417

References ACL_N_SIZE, ARR_DIMS, ARR_LBOUND, elog, ERROR, fb(), palloc0(), and SET_VARSIZE().

Referenced by aclconcat(), aclcopy(), acldefault(), aclnewowner(), aclupdate(), check_circularity(), and make_empty_acl().

◆ check_acl()

static void check_acl ( const Acl acl)
static

Definition at line 603 of file acl.c.

604{
605 if (ARR_ELEMTYPE(acl) != ACLITEMOID)
608 errmsg("ACL array contains wrong data type")));
609 if (ARR_NDIM(acl) != 1)
612 errmsg("ACL arrays must be one-dimensional")));
613 if (ARR_HASNULL(acl))
616 errmsg("ACL arrays must not contain null values")));
617}
#define ARR_NDIM(a)
Definition array.h:290
#define ARR_ELEMTYPE(a)
Definition array.h:292
#define ARR_HASNULL(a)
Definition array.h:291

References ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, ereport, errcode(), errmsg, ERROR, and fb().

Referenced by aclcontains(), aclexplode(), aclmask(), aclmask_direct(), aclmembers(), aclnewowner(), aclupdate(), check_circularity(), and recursive_revoke().

◆ check_can_set_role()

void check_can_set_role ( Oid  member,
Oid  role 
)

Definition at line 5355 of file acl.c.

5356{
5357 if (!member_can_set_role(member, role))
5358 ereport(ERROR,
5360 errmsg("must be able to SET ROLE \"%s\"",
5361 GetUserNameFromId(role, false))));
5362}
bool member_can_set_role(Oid member, Oid role)
Definition acl.c:5332
char * GetUserNameFromId(Oid roleid, bool noerr)
Definition miscinit.c:989

References ereport, errcode(), errmsg, ERROR, fb(), GetUserNameFromId(), and member_can_set_role().

Referenced by AlterDatabaseOwner(), AlterForeignServerOwner_internal(), AlterObjectOwner_internal(), AlterPublicationOwner_internal(), AlterSchemaOwner_internal(), AlterSubscriptionOwner_internal(), AlterTypeOwner(), ATExecChangeOwner(), createdb(), and CreateSchemaCommand().

◆ check_circularity()

static void check_circularity ( const Acl old_acl,
const AclItem mod_aip,
Oid  ownerId 
)
static

Definition at line 1235 of file acl.c.

1237{
1238 Acl *acl;
1239 AclItem *aip;
1240 int i,
1241 num;
1243
1245
1246 /*
1247 * For now, grant options can only be granted to roles, not PUBLIC.
1248 * Otherwise we'd have to work a bit harder here.
1249 */
1250 Assert(mod_aip->ai_grantee != ACL_ID_PUBLIC);
1251
1252 /* The owner always has grant options, no need to check */
1253 if (mod_aip->ai_grantor == ownerId)
1254 return;
1255
1256 /* Make a working copy */
1257 acl = allocacl(ACL_NUM(old_acl));
1259
1260 /* Zap all grant options of target grantee, plus what depends on 'em */
1262 num = ACL_NUM(acl);
1263 aip = ACL_DAT(acl);
1264 for (i = 0; i < num; i++)
1265 {
1266 if (aip[i].ai_grantee == mod_aip->ai_grantee &&
1268 {
1269 Acl *new_acl;
1270
1271 /* We'll actually zap ordinary privs too, but no matter */
1273 ownerId, DROP_CASCADE);
1274
1275 pfree(acl);
1276 acl = new_acl;
1277
1278 goto cc_restart;
1279 }
1280 }
1281
1282 /* Now we can compute grantor's independently-derived privileges */
1283 own_privs = aclmask(acl,
1284 mod_aip->ai_grantor,
1285 ownerId,
1287 ACLMASK_ALL);
1289
1290 if ((ACLITEM_GET_GOPTIONS(*mod_aip) & ~own_privs) != 0)
1291 ereport(ERROR,
1293 errmsg("grant options cannot be granted back to your own grantor")));
1294
1295 pfree(acl);
1296}
AclMode aclmask(const Acl *acl, Oid roleid, Oid ownerId, AclMode mask, AclMaskHow how)
Definition acl.c:1401
#define ACL_OPTION_TO_PRIVS(privs)
Definition acl.h:71
#define ACL_GRANT_OPTION_FOR(privs)
Definition acl.h:70
@ DROP_CASCADE

References ACL_DAT, ACL_GRANT_OPTION_FOR, ACL_ID_PUBLIC, ACL_MODECHG_DEL, ACL_NO_RIGHTS, ACL_NUM, ACL_OPTION_TO_PRIVS, ACL_SIZE, ACLITEM_GET_GOPTIONS, aclmask(), ACLMASK_ALL, aclupdate(), allocacl(), Assert, check_acl(), DROP_CASCADE, ereport, errcode(), errmsg, ERROR, fb(), i, and pfree().

Referenced by aclupdate().

◆ check_rolespec_name()

void check_rolespec_name ( const RoleSpec role,
const char detail_msg 
)

Definition at line 5707 of file acl.c.

5708{
5709 if (!role)
5710 return;
5711
5712 if (role->roletype != ROLESPEC_CSTRING)
5713 return;
5714
5715 if (IsReservedName(role->rolename))
5716 {
5717 if (detail_msg)
5718 ereport(ERROR,
5720 errmsg("role name \"%s\" is reserved",
5721 role->rolename),
5723 else
5724 ereport(ERROR,
5726 errmsg("role name \"%s\" is reserved",
5727 role->rolename)));
5728 }
5729}
bool IsReservedName(const char *name)
Definition catalog.c:278
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
@ ROLESPEC_CSTRING
Definition parsenodes.h:419
RoleSpecType roletype
Definition parsenodes.h:429
char * rolename
Definition parsenodes.h:430

References ereport, errcode(), errdetail_internal(), errmsg, ERROR, fb(), IsReservedName(), RoleSpec::rolename, ROLESPEC_CSTRING, and RoleSpec::roletype.

Referenced by AlterRole(), and AlterRoleSet().

◆ column_privilege_check()

static int column_privilege_check ( Oid  tableoid,
AttrNumber  attnum,
Oid  roleid,
AclMode  mode 
)
static

Definition at line 2548 of file acl.c.

2550{
2552 bool is_missing = false;
2553
2554 /*
2555 * If convert_column_name failed, we can just return -1 immediately.
2556 */
2558 return -1;
2559
2560 /*
2561 * Check for column-level privileges first. This serves in part as a check
2562 * on whether the column even exists, so we need to do it before checking
2563 * table-level privilege.
2564 */
2565 aclresult = pg_attribute_aclcheck_ext(tableoid, attnum, roleid,
2566 mode, &is_missing);
2567 if (aclresult == ACLCHECK_OK)
2568 return 1;
2569 else if (is_missing)
2570 return -1;
2571
2572 /* Next check if we have the privilege at the table level */
2573 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
2574 if (aclresult == ACLCHECK_OK)
2575 return 1;
2576 else if (is_missing)
2577 return -1;
2578 else
2579 return 0;
2580}
AclResult
Definition acl.h:182
@ ACLCHECK_OK
Definition acl.h:183
AclResult pg_class_aclcheck_ext(Oid table_oid, Oid roleid, AclMode mode, bool *is_missing)
Definition aclchk.c:4067
AclResult pg_attribute_aclcheck_ext(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode, bool *is_missing)
Definition aclchk.c:3898
#define InvalidAttrNumber
Definition attnum.h:23
int16 attnum
static PgChecksumMode mode

References ACLCHECK_OK, attnum, fb(), InvalidAttrNumber, mode, pg_attribute_aclcheck_ext(), and pg_class_aclcheck_ext().

Referenced by has_column_privilege_id_attnum(), has_column_privilege_id_id_attnum(), has_column_privilege_id_id_name(), has_column_privilege_id_name(), has_column_privilege_id_name_attnum(), has_column_privilege_id_name_name(), has_column_privilege_name_attnum(), has_column_privilege_name_id_attnum(), has_column_privilege_name_id_name(), has_column_privilege_name_name(), has_column_privilege_name_name_attnum(), and has_column_privilege_name_name_name().

◆ convert_aclright_to_string()

static const char * convert_aclright_to_string ( int  aclright)
static

Definition at line 1747 of file acl.c.

1748{
1749 switch (aclright)
1750 {
1751 case ACL_INSERT:
1752 return "INSERT";
1753 case ACL_SELECT:
1754 return "SELECT";
1755 case ACL_UPDATE:
1756 return "UPDATE";
1757 case ACL_DELETE:
1758 return "DELETE";
1759 case ACL_TRUNCATE:
1760 return "TRUNCATE";
1761 case ACL_REFERENCES:
1762 return "REFERENCES";
1763 case ACL_TRIGGER:
1764 return "TRIGGER";
1765 case ACL_EXECUTE:
1766 return "EXECUTE";
1767 case ACL_USAGE:
1768 return "USAGE";
1769 case ACL_CREATE:
1770 return "CREATE";
1771 case ACL_CREATE_TEMP:
1772 return "TEMPORARY";
1773 case ACL_CONNECT:
1774 return "CONNECT";
1775 case ACL_SET:
1776 return "SET";
1777 case ACL_ALTER_SYSTEM:
1778 return "ALTER SYSTEM";
1779 case ACL_MAINTAIN:
1780 return "MAINTAIN";
1781 default:
1782 elog(ERROR, "unrecognized aclright: %d", aclright);
1783 return NULL;
1784 }
1785}

References ACL_ALTER_SYSTEM, ACL_CONNECT, ACL_CREATE, ACL_CREATE_TEMP, ACL_DELETE, ACL_EXECUTE, ACL_INSERT, ACL_MAINTAIN, ACL_REFERENCES, ACL_SELECT, ACL_SET, ACL_TRIGGER, ACL_TRUNCATE, ACL_UPDATE, ACL_USAGE, elog, ERROR, and fb().

Referenced by aclexplode().

◆ convert_any_priv_string()

static AclMode convert_any_priv_string ( text priv_type_text,
const priv_map privileges 
)
static

Definition at line 1699 of file acl.c.

1701{
1702 AclMode result = 0;
1704 char *chunk;
1705 char *next_chunk;
1706
1707 /* We rely on priv_type being a private, modifiable string */
1709 {
1710 int chunk_len;
1711 const priv_map *this_priv;
1712
1713 /* Split string at commas */
1714 next_chunk = strchr(chunk, ',');
1715 if (next_chunk)
1716 *next_chunk++ = '\0';
1717
1718 /* Drop leading/trailing whitespace in this chunk */
1719 while (*chunk && isspace((unsigned char) *chunk))
1720 chunk++;
1722 while (chunk_len > 0 && isspace((unsigned char) chunk[chunk_len - 1]))
1723 chunk_len--;
1724 chunk[chunk_len] = '\0';
1725
1726 /* Match to the privileges list */
1727 for (this_priv = privileges; this_priv->name; this_priv++)
1728 {
1729 if (pg_strcasecmp(this_priv->name, chunk) == 0)
1730 {
1731 result |= this_priv->value;
1732 break;
1733 }
1734 }
1735 if (!this_priv->name)
1736 ereport(ERROR,
1738 errmsg("unrecognized privilege type: \"%s\"", chunk)));
1739 }
1740
1742 return result;
1743}
int pg_strcasecmp(const char *s1, const char *s2)
Definition acl.c:56
char * text_to_cstring(const text *t)
Definition varlena.c:215

References ereport, errcode(), errmsg, ERROR, fb(), priv_map::name, pfree(), pg_strcasecmp(), and text_to_cstring().

Referenced by convert_column_priv_string(), convert_database_priv_string(), convert_foreign_data_wrapper_priv_string(), convert_function_priv_string(), convert_language_priv_string(), convert_largeobject_priv_string(), convert_parameter_priv_string(), convert_role_priv_string(), convert_schema_priv_string(), convert_sequence_priv_string(), convert_server_priv_string(), convert_table_priv_string(), convert_tablespace_priv_string(), convert_type_priv_string(), and makeaclitem().

◆ convert_column_name()

static AttrNumber convert_column_name ( Oid  tableoid,
text column 
)
static

Definition at line 2908 of file acl.c.

2909{
2910 char *colname;
2913
2914 colname = text_to_cstring(column);
2915
2916 /*
2917 * We don't use get_attnum() here because it will report that dropped
2918 * columns don't exist. We need to treat dropped columns differently from
2919 * nonexistent columns.
2920 */
2922 ObjectIdGetDatum(tableoid),
2923 CStringGetDatum(colname));
2925 {
2927
2929 /* We want to return NULL for dropped columns */
2930 if (attributeForm->attisdropped)
2932 else
2933 attnum = attributeForm->attnum;
2935 }
2936 else
2937 {
2938 char *tablename = get_rel_name(tableoid);
2939
2940 /*
2941 * If the table OID is bogus, or it's just been dropped, we'll get
2942 * NULL back. In such cases we want has_column_privilege to return
2943 * NULL too, so just return InvalidAttrNumber.
2944 */
2945 if (tablename != NULL)
2946 {
2947 /* tableoid exists, colname does not, so throw error */
2948 ereport(ERROR,
2950 errmsg("column \"%s\" of relation \"%s\" does not exist",
2951 colname, tablename)));
2952 }
2953 /* tableoid doesn't exist, so act like attisdropped case */
2955 }
2956
2957 pfree(colname);
2958 return attnum;
2959}
char * get_rel_name(Oid relid)
Definition lsyscache.c:2078
FormData_pg_attribute * Form_pg_attribute
static Datum CStringGetDatum(const char *X)
Definition postgres.h:380
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
Definition syscache.c:230

References attnum, CStringGetDatum(), ereport, errcode(), errmsg, ERROR, fb(), get_rel_name(), GETSTRUCT(), HeapTupleIsValid, InvalidAttrNumber, ObjectIdGetDatum(), pfree(), ReleaseSysCache(), SearchSysCache2(), and text_to_cstring().

Referenced by has_column_privilege_id_id_name(), has_column_privilege_id_name(), has_column_privilege_id_name_name(), has_column_privilege_name_id_name(), has_column_privilege_name_name(), and has_column_privilege_name_name_name().

◆ convert_column_priv_string()

static AclMode convert_column_priv_string ( text priv_type_text)
static

Definition at line 2966 of file acl.c.

2967{
2968 static const priv_map column_priv_map[] = {
2969 {"SELECT", ACL_SELECT},
2970 {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)},
2971 {"INSERT", ACL_INSERT},
2972 {"INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT)},
2973 {"UPDATE", ACL_UPDATE},
2974 {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)},
2975 {"REFERENCES", ACL_REFERENCES},
2976 {"REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES)},
2977 {NULL, 0}
2978 };
2979
2981}
static AclMode convert_any_priv_string(text *priv_type_text, const priv_map *privileges)
Definition acl.c:1699

References ACL_GRANT_OPTION_FOR, ACL_INSERT, ACL_REFERENCES, ACL_SELECT, ACL_UPDATE, convert_any_priv_string(), and fb().

Referenced by has_any_column_privilege_id(), has_any_column_privilege_id_id(), has_any_column_privilege_id_name(), has_any_column_privilege_name(), has_any_column_privilege_name_id(), has_any_column_privilege_name_name(), has_column_privilege_id_attnum(), has_column_privilege_id_id_attnum(), has_column_privilege_id_id_name(), has_column_privilege_id_name(), has_column_privilege_id_name_attnum(), has_column_privilege_id_name_name(), has_column_privilege_name_attnum(), has_column_privilege_name_id_attnum(), has_column_privilege_name_id_name(), has_column_privilege_name_name(), has_column_privilege_name_name_attnum(), and has_column_privilege_name_name_name().

◆ convert_database_name()

static Oid convert_database_name ( text databasename)
static

Definition at line 3160 of file acl.c.

3161{
3163
3164 return get_database_oid(dbname, false);
3165}
Oid get_database_oid(const char *dbname, bool missing_ok)
char * dbname
Definition streamutil.c:49

References dbname, fb(), get_database_oid(), and text_to_cstring().

Referenced by has_database_privilege_id_name(), has_database_privilege_name(), and has_database_privilege_name_name().

◆ convert_database_priv_string()

static AclMode convert_database_priv_string ( text priv_type_text)
static

Definition at line 3172 of file acl.c.

3173{
3174 static const priv_map database_priv_map[] = {
3175 {"CREATE", ACL_CREATE},
3176 {"CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
3177 {"TEMPORARY", ACL_CREATE_TEMP},
3178 {"TEMPORARY WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP)},
3179 {"TEMP", ACL_CREATE_TEMP},
3180 {"TEMP WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE_TEMP)},
3181 {"CONNECT", ACL_CONNECT},
3182 {"CONNECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CONNECT)},
3183 {NULL, 0}
3184 };
3185
3187}

References ACL_CONNECT, ACL_CREATE, ACL_CREATE_TEMP, ACL_GRANT_OPTION_FOR, convert_any_priv_string(), and fb().

Referenced by has_database_privilege_id(), has_database_privilege_id_id(), has_database_privilege_id_name(), has_database_privilege_name(), has_database_privilege_name_id(), and has_database_privilege_name_name().

◆ convert_foreign_data_wrapper_name()

static Oid convert_foreign_data_wrapper_name ( text fdwname)
static

Definition at line 3366 of file acl.c.

3367{
3368 char *fdwstr = text_to_cstring(fdwname);
3369
3370 return get_foreign_data_wrapper_oid(fdwstr, false);
3371}
Oid get_foreign_data_wrapper_oid(const char *fdwname, bool missing_ok)
Definition foreign.c:768

References fb(), get_foreign_data_wrapper_oid(), and text_to_cstring().

Referenced by has_foreign_data_wrapper_privilege_id_name(), has_foreign_data_wrapper_privilege_name(), and has_foreign_data_wrapper_privilege_name_name().

◆ convert_foreign_data_wrapper_priv_string()

◆ convert_function_name()

static Oid convert_function_name ( text functionname)
static

Definition at line 3566 of file acl.c.

3567{
3569 Oid oid;
3570
3573
3574 if (!OidIsValid(oid))
3575 ereport(ERROR,
3577 errmsg("function \"%s\" does not exist", funcname)));
3578
3579 return oid;
3580}
#define DirectFunctionCall1(func, arg1)
Definition fmgr.h:684
#define funcname
static Oid DatumGetObjectId(Datum X)
Definition postgres.h:252
Datum regprocedurein(PG_FUNCTION_ARGS)
Definition regproc.c:229

References CStringGetDatum(), DatumGetObjectId(), DirectFunctionCall1, ereport, errcode(), errmsg, ERROR, fb(), funcname, OidIsValid, regprocedurein(), and text_to_cstring().

Referenced by has_function_privilege_id_name(), has_function_privilege_name(), and has_function_privilege_name_name().

◆ convert_function_priv_string()

static AclMode convert_function_priv_string ( text priv_type_text)
static

◆ convert_language_name()

static Oid convert_language_name ( text languagename)
static

Definition at line 3775 of file acl.c.

3776{
3777 char *langname = text_to_cstring(languagename);
3778
3779 return get_language_oid(langname, false);
3780}
Oid get_language_oid(const char *langname, bool missing_ok)
Definition proclang.c:227

References fb(), get_language_oid(), and text_to_cstring().

Referenced by has_language_privilege_id_name(), has_language_privilege_name(), and has_language_privilege_name_name().

◆ convert_language_priv_string()

static AclMode convert_language_priv_string ( text priv_type_text)
static

◆ convert_largeobject_priv_string()

static AclMode convert_largeobject_priv_string ( text priv_type_text)
static

Definition at line 4822 of file acl.c.

4823{
4824 static const priv_map largeobject_priv_map[] = {
4825 {"SELECT", ACL_SELECT},
4826 {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)},
4827 {"UPDATE", ACL_UPDATE},
4828 {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)},
4829 {NULL, 0}
4830 };
4831
4833}

References ACL_GRANT_OPTION_FOR, ACL_SELECT, ACL_UPDATE, convert_any_priv_string(), and fb().

Referenced by has_largeobject_privilege_id(), has_largeobject_privilege_id_id(), and has_largeobject_privilege_name_id().

◆ convert_parameter_priv_string()

static AclMode convert_parameter_priv_string ( text priv_text)
static

Definition at line 4686 of file acl.c.

4687{
4688 static const priv_map parameter_priv_map[] = {
4689 {"SET", ACL_SET},
4690 {"SET WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SET)},
4691 {"ALTER SYSTEM", ACL_ALTER_SYSTEM},
4692 {"ALTER SYSTEM WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_ALTER_SYSTEM)},
4693 {NULL, 0}
4694 };
4695
4697}

References ACL_ALTER_SYSTEM, ACL_GRANT_OPTION_FOR, ACL_SET, convert_any_priv_string(), and fb().

Referenced by has_parameter_privilege_id_name(), has_parameter_privilege_name(), and has_parameter_privilege_name_name().

◆ convert_role_priv_string()

static AclMode convert_role_priv_string ( text priv_type_text)
static

Definition at line 5000 of file acl.c.

5001{
5002 static const priv_map role_priv_map[] = {
5003 {"USAGE", ACL_USAGE},
5004 {"MEMBER", ACL_CREATE},
5005 {"SET", ACL_SET},
5006 {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5007 {"USAGE WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5008 {"MEMBER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5009 {"MEMBER WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5010 {"SET WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5011 {"SET WITH ADMIN OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
5012 {NULL, 0}
5013 };
5014
5016}

References ACL_CREATE, ACL_GRANT_OPTION_FOR, ACL_SET, ACL_USAGE, convert_any_priv_string(), and fb().

Referenced by pg_has_role_id(), pg_has_role_id_id(), pg_has_role_id_name(), pg_has_role_name(), pg_has_role_name_id(), and pg_has_role_name_name().

◆ convert_schema_name()

static Oid convert_schema_name ( text schemaname)
static

Definition at line 3975 of file acl.c.

3976{
3977 char *nspname = text_to_cstring(schemaname);
3978
3979 return get_namespace_oid(nspname, false);
3980}
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition namespace.c:3607

References get_namespace_oid(), and text_to_cstring().

Referenced by has_schema_privilege_id_name(), has_schema_privilege_name(), and has_schema_privilege_name_name().

◆ convert_schema_priv_string()

static AclMode convert_schema_priv_string ( text priv_type_text)
static

Definition at line 3987 of file acl.c.

3988{
3989 static const priv_map schema_priv_map[] = {
3990 {"CREATE", ACL_CREATE},
3991 {"CREATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_CREATE)},
3992 {"USAGE", ACL_USAGE},
3993 {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)},
3994 {NULL, 0}
3995 };
3996
3998}

References ACL_CREATE, ACL_GRANT_OPTION_FOR, ACL_USAGE, convert_any_priv_string(), and fb().

Referenced by has_schema_privilege_id(), has_schema_privilege_id_id(), has_schema_privilege_id_name(), has_schema_privilege_name(), has_schema_privilege_name_id(), and has_schema_privilege_name_name().

◆ convert_sequence_priv_string()

static AclMode convert_sequence_priv_string ( text priv_type_text)
static

Definition at line 2311 of file acl.c.

2312{
2313 static const priv_map sequence_priv_map[] = {
2314 {"USAGE", ACL_USAGE},
2315 {"USAGE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_USAGE)},
2316 {"SELECT", ACL_SELECT},
2317 {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)},
2318 {"UPDATE", ACL_UPDATE},
2319 {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)},
2320 {NULL, 0}
2321 };
2322
2324}

References ACL_GRANT_OPTION_FOR, ACL_SELECT, ACL_UPDATE, ACL_USAGE, convert_any_priv_string(), and fb().

Referenced by has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), and has_sequence_privilege_name_name().

◆ convert_server_name()

static Oid convert_server_name ( text servername)
static

Definition at line 4177 of file acl.c.

4178{
4179 char *serverstr = text_to_cstring(servername);
4180
4181 return get_foreign_server_oid(serverstr, false);
4182}
Oid get_foreign_server_oid(const char *servername, bool missing_ok)
Definition foreign.c:791

References fb(), get_foreign_server_oid(), and text_to_cstring().

Referenced by has_server_privilege_id_name(), has_server_privilege_name(), and has_server_privilege_name_name().

◆ convert_server_priv_string()

static AclMode convert_server_priv_string ( text priv_type_text)
static

◆ convert_table_name()

◆ convert_table_priv_string()

static AclMode convert_table_priv_string ( text priv_type_text)
static

Definition at line 2076 of file acl.c.

2077{
2078 static const priv_map table_priv_map[] = {
2079 {"SELECT", ACL_SELECT},
2080 {"SELECT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_SELECT)},
2081 {"INSERT", ACL_INSERT},
2082 {"INSERT WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_INSERT)},
2083 {"UPDATE", ACL_UPDATE},
2084 {"UPDATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_UPDATE)},
2085 {"DELETE", ACL_DELETE},
2086 {"DELETE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_DELETE)},
2087 {"TRUNCATE", ACL_TRUNCATE},
2088 {"TRUNCATE WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRUNCATE)},
2089 {"REFERENCES", ACL_REFERENCES},
2090 {"REFERENCES WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_REFERENCES)},
2091 {"TRIGGER", ACL_TRIGGER},
2092 {"TRIGGER WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_TRIGGER)},
2093 {"MAINTAIN", ACL_MAINTAIN},
2094 {"MAINTAIN WITH GRANT OPTION", ACL_GRANT_OPTION_FOR(ACL_MAINTAIN)},
2095 {NULL, 0}
2096 };
2097
2099}

References ACL_DELETE, ACL_GRANT_OPTION_FOR, ACL_INSERT, ACL_MAINTAIN, ACL_REFERENCES, ACL_SELECT, ACL_TRIGGER, ACL_TRUNCATE, ACL_UPDATE, convert_any_priv_string(), and fb().

Referenced by has_table_privilege_id(), has_table_privilege_id_id(), has_table_privilege_id_name(), has_table_privilege_name(), has_table_privilege_name_id(), and has_table_privilege_name_name().

◆ convert_tablespace_name()

static Oid convert_tablespace_name ( text tablespacename)
static

Definition at line 4377 of file acl.c.

4378{
4379 char *spcname = text_to_cstring(tablespacename);
4380
4381 return get_tablespace_oid(spcname, false);
4382}
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)

References fb(), get_tablespace_oid(), and text_to_cstring().

Referenced by has_tablespace_privilege_id_name(), has_tablespace_privilege_name(), and has_tablespace_privilege_name_name().

◆ convert_tablespace_priv_string()

static AclMode convert_tablespace_priv_string ( text priv_type_text)
static

◆ convert_type_name()

static Oid convert_type_name ( text typename)
static

Definition at line 4576 of file acl.c.

4577{
4578 char *typname = text_to_cstring(typename);
4579 Oid oid;
4580
4583
4584 if (!OidIsValid(oid))
4585 ereport(ERROR,
4587 errmsg("type \"%s\" does not exist", typname)));
4588
4589 return oid;
4590}
NameData typname
Definition pg_type.h:43
Datum regtypein(PG_FUNCTION_ARGS)
Definition regproc.c:1184

References CStringGetDatum(), DatumGetObjectId(), DirectFunctionCall1, ereport, errcode(), errmsg, ERROR, fb(), OidIsValid, regtypein(), text_to_cstring(), and typname.

Referenced by has_type_privilege_id_name(), has_type_privilege_name(), and has_type_privilege_name_name().

◆ convert_type_priv_string()

static AclMode convert_type_priv_string ( text priv_type_text)
static

◆ get_role_oid()

Oid get_role_oid ( const char rolname,
bool  missing_ok 
)

◆ get_role_oid_or_public()

◆ get_rolespec_name()

char * get_rolespec_name ( const RoleSpec role)

Definition at line 5685 of file acl.c.

5686{
5687 HeapTuple tp;
5689 char *rolename;
5690
5691 tp = get_rolespec_tuple(role);
5693 rolename = pstrdup(NameStr(authForm->rolname));
5694 ReleaseSysCache(tp);
5695
5696 return rolename;
5697}
HeapTuple get_rolespec_tuple(const RoleSpec *role)
Definition acl.c:5639
char * pstrdup(const char *in)
Definition mcxt.c:1781

References fb(), Form_pg_authid, get_rolespec_tuple(), GETSTRUCT(), NameStr, pstrdup(), and ReleaseSysCache().

Referenced by AddRoleMems(), and DelRoleMems().

◆ get_rolespec_oid()

Oid get_rolespec_oid ( const RoleSpec role,
bool  missing_ok 
)

Definition at line 5600 of file acl.c.

5601{
5602 Oid oid;
5603
5604 switch (role->roletype)
5605 {
5606 case ROLESPEC_CSTRING:
5607 Assert(role->rolename);
5608 oid = get_role_oid(role->rolename, missing_ok);
5609 break;
5610
5613 oid = GetUserId();
5614 break;
5615
5617 oid = GetSessionUserId();
5618 break;
5619
5620 case ROLESPEC_PUBLIC:
5621 ereport(ERROR,
5623 errmsg("role \"%s\" does not exist", "public")));
5624 oid = InvalidOid; /* make compiler happy */
5625 break;
5626
5627 default:
5628 elog(ERROR, "unexpected role type %d", role->roletype);
5629 }
5630
5631 return oid;
5632}
Oid GetUserId(void)
Definition miscinit.c:470
Oid GetSessionUserId(void)
Definition miscinit.c:509
@ ROLESPEC_CURRENT_USER
Definition parsenodes.h:421
@ ROLESPEC_SESSION_USER
Definition parsenodes.h:422
@ ROLESPEC_CURRENT_ROLE
Definition parsenodes.h:420
@ ROLESPEC_PUBLIC
Definition parsenodes.h:423
#define InvalidOid

References Assert, elog, ereport, errcode(), errmsg, ERROR, fb(), get_role_oid(), GetSessionUserId(), GetUserId(), InvalidOid, RoleSpec::rolename, ROLESPEC_CSTRING, ROLESPEC_CURRENT_ROLE, ROLESPEC_CURRENT_USER, ROLESPEC_PUBLIC, ROLESPEC_SESSION_USER, and RoleSpec::roletype.

Referenced by AlterUserMapping(), ATExecCmd(), CreateSchemaCommand(), CreateTableSpace(), CreateUserMapping(), ExecAlterDefaultPrivilegesStmt(), ExecAlterOwnerStmt(), ExecuteGrantStmt(), GrantRole(), policy_role_list_to_array(), ReassignOwnedObjects(), RemoveUserMapping(), and roleSpecsToIds().

◆ get_rolespec_tuple()

HeapTuple get_rolespec_tuple ( const RoleSpec role)

Definition at line 5639 of file acl.c.

5640{
5641 HeapTuple tuple;
5642
5643 switch (role->roletype)
5644 {
5645 case ROLESPEC_CSTRING:
5646 Assert(role->rolename);
5648 if (!HeapTupleIsValid(tuple))
5649 ereport(ERROR,
5651 errmsg("role \"%s\" does not exist", role->rolename)));
5652 break;
5653
5657 if (!HeapTupleIsValid(tuple))
5658 elog(ERROR, "cache lookup failed for role %u", GetUserId());
5659 break;
5660
5663 if (!HeapTupleIsValid(tuple))
5664 elog(ERROR, "cache lookup failed for role %u", GetSessionUserId());
5665 break;
5666
5667 case ROLESPEC_PUBLIC:
5668 ereport(ERROR,
5670 errmsg("role \"%s\" does not exist", "public")));
5671 tuple = NULL; /* make compiler happy */
5672 break;
5673
5674 default:
5675 elog(ERROR, "unexpected role type %d", role->roletype);
5676 }
5677
5678 return tuple;
5679}

References Assert, CStringGetDatum(), elog, ereport, errcode(), errmsg, ERROR, fb(), GetSessionUserId(), GetUserId(), HeapTupleIsValid, ObjectIdGetDatum(), RoleSpec::rolename, ROLESPEC_CSTRING, ROLESPEC_CURRENT_ROLE, ROLESPEC_CURRENT_USER, ROLESPEC_PUBLIC, ROLESPEC_SESSION_USER, RoleSpec::roletype, and SearchSysCache1().

Referenced by AlterRole(), AlterRoleSet(), CreateRole(), and get_rolespec_name().

◆ getid()

static const char * getid ( const char s,
char n,
Node escontext 
)
static

Definition at line 170 of file acl.c.

171{
172 int len = 0;
173 bool in_quotes = false;
174
175 Assert(s && n);
176
177 while (isspace((unsigned char) *s))
178 s++;
179 for (;
180 *s != '\0' &&
181 (in_quotes || *s == '"' || is_safe_acl_char(*s, true));
182 s++)
183 {
184 if (*s == '"')
185 {
186 if (!in_quotes)
187 {
188 in_quotes = true;
189 continue;
190 }
191 /* safe to look at next char (could be '\0' though) */
192 if (*(s + 1) != '"')
193 {
194 in_quotes = false;
195 continue;
196 }
197 /* it's an escaped double quote; skip the escaping char */
198 s++;
199 }
200
201 /* Add the character to the string */
202 if (len >= NAMEDATALEN - 1)
203 ereturn(escontext, NULL,
205 errmsg("identifier too long"),
206 errdetail("Identifier must be less than %d characters.",
207 NAMEDATALEN)));
208
209 n[len++] = *s;
210 }
211 n[len] = '\0';
212 while (isspace((unsigned char) *s))
213 s++;
214 return s;
215}
static bool is_safe_acl_char(unsigned char c, bool is_getid)
Definition acl.c:147
int errdetail(const char *fmt,...) pg_attribute_printf(1
const void size_t len

References Assert, ereturn, errcode(), errdetail(), errmsg, fb(), is_safe_acl_char(), len, and NAMEDATALEN.

Referenced by aclparse().

◆ has_any_column_privilege_id()

Datum has_any_column_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 2437 of file acl.c.

2438{
2439 Oid tableoid = PG_GETARG_OID(0);
2441 Oid roleid;
2442 AclMode mode;
2444 bool is_missing = false;
2445
2446 roleid = GetUserId();
2448
2449 /* First check at table level, then examine each column if needed */
2450 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
2451 if (aclresult != ACLCHECK_OK)
2452 {
2453 if (is_missing)
2455 aclresult = pg_attribute_aclcheck_all_ext(tableoid, roleid, mode,
2457 if (is_missing)
2459 }
2460
2462}
static AclMode convert_column_priv_string(text *priv_type_text)
Definition acl.c:2966
@ ACLMASK_ANY
Definition acl.h:177
AclResult pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid, AclMode mode, AclMaskHow how, bool *is_missing)
Definition aclchk.c:3939
#define PG_GETARG_TEXT_PP(n)
Definition fmgr.h:310
Definition c.h:739

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), fb(), GetUserId(), mode, pg_attribute_aclcheck_all_ext(), pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_any_column_privilege_id_id()

Datum has_any_column_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 2497 of file acl.c.

2498{
2499 Oid roleid = PG_GETARG_OID(0);
2500 Oid tableoid = PG_GETARG_OID(1);
2502 AclMode mode;
2504 bool is_missing = false;
2505
2507
2508 /* First check at table level, then examine each column if needed */
2509 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
2510 if (aclresult != ACLCHECK_OK)
2511 {
2512 if (is_missing)
2514 aclresult = pg_attribute_aclcheck_all_ext(tableoid, roleid, mode,
2516 if (is_missing)
2518 }
2519
2521}

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), fb(), mode, pg_attribute_aclcheck_all_ext(), pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_any_column_privilege_id_name()

Datum has_any_column_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 2470 of file acl.c.

2471{
2472 Oid roleid = PG_GETARG_OID(0);
2473 text *tablename = PG_GETARG_TEXT_PP(1);
2475 Oid tableoid;
2476 AclMode mode;
2478
2479 tableoid = convert_table_name(tablename);
2481
2482 /* First check at table level, then examine each column if needed */
2483 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
2484 if (aclresult != ACLCHECK_OK)
2485 aclresult = pg_attribute_aclcheck_all(tableoid, roleid, mode,
2486 ACLMASK_ANY);
2487
2489}
static Oid convert_table_name(text *tablename)
Definition acl.c:2061
AclResult pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode, AclMaskHow how)
Definition aclchk.c:3928
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
Definition aclchk.c:4057

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), convert_table_name(), fb(), mode, pg_attribute_aclcheck_all(), pg_class_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_any_column_privilege_name()

Datum has_any_column_privilege_name ( PG_FUNCTION_ARGS  )

Definition at line 2374 of file acl.c.

2375{
2376 text *tablename = PG_GETARG_TEXT_PP(0);
2378 Oid roleid;
2379 Oid tableoid;
2380 AclMode mode;
2382
2383 roleid = GetUserId();
2384 tableoid = convert_table_name(tablename);
2386
2387 /* First check at table level, then examine each column if needed */
2388 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
2389 if (aclresult != ACLCHECK_OK)
2390 aclresult = pg_attribute_aclcheck_all(tableoid, roleid, mode,
2391 ACLMASK_ANY);
2392
2394}

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), convert_table_name(), fb(), GetUserId(), mode, pg_attribute_aclcheck_all(), pg_class_aclcheck(), PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_any_column_privilege_name_id()

Datum has_any_column_privilege_name_id ( PG_FUNCTION_ARGS  )

Definition at line 2402 of file acl.c.

2403{
2405 Oid tableoid = PG_GETARG_OID(1);
2407 Oid roleid;
2408 AclMode mode;
2410 bool is_missing = false;
2411
2414
2415 /* First check at table level, then examine each column if needed */
2416 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
2417 if (aclresult != ACLCHECK_OK)
2418 {
2419 if (is_missing)
2421 aclresult = pg_attribute_aclcheck_all_ext(tableoid, roleid, mode,
2423 if (is_missing)
2425 }
2426
2428}
Oid get_role_oid_or_public(const char *rolname)
Definition acl.c:5584
#define PG_GETARG_NAME(n)
Definition fmgr.h:279
static char * username
Definition initdb.c:153
Definition c.h:793

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), fb(), get_role_oid_or_public(), mode, NameStr, pg_attribute_aclcheck_all_ext(), pg_class_aclcheck_ext(), PG_GETARG_NAME, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, PG_RETURN_NULL, and username.

◆ has_any_column_privilege_name_name()

Datum has_any_column_privilege_name_name ( PG_FUNCTION_ARGS  )

Definition at line 2344 of file acl.c.

2345{
2346 Name rolename = PG_GETARG_NAME(0);
2347 text *tablename = PG_GETARG_TEXT_PP(1);
2349 Oid roleid;
2350 Oid tableoid;
2351 AclMode mode;
2353
2354 roleid = get_role_oid_or_public(NameStr(*rolename));
2355 tableoid = convert_table_name(tablename);
2357
2358 /* First check at table level, then examine each column if needed */
2359 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
2360 if (aclresult != ACLCHECK_OK)
2361 aclresult = pg_attribute_aclcheck_all(tableoid, roleid, mode,
2362 ACLMASK_ANY);
2363
2365}

References ACLCHECK_OK, ACLMASK_ANY, convert_column_priv_string(), convert_table_name(), fb(), get_role_oid_or_public(), mode, NameStr, pg_attribute_aclcheck_all(), pg_class_aclcheck(), PG_GETARG_NAME, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_column_privilege_id_attnum()

Datum has_column_privilege_id_attnum ( PG_FUNCTION_ARGS  )

Definition at line 2880 of file acl.c.

2881{
2882 Oid tableoid = PG_GETARG_OID(0);
2885 Oid roleid;
2886 AclMode mode;
2887 int privresult;
2888
2889 roleid = GetUserId();
2891
2892 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2893 if (privresult < 0)
2896}
static int column_privilege_check(Oid tableoid, AttrNumber attnum, Oid roleid, AclMode mode)
Definition acl.c:2548
#define PG_GETARG_INT16(n)
Definition fmgr.h:271

References column_privilege_check(), convert_column_priv_string(), fb(), GetUserId(), mode, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_id_id_attnum()

Datum has_column_privilege_id_id_attnum ( PG_FUNCTION_ARGS  )

◆ has_column_privilege_id_id_name()

Datum has_column_privilege_id_id_name ( PG_FUNCTION_ARGS  )

Definition at line 2748 of file acl.c.

2749{
2750 Oid roleid = PG_GETARG_OID(0);
2751 Oid tableoid = PG_GETARG_OID(1);
2755 AclMode mode;
2756 int privresult;
2757
2760
2761 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2762 if (privresult < 0)
2765}
static AttrNumber convert_column_name(Oid tableoid, text *column)
Definition acl.c:2908

References column_privilege_check(), convert_column_name(), convert_column_priv_string(), fb(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_id_name()

Datum has_column_privilege_id_name ( PG_FUNCTION_ARGS  )

◆ has_column_privilege_id_name_attnum()

Datum has_column_privilege_id_name_attnum ( PG_FUNCTION_ARGS  )

Definition at line 2723 of file acl.c.

2724{
2725 Oid roleid = PG_GETARG_OID(0);
2726 text *tablename = PG_GETARG_TEXT_PP(1);
2729 Oid tableoid;
2730 AclMode mode;
2731 int privresult;
2732
2733 tableoid = convert_table_name(tablename);
2735
2736 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2737 if (privresult < 0)
2740}

References column_privilege_check(), convert_column_priv_string(), convert_table_name(), fb(), mode, PG_GETARG_INT16, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_id_name_name()

Datum has_column_privilege_id_name_name ( PG_FUNCTION_ARGS  )

Definition at line 2696 of file acl.c.

2697{
2698 Oid roleid = PG_GETARG_OID(0);
2699 text *tablename = PG_GETARG_TEXT_PP(1);
2702 Oid tableoid;
2704 AclMode mode;
2705 int privresult;
2706
2707 tableoid = convert_table_name(tablename);
2710
2711 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2712 if (privresult < 0)
2715}

References column_privilege_check(), convert_column_name(), convert_column_priv_string(), convert_table_name(), fb(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_name_attnum()

Datum has_column_privilege_name_attnum ( PG_FUNCTION_ARGS  )

Definition at line 2826 of file acl.c.

2827{
2828 text *tablename = PG_GETARG_TEXT_PP(0);
2831 Oid roleid;
2832 Oid tableoid;
2833 AclMode mode;
2834 int privresult;
2835
2836 roleid = GetUserId();
2837 tableoid = convert_table_name(tablename);
2839
2840 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2841 if (privresult < 0)
2844}

References column_privilege_check(), convert_column_priv_string(), convert_table_name(), fb(), GetUserId(), mode, PG_GETARG_INT16, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_name_id_attnum()

◆ has_column_privilege_name_id_name()

◆ has_column_privilege_name_name()

Datum has_column_privilege_name_name ( PG_FUNCTION_ARGS  )

Definition at line 2797 of file acl.c.

2798{
2799 text *tablename = PG_GETARG_TEXT_PP(0);
2802 Oid roleid;
2803 Oid tableoid;
2805 AclMode mode;
2806 int privresult;
2807
2808 roleid = GetUserId();
2809 tableoid = convert_table_name(tablename);
2812
2813 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2814 if (privresult < 0)
2817}

References column_privilege_check(), convert_column_name(), convert_column_priv_string(), convert_table_name(), fb(), GetUserId(), mode, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_name_name_attnum()

Datum has_column_privilege_name_name_attnum ( PG_FUNCTION_ARGS  )

Definition at line 2617 of file acl.c.

2618{
2619 Name rolename = PG_GETARG_NAME(0);
2620 text *tablename = PG_GETARG_TEXT_PP(1);
2623 Oid roleid;
2624 Oid tableoid;
2625 AclMode mode;
2626 int privresult;
2627
2628 roleid = get_role_oid_or_public(NameStr(*rolename));
2629 tableoid = convert_table_name(tablename);
2631
2632 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2633 if (privresult < 0)
2636}

References column_privilege_check(), convert_column_priv_string(), convert_table_name(), fb(), get_role_oid_or_public(), mode, NameStr, PG_GETARG_INT16, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_column_privilege_name_name_name()

Datum has_column_privilege_name_name_name ( PG_FUNCTION_ARGS  )

Definition at line 2588 of file acl.c.

2589{
2590 Name rolename = PG_GETARG_NAME(0);
2591 text *tablename = PG_GETARG_TEXT_PP(1);
2594 Oid roleid;
2595 Oid tableoid;
2597 AclMode mode;
2598 int privresult;
2599
2600 roleid = get_role_oid_or_public(NameStr(*rolename));
2601 tableoid = convert_table_name(tablename);
2604
2605 privresult = column_privilege_check(tableoid, colattnum, roleid, mode);
2606 if (privresult < 0)
2609}

References column_privilege_check(), convert_column_name(), convert_column_priv_string(), convert_table_name(), fb(), get_role_oid_or_public(), mode, NameStr, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_database_privilege_id()

Datum has_database_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 3080 of file acl.c.

3081{
3084 Oid roleid;
3085 AclMode mode;
3087 bool is_missing = false;
3088
3089 roleid = GetUserId();
3091
3093 roleid, mode,
3094 &is_missing);
3095
3096 if (is_missing)
3098
3100}
static AclMode convert_database_priv_string(text *priv_type_text)
Definition acl.c:3172
AclResult object_aclcheck_ext(Oid classid, Oid objectid, Oid roleid, AclMode mode, bool *is_missing)
Definition aclchk.c:3864

References ACLCHECK_OK, convert_database_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_database_privilege_id_id()

Datum has_database_privilege_id_id ( PG_FUNCTION_ARGS  )

◆ has_database_privilege_id_name()

Datum has_database_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 3108 of file acl.c.

3109{
3110 Oid roleid = PG_GETARG_OID(0);
3114 AclMode mode;
3116
3119
3121
3123}
static Oid convert_database_name(text *databasename)
Definition acl.c:3160
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3854

References ACLCHECK_OK, convert_database_name(), convert_database_priv_string(), fb(), mode, object_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_database_privilege_name()

◆ has_database_privilege_name_id()

◆ has_database_privilege_name_name()

◆ has_foreign_data_wrapper_privilege_id()

Datum has_foreign_data_wrapper_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 3286 of file acl.c.

3287{
3288 Oid fdwid = PG_GETARG_OID(0);
3290 Oid roleid;
3291 AclMode mode;
3293 bool is_missing = false;
3294
3295 roleid = GetUserId();
3297
3299 roleid, mode,
3300 &is_missing);
3301
3302 if (is_missing)
3304
3306}
static AclMode convert_foreign_data_wrapper_priv_string(text *priv_type_text)
Definition acl.c:3378

References ACLCHECK_OK, convert_foreign_data_wrapper_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_foreign_data_wrapper_privilege_id_id()

Datum has_foreign_data_wrapper_privilege_id_id ( PG_FUNCTION_ARGS  )

◆ has_foreign_data_wrapper_privilege_id_name()

Datum has_foreign_data_wrapper_privilege_id_name ( PG_FUNCTION_ARGS  )

◆ has_foreign_data_wrapper_privilege_name()

Datum has_foreign_data_wrapper_privilege_name ( PG_FUNCTION_ARGS  )

◆ has_foreign_data_wrapper_privilege_name_id()

◆ has_foreign_data_wrapper_privilege_name_name()

◆ has_function_privilege_id()

Datum has_function_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 3486 of file acl.c.

3487{
3490 Oid roleid;
3491 AclMode mode;
3493 bool is_missing = false;
3494
3495 roleid = GetUserId();
3497
3499 roleid, mode,
3500 &is_missing);
3501
3502 if (is_missing)
3504
3506}
static AclMode convert_function_priv_string(text *priv_type_text)
Definition acl.c:3587

References ACLCHECK_OK, convert_function_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_function_privilege_id_id()

◆ has_function_privilege_id_name()

◆ has_function_privilege_name()

◆ has_function_privilege_name_id()

◆ has_function_privilege_name_name()

◆ has_language_privilege_id()

Datum has_language_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 3695 of file acl.c.

3696{
3699 Oid roleid;
3700 AclMode mode;
3702 bool is_missing = false;
3703
3704 roleid = GetUserId();
3706
3708 roleid, mode,
3709 &is_missing);
3710
3711 if (is_missing)
3713
3715}
static AclMode convert_language_priv_string(text *priv_type_text)
Definition acl.c:3787

References ACLCHECK_OK, convert_language_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_language_privilege_id_id()

Datum has_language_privilege_id_id ( PG_FUNCTION_ARGS  )

◆ has_language_privilege_id_name()

◆ has_language_privilege_name()

◆ has_language_privilege_name_id()

◆ has_language_privilege_name_name()

◆ has_largeobject_privilege_id()

Datum has_largeobject_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 4775 of file acl.c.

4776{
4778 Oid roleid = GetUserId();
4780 AclMode mode;
4781 bool is_missing = false;
4782 bool result;
4783
4785 result = has_lo_priv_byid(roleid, lobjId, mode, &is_missing);
4786
4787 if (is_missing)
4789
4790 PG_RETURN_BOOL(result);
4791}
static AclMode convert_largeobject_priv_string(text *priv_type_text)
Definition acl.c:4822
static bool has_lo_priv_byid(Oid roleid, Oid lobjId, AclMode priv, bool *is_missing)
Definition acl.c:4716

References convert_largeobject_priv_string(), fb(), GetUserId(), has_lo_priv_byid(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_largeobject_privilege_id_id()

Datum has_largeobject_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 4799 of file acl.c.

4800{
4801 Oid roleid = PG_GETARG_OID(0);
4804 AclMode mode;
4805 bool is_missing = false;
4806 bool result;
4807
4809 result = has_lo_priv_byid(roleid, lobjId, mode, &is_missing);
4810
4811 if (is_missing)
4813
4814 PG_RETURN_BOOL(result);
4815}

References convert_largeobject_priv_string(), fb(), has_lo_priv_byid(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_largeobject_privilege_name_id()

Datum has_largeobject_privilege_name_id ( PG_FUNCTION_ARGS  )

◆ has_lo_priv_byid()

static bool has_lo_priv_byid ( Oid  roleid,
Oid  lobjId,
AclMode  priv,
bool is_missing 
)
static

Definition at line 4716 of file acl.c.

4717{
4718 Snapshot snapshot = NULL;
4720
4721 if (priv & ACL_UPDATE)
4722 snapshot = NULL;
4723 else
4724 snapshot = GetActiveSnapshot();
4725
4726 if (!LargeObjectExistsWithSnapshot(lobjId, snapshot))
4727 {
4729 *is_missing = true;
4730 return false;
4731 }
4732
4734 return true;
4735
4737 roleid,
4738 priv,
4739 snapshot);
4740 return aclresult == ACLCHECK_OK;
4741}
AclResult pg_largeobject_aclcheck_snapshot(Oid lobj_oid, Oid roleid, AclMode mode, Snapshot snapshot)
Definition aclchk.c:4094
bool lo_compat_privileges
Definition inv_api.c:56
bool LargeObjectExistsWithSnapshot(Oid loid, Snapshot snapshot)
Snapshot GetActiveSnapshot(void)
Definition snapmgr.c:800

References ACL_UPDATE, ACLCHECK_OK, Assert, fb(), GetActiveSnapshot(), LargeObjectExistsWithSnapshot(), lo_compat_privileges, and pg_largeobject_aclcheck_snapshot().

Referenced by has_largeobject_privilege_id(), has_largeobject_privilege_id_id(), and has_largeobject_privilege_name_id().

◆ has_param_priv_byname()

static bool has_param_priv_byname ( Oid  roleid,
const text parameter,
AclMode  priv 
)
static

Definition at line 4625 of file acl.c.

4626{
4628
4629 return pg_parameter_aclcheck(paramstr, roleid, priv) == ACLCHECK_OK;
4630}
AclResult pg_parameter_aclcheck(const char *name, Oid roleid, AclMode mode)
Definition aclchk.c:4082

References ACLCHECK_OK, fb(), pg_parameter_aclcheck(), and text_to_cstring().

Referenced by has_parameter_privilege_id_name(), has_parameter_privilege_name(), and has_parameter_privilege_name_name().

◆ has_parameter_privilege_id_name()

Datum has_parameter_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 4668 of file acl.c.

4669{
4670 Oid roleid = PG_GETARG_OID(0);
4673
4675}
static bool has_param_priv_byname(Oid roleid, const text *parameter, AclMode priv)
Definition acl.c:4625
static AclMode convert_parameter_priv_string(text *priv_text)
Definition acl.c:4686

References convert_parameter_priv_string(), fb(), has_param_priv_byname(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_parameter_privilege_name()

◆ has_parameter_privilege_name_name()

◆ has_privs_of_role()

bool has_privs_of_role ( Oid  member,
Oid  role 
)

Definition at line 5298 of file acl.c.

5299{
5300 /* Fast path for simple case */
5301 if (member == role)
5302 return true;
5303
5304 /* Superusers have every privilege, so are part of every role */
5305 if (superuser_arg(member))
5306 return true;
5307
5308 /*
5309 * Find all the roles that member has the privileges of, including
5310 * multi-level recursion, then see if target role is any one of them.
5311 */
5313 InvalidOid, NULL),
5314 role);
5315}
static List * roles_is_member_of(Oid roleid, enum RoleRecurseType type, Oid admin_of, Oid *admin_role)
Definition acl.c:5166
bool list_member_oid(const List *list, Oid datum)
Definition list.c:722
bool superuser_arg(Oid roleid)
Definition superuser.c:57

References fb(), InvalidOid, list_member_oid(), ROLERECURSE_PRIVS, roles_is_member_of(), and superuser_arg().

Referenced by aclmask(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), bbsink_server_new(), calculate_database_size(), calculate_tablespace_size(), check_role_for_policy(), check_role_grantor(), ConfigOptionIsVisible(), convert_and_check_filename(), CreateSubscription(), DoCopy(), DropOwnedObjects(), ExecAlterDefaultPrivilegesStmt(), ExecCheckpoint(), file_fdw_validator(), GetConfigOptionValues(), InitPostgres(), object_ownercheck(), pg_class_aclmask_ext(), pg_get_multixact_stats(), pg_largeobject_aclmask_snapshot(), pg_namespace_aclmask_ext(), pg_role_aclcheck(), pg_signal_backend(), pg_stat_get_recovery(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pgrowlocks(), ReassignOwnedObjects(), ReindexMultipleTables(), shell_check_detail(), and TerminateOtherDBBackends().

◆ has_schema_privilege_id()

Datum has_schema_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 3895 of file acl.c.

3896{
3899 Oid roleid;
3900 AclMode mode;
3902 bool is_missing = false;
3903
3904 roleid = GetUserId();
3906
3908 roleid, mode,
3909 &is_missing);
3910
3911 if (is_missing)
3913
3915}
static AclMode convert_schema_priv_string(text *priv_type_text)
Definition acl.c:3987

References ACLCHECK_OK, convert_schema_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_schema_privilege_id_id()

Datum has_schema_privilege_id_id ( PG_FUNCTION_ARGS  )

◆ has_schema_privilege_id_name()

Datum has_schema_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 3923 of file acl.c.

3924{
3925 Oid roleid = PG_GETARG_OID(0);
3926 text *schemaname = PG_GETARG_TEXT_PP(1);
3928 Oid schemaoid;
3929 AclMode mode;
3931
3932 schemaoid = convert_schema_name(schemaname);
3934
3936
3938}
static Oid convert_schema_name(text *schemaname)
Definition acl.c:3975

References ACLCHECK_OK, convert_schema_name(), convert_schema_priv_string(), fb(), mode, object_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_schema_privilege_name()

Datum has_schema_privilege_name ( PG_FUNCTION_ARGS  )

◆ has_schema_privilege_name_id()

◆ has_schema_privilege_name_name()

◆ has_sequence_privilege_id()

Datum has_sequence_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 2215 of file acl.c.

2216{
2219 Oid roleid;
2220 AclMode mode;
2222 char relkind;
2223 bool is_missing = false;
2224
2225 roleid = GetUserId();
2227 relkind = get_rel_relkind(sequenceoid);
2228 if (relkind == '\0')
2230 else if (relkind != RELKIND_SEQUENCE)
2231 ereport(ERROR,
2233 errmsg("\"%s\" is not a sequence",
2235
2237
2238 if (is_missing)
2240
2242}
static AclMode convert_sequence_priv_string(text *priv_type_text)
Definition acl.c:2311
char get_rel_relkind(Oid relid)
Definition lsyscache.c:2153

References ACLCHECK_OK, convert_sequence_priv_string(), ereport, errcode(), errmsg, ERROR, fb(), get_rel_name(), get_rel_relkind(), GetUserId(), mode, pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_sequence_privilege_id_id()

Datum has_sequence_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 2278 of file acl.c.

2279{
2280 Oid roleid = PG_GETARG_OID(0);
2283 AclMode mode;
2285 char relkind;
2286 bool is_missing = false;
2287
2289 relkind = get_rel_relkind(sequenceoid);
2290 if (relkind == '\0')
2292 else if (relkind != RELKIND_SEQUENCE)
2293 ereport(ERROR,
2295 errmsg("\"%s\" is not a sequence",
2297
2299
2300 if (is_missing)
2302
2304}

References ACLCHECK_OK, convert_sequence_priv_string(), ereport, errcode(), errmsg, ERROR, fb(), get_rel_name(), get_rel_relkind(), mode, pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_sequence_privilege_id_name()

◆ has_sequence_privilege_name()

◆ has_sequence_privilege_name_id()

Datum has_sequence_privilege_name_id ( PG_FUNCTION_ARGS  )

◆ has_sequence_privilege_name_name()

◆ has_server_privilege_id()

Datum has_server_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 4097 of file acl.c.

4098{
4099 Oid serverid = PG_GETARG_OID(0);
4101 Oid roleid;
4102 AclMode mode;
4104 bool is_missing = false;
4105
4106 roleid = GetUserId();
4108
4110 roleid, mode,
4111 &is_missing);
4112
4113 if (is_missing)
4115
4117}
static AclMode convert_server_priv_string(text *priv_type_text)
Definition acl.c:4189

References ACLCHECK_OK, convert_server_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_server_privilege_id_id()

Datum has_server_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 4148 of file acl.c.

4149{
4150 Oid roleid = PG_GETARG_OID(0);
4151 Oid serverid = PG_GETARG_OID(1);
4153 AclMode mode;
4155 bool is_missing = false;
4156
4158
4160 roleid, mode,
4161 &is_missing);
4162
4163 if (is_missing)
4165
4167}

References ACLCHECK_OK, convert_server_priv_string(), fb(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_server_privilege_id_name()

Datum has_server_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 4125 of file acl.c.

4126{
4127 Oid roleid = PG_GETARG_OID(0);
4128 text *servername = PG_GETARG_TEXT_PP(1);
4130 Oid serverid;
4131 AclMode mode;
4133
4134 serverid = convert_server_name(servername);
4136
4138
4140}
static Oid convert_server_name(text *servername)
Definition acl.c:4177

References ACLCHECK_OK, convert_server_name(), convert_server_priv_string(), fb(), mode, object_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_server_privilege_name()

Datum has_server_privilege_name ( PG_FUNCTION_ARGS  )

Definition at line 4043 of file acl.c.

4044{
4045 text *servername = PG_GETARG_TEXT_PP(0);
4047 Oid roleid;
4048 Oid serverid;
4049 AclMode mode;
4051
4052 roleid = GetUserId();
4053 serverid = convert_server_name(servername);
4055
4057
4059}

References ACLCHECK_OK, convert_server_name(), convert_server_priv_string(), fb(), GetUserId(), mode, object_aclcheck(), PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_server_privilege_name_id()

◆ has_server_privilege_name_name()

Datum has_server_privilege_name_name ( PG_FUNCTION_ARGS  )

◆ has_table_privilege_id()

Datum has_table_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 1985 of file acl.c.

1986{
1987 Oid tableoid = PG_GETARG_OID(0);
1989 Oid roleid;
1990 AclMode mode;
1992 bool is_missing = false;
1993
1994 roleid = GetUserId();
1996
1997 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
1998
1999 if (is_missing)
2001
2003}
static AclMode convert_table_priv_string(text *priv_type_text)
Definition acl.c:2076

References ACLCHECK_OK, convert_table_priv_string(), fb(), GetUserId(), mode, pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_table_privilege_id_id()

Datum has_table_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 2034 of file acl.c.

2035{
2036 Oid roleid = PG_GETARG_OID(0);
2037 Oid tableoid = PG_GETARG_OID(1);
2039 AclMode mode;
2041 bool is_missing = false;
2042
2044
2045 aclresult = pg_class_aclcheck_ext(tableoid, roleid, mode, &is_missing);
2046
2047 if (is_missing)
2049
2051}

References ACLCHECK_OK, convert_table_priv_string(), fb(), mode, pg_class_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_table_privilege_id_name()

Datum has_table_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 2011 of file acl.c.

2012{
2013 Oid roleid = PG_GETARG_OID(0);
2014 text *tablename = PG_GETARG_TEXT_PP(1);
2016 Oid tableoid;
2017 AclMode mode;
2019
2020 tableoid = convert_table_name(tablename);
2022
2023 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
2024
2026}

References ACLCHECK_OK, convert_table_name(), convert_table_priv_string(), fb(), mode, pg_class_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_table_privilege_name()

Datum has_table_privilege_name ( PG_FUNCTION_ARGS  )

Definition at line 1933 of file acl.c.

1934{
1935 text *tablename = PG_GETARG_TEXT_PP(0);
1937 Oid roleid;
1938 Oid tableoid;
1939 AclMode mode;
1941
1942 roleid = GetUserId();
1943 tableoid = convert_table_name(tablename);
1945
1946 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
1947
1949}

References ACLCHECK_OK, convert_table_name(), convert_table_priv_string(), fb(), GetUserId(), mode, pg_class_aclcheck(), PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_table_privilege_name_id()

◆ has_table_privilege_name_name()

Datum has_table_privilege_name_name ( PG_FUNCTION_ARGS  )

Definition at line 1907 of file acl.c.

1908{
1909 Name rolename = PG_GETARG_NAME(0);
1910 text *tablename = PG_GETARG_TEXT_PP(1);
1912 Oid roleid;
1913 Oid tableoid;
1914 AclMode mode;
1916
1917 roleid = get_role_oid_or_public(NameStr(*rolename));
1918 tableoid = convert_table_name(tablename);
1920
1921 aclresult = pg_class_aclcheck(tableoid, roleid, mode);
1922
1924}

References ACLCHECK_OK, convert_table_name(), convert_table_priv_string(), fb(), get_role_oid_or_public(), mode, NameStr, pg_class_aclcheck(), PG_GETARG_NAME, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_tablespace_privilege_id()

Datum has_tablespace_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 4297 of file acl.c.

4298{
4301 Oid roleid;
4302 AclMode mode;
4304 bool is_missing = false;
4305
4306 roleid = GetUserId();
4308
4310 roleid, mode,
4311 &is_missing);
4312
4313 if (is_missing)
4315
4317}
static AclMode convert_tablespace_priv_string(text *priv_type_text)
Definition acl.c:4389

References ACLCHECK_OK, convert_tablespace_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_tablespace_privilege_id_id()

◆ has_tablespace_privilege_id_name()

Datum has_tablespace_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 4325 of file acl.c.

4326{
4327 Oid roleid = PG_GETARG_OID(0);
4328 text *tablespacename = PG_GETARG_TEXT_PP(1);
4331 AclMode mode;
4333
4334 tablespaceoid = convert_tablespace_name(tablespacename);
4336
4338
4340}
static Oid convert_tablespace_name(text *tablespacename)
Definition acl.c:4377

References ACLCHECK_OK, convert_tablespace_name(), convert_tablespace_priv_string(), fb(), mode, object_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_tablespace_privilege_name()

◆ has_tablespace_privilege_name_id()

◆ has_tablespace_privilege_name_name()

◆ has_type_privilege_id()

Datum has_type_privilege_id ( PG_FUNCTION_ARGS  )

Definition at line 4496 of file acl.c.

4497{
4498 Oid typeoid = PG_GETARG_OID(0);
4500 Oid roleid;
4501 AclMode mode;
4503 bool is_missing = false;
4504
4505 roleid = GetUserId();
4507
4509 roleid, mode,
4510 &is_missing);
4511
4512 if (is_missing)
4514
4516}
static AclMode convert_type_priv_string(text *priv_type_text)
Definition acl.c:4597

References ACLCHECK_OK, convert_type_priv_string(), fb(), GetUserId(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_type_privilege_id_id()

Datum has_type_privilege_id_id ( PG_FUNCTION_ARGS  )

Definition at line 4547 of file acl.c.

4548{
4549 Oid roleid = PG_GETARG_OID(0);
4550 Oid typeoid = PG_GETARG_OID(1);
4552 AclMode mode;
4554 bool is_missing = false;
4555
4557
4559 roleid, mode,
4560 &is_missing);
4561
4562 if (is_missing)
4564
4566}

References ACLCHECK_OK, convert_type_priv_string(), fb(), mode, object_aclcheck_ext(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and PG_RETURN_NULL.

◆ has_type_privilege_id_name()

Datum has_type_privilege_id_name ( PG_FUNCTION_ARGS  )

Definition at line 4524 of file acl.c.

4525{
4526 Oid roleid = PG_GETARG_OID(0);
4527 text *typename = PG_GETARG_TEXT_PP(1);
4529 Oid typeoid;
4530 AclMode mode;
4532
4533 typeoid = convert_type_name(typename);
4535
4536 aclresult = object_aclcheck(TypeRelationId, typeoid, roleid, mode);
4537
4539}
static Oid convert_type_name(text *typename)
Definition acl.c:4576

References ACLCHECK_OK, convert_type_name(), convert_type_priv_string(), fb(), mode, object_aclcheck(), PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_type_privilege_name()

Datum has_type_privilege_name ( PG_FUNCTION_ARGS  )

Definition at line 4442 of file acl.c.

4443{
4444 text *typename = PG_GETARG_TEXT_PP(0);
4446 Oid roleid;
4447 Oid typeoid;
4448 AclMode mode;
4450
4451 roleid = GetUserId();
4452 typeoid = convert_type_name(typename);
4454
4455 aclresult = object_aclcheck(TypeRelationId, typeoid, roleid, mode);
4456
4458}

References ACLCHECK_OK, convert_type_name(), convert_type_priv_string(), fb(), GetUserId(), mode, object_aclcheck(), PG_GETARG_TEXT_PP, and PG_RETURN_BOOL.

◆ has_type_privilege_name_id()

Datum has_type_privilege_name_id ( PG_FUNCTION_ARGS  )

◆ has_type_privilege_name_name()

Datum has_type_privilege_name_name ( PG_FUNCTION_ARGS  )

◆ hash_aclitem()

Datum hash_aclitem ( PG_FUNCTION_ARGS  )

Definition at line 781 of file acl.c.

782{
784
785 /* not very bright, but avoids any issue of padding in struct */
786 PG_RETURN_UINT32((uint32) (a->ai_privs + a->ai_grantee + a->ai_grantor));
787}
uint32_t uint32
Definition c.h:579
#define PG_RETURN_UINT32(x)
Definition fmgr.h:356
int a
Definition isn.c:73

References a, PG_GETARG_ACLITEM_P, and PG_RETURN_UINT32.

◆ hash_aclitem_extended()

Datum hash_aclitem_extended ( PG_FUNCTION_ARGS  )

Definition at line 795 of file acl.c.

796{
798 uint64 seed = PG_GETARG_INT64(1);
799 uint32 sum = (uint32) (a->ai_privs + a->ai_grantee + a->ai_grantor);
800
801 return (seed == 0) ? UInt64GetDatum(sum) : hash_uint32_extended(sum, seed);
802}
uint64_t uint64
Definition c.h:580
#define PG_GETARG_INT64(n)
Definition fmgr.h:284
static Datum hash_uint32_extended(uint32 k, uint64 seed)
Definition hashfn.h:49
static Datum UInt64GetDatum(uint64 X)
Definition postgres.h:443

References a, hash_uint32_extended(), PG_GETARG_ACLITEM_P, PG_GETARG_INT64, and UInt64GetDatum().

◆ initialize_acl()

void initialize_acl ( void  )

Definition at line 5053 of file acl.c.

5054{
5056 {
5060
5061 /*
5062 * In normal mode, set a callback on any syscache invalidation of rows
5063 * of pg_auth_members (for roles_is_member_of()) pg_database (for
5064 * roles_is_member_of())
5065 */
5068 (Datum) 0);
5071 (Datum) 0);
5074 (Datum) 0);
5075 }
5076}
static uint32 cached_db_hash
Definition acl.c:83
static void RoleMembershipCacheCallback(Datum arg, SysCacheIdentifier cacheid, uint32 hashvalue)
Definition acl.c:5083
Oid MyDatabaseId
Definition globals.c:94
void CacheRegisterSyscacheCallback(SysCacheIdentifier cacheid, SyscacheCallbackFunction func, Datum arg)
Definition inval.c:1816
#define GetSysCacheHashValue1(cacheId, key1)
Definition syscache.h:118

References cached_db_hash, CacheRegisterSyscacheCallback(), fb(), GetSysCacheHashValue1, IsBootstrapProcessingMode, MyDatabaseId, ObjectIdGetDatum(), and RoleMembershipCacheCallback().

Referenced by InitPostgres().

◆ is_admin_of_role()

bool is_admin_of_role ( Oid  member,
Oid  role 
)

Definition at line 5428 of file acl.c.

5429{
5431
5432 if (superuser_arg(member))
5433 return true;
5434
5435 /* By policy, a role cannot have WITH ADMIN OPTION on itself. */
5436 if (member == role)
5437 return false;
5438
5440 return OidIsValid(admin_role);
5441}

References fb(), OidIsValid, ROLERECURSE_MEMBERS, roles_is_member_of(), and superuser_arg().

Referenced by AlterRole(), AlterRoleSet(), check_object_ownership(), check_role_membership_authorization(), DropRole(), pg_role_aclcheck(), and RenameRole().

◆ is_member_of_role()

bool is_member_of_role ( Oid  member,
Oid  role 
)

Definition at line 5378 of file acl.c.

5379{
5380 /* Fast path for simple case */
5381 if (member == role)
5382 return true;
5383
5384 /* Superusers have every privilege, so are part of every role */
5385 if (superuser_arg(member))
5386 return true;
5387
5388 /*
5389 * Find all the roles that member is a member of, including multi-level
5390 * recursion, then see if target role is any one of them.
5391 */
5393 InvalidOid, NULL),
5394 role);
5395}

References fb(), InvalidOid, list_member_oid(), ROLERECURSE_MEMBERS, roles_is_member_of(), and superuser_arg().

Referenced by pg_role_aclcheck().

◆ is_member_of_role_nosuper()

bool is_member_of_role_nosuper ( Oid  member,
Oid  role 
)

Definition at line 5406 of file acl.c.

5407{
5408 /* Fast path for simple case */
5409 if (member == role)
5410 return true;
5411
5412 /*
5413 * Find all the roles that member is a member of, including multi-level
5414 * recursion, then see if target role is any one of them.
5415 */
5417 InvalidOid, NULL),
5418 role);
5419}

References fb(), InvalidOid, list_member_oid(), ROLERECURSE_MEMBERS, and roles_is_member_of().

Referenced by AddRoleMems(), and is_member().

◆ is_safe_acl_char()

static bool is_safe_acl_char ( unsigned char  c,
bool  is_getid 
)
inlinestatic

Definition at line 147 of file acl.c.

148{
149 if (IS_HIGHBIT_SET(c))
150 return is_getid;
151 return isalnum(c) || c == '_';
152}
#define IS_HIGHBIT_SET(ch)
Definition c.h:1207
char * c

References fb(), and IS_HIGHBIT_SET.

Referenced by getid(), and putid().

◆ make_empty_acl()

Acl * make_empty_acl ( void  )

Definition at line 461 of file acl.c.

462{
463 return allocacl(0);
464}

References allocacl().

Referenced by SetDefaultACL().

◆ makeaclitem()

Datum makeaclitem ( PG_FUNCTION_ARGS  )

Definition at line 1647 of file acl.c.

1648{
1650 Oid grantor = PG_GETARG_OID(1);
1652 bool goption = PG_GETARG_BOOL(3);
1653 AclItem *result;
1654 AclMode priv;
1655 static const priv_map any_priv_map[] = {
1656 {"SELECT", ACL_SELECT},
1657 {"INSERT", ACL_INSERT},
1658 {"UPDATE", ACL_UPDATE},
1659 {"DELETE", ACL_DELETE},
1660 {"TRUNCATE", ACL_TRUNCATE},
1661 {"REFERENCES", ACL_REFERENCES},
1662 {"TRIGGER", ACL_TRIGGER},
1663 {"EXECUTE", ACL_EXECUTE},
1664 {"USAGE", ACL_USAGE},
1665 {"CREATE", ACL_CREATE},
1666 {"TEMP", ACL_CREATE_TEMP},
1667 {"TEMPORARY", ACL_CREATE_TEMP},
1668 {"CONNECT", ACL_CONNECT},
1669 {"SET", ACL_SET},
1670 {"ALTER SYSTEM", ACL_ALTER_SYSTEM},
1671 {"MAINTAIN", ACL_MAINTAIN},
1672 {NULL, 0}
1673 };
1674
1676
1677 result = palloc_object(AclItem);
1678
1679 result->ai_grantee = grantee;
1680 result->ai_grantor = grantor;
1681
1682 ACLITEM_SET_PRIVS_GOPTIONS(*result, priv,
1683 (goption ? priv : ACL_NO_RIGHTS));
1684
1685 PG_RETURN_ACLITEM_P(result);
1686}
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
Oid ai_grantee
Definition acl.h:56
Oid ai_grantor
Definition acl.h:57

References ACL_ALTER_SYSTEM, ACL_CONNECT, ACL_CREATE, ACL_CREATE_TEMP, ACL_DELETE, ACL_EXECUTE, ACL_INSERT, ACL_MAINTAIN, ACL_NO_RIGHTS, ACL_REFERENCES, ACL_SELECT, ACL_SET, ACL_TRIGGER, ACL_TRUNCATE, ACL_UPDATE, ACL_USAGE, ACLITEM_SET_PRIVS_GOPTIONS, AclItem::ai_grantee, AclItem::ai_grantor, convert_any_priv_string(), fb(), palloc_object, PG_GETARG_BOOL, PG_GETARG_OID, PG_GETARG_TEXT_PP, and PG_RETURN_ACLITEM_P.

◆ member_can_set_role()

bool member_can_set_role ( Oid  member,
Oid  role 
)

Definition at line 5332 of file acl.c.

5333{
5334 /* Fast path for simple case */
5335 if (member == role)
5336 return true;
5337
5338 /* Superusers have every privilege, so can always SET ROLE */
5339 if (superuser_arg(member))
5340 return true;
5341
5342 /*
5343 * Find all the roles that member can access via SET ROLE, including
5344 * multi-level recursion, then see if target role is any one of them.
5345 */
5347 InvalidOid, NULL),
5348 role);
5349}

References fb(), InvalidOid, list_member_oid(), ROLERECURSE_SETROLE, roles_is_member_of(), and superuser_arg().

Referenced by check_can_set_role(), check_role(), pg_role_aclcheck(), and SwitchToUntrustedUser().

◆ pg_has_role_id()

Datum pg_has_role_id ( PG_FUNCTION_ARGS  )

Definition at line 4925 of file acl.c.

4926{
4927 Oid roleoid = PG_GETARG_OID(0);
4929 Oid roleid;
4930 AclMode mode;
4932
4933 roleid = GetUserId();
4935
4936 aclresult = pg_role_aclcheck(roleoid, roleid, mode);
4937
4939}
static AclMode convert_role_priv_string(text *priv_type_text)
Definition acl.c:5000
static AclResult pg_role_aclcheck(Oid role_oid, Oid roleid, AclMode mode)
Definition acl.c:5023

References ACLCHECK_OK, convert_role_priv_string(), fb(), GetUserId(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and pg_role_aclcheck().

◆ pg_has_role_id_id()

Datum pg_has_role_id_id ( PG_FUNCTION_ARGS  )

Definition at line 4970 of file acl.c.

4971{
4972 Oid roleid = PG_GETARG_OID(0);
4973 Oid roleoid = PG_GETARG_OID(1);
4975 AclMode mode;
4977
4979
4980 aclresult = pg_role_aclcheck(roleoid, roleid, mode);
4981
4983}

References ACLCHECK_OK, convert_role_priv_string(), fb(), mode, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and pg_role_aclcheck().

◆ pg_has_role_id_name()

Datum pg_has_role_id_name ( PG_FUNCTION_ARGS  )

Definition at line 4947 of file acl.c.

4948{
4949 Oid roleid = PG_GETARG_OID(0);
4950 Name rolename = PG_GETARG_NAME(1);
4952 Oid roleoid;
4953 AclMode mode;
4955
4956 roleoid = get_role_oid(NameStr(*rolename), false);
4958
4959 aclresult = pg_role_aclcheck(roleoid, roleid, mode);
4960
4962}

References ACLCHECK_OK, convert_role_priv_string(), fb(), get_role_oid(), mode, NameStr, PG_GETARG_NAME, PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and pg_role_aclcheck().

◆ pg_has_role_name()

Datum pg_has_role_name ( PG_FUNCTION_ARGS  )

Definition at line 4877 of file acl.c.

4878{
4879 Name rolename = PG_GETARG_NAME(0);
4881 Oid roleid;
4882 Oid roleoid;
4883 AclMode mode;
4885
4886 roleid = GetUserId();
4887 roleoid = get_role_oid(NameStr(*rolename), false);
4889
4890 aclresult = pg_role_aclcheck(roleoid, roleid, mode);
4891
4893}

References ACLCHECK_OK, convert_role_priv_string(), fb(), get_role_oid(), GetUserId(), mode, NameStr, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, and pg_role_aclcheck().

◆ pg_has_role_name_id()

Datum pg_has_role_name_id ( PG_FUNCTION_ARGS  )

◆ pg_has_role_name_name()

Datum pg_has_role_name_name ( PG_FUNCTION_ARGS  )

Definition at line 4851 of file acl.c.

4852{
4854 Name rolename = PG_GETARG_NAME(1);
4856 Oid roleid;
4857 Oid roleoid;
4858 AclMode mode;
4860
4861 roleid = get_role_oid(NameStr(*username), false);
4862 roleoid = get_role_oid(NameStr(*rolename), false);
4864
4865 aclresult = pg_role_aclcheck(roleoid, roleid, mode);
4866
4868}

References ACLCHECK_OK, convert_role_priv_string(), fb(), get_role_oid(), mode, NameStr, PG_GETARG_NAME, PG_GETARG_TEXT_PP, PG_RETURN_BOOL, pg_role_aclcheck(), and username.

◆ pg_role_aclcheck()

static AclResult pg_role_aclcheck ( Oid  role_oid,
Oid  roleid,
AclMode  mode 
)
static

Definition at line 5023 of file acl.c.

5024{
5026 {
5027 if (is_admin_of_role(roleid, role_oid))
5028 return ACLCHECK_OK;
5029 }
5030 if (mode & ACL_CREATE)
5031 {
5032 if (is_member_of_role(roleid, role_oid))
5033 return ACLCHECK_OK;
5034 }
5035 if (mode & ACL_USAGE)
5036 {
5037 if (has_privs_of_role(roleid, role_oid))
5038 return ACLCHECK_OK;
5039 }
5040 if (mode & ACL_SET)
5041 {
5042 if (member_can_set_role(roleid, role_oid))
5043 return ACLCHECK_OK;
5044 }
5045 return ACLCHECK_NO_PRIV;
5046}
bool is_admin_of_role(Oid member, Oid role)
Definition acl.c:5428
bool is_member_of_role(Oid member, Oid role)
Definition acl.c:5378
@ ACLCHECK_NO_PRIV
Definition acl.h:184

References ACL_CREATE, ACL_GRANT_OPTION_FOR, ACL_SET, ACL_USAGE, ACLCHECK_NO_PRIV, ACLCHECK_OK, fb(), has_privs_of_role(), is_admin_of_role(), is_member_of_role(), member_can_set_role(), and mode.

Referenced by pg_has_role_id(), pg_has_role_id_id(), pg_has_role_id_name(), pg_has_role_name(), pg_has_role_name_id(), and pg_has_role_name_name().

◆ putid()

static void putid ( char p,
const char s 
)
static

Definition at line 223 of file acl.c.

224{
225 const char *src;
226 bool safe = true;
227
228 /* Detect whether we need to use double quotes */
229 for (src = s; *src; src++)
230 {
231 if (!is_safe_acl_char(*src, false))
232 {
233 safe = false;
234 break;
235 }
236 }
237 if (!safe)
238 *p++ = '"';
239 for (src = s; *src; src++)
240 {
241 /* A double quote character in a username is encoded as "" */
242 if (*src == '"')
243 *p++ = '"';
244 *p++ = *src;
245 }
246 if (!safe)
247 *p++ = '"';
248 *p = '\0';
249}

References fb(), and is_safe_acl_char().

Referenced by aclitemout().

◆ recursive_revoke()

static Acl * recursive_revoke ( Acl acl,
Oid  grantee,
AclMode  revoke_privs,
Oid  ownerId,
DropBehavior  behavior 
)
static

Definition at line 1315 of file acl.c.

1320{
1322 AclItem *aip;
1323 int i,
1324 num;
1325
1326 check_acl(acl);
1327
1328 /* The owner can never truly lose grant options, so short-circuit */
1329 if (grantee == ownerId)
1330 return acl;
1331
1332 /* The grantee might still have some grant options via another grantor */
1333 still_has = aclmask(acl, grantee, ownerId,
1335 ACLMASK_ALL);
1338 return acl;
1339
1340restart:
1341 num = ACL_NUM(acl);
1342 aip = ACL_DAT(acl);
1343 for (i = 0; i < num; i++)
1344 {
1345 if (aip[i].ai_grantor == grantee
1346 && (ACLITEM_GET_PRIVS(aip[i]) & revoke_privs) != 0)
1347 {
1349 Acl *new_acl;
1350
1351 if (behavior == DROP_RESTRICT)
1352 ereport(ERROR,
1354 errmsg("dependent privileges exist"),
1355 errhint("Use CASCADE to revoke them too.")));
1356
1357 mod_acl.ai_grantor = grantee;
1358 mod_acl.ai_grantee = aip[i].ai_grantee;
1361 revoke_privs);
1362
1364 ownerId, behavior);
1365
1366 pfree(acl);
1367 acl = new_acl;
1368
1369 goto restart;
1370 }
1371 }
1372
1373 return acl;
1374}

References ACL_DAT, ACL_GRANT_OPTION_FOR, ACL_MODECHG_DEL, ACL_NO_RIGHTS, ACL_NUM, ACLITEM_GET_PRIVS, ACLITEM_SET_PRIVS_GOPTIONS, aclmask(), ACLMASK_ALL, aclupdate(), check_acl(), DROP_RESTRICT, ereport, errcode(), errhint(), errmsg, ERROR, fb(), i, and pfree().

Referenced by aclupdate().

◆ RoleMembershipCacheCallback()

static void RoleMembershipCacheCallback ( Datum  arg,
SysCacheIdentifier  cacheid,
uint32  hashvalue 
)
static

Definition at line 5083 of file acl.c.

5085{
5086 if (cacheid == DATABASEOID &&
5087 hashvalue != cached_db_hash &&
5088 hashvalue != 0)
5089 {
5090 return; /* ignore pg_database changes for other DBs */
5091 }
5092
5093 /* Force membership caches to be recomputed on next use */
5097}
static Oid cached_role[]
Definition acl.c:81

References cached_db_hash, cached_role, fb(), InvalidOid, ROLERECURSE_MEMBERS, ROLERECURSE_PRIVS, and ROLERECURSE_SETROLE.

Referenced by initialize_acl().

◆ roles_is_member_of()

static List * roles_is_member_of ( Oid  roleid,
enum RoleRecurseType  type,
Oid  admin_of,
Oid admin_role 
)
static

Definition at line 5166 of file acl.c.

5168{
5169 Oid dba;
5171 ListCell *l;
5174 bloom_filter *bf = NULL;
5175
5177 if (admin_role != NULL)
5179
5180 /* If cache is valid and ADMIN OPTION not sought, just return the list */
5181 if (cached_role[type] == roleid && !OidIsValid(admin_of) &&
5183 return cached_roles[type];
5184
5185 /*
5186 * Role expansion happens in a non-database backend when guc.c checks
5187 * ROLE_PG_READ_ALL_SETTINGS for a physical walsender SHOW command. In
5188 * that case, no role gets pg_database_owner.
5189 */
5191 dba = InvalidOid;
5192 else
5193 {
5195
5197 if (!HeapTupleIsValid(dbtup))
5198 elog(ERROR, "cache lookup failed for database %u", MyDatabaseId);
5201 }
5202
5203 /*
5204 * Find all the roles that roleid is a member of, including multi-level
5205 * recursion. The role itself will always be the first element of the
5206 * resulting list.
5207 *
5208 * Each element of the list is scanned to see if it adds any indirect
5209 * memberships. We can use a single list as both the record of
5210 * already-found memberships and the agenda of roles yet to be scanned.
5211 * This is a bit tricky but works because the foreach() macro doesn't
5212 * fetch the next list element until the bottom of the loop.
5213 */
5214 roles_list = list_make1_oid(roleid);
5215
5216 foreach(l, roles_list)
5217 {
5218 Oid memberid = lfirst_oid(l);
5220 int i;
5221
5222 /* Find roles that memberid is directly a member of */
5225 for (i = 0; i < memlist->n_members; i++)
5226 {
5227 HeapTuple tup = &memlist->members[i]->tuple;
5229 Oid otherid = form->roleid;
5230
5231 /*
5232 * While otherid==InvalidOid shouldn't appear in the catalog, the
5233 * OidIsValid() avoids crashing if that arises.
5234 */
5235 if (otherid == admin_of && form->admin_option &&
5238
5239 /* If we're supposed to ignore non-heritable grants, do so. */
5240 if (type == ROLERECURSE_PRIVS && !form->inherit_option)
5241 continue;
5242
5243 /* If we're supposed to ignore non-SET grants, do so. */
5244 if (type == ROLERECURSE_SETROLE && !form->set_option)
5245 continue;
5246
5247 /*
5248 * Even though there shouldn't be any loops in the membership
5249 * graph, we must test for having already seen this role. It is
5250 * legal for instance to have both A->B and A->C->B.
5251 */
5253 }
5255
5256 /* implement pg_database_owner implicit membership */
5257 if (memberid == dba && OidIsValid(dba))
5260 }
5261
5262 /*
5263 * Free the Bloom filter created by roles_list_append(), if there is one.
5264 */
5265 if (bf)
5266 bloom_free(bf);
5267
5268 /*
5269 * Copy the completed list into TopMemoryContext so it will persist.
5270 */
5275
5276 /*
5277 * Now safe to assign to state variable
5278 */
5279 cached_role[type] = InvalidOid; /* just paranoia */
5282 cached_role[type] = roleid;
5283
5284 /* And now we can return the answer */
5285 return cached_roles[type];
5286}
static List * roles_list_append(List *roles_list, bloom_filter **bf, Oid role)
Definition acl.c:5106
static List * cached_roles[]
Definition acl.c:82
void bloom_free(bloom_filter *filter)
List * list_copy(const List *oldlist)
Definition list.c:1573
void list_free(List *list)
Definition list.c:1546
MemoryContext TopMemoryContext
Definition mcxt.c:166
END_CATALOG_STRUCT typedef FormData_pg_auth_members * Form_pg_auth_members
END_CATALOG_STRUCT typedef FormData_pg_database * Form_pg_database
#define list_make1_oid(x1)
Definition pg_list.h:242
#define lfirst_oid(lc)
Definition pg_list.h:174
Definition pg_list.h:54
#define ReleaseSysCacheList(x)
Definition syscache.h:134
#define SearchSysCacheList1(cacheId, key1)
Definition syscache.h:127
const char * type

References Assert, bloom_free(), cached_role, cached_roles, elog, ERROR, fb(), Form_pg_auth_members, Form_pg_database, GETSTRUCT(), HeapTupleIsValid, i, InvalidOid, lfirst_oid, list_copy(), list_free(), list_make1_oid, MemoryContextSwitchTo(), MyDatabaseId, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), ReleaseSysCacheList, ROLERECURSE_PRIVS, ROLERECURSE_SETROLE, roles_list_append(), SearchSysCache1(), SearchSysCacheList1, TopMemoryContext, and type.

Referenced by has_privs_of_role(), is_admin_of_role(), is_member_of_role(), is_member_of_role_nosuper(), member_can_set_role(), select_best_admin(), and select_best_grantor().

◆ roles_list_append()

static List * roles_list_append ( List roles_list,
bloom_filter **  bf,
Oid  role 
)
inlinestatic

Definition at line 5106 of file acl.c.

5107{
5108 unsigned char *roleptr = (unsigned char *) &role;
5109
5110 /*
5111 * If there is a previously-created Bloom filter, use it to try to
5112 * determine whether the role is missing from the list. If it says yes,
5113 * that's a hard fact and we can go ahead and add the role. If it says
5114 * no, that's only probabilistic and we'd better search the list. Without
5115 * a filter, we must always do an ordinary linear search through the
5116 * existing list.
5117 */
5118 if ((*bf && bloom_lacks_element(*bf, roleptr, sizeof(Oid))) ||
5120 {
5121 /*
5122 * If the list is large, we take on the overhead of creating and
5123 * populating a Bloom filter to speed up future calls to this
5124 * function.
5125 */
5126 if (*bf == NULL &&
5128 {
5130 foreach_oid(roleid, roles_list)
5131 bloom_add_element(*bf, (unsigned char *) &roleid, sizeof(Oid));
5132 }
5133
5134 /*
5135 * Finally, add the role to the list and the Bloom filter, if it
5136 * exists.
5137 */
5139 if (*bf)
5140 bloom_add_element(*bf, roleptr, sizeof(Oid));
5141 }
5142
5143 return roles_list;
5144}
#define ROLES_LIST_BLOOM_THRESHOLD
Definition acl.c:91
bloom_filter * bloom_create(int64 total_elems, int bloom_work_mem, uint64 seed)
Definition bloomfilter.c:87
bool bloom_lacks_element(bloom_filter *filter, unsigned char *elem, size_t len)
void bloom_add_element(bloom_filter *filter, unsigned char *elem, size_t len)
int work_mem
Definition globals.c:131
List * lappend_oid(List *list, Oid datum)
Definition list.c:375
static int list_length(const List *l)
Definition pg_list.h:152
#define foreach_oid(var, lst)
Definition pg_list.h:471

References bloom_add_element(), bloom_create(), bloom_lacks_element(), fb(), foreach_oid, lappend_oid(), list_length(), list_member_oid(), ROLES_LIST_BLOOM_THRESHOLD, and work_mem.

Referenced by roles_is_member_of().

◆ select_best_admin()

Oid select_best_admin ( Oid  member,
Oid  role 
)

Definition at line 5453 of file acl.c.

5454{
5456
5457 /* By policy, a role cannot have WITH ADMIN OPTION on itself. */
5458 if (member == role)
5459 return InvalidOid;
5460
5462 return admin_role;
5463}

References fb(), InvalidOid, ROLERECURSE_PRIVS, and roles_is_member_of().

Referenced by check_role_grantor().

◆ select_best_grantor()

void select_best_grantor ( Oid  roleId,
AclMode  privileges,
const Acl acl,
Oid  ownerId,
Oid grantorId,
AclMode grantOptions 
)

Definition at line 5490 of file acl.c.

5493{
5496 int nrights;
5497 ListCell *l;
5498
5499 /*
5500 * The object owner is always treated as having all grant options, so if
5501 * roleId is the owner it's easy. Also, if roleId is a superuser it's
5502 * easy: superusers are implicitly members of every role, so they act as
5503 * the object owner.
5504 */
5505 if (roleId == ownerId || superuser_arg(roleId))
5506 {
5507 *grantorId = ownerId;
5509 return;
5510 }
5511
5512 /*
5513 * Otherwise we have to do a careful search to see if roleId has the
5514 * privileges of any suitable role. Note: we can hang onto the result of
5515 * roles_is_member_of() throughout this loop, because aclmask_direct()
5516 * doesn't query any role memberships.
5517 */
5519 InvalidOid, NULL);
5520
5521 /* initialize candidate result as default */
5522 *grantorId = roleId;
5524 nrights = 0;
5525
5526 foreach(l, roles_list)
5527 {
5530
5531 otherprivs = aclmask_direct(acl, otherrole, ownerId,
5534 {
5535 /* Found a suitable grantor */
5538 return;
5539 }
5540
5541 /*
5542 * If it has just some of the needed privileges, remember best
5543 * candidate.
5544 */
5546 {
5548
5549 if (nnewrights > nrights)
5550 {
5554 }
5555 }
5556 }
5557}
static AclMode aclmask_direct(const Acl *acl, Oid roleid, Oid ownerId, AclMode mask, AclMaskHow how)
Definition acl.c:1490
static int pg_popcount64(uint64 word)

References ACL_GRANT_OPTION_FOR, ACL_NO_RIGHTS, ACLMASK_ALL, aclmask_direct(), fb(), InvalidOid, lfirst_oid, pg_popcount64(), ROLERECURSE_PRIVS, roles_is_member_of(), and superuser_arg().

Referenced by ExecGrant_Attribute(), ExecGrant_common(), ExecGrant_Largeobject(), ExecGrant_Parameter(), and ExecGrant_Relation().

Variable Documentation

◆ cached_db_hash

uint32 cached_db_hash
static

Definition at line 83 of file acl.c.

Referenced by initialize_acl(), and RoleMembershipCacheCallback().

◆ cached_role

Oid cached_role[] = {InvalidOid, InvalidOid, InvalidOid}
static

Definition at line 81 of file acl.c.

Referenced by RoleMembershipCacheCallback(), and roles_is_member_of().

◆ cached_roles

List* cached_roles[] = {NIL, NIL, NIL}
static

Definition at line 82 of file acl.c.

82{NIL, NIL, NIL};
#define NIL
Definition pg_list.h:68

Referenced by roles_is_member_of().