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

Function sepgsql_get_label

contrib/sepgsql/label.c:444–474  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

442 * shall be returned.
443 */
444char *
445sepgsql_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

Calls 4

GetSecurityLabelFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
pstrdupFunction · 0.50

Tested by

no test coverage detected