PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <selinux/label.h>
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_class.h"
#include "catalog/pg_database.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "commands/dbcommands.h"
#include "commands/seclabel.h"
#include "libpq/auth.h"
#include "libpq/libpq-be.h"
#include "miscadmin.h"
#include "sepgsql.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
Go to the source code of this file.
Data Structures | |
struct | pending_label |
Variables | |
static ClientAuthentication_hook_type | next_client_auth_hook = NULL |
static needs_fmgr_hook_type | next_needs_fmgr_hook = NULL |
static fmgr_hook_type | next_fmgr_hook = NULL |
static char * | client_label_peer = NULL |
static List * | client_label_pending = NIL |
static char * | client_label_committed = NULL |
static char * | client_label_func = NULL |
|
static |
Definition at line 678 of file label.c.
References AccessShareLock, context, elog, ereport, errcode(), errmsg(), ERROR, get_database_name(), get_namespace_name(), get_rel_name(), get_rel_namespace(), get_rel_relkind(), GETSTRUCT, HeapTupleIsValid, InvalidOid, MyDatabaseId, NameStr, NoLock, pfree(), PG_END_TRY, PG_FINALLY, PG_TRY, quote_object_name(), SEPGSQL_LABEL_TAG, sepgsql_object_relabel(), SetSecurityLabel(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), and WARNING.
Referenced by sepgsql_restorecon().
PG_FUNCTION_INFO_V1 | ( | sepgsql_getcon | ) |
PG_FUNCTION_INFO_V1 | ( | sepgsql_mcstrans_in | ) |
PG_FUNCTION_INFO_V1 | ( | sepgsql_mcstrans_out | ) |
PG_FUNCTION_INFO_V1 | ( | sepgsql_restorecon | ) |
PG_FUNCTION_INFO_V1 | ( | sepgsql_setcon | ) |
|
static |
Definition at line 653 of file label.c.
References appendStringInfo(), appendStringInfoString(), StringInfoData::data, initStringInfo(), and quote_identifier().
Referenced by exec_object_restorecon().
|
static |
Definition at line 230 of file label.c.
References client_label_peer, ereport, errcode(), errmsg(), FATAL, next_client_auth_hook, port, sepgsql_get_permissive(), SEPGSQL_MODE_DEFAULT, SEPGSQL_MODE_PERMISSIVE, sepgsql_set_mode(), and STATUS_OK.
Referenced by sepgsql_init_client_label().
|
static |
Definition at line 311 of file label.c.
References Assert, ObjectAddress::classId, client_label_func, DatumGetPointer(), elog, ERROR, FHET_ABORT, FHET_END, FHET_START, FmgrInfo::fn_mcxt, FmgrInfo::fn_oid, getObjectDescription(), MemoryContextSwitchTo(), next_fmgr_hook, palloc(), PointerGetDatum(), SEPG_CLASS_DB_PROCEDURE, SEPG_CLASS_PROCESS, SEPG_DB_PROCEDURE__ENTRYPOINT, SEPG_PROCESS__TRANSITION, sepgsql_avc_check_perms(), sepgsql_avc_check_perms_label(), and sepgsql_avc_trusted_proc().
Referenced by sepgsql_init_client_label().
char* sepgsql_get_client_label | ( | void | ) |
Definition at line 80 of file label.c.
References Assert, client_label_committed, client_label_func, client_label_peer, client_label_pending, pending_label::label, and llast.
Referenced by sepgsql_attribute_post_create(), sepgsql_avc_check_perms_label(), sepgsql_avc_trusted_proc(), sepgsql_database_post_create(), sepgsql_getcon(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), sepgsql_schema_post_create(), and sepgsql_set_client_label().
Definition at line 445 of file label.c.
References ereport, errcode(), errmsg(), ERROR, GetSecurityLabel(), label, PG_END_TRY, PG_FINALLY, PG_TRY, pstrdup(), and SEPGSQL_LABEL_TAG.
Referenced by sepgsql_attribute_post_create(), sepgsql_database_post_create(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), and sepgsql_schema_post_create().
Datum sepgsql_getcon | ( | PG_FUNCTION_ARGS | ) |
Definition at line 537 of file label.c.
References cstring_to_text(), PG_RETURN_NULL, PG_RETURN_TEXT_P, sepgsql_get_client_label(), and sepgsql_is_enabled().
void sepgsql_init_client_label | ( | void | ) |
Definition at line 404 of file label.c.
References client_label_peer, ClientAuthentication_hook, ereport, errcode(), errmsg(), ERROR, fmgr_hook, needs_fmgr_hook, next_client_auth_hook, next_fmgr_hook, next_needs_fmgr_hook, RegisterSubXactCallback(), RegisterXactCallback(), sepgsql_client_auth(), sepgsql_fmgr_hook(), sepgsql_needs_fmgr_hook(), sepgsql_subxact_callback(), and sepgsql_xact_callback().
Referenced by _PG_init().
Datum sepgsql_mcstrans_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 578 of file label.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, label, PG_END_TRY, PG_FINALLY, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, PG_TRY, pstrdup(), sepgsql_is_enabled(), and text_to_cstring().
Datum sepgsql_mcstrans_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 616 of file label.c.
References cstring_to_text(), ereport, errcode(), errmsg(), ERROR, label, PG_END_TRY, PG_FINALLY, PG_GETARG_TEXT_PP, PG_RETURN_TEXT_P, PG_TRY, pstrdup(), sepgsql_is_enabled(), and text_to_cstring().
|
static |
Definition at line 268 of file label.c.
References ObjectAddress::classId, next_needs_fmgr_hook, SEPG_CLASS_DB_PROCEDURE, SEPG_DB_PROCEDURE__ENTRYPOINT, SEPG_DB_PROCEDURE__EXECUTE, sepgsql_avc_check_perms(), SEPGSQL_AVC_NOAUDIT, and sepgsql_avc_trusted_proc().
Referenced by sepgsql_init_client_label().
void sepgsql_object_relabel | ( | const ObjectAddress * | object, |
const char * | seclabel | ||
) |
Definition at line 482 of file label.c.
References ObjectAddress::classId, ereport, errcode(), errmsg(), ERROR, getObjectTypeDescription(), ObjectAddress::objectId, ObjectAddress::objectSubId, sepgsql_attribute_relabel(), sepgsql_database_relabel(), sepgsql_proc_relabel(), sepgsql_relation_relabel(), and sepgsql_schema_relabel().
Referenced by _PG_init(), and exec_object_restorecon().
Datum sepgsql_restorecon | ( | PG_FUNCTION_ARGS | ) |
Definition at line 860 of file label.c.
References ereport, errcode(), errmsg(), ERROR, exec_object_restorecon(), PG_ARGISNULL, PG_END_TRY, PG_FINALLY, PG_GETARG_DATUM, PG_RETURN_BOOL, PG_TRY, sepgsql_is_enabled(), superuser(), and TextDatumGetCString.
|
static |
Definition at line 111 of file label.c.
References client_label_peer, client_label_pending, CurTransactionContext, ereport, errcode(), errmsg(), ERROR, GetCurrentSubTransactionId(), pending_label::label, lappend(), MemoryContextSwitchTo(), palloc0(), pstrdup(), SEPG_CLASS_PROCESS, SEPG_PROCESS__DYNTRANSITION, SEPG_PROCESS__SETCURRENT, sepgsql_avc_check_perms_label(), sepgsql_get_client_label(), and pending_label::subid.
Referenced by sepgsql_setcon().
Datum sepgsql_setcon | ( | PG_FUNCTION_ARGS | ) |
Definition at line 556 of file label.c.
References PG_ARGISNULL, PG_GETARG_DATUM, PG_RETURN_BOOL, sepgsql_set_client_label(), and TextDatumGetCString.
|
static |
Definition at line 204 of file label.c.
References client_label_pending, foreach_delete_current, lfirst, pending_label::subid, and SUBXACT_EVENT_ABORT_SUB.
Referenced by sepgsql_init_client_label().
|
static |
Definition at line 165 of file label.c.
References client_label_committed, client_label_pending, pending_label::label, llast, MemoryContextStrdup(), NIL, pfree(), TopMemoryContext, XACT_EVENT_ABORT, and XACT_EVENT_COMMIT.
Referenced by sepgsql_init_client_label().
|
static |
Definition at line 62 of file label.c.
Referenced by sepgsql_get_client_label(), and sepgsql_xact_callback().
|
static |
Definition at line 64 of file label.c.
Referenced by sepgsql_fmgr_hook(), and sepgsql_get_client_label().
|
static |
Definition at line 59 of file label.c.
Referenced by sepgsql_client_auth(), sepgsql_get_client_label(), sepgsql_init_client_label(), and sepgsql_set_client_label().
Definition at line 60 of file label.c.
Referenced by sepgsql_get_client_label(), sepgsql_set_client_label(), sepgsql_subxact_callback(), and sepgsql_xact_callback().
|
static |
Definition at line 42 of file label.c.
Referenced by sepgsql_client_auth(), and sepgsql_init_client_label().
|
static |
Definition at line 44 of file label.c.
Referenced by sepgsql_fmgr_hook(), and sepgsql_init_client_label().
|
static |
Definition at line 43 of file label.c.
Referenced by sepgsql_init_client_label(), and sepgsql_needs_fmgr_hook().