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

Function sepgsql_mcstrans_out

contrib/sepgsql/label.c:615–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613 */
614PG_FUNCTION_INFO_V1(sepgsql_mcstrans_out);
615Datum
616sepgsql_mcstrans_out(PG_FUNCTION_ARGS)
617{
618 text *label = PG_GETARG_TEXT_PP(0);
619 char *qual_label;
620 char *result;
621
622 if (!sepgsql_is_enabled())
623 ereport(ERROR,
624 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
625 errmsg("sepgsql is not currently enabled")));
626
627 if (selinux_raw_to_trans_context(text_to_cstring(label),
628 &qual_label) < 0)
629 ereport(ERROR,
630 (errcode(ERRCODE_INTERNAL_ERROR),
631 errmsg("SELinux: could not translate security label: %m")));
632
633 PG_TRY();
634 {
635 result = pstrdup(qual_label);
636 }
637 PG_FINALLY();
638 {
639 freecon(qual_label);
640 }
641 PG_END_TRY();
642
643 PG_RETURN_TEXT_P(cstring_to_text(result));
644}
645
646/*
647 * quote_object_name

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