More cleanup of userid to be AclId rather than Oid.
This commit is contained in:
parent
caaf941070
commit
7816c7cb94
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.98 2002/12/04 05:18:33 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.99 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -68,7 +68,7 @@ static void recreate_indexattr(Oid OIDOldHeap, List *indexes);
|
||||
static void swap_relfilenodes(Oid r1, Oid r2);
|
||||
static void cluster_rel(relToCluster *rv);
|
||||
static bool check_cluster_ownership(Oid relOid);
|
||||
static List *get_tables_to_cluster(Oid owner);
|
||||
static List *get_tables_to_cluster(AclId owner);
|
||||
|
||||
static MemoryContext cluster_context = NULL;
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.108 2002/12/02 05:20:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.109 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -63,7 +63,7 @@ createdb(const CreatedbStmt *stmt)
|
||||
char src_loc[MAXPGPATH];
|
||||
char buf[2 * MAXPGPATH + 100];
|
||||
Oid src_dboid;
|
||||
int4 src_owner;
|
||||
AclId src_owner;
|
||||
int src_encoding;
|
||||
bool src_istemplate;
|
||||
Oid src_lastsysoid;
|
||||
@ -76,7 +76,7 @@ createdb(const CreatedbStmt *stmt)
|
||||
Datum new_record[Natts_pg_database];
|
||||
char new_record_nulls[Natts_pg_database];
|
||||
Oid dboid;
|
||||
int32 datdba;
|
||||
AclId datdba;
|
||||
List *option;
|
||||
DefElem *downer = NULL;
|
||||
DefElem *dpath = NULL;
|
||||
@ -157,7 +157,7 @@ createdb(const CreatedbStmt *stmt)
|
||||
else
|
||||
datdba = GetUserId();
|
||||
|
||||
if (datdba == (int32) GetUserId())
|
||||
if (datdba == GetUserId())
|
||||
{
|
||||
/* creating database for self: can be superuser or createdb */
|
||||
if (!superuser() && !have_createdb_privilege())
|
||||
@ -670,7 +670,7 @@ have_createdb_privilege(void)
|
||||
bool retval;
|
||||
|
||||
utup = SearchSysCache(SHADOWSYSID,
|
||||
ObjectIdGetDatum(GetUserId()),
|
||||
Int32GetDatum(GetUserId()),
|
||||
0, 0, 0);
|
||||
|
||||
if (!HeapTupleIsValid(utup))
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.6 2002/09/04 20:31:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.7 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -41,8 +41,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
|
||||
List *parsetree_list;
|
||||
List *parsetree_item;
|
||||
const char *owner_name;
|
||||
Oid owner_userid;
|
||||
Oid saved_userid;
|
||||
AclId owner_userid;
|
||||
AclId saved_userid;
|
||||
AclResult aclresult;
|
||||
|
||||
saved_userid = GetUserId();
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.114 2002/12/02 05:20:47 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.115 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -984,7 +984,7 @@ DropUser(DropUserStmt *stmt)
|
||||
TupleDesc pg_dsc;
|
||||
ScanKeyData scankey;
|
||||
HeapScanDesc scan;
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
|
||||
tuple = SearchSysCache(SHADOWNAME,
|
||||
PointerGetDatum(user),
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.71 2002/09/04 20:31:17 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.72 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -526,7 +526,7 @@ show_server_encoding(void)
|
||||
const char *
|
||||
assign_session_authorization(const char *value, bool doit, bool interactive)
|
||||
{
|
||||
Oid usesysid;
|
||||
AclId usesysid;
|
||||
char *endptr;
|
||||
char *result;
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.188 2002/11/29 19:03:01 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.189 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -346,7 +346,7 @@ static void
|
||||
ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation)
|
||||
{
|
||||
Oid relOid;
|
||||
Oid userid;
|
||||
AclId userid;
|
||||
AclResult aclcheck_result;
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.80 2002/09/11 14:48:54 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.81 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -32,7 +32,7 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
static void setRuleCheckAsUser(Query *qry, Oid userid);
|
||||
static void setRuleCheckAsUser(Query *qry, AclId userid);
|
||||
static bool setRuleCheckAsUser_walker(Node *node, Oid *context);
|
||||
|
||||
|
||||
@ -445,7 +445,7 @@ DefineQueryRewrite(RuleStmt *stmt)
|
||||
* them always.
|
||||
*/
|
||||
static void
|
||||
setRuleCheckAsUser(Query *qry, Oid userid)
|
||||
setRuleCheckAsUser(Query *qry, AclId userid)
|
||||
{
|
||||
List *l;
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.83 2002/11/13 00:39:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.84 2002/12/05 04:04:42 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -703,7 +703,7 @@ has_table_privilege_name(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *tablename = PG_GETARG_TEXT_P(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
Oid tableoid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
@ -751,7 +751,7 @@ has_table_privilege_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid tableoid = PG_GETARG_OID(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
|
||||
@ -913,7 +913,7 @@ has_database_privilege_name(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *databasename = PG_GETARG_TEXT_P(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
Oid databaseoid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
@ -961,7 +961,7 @@ has_database_privilege_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid databaseoid = PG_GETARG_OID(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
|
||||
@ -1116,7 +1116,7 @@ has_function_privilege_name(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *functionname = PG_GETARG_TEXT_P(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
Oid functionoid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
@ -1164,7 +1164,7 @@ has_function_privilege_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid functionoid = PG_GETARG_OID(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
|
||||
@ -1315,7 +1315,7 @@ has_language_privilege_name(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *languagename = PG_GETARG_TEXT_P(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
Oid languageoid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
@ -1363,7 +1363,7 @@ has_language_privilege_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid languageoid = PG_GETARG_OID(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
|
||||
@ -1514,7 +1514,7 @@ has_schema_privilege_name(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *schemaname = PG_GETARG_TEXT_P(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
Oid schemaoid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
@ -1562,7 +1562,7 @@ has_schema_privilege_id(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid schemaoid = PG_GETARG_OID(0);
|
||||
text *priv_type_text = PG_GETARG_TEXT_P(1);
|
||||
int32 usesysid;
|
||||
AclId usesysid;
|
||||
AclMode mode;
|
||||
AclResult aclresult;
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.44 2002/11/29 21:39:11 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.45 2002/12/05 04:04:43 momjian Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@ -171,7 +171,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
|
||||
bool isnull;
|
||||
int i;
|
||||
int match_type;
|
||||
Oid save_uid;
|
||||
AclId save_uid;
|
||||
|
||||
save_uid = GetUserId();
|
||||
|
||||
@ -546,7 +546,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
|
||||
Datum check_values[RI_MAX_NUMKEYS];
|
||||
char check_nulls[RI_MAX_NUMKEYS + 1];
|
||||
int i;
|
||||
Oid save_uid;
|
||||
AclId save_uid;
|
||||
bool result;
|
||||
|
||||
save_uid = GetUserId();
|
||||
@ -712,7 +712,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
|
||||
bool isnull;
|
||||
int i;
|
||||
int match_type;
|
||||
Oid save_uid;
|
||||
AclId save_uid;
|
||||
|
||||
save_uid = GetUserId();
|
||||
|
||||
@ -942,7 +942,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
|
||||
bool isnull;
|
||||
int i;
|
||||
int match_type;
|
||||
Oid save_uid;
|
||||
AclId save_uid;
|
||||
|
||||
save_uid = GetUserId();
|
||||
|
||||
@ -1179,8 +1179,8 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
|
||||
char del_nulls[RI_MAX_NUMKEYS + 1];
|
||||
bool isnull;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -1387,8 +1387,8 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
|
||||
bool isnull;
|
||||
int i;
|
||||
int j;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -1631,8 +1631,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
|
||||
char del_nulls[RI_MAX_NUMKEYS + 1];
|
||||
bool isnull;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -1854,8 +1854,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
|
||||
char upd_nulls[RI_MAX_NUMKEYS + 1];
|
||||
bool isnull;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -2082,8 +2082,8 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
|
||||
char upd_nulls[RI_MAX_NUMKEYS + 1];
|
||||
bool isnull;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -2301,8 +2301,8 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
|
||||
int i;
|
||||
int match_type;
|
||||
bool use_cached_query;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -2566,8 +2566,8 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
|
||||
char upd_nulls[RI_MAX_NUMKEYS + 1];
|
||||
bool isnull;
|
||||
int i;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
@ -2828,8 +2828,8 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
|
||||
bool isnull;
|
||||
int i;
|
||||
int match_type;
|
||||
Oid save_uid;
|
||||
Oid fk_owner;
|
||||
AclId save_uid;
|
||||
AclId fk_owner;
|
||||
|
||||
ReferentialIntegritySnapshotOverride = true;
|
||||
|
||||
|
5
src/backend/utils/cache/lsyscache.c
vendored
5
src/backend/utils/cache/lsyscache.c
vendored
@ -7,13 +7,14 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.87 2002/12/01 21:05:14 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.88 2002/12/05 04:04:44 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "miscadmin.h"
|
||||
|
||||
#include "access/tupmacs.h"
|
||||
#include "catalog/pg_amop.h"
|
||||
@ -1529,7 +1530,7 @@ get_namespace_name(Oid nspid)
|
||||
* someday. It'd be reasonable to return zero on failure if we were
|
||||
* using Oid ...
|
||||
*/
|
||||
int32
|
||||
AclId
|
||||
get_usesysid(const char *username)
|
||||
{
|
||||
int32 result;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.66 2002/11/13 00:39:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.67 2002/12/05 04:04:44 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -633,7 +633,7 @@ fmgr_oldstyle(PG_FUNCTION_ARGS)
|
||||
struct fmgr_security_definer_cache
|
||||
{
|
||||
FmgrInfo flinfo;
|
||||
Oid userid;
|
||||
AclId userid;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -650,7 +650,7 @@ fmgr_security_definer(PG_FUNCTION_ARGS)
|
||||
Datum result;
|
||||
FmgrInfo *save_flinfo;
|
||||
struct fmgr_security_definer_cache *fcache;
|
||||
Oid save_userid;
|
||||
AclId save_userid;
|
||||
HeapTuple tuple;
|
||||
|
||||
if (!fcinfo->flinfo->fn_extra)
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.97 2002/11/08 20:23:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.98 2002/12/05 04:04:46 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -484,27 +484,27 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
||||
* restore the current user id if you need to change it.
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
static Oid AuthenticatedUserId = InvalidOid;
|
||||
static Oid SessionUserId = InvalidOid;
|
||||
static Oid CurrentUserId = InvalidOid;
|
||||
static AclId AuthenticatedUserId = 0;
|
||||
static AclId SessionUserId = 0;
|
||||
static AclId CurrentUserId = 0;
|
||||
|
||||
static bool AuthenticatedUserIsSuperuser = false;
|
||||
|
||||
/*
|
||||
* This function is relevant for all privilege checks.
|
||||
*/
|
||||
Oid
|
||||
AclId
|
||||
GetUserId(void)
|
||||
{
|
||||
AssertState(OidIsValid(CurrentUserId));
|
||||
AssertState(AclIdIsValid(CurrentUserId));
|
||||
return CurrentUserId;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SetUserId(Oid newid)
|
||||
SetUserId(AclId newid)
|
||||
{
|
||||
AssertArg(OidIsValid(newid));
|
||||
AssertArg(AclIdIsValid(newid));
|
||||
CurrentUserId = newid;
|
||||
}
|
||||
|
||||
@ -512,21 +512,21 @@ SetUserId(Oid newid)
|
||||
/*
|
||||
* This value is only relevant for informational purposes.
|
||||
*/
|
||||
Oid
|
||||
AclId
|
||||
GetSessionUserId(void)
|
||||
{
|
||||
AssertState(OidIsValid(SessionUserId));
|
||||
AssertState(AclIdIsValid(SessionUserId));
|
||||
return SessionUserId;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SetSessionUserId(Oid newid)
|
||||
SetSessionUserId(AclId newid)
|
||||
{
|
||||
AssertArg(OidIsValid(newid));
|
||||
AssertArg(AclIdIsValid(newid));
|
||||
SessionUserId = newid;
|
||||
/* Current user defaults to session user. */
|
||||
if (!OidIsValid(CurrentUserId))
|
||||
if (!AclIdIsValid(CurrentUserId))
|
||||
CurrentUserId = newid;
|
||||
}
|
||||
|
||||
@ -537,7 +537,7 @@ InitializeSessionUserId(const char *username)
|
||||
HeapTuple userTup;
|
||||
Datum datum;
|
||||
bool isnull;
|
||||
Oid usesysid;
|
||||
AclId usesysid;
|
||||
|
||||
/*
|
||||
* Don't do scans if we're bootstrapping, none of the system catalogs
|
||||
@ -605,10 +605,10 @@ InitializeSessionUserIdStandalone(void)
|
||||
* Only a superuser may set auth ID to something other than himself.
|
||||
*/
|
||||
void
|
||||
SetSessionAuthorization(Oid userid)
|
||||
SetSessionAuthorization(AclId userid)
|
||||
{
|
||||
/* Must have authenticated already, else can't make permission check */
|
||||
AssertState(OidIsValid(AuthenticatedUserId));
|
||||
AssertState(AclIdIsValid(AuthenticatedUserId));
|
||||
|
||||
if (userid != AuthenticatedUserId &&
|
||||
!AuthenticatedUserIsSuperuser)
|
||||
@ -623,7 +623,7 @@ SetSessionAuthorization(Oid userid)
|
||||
* Get user name from user id
|
||||
*/
|
||||
char *
|
||||
GetUserNameFromId(Oid userid)
|
||||
GetUserNameFromId(AclId userid)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
char *result;
|
||||
@ -632,7 +632,7 @@ GetUserNameFromId(Oid userid)
|
||||
ObjectIdGetDatum(userid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "invalid user id %u", (unsigned) userid);
|
||||
elog(ERROR, "invalid user id %d", userid);
|
||||
|
||||
result = pstrdup(NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename));
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.24 2002/08/09 16:45:14 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.25 2002/12/05 04:04:47 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -39,7 +39,7 @@ superuser(void)
|
||||
|
||||
|
||||
bool
|
||||
superuser_arg(Oid userid)
|
||||
superuser_arg(AclId userid)
|
||||
{
|
||||
bool result = false;
|
||||
HeapTuple utup;
|
||||
@ -49,7 +49,7 @@ superuser_arg(Oid userid)
|
||||
return true;
|
||||
|
||||
utup = SearchSysCache(SHADOWSYSID,
|
||||
ObjectIdGetDatum(userid),
|
||||
Int32GetDatum(userid),
|
||||
0, 0, 0);
|
||||
if (HeapTupleIsValid(utup))
|
||||
{
|
||||
@ -67,7 +67,7 @@ superuser_arg(Oid userid)
|
||||
bool
|
||||
is_dbadmin(Oid dbid)
|
||||
{
|
||||
Oid dba;
|
||||
AclId dba;
|
||||
|
||||
dba = get_database_owner(dbid);
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: c.h,v 1.132 2002/11/13 00:37:06 momjian Exp $
|
||||
* $Id: c.h,v 1.133 2002/12/05 04:04:48 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -462,6 +462,8 @@ typedef NameData *Name;
|
||||
|
||||
#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
|
||||
|
||||
#define AclIdIsValid(aclId) ((bool) ((aclId) != 0))
|
||||
|
||||
#define RegProcedureIsValid(p) OidIsValid(p)
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: miscadmin.h,v 1.112 2002/12/04 05:18:34 momjian Exp $
|
||||
* $Id: miscadmin.h,v 1.113 2002/12/05 04:04:50 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* some of the information in this file should be moved to
|
||||
@ -200,21 +200,20 @@ extern char *ExpandDatabasePath(const char *path);
|
||||
extern void SetDatabaseName(const char *name);
|
||||
extern void SetDatabasePath(const char *path);
|
||||
|
||||
extern char *GetUserNameFromId(Oid userid);
|
||||
|
||||
/*
|
||||
* AclId system identifier for the user, group, etc.
|
||||
* XXX Perhaps replace this type by OID?
|
||||
*/
|
||||
typedef uint32 AclId;
|
||||
typedef int32 AclId;
|
||||
|
||||
extern char *GetUserNameFromId(AclId userid);
|
||||
|
||||
extern AclId GetUserId(void);
|
||||
extern void SetUserId(Oid userid);
|
||||
extern Oid GetSessionUserId(void);
|
||||
extern void SetSessionUserId(Oid userid);
|
||||
extern void SetUserId(AclId userid);
|
||||
extern AclId GetSessionUserId(void);
|
||||
extern void SetSessionUserId(AclId userid);
|
||||
extern void InitializeSessionUserId(const char *username);
|
||||
extern void InitializeSessionUserIdStandalone(void);
|
||||
extern void SetSessionAuthorization(Oid userid);
|
||||
extern void SetSessionAuthorization(AclId userid);
|
||||
|
||||
extern void SetDataDir(const char *dir);
|
||||
|
||||
@ -229,7 +228,7 @@ extern char *convertstr(unsigned char *buff, int len, int dest);
|
||||
|
||||
/* in utils/misc/superuser.c */
|
||||
extern bool superuser(void); /* current user is superuser */
|
||||
extern bool superuser_arg(Oid userid); /* given user is superuser */
|
||||
extern bool superuser_arg(AclId userid); /* given user is superuser */
|
||||
extern bool is_dbadmin(Oid dbid); /* current user is owner of
|
||||
* database */
|
||||
|
||||
|
@ -5,12 +5,14 @@
|
||||
*
|
||||
* Copyright (c) 2001, PostgreSQL Global Development Group
|
||||
*
|
||||
* $Id: pgstat.h,v 1.10 2001/11/05 17:46:31 momjian Exp $
|
||||
* $Id: pgstat.h,v 1.11 2002/12/05 04:04:51 momjian Exp $
|
||||
* ----------
|
||||
*/
|
||||
#ifndef PGSTAT_H
|
||||
#define PGSTAT_H
|
||||
|
||||
#include "miscadmin.h"
|
||||
|
||||
/* ----------
|
||||
* Paths for the statistics files. The %s is replaced with the
|
||||
* installations $PGDATA.
|
||||
@ -170,7 +172,7 @@ typedef struct PgStat_MsgHdr
|
||||
int m_backendid;
|
||||
int m_procpid;
|
||||
Oid m_databaseid;
|
||||
Oid m_userid;
|
||||
AclId m_userid;
|
||||
} PgStat_MsgHdr;
|
||||
|
||||
/* ----------
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: acl.h,v 1.48 2002/12/04 05:18:38 momjian Exp $
|
||||
* $Id: acl.h,v 1.49 2002/12/05 04:04:51 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* For backward-compatibility purposes we have to allow there
|
||||
@ -190,11 +190,11 @@ extern void ExecuteGrantStmt(GrantStmt *stmt);
|
||||
extern AclId get_grosysid(char *groname);
|
||||
extern char *get_groname(AclId grosysid);
|
||||
|
||||
extern AclResult pg_class_aclcheck(Oid table_oid, Oid userid, AclMode mode);
|
||||
extern AclResult pg_database_aclcheck(Oid db_oid, Oid userid, AclMode mode);
|
||||
extern AclResult pg_proc_aclcheck(Oid proc_oid, Oid userid, AclMode mode);
|
||||
extern AclResult pg_language_aclcheck(Oid lang_oid, Oid userid, AclMode mode);
|
||||
extern AclResult pg_namespace_aclcheck(Oid nsp_oid, Oid userid, AclMode mode);
|
||||
extern AclResult pg_class_aclcheck(Oid table_oid, AclId userid, AclMode mode);
|
||||
extern AclResult pg_database_aclcheck(Oid db_oid, AclId userid, AclMode mode);
|
||||
extern AclResult pg_proc_aclcheck(Oid proc_oid, AclId userid, AclMode mode);
|
||||
extern AclResult pg_language_aclcheck(Oid lang_oid, AclId userid, AclMode mode);
|
||||
extern AclResult pg_namespace_aclcheck(Oid nsp_oid, AclId userid, AclMode mode);
|
||||
|
||||
extern void aclcheck_error(AclResult errcode, const char *objectname);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user