PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/binary_upgrade.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_auth_members.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/seclabel.h"
#include "commands/user.h"
#include "libpq/crypt.h"
#include "miscadmin.h"
#include "storage/lmgr.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/syscache.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Functions | |
static void | AddRoleMems (const char *rolename, Oid roleid, List *memberSpecs, List *memberIds, Oid grantorId, bool admin_opt) |
static void | DelRoleMems (const char *rolename, Oid roleid, List *memberSpecs, List *memberIds, bool admin_opt) |
static bool | have_createrole_privilege (void) |
Oid | CreateRole (ParseState *pstate, CreateRoleStmt *stmt) |
Oid | AlterRole (ParseState *pstate, AlterRoleStmt *stmt) |
Oid | AlterRoleSet (AlterRoleSetStmt *stmt) |
void | DropRole (DropRoleStmt *stmt) |
ObjectAddress | RenameRole (const char *oldname, const char *newname) |
void | GrantRole (GrantRoleStmt *stmt) |
void | DropOwnedObjects (DropOwnedStmt *stmt) |
void | ReassignOwnedObjects (ReassignOwnedStmt *stmt) |
List * | roleSpecsToIds (List *memberNames) |
Variables | |
Oid | binary_upgrade_next_pg_authid_oid = InvalidOid |
int | Password_encryption = PASSWORD_TYPE_SCRAM_SHA_256 |
check_password_hook_type | check_password_hook = NULL |
|
static |
Definition at line 1376 of file user.c.
References admin_option, Assert(), AUTHMEMROLEMEM, BoolGetDatum, CatalogTupleInsert(), CatalogTupleUpdate(), CommandCounterIncrement(), ereport, errcode(), errmsg(), ERROR, forboth, get_rolespec_name(), GETSTRUCT, GetUserId(), have_createrole_privilege(), heap_form_tuple(), heap_modify_tuple(), HeapTupleIsValid, is_admin_of_role(), is_member_of_role_nosuper(), lfirst_node, lfirst_oid, list_length(), MemSet, NoLock, NOTICE, ObjectIdGetDatum, RelationGetDescr, ReleaseSysCache(), RowExclusiveLock, SearchSysCache2(), superuser(), superuser_arg(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by AlterRole(), CreateRole(), and GrantRole().
Oid AlterRole | ( | ParseState * | pstate, |
AlterRoleStmt * | stmt | ||
) |
Definition at line 493 of file user.c.
References AlterRoleStmt::action, AddRoleMems(), DefElem::arg, AUTHNAME, BoolGetDatum, boolVal, CatalogTupleUpdate(), check_password_hook, check_rolespec_name(), CommandCounterIncrement(), CStringGetDatum, CStringGetTextDatum, DefElem::defname, DelRoleMems(), DirectFunctionCall3, elog, encrypt_password(), ereport, errcode(), errmsg(), ERROR, errorConflictingDefElem(), get_password_type(), get_rolespec_tuple(), GETSTRUCT, GetUserId(), have_createrole_privilege(), heap_freetuple(), heap_modify_tuple(), Int32GetDatum, intVal, InvalidOid, InvokeObjectPostAlterHook, lfirst, MemSet, NameStr, NoLock, NOTICE, ObjectIdGetDatum, AlterRoleStmt::options, password, Password_encryption, plain_crypt_verify(), pstrdup(), RelationGetDescr, ReleaseSysCache(), AlterRoleStmt::role, roleSpecsToIds(), RowExclusiveLock, STATUS_OK, strVal, superuser(), SysCacheGetAttr(), HeapTupleData::t_self, table_close(), table_open(), and timestamptz_in().
Referenced by standard_ProcessUtility().
Oid AlterRoleSet | ( | AlterRoleSetStmt * | stmt | ) |
Definition at line 828 of file user.c.
References aclcheck_error(), ACLCHECK_NOT_OWNER, AlterSetting(), check_rolespec_name(), AlterRoleSetStmt::database, ereport, errcode(), errmsg(), ERROR, get_database_oid(), get_rolespec_tuple(), GETSTRUCT, GetUserId(), have_createrole_privilege(), InvalidOid, OBJECT_DATABASE, pg_database_ownercheck(), ReleaseSysCache(), AlterRoleSetStmt::role, AlterRoleSetStmt::setstmt, shdepLockAndCheckObject(), and superuser().
Referenced by standard_ProcessUtility().
Oid CreateRole | ( | ParseState * | pstate, |
CreateRoleStmt * | stmt | ||
) |
Definition at line 72 of file user.c.
References AddRoleMems(), DefElem::arg, binary_upgrade_next_pg_authid_oid, BoolGetDatum, boolVal, CatalogTupleInsert(), check_password_hook, CommandCounterIncrement(), createdb(), CStringGetDatum, CStringGetTextDatum, DefElem::defname, DirectFunctionCall1, DirectFunctionCall3, elog, encrypt_password(), ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errmsg(), ERROR, errorConflictingDefElem(), get_password_type(), get_role_oid(), get_rolespec_tuple(), GetNewOidWithIndex(), GETSTRUCT, GetUserId(), have_createrole_privilege(), heap_form_tuple(), if(), Int32GetDatum, intVal, InvalidOid, InvokeObjectPostCreateHook, IsBinaryUpgrade, IsReservedName(), lfirst, list_make1, list_make1_oid, RoleSpec::location, makeNode, MemSet, namein(), NameStr, NIL, NoLock, NOTICE, ObjectIdGetDatum, OidIsValid, CreateRoleStmt::options, password, Password_encryption, plain_crypt_verify(), RelationGetDescr, ReleaseSysCache(), CreateRoleStmt::role, RoleSpec::rolename, ROLESPEC_CSTRING, roleSpecsToIds(), ROLESTMT_GROUP, ROLESTMT_ROLE, ROLESTMT_USER, RoleSpec::roletype, RowExclusiveLock, STATUS_OK, CreateRoleStmt::stmt_type, strVal, superuser(), table_close(), table_open(), timestamptz_in(), and WARNING.
Referenced by standard_ProcessUtility().
|
static |
Definition at line 1549 of file user.c.
References Assert(), AUTHMEMROLEMEM, BoolGetDatum, CatalogTupleDelete(), CatalogTupleUpdate(), CommandCounterIncrement(), ereport, errcode(), errmsg(), ERROR, forboth, get_rolespec_name(), GetUserId(), have_createrole_privilege(), heap_modify_tuple(), HeapTupleIsValid, is_admin_of_role(), lfirst, lfirst_oid, list_length(), MemSet, NoLock, ObjectIdGetDatum, RelationGetDescr, ReleaseSysCache(), RowExclusiveLock, SearchSysCache2(), superuser(), superuser_arg(), HeapTupleData::t_self, table_close(), table_open(), and WARNING.
Referenced by AlterRole(), and GrantRole().
void DropOwnedObjects | ( | DropOwnedStmt * | stmt | ) |
Definition at line 1286 of file user.c.
References DropOwnedStmt::behavior, ereport, errcode(), errmsg(), ERROR, GetUserId(), has_privs_of_role(), lfirst_oid, DropOwnedStmt::roles, roleSpecsToIds(), and shdepDropOwned().
Referenced by ProcessUtilitySlow().
void DropRole | ( | DropRoleStmt * | stmt | ) |
Definition at line 909 of file user.c.
References AccessExclusiveLock, AUTHNAME, BTEqualStrategyNumber, CatalogTupleDelete(), checkSharedDependencies(), CommandCounterIncrement(), DeleteSharedComments(), DeleteSharedSecurityLabel(), DropSetting(), ereport, errcode(), errdetail_internal(), errdetail_log(), errmsg(), ERROR, GetOuterUserId(), GetSessionUserId(), GETSTRUCT, GetUserId(), have_createrole_privilege(), HeapTupleIsValid, InvalidOid, InvokeObjectDropHook, lfirst, LockSharedObject(), DropRoleStmt::missing_ok, NoLock, NOTICE, ObjectIdGetDatum, PointerGetDatum, ReleaseSysCache(), RoleSpec::rolename, DropRoleStmt::roles, ROLESPEC_CSTRING, RoleSpec::roletype, RowExclusiveLock, ScanKeyInit(), SearchSysCache1(), superuser(), systable_beginscan(), systable_endscan(), systable_getnext(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by standard_ProcessUtility().
void GrantRole | ( | GrantRoleStmt * | stmt | ) |
Definition at line 1227 of file user.c.
References AccessShareLock, AddRoleMems(), GrantRoleStmt::admin_opt, AccessPriv::cols, DelRoleMems(), ereport, errcode(), errmsg(), ERROR, get_role_oid(), get_rolespec_oid(), GetUserId(), GrantRoleStmt::granted_roles, GrantRoleStmt::grantee_roles, GrantRoleStmt::grantor, GrantRoleStmt::is_grant, lfirst, NIL, NoLock, AccessPriv::priv_name, roleSpecsToIds(), table_close(), and table_open().
Referenced by standard_ProcessUtility().
|
static |
Definition at line 62 of file user.c.
References GetUserId(), and has_createrole_privilege().
Referenced by AddRoleMems(), AlterRole(), AlterRoleSet(), CreateRole(), DelRoleMems(), DropRole(), and RenameRole().
void ReassignOwnedObjects | ( | ReassignOwnedStmt * | stmt | ) |
Definition at line 1312 of file user.c.
References ereport, errcode(), errmsg(), ERROR, get_rolespec_oid(), GetUserId(), has_privs_of_role(), lfirst_oid, ReassignOwnedStmt::newrole, ReassignOwnedStmt::roles, roleSpecsToIds(), and shdepReassignOwned().
Referenced by standard_ProcessUtility().
ObjectAddress RenameRole | ( | const char * | oldname, |
const char * | newname | ||
) |
Definition at line 1087 of file user.c.
References AUTHNAME, CatalogTupleUpdate(), CStringGetDatum, DirectFunctionCall1, elog, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errmsg(), ERROR, get_password_type(), GetOuterUserId(), GetSessionUserId(), GETSTRUCT, have_createrole_privilege(), heap_getattr(), heap_modify_tuple(), HeapTupleIsValid, i, InvokeObjectPostAlterHook, IsReservedName(), namein(), NameStr, NoLock, NOTICE, ObjectAddressSet, PASSWORD_TYPE_MD5, RelationGetDescr, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), SearchSysCacheExists1, superuser(), HeapTupleData::t_self, table_close(), table_open(), TextDatumGetCString, and WARNING.
Referenced by ExecRenameStmt().
Definition at line 1349 of file user.c.
References get_rolespec_oid(), lappend_oid(), lfirst_node, and NIL.
Referenced by AlterRole(), AlterTableMoveAll(), CreateRole(), DropOwnedObjects(), GrantRole(), and ReassignOwnedObjects().
Oid binary_upgrade_next_pg_authid_oid = InvalidOid |
Definition at line 43 of file user.c.
Referenced by binary_upgrade_set_next_pg_authid_oid(), and CreateRole().
check_password_hook_type check_password_hook = NULL |
Definition at line 50 of file user.c.
Referenced by _PG_init(), AlterRole(), and CreateRole().
int Password_encryption = PASSWORD_TYPE_SCRAM_SHA_256 |
Definition at line 47 of file user.c.
Referenced by AlterRole(), CheckPWChallengeAuth(), and CreateRole().