Skip to content

Commit 1d4e19d

Browse files
committed
Make queue depth user configurable
Introduced a configurable queue depth in the audisp-af_unix plugin by defining a default of 800 and allowing an optional numeric argument to override it. Clarified af_unix.conf to describe the optional fourth queue-depth argument and provided an example showing how to override the default. Updated the plugin’s man page to document the optional queue depth parameter and its default value of 800.
1 parent bd756dc commit 1d4e19d

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# This file controls the configuration of the
22
# af_unix socket plugin. It simply takes events
33
# and writes them to a unix domain socket. This
4-
# plugin can take 2 arguments, the path for the
5-
# socket and the socket permissions in octal.
4+
# plugin can take up to 4 arguments: the socket
5+
# permissions in octal, the path for the socket,
6+
# the output format, and optionally the queue depth.
67

78
active = no
89
path = /sbin/audisp-af_unix
910
type = always
1011
args = 0640 /run/audit/audispd_events string
12+
# To change the queue depth from the default of 800, append the value:
13+
# args = 0640 /run/audit/audispd_events string 1000
1114
format = binary

audisp/plugins/af_unix/audisp-af_unix.8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ audisp-af_unix \- plugin to push audit events to an af_unix socket
99
.B args
1010
line of the
1111
.B af_unix.conf
12-
file expects three arguments: access mode, socket path, and output format. The access mode determines the permissions for the socket and defaults to 0640. The socket path specifies where the socket will be created, with the default location being /run/audit/audispd_events. The output format determines the format in which events are delivered to the socket and supports two options: "string" and "binary". The "string" format delivers events in a human-readable form, while the "binary" format delivers events in their binary representation, which is essential for applications that need to process events in binary and reconstruct headers accurately. If the output format is not specified, the plugin defaults to the "string" format.
12+
file expects three arguments: access mode, socket path, and output format, and optionally a fourth argument specifying the queue depth. The access mode determines the permissions for the socket and defaults to 0640. The socket path specifies where the socket will be created, with the default location being /run/audit/audispd_events. The output format determines the format in which events are delivered to the socket and supports two options: "string" and "binary". The "string" format delivers events in a human-readable form, while the "binary" format delivers events in their binary representation, which is essential for applications that need to process events in binary and reconstruct headers accurately. If the output format is not specified, the plugin defaults to the "string" format. If no queue depth is specified, it defaults to 800.
1313

1414
The
1515
.B af_unix.conf

audisp/plugins/af_unix/audisp-af_unix.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ int inbound_protocol = -1;
6969
static struct mallinfo2 last_mi;
7070
#endif
7171

72-
#define QUEUE_DEPTH 800
72+
#define DEFAULT_QUEUE_DEPTH 800
7373
#define QUEUE_ENTRY_SIZE MAX_AUDIT_EVENT_FRAME_SIZE+1
7474

75+
static size_t queue_depth = DEFAULT_QUEUE_DEPTH;
7576
static struct queue *queue;
7677
static const unsigned char *out_buf;
7778
static size_t out_len;
@@ -194,14 +195,25 @@ int setup_socket(int argc, char *argv[])
194195
for (int i = 1; i < argc; i++) {
195196
char *arg = argv[i];
196197
if (isdigit((unsigned char)arg[0])) {
197-
// parse mode
198198
errno = 0;
199-
mode = strtoul(arg, NULL, 8);
200-
if (errno) {
201-
syslog(LOG_ERR,
202-
"Error converting %s (%s)",
203-
argv[i], strerror(errno));
204-
mode = 0;
199+
if (mode == 0) {
200+
// parse mode
201+
mode = strtoul(arg, NULL, 8);
202+
if (errno) {
203+
syslog(LOG_ERR,
204+
"Error converting %s (%s)",
205+
argv[i], strerror(errno));
206+
mode = 0;
207+
}
208+
} else {
209+
// parse queue depth
210+
queue_depth = strtoul(arg, NULL, 10);
211+
if (errno || queue_depth == 0) {
212+
syslog(LOG_ERR,
213+
"Error converting %s (%s)",
214+
argv[i], strerror(errno));
215+
queue_depth = DEFAULT_QUEUE_DEPTH;
216+
}
205217
}
206218
} else if (strchr(arg, '/') != NULL) {
207219
// parse path
@@ -254,6 +266,8 @@ int setup_socket(int argc, char *argv[])
254266
syslog(LOG_INFO, "Using default format");
255267
}
256268
}
269+
if (queue_depth == DEFAULT_QUEUE_DEPTH)
270+
syslog(LOG_INFO, "Using default queue depth");
257271

258272
return create_af_unix_socket(path, mode);
259273
}
@@ -660,7 +674,7 @@ int main(int argc, char *argv[])
660674
syslog(LOG_WARNING, "audisp-af_unix plugin was unable to "
661675
"drop capabilities, continuing with elevated priviles");
662676
#endif
663-
queue = q_open(QUEUE_DEPTH, QUEUE_ENTRY_SIZE);
677+
queue = q_open(queue_depth, QUEUE_ENTRY_SIZE);
664678
if (queue == NULL) {
665679
syslog(LOG_ERR, "Unable to create queue (%s)",
666680
strerror(errno));

0 commit comments

Comments
 (0)