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

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

Variables

 PG_MODULE_MAGIC
 

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 47 of file dummy_seclabel.c.

48 {
50 }
static void dummy_object_relabel(const ObjectAddress *object, const char *seclabel)
void register_label_provider(const char *provider_name, check_object_relabel_type hook)
Definition: seclabel.c:570

References dummy_object_relabel(), and register_label_provider().

◆ dummy_object_relabel()

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

Definition at line 25 of file dummy_seclabel.c.

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

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

Referenced by _PG_init().

◆ dummy_seclabel_dummy()

Datum dummy_seclabel_dummy ( PG_FUNCTION_ARGS  )

Definition at line 57 of file dummy_seclabel.c.

58 {
60 }
#define PG_RETURN_VOID()
Definition: fmgr.h:349

References PG_RETURN_VOID.

◆ 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.