lkml.org 
[lkml]   [2014]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/4] ima: ignore empty and with whitespaces policy lines
Date
Empty policy lines cause parsing failures which is, especially
for new users, hard to spot. This patch prevents it.

It is now possible to 'cat policy > <securityfs>/ima/policy'.

Changes in v2:
* strip leading blanks and tabs in rules to prevent parsing failures

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
---
security/integrity/ima/ima_policy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index bf232b9..d2c47d4 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -696,8 +696,9 @@ ssize_t ima_parse_add_rule(char *rule)

p = strsep(&rule, "\n");
len = strlen(p) + 1;
+ p += strspn(p, " \t");

- if (*p == '#')
+ if (*p == '#' || *p == '\0')
return len;

entry = kzalloc(sizeof(*entry), GFP_KERNEL);
--
1.9.1


\
 
 \ /
  Last update: 2014-10-03 14:21    [W:0.073 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site