Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions lib/audit_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
#include <libaudit.h>
#include <errno.h>
#include <stdio.h>
#include <alloca.h>

#include "attr.h"
#include "prototypes.h"
#include "shadowlog.h"
#include "string/strcmp/streq.h"
int audit_fd;

void audit_help_open (void)
Expand All @@ -44,6 +46,19 @@ void audit_help_open (void)
}
}

/*
* This takes a string and replaces the old character with the new.
*/
static inline const char *
strtr(char *str, char old, char new)
{
for (char *p = str; !streq(p, ""); p++) {
if (*p == old)
*p = new;
}
return str;
}

/*
* This function will log a message to the audit system using a predefined
* message format. Parameter usage is as follows:
Expand All @@ -63,8 +78,15 @@ void audit_logger (int type, MAYBE_UNUSED const char *pgname, const char *op,
if (audit_fd < 0) {
return;
} else {
audit_log_acct_message (audit_fd, type, NULL, op, name, id,
NULL, NULL, NULL, result);
/*
* The audit system needs white space in the op field to
* be replaced with dashes so that parsers get the whole
* field.
*/
const char *fixed_op = strtr(strdupa(op), ' ', '-');
audit_log_acct_message(audit_fd, type, NULL,
Comment thread
alejandro-colomar marked this conversation as resolved.
fixed_op, name, id,
NULL, NULL, NULL, result);
}
}

Expand Down