diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2008-04-28 10:15:49 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-04-28 12:28:37 +0200 |
commit | 8b67dca9420474623709e00d72a066068a502b20 (patch) | |
tree | 9d4dc19d849dd23cf00cee0851fd402062cdf1ea /kernel/auditsc.c | |
parent | [patch 2/2] Use find_task_by_vpid in audit code (diff) | |
download | linux-8b67dca9420474623709e00d72a066068a502b20.tar.xz linux-8b67dca9420474623709e00d72a066068a502b20.zip |
[PATCH] new predicate - AUDIT_FILETYPE
Argument is S_IF... | <index>, where index is normally 0 or 1.
Triggers if chosen element of ctx->names[] is present and the
mode of object in question matches the upper bits of argument.
I.e. for things like "is the argument of that chmod a directory",
etc.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r-- | kernel/auditsc.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 091409996577..c10e7aae04d7 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -280,6 +280,19 @@ static int audit_match_perm(struct audit_context *ctx, int mask) } } +static int audit_match_filetype(struct audit_context *ctx, int which) +{ + unsigned index = which & ~S_IFMT; + mode_t mode = which & S_IFMT; + if (index >= ctx->name_count) + return 0; + if (ctx->names[index].ino == -1) + return 0; + if ((ctx->names[index].mode ^ mode) & S_IFMT) + return 0; + return 1; +} + /* * We keep a linked list of fixed-sized (31 pointer) arrays of audit_chunk *; * ->first_trees points to its beginning, ->trees - to the current end of data. @@ -589,6 +602,9 @@ static int audit_filter_rules(struct task_struct *tsk, case AUDIT_PERM: result = audit_match_perm(ctx, f->val); break; + case AUDIT_FILETYPE: + result = audit_match_filetype(ctx, f->val); + break; } if (!result) |