mirror of https://github.com/postgres/postgres
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
|
30 years ago
|
/*-------------------------------------------------------------------------
|
||
|
|
*
|
||
|
|
* superuser.c--
|
||
|
|
*
|
||
|
|
* The superuser() function. Determines if user has superuser privilege.
|
||
|
|
*
|
||
|
|
* Copyright (c) 1994, Regents of the University of California
|
||
|
|
*
|
||
|
|
*
|
||
|
|
* IDENTIFICATION
|
||
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.1 1996/11/02 02:06:47 bryanh Exp $
|
||
|
|
*
|
||
|
|
* DESCRIPTION
|
||
|
|
* See superuser().
|
||
|
|
*-------------------------------------------------------------------------
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <c.h>
|
||
|
|
#include <postgres.h>
|
||
|
|
#include <access/htup.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;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|