MCPcopy Create free account
hub / github.com/apache/cloudberry / sepgsql_mcstrans_in

Function sepgsql_mcstrans_in

contrib/sepgsql/label.c:577–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575 */
576PG_FUNCTION_INFO_V1(sepgsql_mcstrans_in);
577Datum
578sepgsql_mcstrans_in(PG_FUNCTION_ARGS)
579{
580 text *label = PG_GETARG_TEXT_PP(0);
581 char *raw_label;
582 char *result;
583
584 if (!sepgsql_is_enabled())
585 ereport(ERROR,
586 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
587 errmsg("sepgsql is not enabled")));
588
589 if (selinux_trans_to_raw_context(text_to_cstring(label),
590 &raw_label) < 0)
591 ereport(ERROR,
592 (errcode(ERRCODE_INTERNAL_ERROR),
593 errmsg("SELinux: could not translate security label: %m")));
594
595 PG_TRY();
596 {
597 result = pstrdup(raw_label);
598 }
599 PG_FINALLY();
600 {
601 freecon(raw_label);
602 }
603 PG_END_TRY();
604
605 PG_RETURN_TEXT_P(cstring_to_text(result));
606}
607
608/*
609 * TEXT sepgsql_mcstrans_out(TEXT)

Callers

nothing calls this directly

Calls 6

sepgsql_is_enabledFunction · 0.85
text_to_cstringFunction · 0.85
cstring_to_textFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
pstrdupFunction · 0.50

Tested by

no test coverage detected