audit.c 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <linux/init.h>
  2. #include <linux/types.h>
  3. #include <linux/audit.h>
  4. #include <asm/unistd.h>
  5. static unsigned dir_class[] = {
  6. #include <asm-generic/audit_dir_write.h>
  7. ~0U
  8. };
  9. static unsigned read_class[] = {
  10. #include <asm-generic/audit_read.h>
  11. ~0U
  12. };
  13. static unsigned write_class[] = {
  14. #include <asm-generic/audit_write.h>
  15. ~0U
  16. };
  17. static unsigned chattr_class[] = {
  18. #include <asm-generic/audit_change_attr.h>
  19. ~0U
  20. };
  21. int audit_classify_syscall(int abi, unsigned syscall)
  22. {
  23. switch(syscall) {
  24. case __NR_open:
  25. return 2;
  26. case __NR_openat:
  27. return 3;
  28. #ifdef __NR_socketcall
  29. case __NR_socketcall:
  30. return 4;
  31. #endif
  32. case __NR_execve:
  33. return 5;
  34. default:
  35. return 0;
  36. }
  37. }
  38. static int __init audit_classes_init(void)
  39. {
  40. audit_register_class(AUDIT_CLASS_WRITE, write_class);
  41. audit_register_class(AUDIT_CLASS_READ, read_class);
  42. audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class);
  43. audit_register_class(AUDIT_CLASS_CHATTR, chattr_class);
  44. return 0;
  45. }
  46. __initcall(audit_classes_init);