Add audit_log_type

Add audit_log_type to allow callers to specify type and pid when logging.
Convert audit_log to wrapper around audit_log_type.  Could have
converted all audit_log callers directly, but common case is default
of type AUDIT_KERNEL and pid 0.  Update audit_log_start to take type
and pid values when creating a new audit_buffer.  Move sequences that
did audit_log_start, audit_log_format, audit_set_type, audit_log_end,
to simply call audit_log_type directly.  This obsoletes audit_set_type
and audit_set_pid, so remove them.

Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
Chris Wright
2005-05-11 10:55:10 +01:00
committed by David Woodhouse
parent 197c69c6af
commit c1b773d87e
4 changed files with 33 additions and 56 deletions
+7 -16
View File
@@ -648,7 +648,7 @@ static void audit_log_exit(struct audit_context *context)
int i;
struct audit_buffer *ab;
ab = audit_log_start(context);
ab = audit_log_start(context, AUDIT_KERNEL, 0);
if (!ab)
return; /* audit_panic has been called */
audit_log_format(ab, "syscall=%d", context->major);
@@ -680,7 +680,7 @@ static void audit_log_exit(struct audit_context *context)
while (context->aux) {
struct audit_aux_data *aux;
ab = audit_log_start(context);
ab = audit_log_start(context, AUDIT_KERNEL, 0);
if (!ab)
continue; /* audit_panic has been called */
@@ -701,7 +701,7 @@ static void audit_log_exit(struct audit_context *context)
}
for (i = 0; i < context->name_count; i++) {
ab = audit_log_start(context);
ab = audit_log_start(context, AUDIT_KERNEL, 0);
if (!ab)
continue; /* audit_panic has been called */
audit_log_format(ab, "item=%d", i);
@@ -1005,22 +1005,13 @@ int audit_get_stamp(struct audit_context *ctx,
return 0;
}
extern int audit_set_type(struct audit_buffer *ab, int type);
int audit_set_loginuid(struct task_struct *task, uid_t loginuid)
{
if (task->audit_context) {
struct audit_buffer *ab;
ab = audit_log_start(NULL);
if (ab) {
audit_log_format(ab, "login pid=%d uid=%u "
"old loginuid=%u new loginuid=%u",
task->pid, task->uid,
task->audit_context->loginuid, loginuid);
audit_set_type(ab, AUDIT_LOGIN);
audit_log_end(ab);
}
audit_log_type(NULL, AUDIT_LOGIN, 0,
"login pid=%d uid=%u old loginuid=%u new loginuid=%u",
task->pid, task->uid, task->audit_context->loginuid,
loginuid);
task->audit_context->loginuid = loginuid;
}
return 0;