summaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima_template.c
diff options
context:
space:
mode:
authorRoberto Sassu <roberto.sassu@polito.it>2013-06-07 12:16:30 +0200
committerMimi Zohar <zohar@linux.vnet.ibm.com>2013-10-25 17:17:05 -0400
commit3ce1217d6cd5dfa82a9db5c2a999cc1bb01490d9 (patch)
tree4645a20eaa70b3dc5dd4654fa31a7cf132291fd5 /security/integrity/ima/ima_template.c
parentadf53a778a0a5a5dc9103509da4a9719046e5310 (diff)
ima: define template fields library and new helpers
This patch defines a library containing two initial template fields, inode digest (d) and file name (n), the 'ima' template descriptor, whose format is 'd|n', and two helper functions, ima_write_template_field_data() and ima_show_template_field_data(). Changelog: - replace ima_eventname_init() parameter NULL checking with BUG_ON. (suggested by Mimi) - include "new template fields for inode digest (d) and file name (n)" definitions to fix a compiler warning. - Mimi - unnecessary to prefix static function names with 'ima_'. remove prefix to resolve Lindent formatting changes. - Mimi - abbreviated/removed inline comments - Mimi - always send the template field length - Mimi Signed-off-by: Roberto Sassu <roberto.sassu@polito.it> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security/integrity/ima/ima_template.c')
-rw-r--r--security/integrity/ima/ima_template.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/security/integrity/ima/ima_template.c b/security/integrity/ima/ima_template.c
index 7e86783ccf5..81004226439 100644
--- a/security/integrity/ima/ima_template.c
+++ b/security/integrity/ima/ima_template.c
@@ -13,15 +13,20 @@
* Helpers to manage template descriptors.
*/
#include "ima.h"
+#include "ima_template_lib.h"
static struct ima_template_desc defined_templates[] = {
+ {.name = IMA_TEMPLATE_IMA_NAME,.fmt = IMA_TEMPLATE_IMA_FMT},
};
static struct ima_template_field supported_fields[] = {
+ {.field_id = "d",.field_init = ima_eventdigest_init,
+ .field_show = ima_show_template_digest},
+ {.field_id = "n",.field_init = ima_eventname_init,
+ .field_show = ima_show_template_string},
};
-static struct ima_template_field *ima_lookup_template_field(
- const char *field_id)
+static struct ima_template_field *lookup_template_field(const char *field_id)
{
int i;
@@ -32,7 +37,7 @@ static struct ima_template_field *ima_lookup_template_field(
return NULL;
}
-static int ima_template_fmt_size(char *template_fmt)
+static int template_fmt_size(char *template_fmt)
{
char c;
int template_fmt_len = strlen(template_fmt);
@@ -53,7 +58,7 @@ static int template_desc_init_fields(char *template_fmt,
int *num_fields)
{
char *c, *template_fmt_ptr = template_fmt;
- int template_num_fields = ima_template_fmt_size(template_fmt);
+ int template_num_fields = template_fmt_size(template_fmt);
int i, result = 0;
if (template_num_fields > IMA_TEMPLATE_NUM_FIELDS_MAX)
@@ -66,7 +71,7 @@ static int template_desc_init_fields(char *template_fmt,
}
for (i = 0; (c = strsep(&template_fmt_ptr, "|")) != NULL &&
i < template_num_fields; i++) {
- struct ima_template_field *f = ima_lookup_template_field(c);
+ struct ima_template_field *f = lookup_template_field(c);
if (!f) {
result = -ENOENT;