audit.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SELinux support for the Audit LSM hooks
  3. *
  4. * Most of below header was moved from include/linux/selinux.h which
  5. * is released under below copyrights:
  6. *
  7. * Author: James Morris <jmorris@redhat.com>
  8. *
  9. * Copyright (C) 2005 Red Hat, Inc., James Morris <jmorris@redhat.com>
  10. * Copyright (C) 2006 Trusted Computer Solutions, Inc. <dgoeddel@trustedcs.com>
  11. * Copyright (C) 2006 IBM Corporation, Timothy R. Chavez <tinytim@us.ibm.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2,
  15. * as published by the Free Software Foundation.
  16. */
  17. #ifndef _SELINUX_AUDIT_H
  18. #define _SELINUX_AUDIT_H
  19. /**
  20. * selinux_audit_rule_init - alloc/init an selinux audit rule structure.
  21. * @field: the field this rule refers to
  22. * @op: the operater the rule uses
  23. * @rulestr: the text "target" of the rule
  24. * @rule: pointer to the new rule structure returned via this
  25. *
  26. * Returns 0 if successful, -errno if not. On success, the rule structure
  27. * will be allocated internally. The caller must free this structure with
  28. * selinux_audit_rule_free() after use.
  29. */
  30. int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **rule);
  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. * selinux_audit_rule_match - determine if a context ID matches a rule.
  41. * @sid: the context ID to check
  42. * @field: the field this rule refers to
  43. * @op: the operater the rule uses
  44. * @rule: pointer to the audit rule to check against
  45. * @actx: the audit context (can be NULL) associated with the check
  46. *
  47. * Returns 1 if the context id matches the rule, 0 if it does not, and
  48. * -errno on failure.
  49. */
  50. int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *rule,
  51. struct audit_context *actx);
  52. /**
  53. * selinux_audit_rule_known - check to see if rule contains selinux fields.
  54. * @rule: rule to be checked
  55. * Returns 1 if there are selinux fields specified in the rule, 0 otherwise.
  56. */
  57. int selinux_audit_rule_known(struct audit_krule *krule);
  58. #endif /* _SELINUX_AUDIT_H */