* sepgsql_object_relabel * * An entrypoint of SECURITY LABEL statement */
| 479 | * An entrypoint of SECURITY LABEL statement |
| 480 | */ |
| 481 | void |
| 482 | sepgsql_object_relabel(const ObjectAddress *object, const char *seclabel) |
| 483 | { |
| 484 | /* |
| 485 | * validate format of the supplied security label, if it is security |
| 486 | * context of selinux. |
| 487 | */ |
| 488 | if (seclabel && |
| 489 | security_check_context_raw(seclabel) < 0) |
| 490 | ereport(ERROR, |
| 491 | (errcode(ERRCODE_INVALID_NAME), |
| 492 | errmsg("SELinux: invalid security label: \"%s\"", seclabel))); |
| 493 | |
| 494 | /* |
| 495 | * Do actual permission checks for each object classes |
| 496 | */ |
| 497 | switch (object->classId) |
| 498 | { |
| 499 | case DatabaseRelationId: |
| 500 | sepgsql_database_relabel(object->objectId, seclabel); |
| 501 | break; |
| 502 | |
| 503 | case NamespaceRelationId: |
| 504 | sepgsql_schema_relabel(object->objectId, seclabel); |
| 505 | break; |
| 506 | |
| 507 | case RelationRelationId: |
| 508 | if (object->objectSubId == 0) |
| 509 | sepgsql_relation_relabel(object->objectId, |
| 510 | seclabel); |
| 511 | else |
| 512 | sepgsql_attribute_relabel(object->objectId, |
| 513 | object->objectSubId, |
| 514 | seclabel); |
| 515 | break; |
| 516 | |
| 517 | case ProcedureRelationId: |
| 518 | sepgsql_proc_relabel(object->objectId, seclabel); |
| 519 | break; |
| 520 | |
| 521 | default: |
| 522 | ereport(ERROR, |
| 523 | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), |
| 524 | errmsg("sepgsql provider does not support labels on %s", |
| 525 | getObjectTypeDescription(object, false)))); |
| 526 | break; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | /* |
| 531 | * TEXT sepgsql_getcon(VOID) |
no test coverage detected