Merge branch 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[sfrench/cifs-2.6.git] / security / selinux / include / audit.h
1 /*
2  * SELinux support for the Audit LSM hooks
3  *
4  * Author: James Morris <jmorris@redhat.com>
5  *
6  * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
7  * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
8  * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2,
12  * as published by the Free Software Foundation.
13  */
14
15 #ifndef _SELINUX_AUDIT_H
16 #define _SELINUX_AUDIT_H
17
18 /**
19  *      selinux_audit_rule_init - alloc/init an selinux audit rule structure.
20  *      @field: the field this rule refers to
21  *      @op: the operater the rule uses
22  *      @rulestr: the text "target" of the rule
23  *      @rule: pointer to the new rule structure returned via this
24  *
25  *      Returns 0 if successful, -errno if not.  On success, the rule structure
26  *      will be allocated internally.  The caller must free this structure with
27  *      selinux_audit_rule_free() after use.
28  */
29 int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **rule);
30
31 /**
32  *      selinux_audit_rule_free - free an selinux audit rule structure.
33  *      @rule: pointer to the audit rule to be freed
34  *
35  *      This will free all memory associated with the given rule.
36  *      If @rule is NULL, no operation is performed.
37  */
38 void selinux_audit_rule_free(void *rule);
39
40 /**
41  *      selinux_audit_rule_match - determine if a context ID matches a rule.
42  *      @sid: the context ID to check
43  *      @field: the field this rule refers to
44  *      @op: the operater the rule uses
45  *      @rule: pointer to the audit rule to check against
46  *      @actx: the audit context (can be NULL) associated with the check
47  *
48  *      Returns 1 if the context id matches the rule, 0 if it does not, and
49  *      -errno on failure.
50  */
51 int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *rule,
52                              struct audit_context *actx);
53
54 /**
55  *      selinux_audit_rule_known - check to see if rule contains selinux fields.
56  *      @rule: rule to be checked
57  *      Returns 1 if there are selinux fields specified in the rule, 0 otherwise.
58  */
59 int selinux_audit_rule_known(struct audit_krule *krule);
60
61 #endif /* _SELINUX_AUDIT_H */
62