* 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
| 675 | * defines several security functionalities for audit features. |
| 676 | */ |
| 677 | void |
| 678 | sepgsql_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 |
no test coverage detected