|
@@ -19,7 +19,7 @@
|
|
#include "include/audit.h"
|
|
#include "include/audit.h"
|
|
#include "include/policy.h"
|
|
#include "include/policy.h"
|
|
#include "include/policy_ns.h"
|
|
#include "include/policy_ns.h"
|
|
-
|
|
|
|
|
|
+#include "include/secid.h"
|
|
|
|
|
|
const char *const audit_mode_names[] = {
|
|
const char *const audit_mode_names[] = {
|
|
"normal",
|
|
"normal",
|
|
@@ -163,3 +163,96 @@ int aa_audit(int type, struct aa_profile *profile, struct common_audit_data *sa,
|
|
|
|
|
|
return aad(sa)->error;
|
|
return aad(sa)->error;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+struct aa_audit_rule {
|
|
|
|
+ char *profile;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+void aa_audit_rule_free(void *vrule)
|
|
|
|
+{
|
|
|
|
+ struct aa_audit_rule *rule = vrule;
|
|
|
|
+
|
|
|
|
+ if (rule) {
|
|
|
|
+ kfree(rule->profile);
|
|
|
|
+ kfree(rule);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
|
|
|
|
+{
|
|
|
|
+ struct aa_audit_rule *rule;
|
|
|
|
+
|
|
|
|
+ switch (field) {
|
|
|
|
+ case AUDIT_SUBJ_ROLE:
|
|
|
|
+ if (op != Audit_equal && op != Audit_not_equal)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rule = kzalloc(sizeof(struct aa_audit_rule), GFP_KERNEL);
|
|
|
|
+
|
|
|
|
+ if (!rule)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+
|
|
|
|
+ rule->profile = kstrdup(rulestr, GFP_KERNEL);
|
|
|
|
+
|
|
|
|
+ if (!rule->profile) {
|
|
|
|
+ kfree(rule);
|
|
|
|
+ return -ENOMEM;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *vrule = rule;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int aa_audit_rule_known(struct audit_krule *rule)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < rule->field_count; i++) {
|
|
|
|
+ struct audit_field *f = &rule->fields[i];
|
|
|
|
+
|
|
|
|
+ switch (f->type) {
|
|
|
|
+ case AUDIT_SUBJ_ROLE:
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int aa_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
|
|
|
|
+ struct audit_context *actx)
|
|
|
|
+{
|
|
|
|
+ struct aa_audit_rule *rule = vrule;
|
|
|
|
+ struct aa_label *label;
|
|
|
|
+ struct label_it i;
|
|
|
|
+ struct aa_profile *profile;
|
|
|
|
+ int found = 0;
|
|
|
|
+
|
|
|
|
+ label = aa_secid_to_label(sid);
|
|
|
|
+
|
|
|
|
+ if (!label)
|
|
|
|
+ return -ENOENT;
|
|
|
|
+
|
|
|
|
+ label_for_each(i, label, profile) {
|
|
|
|
+ if (strcmp(rule->profile, profile->base.hname) == 0) {
|
|
|
|
+ found = 1;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ switch (field) {
|
|
|
|
+ case AUDIT_SUBJ_ROLE:
|
|
|
|
+ switch (op) {
|
|
|
|
+ case Audit_equal:
|
|
|
|
+ return found;
|
|
|
|
+ case Audit_not_equal:
|
|
|
|
+ return !found;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|