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

Function exec_object_restorecon

contrib/sepgsql/label.c:698–866  ·  view source on GitHub ↗

* exec_object_restorecon * * This routine is a helper called by sepgsql_restorecon; it set up * initial security labels of database objects within the supplied * catalog OID. */

Source from the content-addressed store, hash-verified

696 * catalog OID.
697 */
698static void
699exec_object_restorecon(struct selabel_handle *sehnd, Oid catalogId)
700{
701 Relation rel;
702 SysScanDesc sscan;
703 HeapTuple tuple;
704 char *database_name = get_database_name(MyDatabaseId);
705 char *namespace_name;
706 Oid namespace_id;
707 char *relation_name;
708
709 /*
710 * Open the target catalog. We don't want to allow writable accesses by
711 * other session during initial labeling.
712 */
713 rel = table_open(catalogId, AccessShareLock);
714
715 sscan = systable_beginscan(rel, InvalidOid, false,
716 NULL, 0, NULL);
717 while (HeapTupleIsValid(tuple = systable_getnext(sscan)))
718 {
719 Form_pg_database datForm;
720 Form_pg_namespace nspForm;
721 Form_pg_class relForm;
722 Form_pg_attribute attForm;
723 Form_pg_proc proForm;
724 char *objname;
725 int objtype = 1234;
726 ObjectAddress object;
727 char *context;
728
729 /*
730 * The way to determine object name depends on object classes. So, any
731 * branches set up `objtype', `objname' and `object' here.
732 */
733 switch (catalogId)
734 {
735 case DatabaseRelationId:
736 datForm = (Form_pg_database) GETSTRUCT(tuple);
737
738 objtype = SELABEL_DB_DATABASE;
739
740 objname = quote_object_name(NameStr(datForm->datname),
741 NULL, NULL, NULL);
742
743 object.classId = DatabaseRelationId;
744 object.objectId = datForm->oid;
745 object.objectSubId = 0;
746 break;
747
748 case NamespaceRelationId:
749 nspForm = (Form_pg_namespace) GETSTRUCT(tuple);
750
751 objtype = SELABEL_DB_SCHEMA;
752
753 objname = quote_object_name(database_name,
754 NameStr(nspForm->nspname),
755 NULL, NULL);

Callers 1

sepgsql_restoreconFunction · 0.85

Calls 15

get_database_nameFunction · 0.85
table_openFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
quote_object_nameFunction · 0.85
get_namespace_nameFunction · 0.85
get_rel_relkindFunction · 0.85
get_rel_namespaceFunction · 0.85
get_rel_nameFunction · 0.85
sepgsql_object_relabelFunction · 0.85
SetSecurityLabelFunction · 0.85
systable_endscanFunction · 0.85

Tested by

no test coverage detected