Skip to content

Commit 691fe2a

Browse files
committed
improve text generation for process groups
1 parent a009fe9 commit 691fe2a

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

auparse/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void aup_free_config(struct daemon_conf *config);
194194

195195
/* Resolve @name to a uid, caching the result for future lookups. */
196196
uid_t lookup_uid_from_name(auparse_state_t *au, const char *name);
197+
197198
// normalize.c
198199
void init_normalizer(normalize_data *d);
199200
void clear_normalizer(normalize_data *d);

auparse/normalize.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,8 +797,6 @@ static int normalize_syscall(auparse_state_t *au, const char *syscall)
797797
auparse_get_record_num(au));
798798
attr = set_field(attr,
799799
auparse_get_field_num(au));
800-
if (is_unset(D.thing.primary))
801-
D.thing.primary = attr;
802800
cllist_append(&D.thing.attr, attr,
803801
NULL);
804802
}
@@ -2264,6 +2262,11 @@ const char *auparse_normalize_object_kind(const auparse_state_t *au)
22642262
return normalize_obj_kind_map_i2s(D.thing.what);
22652263
}
22662264

2265+
int auparse_normalize_object_kind_int(const auparse_state_t *au)
2266+
{
2267+
return D.thing.what;
2268+
}
2269+
22672270
int auparse_normalize_get_results(auparse_state_t *au)
22682271
{
22692272
return seek_field(au, D.results);

src/ausearch-report.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "auparse.h"
3535
#include "auparse-idata.h"
3636
#include "auditd-config.h"
37+
#include "normalize-internal.h" // pid list
3738

3839
static int interp_init = 0;
3940
static auparse_state_t *au = NULL;
@@ -691,6 +692,7 @@ static void csv_event(auparse_state_t *au,
691692

692693
/* This function will output a normalized line of audit
693694
* fields one line per event as an english sentence */
695+
extern int auparse_normalize_object_kind_int(const auparse_state_t *au);
694696
static void text_event(auparse_state_t *au,
695697
auparse_cb_event_t cb_event_type, void *user_data)
696698
{
@@ -800,6 +802,33 @@ static void text_event(auparse_state_t *au,
800802
printf("to %s ", val);
801803
}
802804

805+
// Print pid list if process group
806+
int kind = auparse_normalize_object_kind_int(au);
807+
if (kind == NORM_WHAT_PROCESS_GROUP || kind == NORM_WHAT_PROCESS) {
808+
rc = auparse_normalize_object_first_attribute(au);
809+
if (rc == 1) {
810+
int sep = 0, cnt = 1;
811+
putchar('(');
812+
do {
813+
const char *name = auparse_get_field_name(au);
814+
if (strcmp(name, "opid") == 0) {
815+
if (sep)
816+
putchar(',');
817+
printf("%s",
818+
auparse_interpret_field(au));
819+
sep = 1;
820+
}
821+
rc = auparse_normalize_object_next_attribute(au);
822+
cnt++;
823+
} while (rc == 1 && cnt < 4);
824+
if (cnt >= 4)
825+
printf(",...)");
826+
else
827+
putchar(')');
828+
putchar(' ');
829+
}
830+
}
831+
803832
how = auparse_normalize_how(au);
804833
if (how && action && *action != 'e') // Don't print for ended-session
805834
printf("using %s", how);

0 commit comments

Comments
 (0)