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

Function sepgsql_object_relabel

contrib/sepgsql/label.c:481–528  ·  view source on GitHub ↗

* sepgsql_object_relabel * * An entrypoint of SECURITY LABEL statement */

Source from the content-addressed store, hash-verified

479 * An entrypoint of SECURITY LABEL statement
480 */
481void
482sepgsql_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)

Callers 1

exec_object_restoreconFunction · 0.85

Calls 8

sepgsql_database_relabelFunction · 0.85
sepgsql_schema_relabelFunction · 0.85
sepgsql_relation_relabelFunction · 0.85
sepgsql_proc_relabelFunction · 0.85
getObjectTypeDescriptionFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected