1996-11-02 02:06:47 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* superuser.c
|
1996-11-02 02:06:47 +00:00
|
|
|
*
|
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
|
|
|
*
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-11-02 02:06:47 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2000-09-06 14:15:31 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.15 2000/09/06 14:15:22 petere 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
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1999-07-15 23:04:24 +00:00
|
|
|
#include "postgres.h"
|
|
|
|
#include "catalog/pg_shadow.h"
|
1999-07-16 05:23:30 +00:00
|
|
|
#include "utils/syscache.h"
|
2000-01-14 22:11:38 +00:00
|
|
|
#include "miscadmin.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
|
|
|
HeapTuple utup;
|
1996-11-02 02:06:47 +00:00
|
|
|
|
2000-09-06 14:15:31 +00:00
|
|
|
utup = SearchSysCacheTuple(SHADOWSYSID,
|
|
|
|
ObjectIdGetDatum(GetUserId()),
|
1998-09-01 04:40:42 +00:00
|
|
|
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
|
|
|
}
|