summaryrefslogtreecommitdiffstats
path: root/security/apparmor/lib.c
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2017-05-26 15:07:22 -0700
committerJohn Johansen <john.johansen@canonical.com>2017-06-09 05:59:22 -0700
commite53cfe6c7caa79ccdccce53e600dae522acb1c84 (patch)
tree7258a54f52ef5861269df3d60bbee5e232fb90df /security/apparmor/lib.c
parentfc7e0b26b8d26e680bb2f252e9521385e0092e4c (diff)
downloadlinux-e53cfe6c7caa79ccdccce53e600dae522acb1c84.tar.bz2
apparmor: rework perm mapping to a slightly broader set
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor/lib.c')
-rw-r--r--security/apparmor/lib.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/security/apparmor/lib.c b/security/apparmor/lib.c
index 90eb14c9e0cf..90d4631ddafe 100644
--- a/security/apparmor/lib.c
+++ b/security/apparmor/lib.c
@@ -129,6 +129,65 @@ void aa_info_message(const char *str)
printk(KERN_INFO "AppArmor: %s\n", str);
}
+const char aa_file_perm_chrs[] = "xwracd km l ";
+const char *aa_file_perm_names[] = {
+ "exec",
+ "write",
+ "read",
+ "append",
+
+ "create",
+ "delete",
+ "open",
+ "rename",
+
+ "setattr",
+ "getattr",
+ "setcred",
+ "getcred",
+
+ "chmod",
+ "chown",
+ "chgrp",
+ "lock",
+
+ "mmap",
+ "mprot",
+ "link",
+ "snapshot",
+
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+
+ "stack",
+ "change_onexec",
+ "change_profile",
+ "change_hat",
+};
+
+/**
+ * aa_perm_mask_to_str - convert a perm mask to its short string
+ * @str: character buffer to store string in (at least 10 characters)
+ * @mask: permission mask to convert
+ */
+void aa_perm_mask_to_str(char *str, const char *chrs, u32 mask)
+{
+ unsigned int i, perm = 1;
+
+ for (i = 0; i < 32; perm <<= 1, i++) {
+ if (mask & perm)
+ *str++ = chrs[i];
+ }
+ *str = '\0';
+}
+
/**
* aa_policy_init - initialize a policy structure
* @policy: policy to initialize (NOT NULL)