From 763adb5235d3ca07f753e0eeb3f0e3c99545ab93 Mon Sep 17 00:00:00 2001 From: Bryan Henderson Date: Sat, 2 Nov 1996 02:06:47 +0000 Subject: Convenience routine for checking superuser status. --- src/backend/utils/misc/superuser.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/backend/utils/misc/superuser.c (limited to 'src/backend/utils/misc/superuser.c') diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c new file mode 100644 index 00000000000..69781ef34d1 --- /dev/null +++ b/src/backend/utils/misc/superuser.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------------------- + * + * 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 +#include +#include +#include +#include + + + +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; +} + + + -- cgit v1.2.3