PostgreSQL Source Code  git master
dummy_seclabel.c File Reference
#include "postgres.h"
#include "commands/seclabel.h"
#include "fmgr.h"
#include "miscadmin.h"
#include "utils/rel.h"
Include dependency graph for dummy_seclabel.c:

Go to the source code of this file.

Functions

void _PG_init (void)
 
 PG_FUNCTION_INFO_V1 (dummy_seclabel_dummy)
 
static void dummy_object_relabel (const ObjectAddress *object, const char *seclabel)
 
Datum dummy_seclabel_dummy (PG_FUNCTION_ARGS)
 

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 50 of file dummy_seclabel.c.

References dummy_object_relabel(), and register_label_provider().

51 {
53 }
void register_label_provider(const char *provider_name, check_object_relabel_type hook)
Definition: seclabel.c:493
static void dummy_object_relabel(const ObjectAddress *object, const char *seclabel)

◆ dummy_object_relabel()

static void dummy_object_relabel ( const ObjectAddress object,
const char *  seclabel 
)
static

Definition at line 28 of file dummy_seclabel.c.

References ereport, errcode(), errmsg(), ERROR, and superuser().

Referenced by _PG_init().

29 {
30  if (seclabel == NULL ||
31  strcmp(seclabel, "unclassified") == 0 ||
32  strcmp(seclabel, "classified") == 0)
33  return;
34 
35  if (strcmp(seclabel, "secret") == 0 ||
36  strcmp(seclabel, "top secret") == 0)
37  {
38  if (!superuser())
39  ereport(ERROR,
40  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
41  errmsg("only superuser can set '%s' label", seclabel)));
42  return;
43  }
44  ereport(ERROR,
45  (errcode(ERRCODE_INVALID_NAME),
46  errmsg("'%s' is not a valid security label", seclabel)));
47 }
int errcode(int sqlerrcode)
Definition: elog.c:608
bool superuser(void)
Definition: superuser.c:46
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:141
int errmsg(const char *fmt,...)
Definition: elog.c:822

◆ dummy_seclabel_dummy()

Datum dummy_seclabel_dummy ( PG_FUNCTION_ARGS  )

Definition at line 60 of file dummy_seclabel.c.

References PG_RETURN_VOID.

61 {
63 }
#define PG_RETURN_VOID()
Definition: fmgr.h:339

◆ PG_FUNCTION_INFO_V1()

PG_FUNCTION_INFO_V1 ( dummy_seclabel_dummy  )

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 20 of file dummy_seclabel.c.