| 613 | */ |
| 614 | PG_FUNCTION_INFO_V1(sepgsql_mcstrans_out); |
| 615 | Datum |
| 616 | sepgsql_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 |
nothing calls this directly
no test coverage detected