* sepgsql_get_label * * It returns a security context of the specified database object. * If unlabeled or incorrectly labeled, the system "unlabeled" label * shall be returned. */
| 442 | * shall be returned. |
| 443 | */ |
| 444 | char * |
| 445 | sepgsql_get_label(Oid classId, Oid objectId, int32 subId) |
| 446 | { |
| 447 | ObjectAddress object; |
| 448 | char *label; |
| 449 | |
| 450 | object.classId = classId; |
| 451 | object.objectId = objectId; |
| 452 | object.objectSubId = subId; |
| 453 | |
| 454 | label = GetSecurityLabel(&object, SEPGSQL_LABEL_TAG); |
| 455 | if (!label || security_check_context_raw(label)) |
| 456 | { |
| 457 | char *unlabeled; |
| 458 | |
| 459 | if (security_get_initial_context_raw("unlabeled", &unlabeled) < 0) |
| 460 | ereport(ERROR, |
| 461 | (errcode(ERRCODE_INTERNAL_ERROR), |
| 462 | errmsg("SELinux: failed to get initial security label: %m"))); |
| 463 | PG_TRY(); |
| 464 | { |
| 465 | label = pstrdup(unlabeled); |
| 466 | } |
| 467 | PG_FINALLY(); |
| 468 | { |
| 469 | freecon(unlabeled); |
| 470 | } |
| 471 | PG_END_TRY(); |
| 472 | } |
| 473 | return label; |
| 474 | } |
| 475 | |
| 476 | /* |
| 477 | * sepgsql_object_relabel |
no test coverage detected