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