Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit763adb5

Browse files
author
Bryan Henderson
committed
Convenience routine for checking superuser status.
1 parent675740a commit763adb5

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

‎src/backend/utils/misc/Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# Makefile--
4+
# Makefile for utils/misc
5+
#
6+
# IDENTIFICATION
7+
# $Header: /cvsroot/pgsql/src/backend/utils/misc/Makefile,v 1.1 1996/11/02 02:06:46 bryanh Exp $
8+
#
9+
#-------------------------------------------------------------------------
10+
11+
SRCDIR = ../../..
12+
include ../../../Makefile.global
13+
14+
INCLUDE_OPT =\
15+
-I../../port/$(PORTNAME)\
16+
-I../../include\
17+
-I../../../include
18+
19+
CFLAGS +=$(INCLUDE_OPT)
20+
21+
OBJS = superuser.o
22+
23+
all: SUBSYS.o
24+
25+
SUBSYS.o:$(OBJS)
26+
$(LD) -r -o SUBSYS.o$(OBJS)
27+
28+
dependdep:
29+
$(CC) -MM$(INCLUDE_OPT)*.c>depend
30+
31+
clean:
32+
rm -f SUBSYS.o$(OBJS)
33+
34+
ifeq (depend,$(wildcard depend))
35+
include depend
36+
endif
37+

‎src/backend/utils/misc/superuser.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* superuser.c--
4+
*
5+
* The superuser() function. Determines if user has superuser privilege.
6+
*
7+
* Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.1 1996/11/02 02:06:47 bryanh Exp $
12+
*
13+
* DESCRIPTION
14+
* See superuser().
15+
*-------------------------------------------------------------------------
16+
*/
17+
18+
#include<c.h>
19+
#include<postgres.h>
20+
#include<access/htup.h>
21+
#include<utils/syscache.h>
22+
#include<catalog/pg_user.h>
23+
24+
25+
26+
bool
27+
superuser(void) {
28+
/*--------------------------------------------------------------------------
29+
The Postgres user running this command has Postgres superuser
30+
privileges.
31+
--------------------------------------------------------------------------*/
32+
externchar*UserName;/* defined in global.c */
33+
34+
HeapTupleutup;
35+
36+
utup=SearchSysCacheTuple(USENAME,PointerGetDatum(UserName),
37+
0,0,0);
38+
Assert(utup!=NULL);
39+
return ((Form_pg_user)GETSTRUCT(utup))->usesuper;
40+
}
41+
42+
43+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp