apparmorfs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * AppArmor security module
  3. *
  4. * This file contains AppArmor filesystem definitions.
  5. *
  6. * Copyright (C) 1998-2008 Novell/SUSE
  7. * Copyright 2009-2010 Canonical Ltd.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation, version 2 of the
  12. * License.
  13. */
  14. #ifndef __AA_APPARMORFS_H
  15. #define __AA_APPARMORFS_H
  16. extern struct path aa_null;
  17. enum aa_sfs_type {
  18. AA_SFS_TYPE_BOOLEAN,
  19. AA_SFS_TYPE_STRING,
  20. AA_SFS_TYPE_U64,
  21. AA_SFS_TYPE_FOPS,
  22. AA_SFS_TYPE_DIR,
  23. };
  24. struct aa_sfs_entry;
  25. struct aa_sfs_entry {
  26. const char *name;
  27. struct dentry *dentry;
  28. umode_t mode;
  29. enum aa_sfs_type v_type;
  30. union {
  31. bool boolean;
  32. char *string;
  33. unsigned long u64;
  34. struct aa_sfs_entry *files;
  35. } v;
  36. const struct file_operations *file_ops;
  37. };
  38. extern const struct file_operations aa_sfs_seq_file_ops;
  39. #define AA_SFS_FILE_BOOLEAN(_name, _value) \
  40. { .name = (_name), .mode = 0444, \
  41. .v_type = AA_SFS_TYPE_BOOLEAN, .v.boolean = (_value), \
  42. .file_ops = &aa_sfs_seq_file_ops }
  43. #define AA_SFS_FILE_STRING(_name, _value) \
  44. { .name = (_name), .mode = 0444, \
  45. .v_type = AA_SFS_TYPE_STRING, .v.string = (_value), \
  46. .file_ops = &aa_sfs_seq_file_ops }
  47. #define AA_SFS_FILE_U64(_name, _value) \
  48. { .name = (_name), .mode = 0444, \
  49. .v_type = AA_SFS_TYPE_U64, .v.u64 = (_value), \
  50. .file_ops = &aa_sfs_seq_file_ops }
  51. #define AA_SFS_FILE_FOPS(_name, _mode, _fops) \
  52. { .name = (_name), .v_type = AA_SFS_TYPE_FOPS, \
  53. .mode = (_mode), .file_ops = (_fops) }
  54. #define AA_SFS_DIR(_name, _value) \
  55. { .name = (_name), .v_type = AA_SFS_TYPE_DIR, .v.files = (_value) }
  56. extern void __init aa_destroy_aafs(void);
  57. struct aa_profile;
  58. struct aa_ns;
  59. enum aafs_ns_type {
  60. AAFS_NS_DIR,
  61. AAFS_NS_PROFS,
  62. AAFS_NS_NS,
  63. AAFS_NS_RAW_DATA,
  64. AAFS_NS_LOAD,
  65. AAFS_NS_REPLACE,
  66. AAFS_NS_REMOVE,
  67. AAFS_NS_REVISION,
  68. AAFS_NS_COUNT,
  69. AAFS_NS_MAX_COUNT,
  70. AAFS_NS_SIZE,
  71. AAFS_NS_MAX_SIZE,
  72. AAFS_NS_OWNER,
  73. AAFS_NS_SIZEOF,
  74. };
  75. enum aafs_prof_type {
  76. AAFS_PROF_DIR,
  77. AAFS_PROF_PROFS,
  78. AAFS_PROF_NAME,
  79. AAFS_PROF_MODE,
  80. AAFS_PROF_ATTACH,
  81. AAFS_PROF_HASH,
  82. AAFS_PROF_RAW_DATA,
  83. AAFS_PROF_RAW_HASH,
  84. AAFS_PROF_RAW_ABI,
  85. AAFS_PROF_SIZEOF,
  86. };
  87. #define ns_dir(X) ((X)->dents[AAFS_NS_DIR])
  88. #define ns_subns_dir(X) ((X)->dents[AAFS_NS_NS])
  89. #define ns_subprofs_dir(X) ((X)->dents[AAFS_NS_PROFS])
  90. #define ns_subdata_dir(X) ((X)->dents[AAFS_NS_RAW_DATA])
  91. #define ns_subload(X) ((X)->dents[AAFS_NS_LOAD])
  92. #define ns_subreplace(X) ((X)->dents[AAFS_NS_REPLACE])
  93. #define ns_subremove(X) ((X)->dents[AAFS_NS_REMOVE])
  94. #define ns_subrevision(X) ((X)->dents[AAFS_NS_REVISION])
  95. #define prof_dir(X) ((X)->dents[AAFS_PROF_DIR])
  96. #define prof_child_dir(X) ((X)->dents[AAFS_PROF_PROFS])
  97. void __aa_bump_ns_revision(struct aa_ns *ns);
  98. void __aafs_profile_rmdir(struct aa_profile *profile);
  99. void __aafs_profile_migrate_dents(struct aa_profile *old,
  100. struct aa_profile *new);
  101. int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent);
  102. void __aafs_ns_rmdir(struct aa_ns *ns);
  103. int __aafs_ns_mkdir(struct aa_ns *ns, struct dentry *parent, const char *name,
  104. struct dentry *dent);
  105. struct aa_loaddata;
  106. void __aa_fs_remove_rawdata(struct aa_loaddata *rawdata);
  107. int __aa_fs_create_rawdata(struct aa_ns *ns, struct aa_loaddata *rawdata);
  108. #endif /* __AA_APPARMORFS_H */