* 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. */
| 696 | * catalog OID. |
| 697 | */ |
| 698 | static void |
| 699 | exec_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); |
no test coverage detected