* sepgsql_relation_drop * * It checks privileges to drop the supplied relation. */
| 413 | * It checks privileges to drop the supplied relation. |
| 414 | */ |
| 415 | void |
| 416 | sepgsql_relation_drop(Oid relOid) |
| 417 | { |
| 418 | ObjectAddress object; |
| 419 | char *audit_name; |
| 420 | uint16_t tclass = 0; |
| 421 | char relkind = get_rel_relkind(relOid); |
| 422 | |
| 423 | switch (relkind) |
| 424 | { |
| 425 | case RELKIND_RELATION: |
| 426 | case RELKIND_PARTITIONED_TABLE: |
| 427 | tclass = SEPG_CLASS_DB_TABLE; |
| 428 | break; |
| 429 | case RELKIND_SEQUENCE: |
| 430 | tclass = SEPG_CLASS_DB_SEQUENCE; |
| 431 | break; |
| 432 | case RELKIND_VIEW: |
| 433 | tclass = SEPG_CLASS_DB_VIEW; |
| 434 | break; |
| 435 | case RELKIND_INDEX: |
| 436 | /* ignore indexes on toast tables */ |
| 437 | if (get_rel_namespace(relOid) == PG_TOAST_NAMESPACE) |
| 438 | return; |
| 439 | /* other indexes are handled specially below; no need for tclass */ |
| 440 | break; |
| 441 | default: |
| 442 | /* ignore other relkinds */ |
| 443 | return; |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | * check db_schema:{remove_name} permission |
| 448 | */ |
| 449 | object.classId = NamespaceRelationId; |
| 450 | object.objectId = get_rel_namespace(relOid); |
| 451 | object.objectSubId = 0; |
| 452 | audit_name = getObjectIdentity(&object, false); |
| 453 | |
| 454 | sepgsql_avc_check_perms(&object, |
| 455 | SEPG_CLASS_DB_SCHEMA, |
| 456 | SEPG_DB_SCHEMA__REMOVE_NAME, |
| 457 | audit_name, |
| 458 | true); |
| 459 | pfree(audit_name); |
| 460 | |
| 461 | /* deal with indexes specially */ |
| 462 | if (relkind == RELKIND_INDEX) |
| 463 | { |
| 464 | sepgsql_index_modify(relOid); |
| 465 | return; |
| 466 | } |
| 467 | |
| 468 | /* |
| 469 | * check db_table/sequence/view:{drop} permission |
| 470 | */ |
| 471 | object.classId = RelationRelationId; |
| 472 | object.objectId = relOid; |
no test coverage detected