| 575 | */ |
| 576 | PG_FUNCTION_INFO_V1(sepgsql_mcstrans_in); |
| 577 | Datum |
| 578 | sepgsql_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) |
nothing calls this directly
no test coverage detected