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

Function sepgsql_audit_log

contrib/sepgsql/selinux.c:677–717  ·  view source on GitHub ↗

* sepgsql_audit_log * * It generates a security audit record. It writes out audit records * into standard PG's logfile. * * SELinux can control what should be audited and should not using * "auditdeny" and "auditallow" rules in the security policy. In the * default, all the access violations are audited, and all the access * allowed are not audited. But we can set up the security policy, s

Source from the content-addressed store, hash-verified

675 * defines several security functionalities for audit features.
676 */
677void
678sepgsql_audit_log(bool denied,
679 const char *scontext,
680 const char *tcontext,
681 uint16 tclass,
682 uint32 audited,
683 const char *audit_name)
684{
685 StringInfoData buf;
686 const char *class_name;
687 const char *av_name;
688 int i;
689
690 /* lookup name of the object class */
691 Assert(tclass < SEPG_CLASS_MAX);
692 class_name = selinux_catalog[tclass].class_name;
693
694 /* lookup name of the permissions */
695 initStringInfo(&buf);
696 appendStringInfo(&buf, "%s {",
697 (denied ? "denied" : "allowed"));
698 for (i = 0; selinux_catalog[tclass].av[i].av_name; i++)
699 {
700 if (audited & (1UL << i))
701 {
702 av_name = selinux_catalog[tclass].av[i].av_name;
703 appendStringInfo(&buf, " %s", av_name);
704 }
705 }
706 appendStringInfoString(&buf, " }");
707
708 /*
709 * Call external audit module, if loaded
710 */
711 appendStringInfo(&buf, " scontext=%s tcontext=%s tclass=%s",
712 scontext, tcontext, class_name);
713 if (audit_name)
714 appendStringInfo(&buf, " name=\"%s\"", audit_name);
715
716 ereport(LOG, (errmsg("SELinux: %s", buf.data)));
717}
718
719/*
720 * sepgsql_compute_avd

Callers 2

sepgsql_check_permsFunction · 0.85

Calls 4

initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
appendStringInfoStringFunction · 0.85
errmsgFunction · 0.50

Tested by

no test coverage detected