PostgreSQL Source Code  git master
dummy_seclabel.c File Reference
#include "postgres.h"
#include "commands/seclabel.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 49 of file dummy_seclabel.c.

References dummy_object_relabel(), and register_label_provider().

50 {
52 }
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 27 of file dummy_seclabel.c.

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

Referenced by _PG_init().

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

◆ dummy_seclabel_dummy()

Datum dummy_seclabel_dummy ( PG_FUNCTION_ARGS  )

Definition at line 59 of file dummy_seclabel.c.

References PG_RETURN_VOID.

60 {
62 }
#define PG_RETURN_VOID()
Definition: fmgr.h:309

◆ PG_FUNCTION_INFO_V1()

PG_FUNCTION_INFO_V1 ( dummy_seclabel_dummy  )

Variable Documentation

◆ PG_MODULE_MAGIC

PG_MODULE_MAGIC

Definition at line 19 of file dummy_seclabel.c.