1996-11-02 03:06:47 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* superuser.c--
|
|
|
|
*
|
|
|
|
* The superuser() function. Determines if user has superuser privilege.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1996-11-04 00:46:28 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.2 1996/11/03 23:46:28 scrappy Exp $
|
1996-11-02 03:06:47 +01:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* See superuser().
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <postgres.h>
|
|
|
|
#include <utils/syscache.h>
|
|
|
|
#include <catalog/pg_user.h>
|
|
|
|
|
|
|
|
bool
|
|
|
|
superuser(void) {
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
The Postgres user running this command has Postgres superuser
|
|
|
|
privileges.
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
extern char *UserName; /* defined in global.c */
|
|
|
|
|
|
|
|
HeapTuple utup;
|
|
|
|
|
|
|
|
utup = SearchSysCacheTuple(USENAME, PointerGetDatum(UserName),
|
|
|
|
0,0,0);
|
|
|
|
Assert(utup != NULL);
|
|
|
|
return ((Form_pg_user)GETSTRUCT(utup))->usesuper;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|