1996-11-02 03:06:47 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* superuser.c
|
1996-11-02 03:06:47 +01:00
|
|
|
*
|
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
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-11-02 03:06:47 +01:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2000-11-16 23:30:52 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.16 2000/11/16 22:30:40 tgl 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
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
#include "catalog/pg_shadow.h"
|
1999-07-16 07:23:30 +02:00
|
|
|
#include "utils/syscache.h"
|
2000-01-14 23:11:38 +01:00
|
|
|
#include "miscadmin.h"
|
1996-11-02 03:06:47 +01:00
|
|
|
|
|
|
|
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-08 04:41:22 +02:00
|
|
|
HeapTuple utup;
|
2000-11-16 23:30:52 +01:00
|
|
|
bool result;
|
1996-11-02 03:06:47 +01:00
|
|
|
|
2000-11-16 23:30:52 +01:00
|
|
|
utup = SearchSysCache(SHADOWSYSID,
|
|
|
|
ObjectIdGetDatum(GetUserId()),
|
|
|
|
0, 0, 0);
|
|
|
|
if (HeapTupleIsValid(utup))
|
|
|
|
{
|
|
|
|
result = ((Form_pg_shadow) GETSTRUCT(utup))->usesuper;
|
|
|
|
ReleaseSysCache(utup);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
return false;
|
1996-11-02 03:06:47 +01:00
|
|
|
}
|