1996-11-02 02:06:47 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* superuser.c--
|
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* The superuser() function. Determines if user has superuser privilege.
|
1996-11-02 02:06:47 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1998-08-19 02:04:17 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.6 1998/08/19 02:03:25 momjian Exp $
|
1996-11-02 02:06:47 +00:00
|
|
|
*
|
|
|
|
* DESCRIPTION
|
1997-09-07 05:04:48 +00:00
|
|
|
* See superuser().
|
1996-11-02 02:06:47 +00:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <postgres.h>
|
|
|
|
#include <utils/syscache.h>
|
1998-02-25 13:09:49 +00:00
|
|
|
#include <catalog/pg_shadow.h>
|
1996-11-02 02:06:47 +00:00
|
|
|
|
|
|
|
bool
|
1997-09-07 05:04:48 +00:00
|
|
|
superuser(void)
|
|
|
|
{
|
1996-11-02 02:06:47 +00:00
|
|
|
/*--------------------------------------------------------------------------
|
1997-09-07 05:04:48 +00:00
|
|
|
The Postgres user running this command has Postgres superuser
|
|
|
|
privileges.
|
1996-11-02 02:06:47 +00:00
|
|
|
--------------------------------------------------------------------------*/
|
1997-09-08 02:41:22 +00:00
|
|
|
extern char *UserName; /* defined in global.c */
|
1996-11-02 02:06:47 +00:00
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
HeapTuple utup;
|
1996-11-02 02:06:47 +00:00
|
|
|
|
1998-08-19 02:04:17 +00:00
|
|
|
utup = SearchSysCacheTuple(USENAME,
|
|
|
|
PointerGetDatum(UserName),
|
|
|
|
0, 0, 0);
|
1997-09-07 05:04:48 +00:00
|
|
|
Assert(utup != NULL);
|
1998-02-25 13:09:49 +00:00
|
|
|
return ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
|
1996-11-02 02:06:47 +00:00
|
|
|
}
|