Skip to content

Commit 6b5f04e

Browse files
committed
Remove auparse-stub.h
With the previous commit, auparse-stub.h is now obsolete. Refactor the code for it's removal.
1 parent f0a4b31 commit 6b5f04e

File tree

8 files changed

+43
-56
lines changed

8 files changed

+43
-56
lines changed

auparse/internal.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ typedef struct data
142142

143143
struct opaque
144144
{
145-
nvlist interpretations; // Per-parser interpretations list
146145
ausource_t source; // Source type
147146
char **source_list; // Array of buffers, or array of
148147
// file names
@@ -181,6 +180,7 @@ struct opaque
181180
debug_message_t debug_message; // Whether or not messages are debug or not
182181
const char *tmp_translation; // Pointer to manage mem for field translation
183182
normalize_data norm_data;
183+
nvlist interpretations; // Per-parser interpretations list
184184
Queue *uid_cache; // per-parser UID cache
185185
int uid_cache_created;
186186
Queue *gid_cache; // per-parser GID cache
@@ -190,7 +190,8 @@ struct opaque
190190
AUDIT_HIDDEN_START
191191

192192
// auditd-config.c
193-
int aup_load_config(auparse_state_t *au, struct daemon_conf *config, log_test_t lt);
193+
int aup_load_config(auparse_state_t *au, struct daemon_conf *config,
194+
log_test_t lt);
194195
void aup_free_config(struct daemon_conf *config);
195196

196197
// normalize.c

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SUBDIRS = test
2626
AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/src/libev -I${top_srcdir}/auparse -I${top_srcdir}/audisp -I${top_srcdir}/common
2727
sbin_PROGRAMS = auditd auditctl aureport ausearch
2828
AM_CFLAGS = -D_GNU_SOURCE -Wno-pointer-sign ${WFLAGS}
29-
noinst_HEADERS = auditd-config.h auditd-event.h auditd-listen.h ausearch-llist.h ausearch-options.h auditctl-llist.h aureport-options.h ausearch-parse.h aureport-scan.h ausearch-lookup.h ausearch-int.h auditd-dispatch.h ausearch-string.h ausearch-nvpair.h ausearch-common.h ausearch-avc.h ausearch-time.h ausearch-lol.h auditctl-listing.h ausearch-checkpt.h auparse-stub.h
29+
noinst_HEADERS = auditd-config.h auditd-event.h auditd-listen.h ausearch-llist.h ausearch-options.h auditctl-llist.h aureport-options.h ausearch-parse.h aureport-scan.h ausearch-lookup.h ausearch-int.h auditd-dispatch.h ausearch-string.h ausearch-nvpair.h ausearch-common.h ausearch-avc.h ausearch-time.h ausearch-lol.h auditctl-listing.h ausearch-checkpt.h
3030

3131
auditd_SOURCES = auditd.c auditd-event.c auditd-config.c auditd-reconfig.c auditd-sendmail.c auditd-dispatch.c
3232
if ENABLE_LISTENER

src/auditctl-listing.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@
3232
#include "private.h"
3333
#include "auditctl-llist.h"
3434
#include "auparse-idata.h"
35-
#include "auparse-stub.h"
36-
3735

3836
#ifndef IORING_OP_LAST
3937
#define IORING_OP_LAST 37
4038
#endif
4139

4240
/* Global vars */
41+
static auparse_state_t *au = NULL;
4342
static llist l;
4443
static int printed;
4544
extern int list_requested, interpret;
@@ -469,7 +468,7 @@ static void print_rule(const struct audit_rule_data *r)
469468
type = auparse_interp_adjust_type(
470469
AUDIT_SYSCALL, name, val);
471470
out = auparse_do_interpretation(
472-
interp_au, type, &id,
471+
au, type, &id,
473472
AUPARSE_ESC_TTY);
474473
printf(" -F %s%s%s", name,
475474
audit_operator_to_symbol(op),
@@ -568,8 +567,8 @@ int audit_print_reply(const struct audit_reply *rep, int fd)
568567
{
569568
static int init_done = 0;
570569
if (!init_done) {
571-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
572-
if (interp_au == NULL)
570+
au = auparse_init(AUSOURCE_BUFFER, "");
571+
if (au == NULL)
573572
return 0;
574573
init_done = 1;
575574
}

src/auparse-stub.h

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/aureport.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@
4242
#include "ausearch-lol.h"
4343
#include "ausearch-lookup.h"
4444
#include "auparse-idata.h"
45-
#include "auparse-stub.h"
46-
4745
#include "ausearch-parse.h"
4846

4947

5048
extern event very_first_event;
5149
event very_last_event;
50+
static auparse_state_t *au = NULL;
5251
static FILE *log_fd = NULL;
5352
static lol lo;
5453
static int found = 0;
@@ -100,8 +99,8 @@ int main(int argc, char *argv[])
10099
set_aumessage_mode(MSG_STDERR, DBG_NO);
101100
(void) umask( umask( 077 ) | 027 );
102101
very_first_event.sec = 0;
103-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
104-
if (interp_au == NULL) {
102+
au = auparse_init(AUSOURCE_BUFFER, "");
103+
if (au == NULL) {
105104
fprintf(stderr, "cannot init parser\n");
106105
return 1;
107106
}
@@ -245,13 +244,13 @@ static void process_event(llist *entries)
245244
// If its a single event or SYSCALL load interpretations
246245
if ((entries->cnt == 1) ||
247246
(entries->head->type == AUDIT_SYSCALL)) {
248-
_auparse_load_interpretations(interp_au,
247+
_auparse_load_interpretations(au,
249248
entries->head->interp);
250249
}
251250
// This is the per entry action item
252251
if (per_event_processing(entries))
253252
found = 1;
254-
_auparse_free_interpretations(interp_au);
253+
_auparse_free_interpretations(au);
255254
}
256255
}
257256

src/ausearch-lookup.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
#include "ausearch-options.h"
3333
#include "ausearch-nvpair.h"
3434
#include "auparse-idata.h"
35-
#include "auparse-stub.h"
35+
3636
static int interp_init = 0;
37+
static auparse_state_t *au = NULL;
3738

3839
/* This is the name/value pair used by search tables */
3940
struct nv_pair {
@@ -76,8 +77,8 @@ const char *aulookup_syscall(llist *l, char *buf, size_t size)
7677
const char *sys;
7778

7879
if (!interp_init) {
79-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
80-
if (interp_au == NULL)
80+
au = auparse_init(AUSOURCE_BUFFER, "");
81+
if (au == NULL)
8182
return NULL;
8283
interp_init = 1;
8384
}
@@ -87,8 +88,7 @@ const char *aulookup_syscall(llist *l, char *buf, size_t size)
8788
return buf;
8889
}
8990

90-
sys = _auparse_lookup_interpretation(interp_au,
91-
"syscall");
91+
sys = _auparse_lookup_interpretation(au, "syscall");
9292
if (sys) {
9393
snprintf(buf, size, "%s", sys);
9494
free((void *)sys);
@@ -208,8 +208,8 @@ const char *aulookup_uid(uid_t uid, char *buf, size_t size)
208208
int rc;
209209

210210
if (!interp_init) {
211-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
212-
if (interp_au == NULL)
211+
au = auparse_init(AUSOURCE_BUFFER, "");
212+
if (au == NULL)
213213
return NULL;
214214
interp_init = 1;
215215
}
@@ -223,7 +223,7 @@ const char *aulookup_uid(uid_t uid, char *buf, size_t size)
223223
return buf;
224224
}
225225

226-
name = _auparse_lookup_interpretation(interp_au, "auid");
226+
name = _auparse_lookup_interpretation(au, "auid");
227227
if (name) {
228228
snprintf(buf, size, "%s", name);
229229
free((void *)name);

src/ausearch-parse.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "ausearch-lookup.h"
4040
#include "ausearch-parse.h"
4141
#include "auparse-idata.h"
42-
#include "auparse-stub.h"
4342
#include "ausearch-nvpair.h"
4443

4544

@@ -212,18 +211,19 @@ int extract_search_items(llist *l)
212211
static nvlist uid_nvl;
213212
static int uid_list_created=0;
214213
static int interp_init = 0;
214+
static auparse_state_t *au = NULL;
215215
static const char *lookup_uid(const char *field, uid_t uid)
216216
{
217217
const char *value;
218218

219219
if (!interp_init) {
220-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
221-
if (interp_au == NULL)
220+
au = auparse_init(AUSOURCE_BUFFER, "");
221+
if (au == NULL)
222222
return NULL;
223223
interp_init = 1;
224224
}
225225

226-
value = _auparse_lookup_interpretation(interp_au, field);
226+
value = _auparse_lookup_interpretation(au, field);
227227
if (value)
228228
return value;
229229
if (uid == 0)

src/ausearch-report.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
#include "ausearch-lookup.h"
3434
#include "auparse.h"
3535
#include "auparse-idata.h"
36-
#include "auparse-stub.h"
3736
#include "auditd-config.h"
3837

3938
static int interp_init = 0;
39+
static auparse_state_t *au = NULL;
4040

4141
/* Local functions */
4242
static void output_raw(llist *l);
@@ -52,7 +52,7 @@ static void text_event(auparse_state_t *au,
5252

5353
extern time_t lol_get_eoe_timeout(void);
5454

55-
static auparse_state_t *au = NULL;
55+
static auparse_state_t *feed_au = NULL;
5656

5757

5858
/* The machine based on elf type */
@@ -69,20 +69,20 @@ void ausearch_load_interpretations(const lnode *n)
6969
{
7070
if (loaded == 0) {
7171
if (!interp_init) {
72-
interp_au = auparse_init(AUSOURCE_BUFFER, "");
73-
if (interp_au == NULL)
72+
au = auparse_init(AUSOURCE_BUFFER, "");
73+
if (au == NULL)
7474
return;
7575
interp_init = 1;
7676
}
77-
_auparse_load_interpretations(interp_au, n->interp);
77+
_auparse_load_interpretations(au, n->interp);
7878
loaded = 1;
7979
}
8080
}
8181

8282
void ausearch_free_interpretations(void)
8383
{
84-
if (loaded && interp_au) {
85-
_auparse_free_interpretations(interp_au);
84+
if (loaded && au) {
85+
_auparse_free_interpretations(au);
8686
loaded = 0;
8787
}
8888
}
@@ -394,7 +394,7 @@ static void report_interpret(char *name, char *val, int comma, int rtype)
394394
id.val = val;
395395
id.cwd = NULL;
396396

397-
char *out = auparse_do_interpretation(interp_au,type,&id,escape_mode);
397+
char *out = auparse_do_interpretation(au, type, &id, escape_mode);
398398
if (type == AUPARSE_TYPE_UNCLASSIFIED)
399399
printf("%s%c", val, comma ? ',' : ' ');
400400
else if (name[0] == 'k' && strcmp(name, "key") == 0) {
@@ -819,30 +819,30 @@ static void feed_auparse(llist *l, auparse_callback_ptr callback)
819819
fprintf(stderr, "Error - no elements in record.");
820820
return;
821821
}
822-
if (au == NULL) {
823-
au = auparse_init(AUSOURCE_FEED, 0);
824-
auparse_set_escape_mode(au, escape_mode);
822+
if (feed_au == NULL) {
823+
feed_au = auparse_init(AUSOURCE_FEED, 0);
824+
auparse_set_escape_mode(feed_au, escape_mode);
825825
auparse_set_eoe_timeout(lol_get_eoe_timeout());
826-
auparse_add_callback(au, callback, NULL, NULL);
827-
}
826+
auparse_add_callback(feed_au, callback, NULL, NULL);
827+
}
828828
do {
829829
// Records need to be terminated by a newline
830830
// Temporarily replace it.
831831
if (l->fmt == LF_ENRICHED)
832832
n->message[n->mlen] = AUDIT_INTERP_SEPARATOR;
833833
n->message[n->tlen] = 0x0a;
834-
auparse_feed(au, n->message, n->tlen+1);
834+
auparse_feed(feed_au, n->message, n->tlen+1);
835835
if (l->fmt == LF_ENRICHED)
836836
n->message[n->mlen] = 0;
837837
n->message[n->tlen] = 0;
838838
} while ((n=list_next(l)));
839839

840-
auparse_flush_feed(au);
840+
auparse_flush_feed(feed_au);
841841
}
842842

843843
void output_auparse_finish(void)
844844
{
845-
if (au)
846-
auparse_destroy(au);
847-
au = NULL;
845+
if (feed_au)
846+
auparse_destroy(feed_au);
847+
feed_au = NULL;
848848
}

0 commit comments

Comments
 (0)