Skip to contentSkip to conversation

Add auditd listener and remote audit protocol

PATCH Applied DJ Delorie 5 participants 25 messages Aug 14, 2008 – Sep 29, 2009 Library code

lore
Share & tools
lore

DJ Delorie

author
#0 lore raw

PATCH 1/1 Add auditd listener and remote audit protocol

Second in a series, a bit bigger than the first one.
(http://www.redhat.com/archives/linux-audit/2008-August/msg00070.html)

The goal of this patch is to add the server side of the remote logging feature. To this end, a new auditd-listener.c is added which listens on a TCP port for connections from other systems' audisp-remote plugins. A new (private) protocol is added which prepends each message with a header, giving length, status, version, and sequence information. Each message begets a reply from the server, so we can pass along status like "disk full" or "ok". Currently, these call a set of stub functions, as the details of performing appropriate actions from the plugin are yet to be decided.

The remote plugin has a new option "format" for "ascii" or "managed" to choose between the old protocol (ascii strings) and the new one (the header with ACK, default).

The listener will accept either format. It has new options for the listen port, accept queue size, and acceptable client-side ports.

Comments?

DJ

Proposed ChangeLog entry:

- Add TCP listener and managed remote protocol features.

audisp/plugins/remote/audisp-remote.c +211 -6
diff -N -U 3 -x .svn -r pristine/audisp/plugins/remote/audisp-remote.c trunk/audisp/plugins/remote/audisp-remote.c
@@ -30,7 +30,11 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
 #include "libaudit.h"
+#include "private.h"
 #include "remote-config.h"
 
 #define CONFIG_FILE "/etc/audisp/audisp-remote.conf"
@@ -68,6 +72,56 @@
 	hup = 0;
 }
 
+/*
+ * Handlers for various events coming back from the remote server.
+ * Return -1 if the remote dispatcher should exit.
+ */
+
+/* Loss of sync - got an invalid response.  */
+static int sync_error_handler (const char *why)
+{
+	/* "why" has human-readable details on why we've lost (or will
+	   be losing) sync.  */
+	syslog (LOG_ERR, "lost/losing sync, %s", why);
+	return -1;
+}
+
+static int remote_disk_low_handler (const char *message)
+{
+	syslog (LOG_WARNING, "remote disk low, %s", message);
+	return 0;
+}
+
+static int remote_disk_full_handler (const char *message)
+{
+	syslog (LOG_ERR, "remote disk full, %s", message);
+	return -1;
+}
+
+static int remote_disk_error_handler (const char *message)
+{
+	syslog (LOG_ERR, "remote disk error, %s", message);
+	return -1;
+}
+
+static int remote_server_ending_handler (const char *message)
+{
+	syslog (LOG_INFO, "remote server ending, %s", message);
+	return -1;
+}
+
+static int generic_remote_error_handler (const char *message)
+{
+	stop = 1;
+	syslog(LOG_INFO, "audisp-remote: remote error: %s", message);
+	return -1;
+}
+static int generic_remote_warning_handler (const char *message)
+{
+	syslog(LOG_INFO, "audisp-remote: remote warning: %s", message);
+	return 0;
+}
+
 
 int main(int argc, char *argv[])
 {
@@ -122,6 +176,7 @@
 	struct addrinfo *ai;
 	struct addrinfo hints;
 	char remote[BUF_SIZE];
+	int one=1;
 
 	memset(&hints, '\0', sizeof(hints));
 	hints.ai_flags = AI_ADDRCONFIG|AI_NUMERICSERV;
@@ -140,12 +195,35 @@
 		freeaddrinfo(ai);
 		return -1;
 	}
+
+	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof (int));
+
+	if (config.local_port != 0) {
+		struct sockaddr_in address;
+		
+		memset (&address, 0, sizeof(address));
+		address.sin_family = htons(AF_INET);
+		address.sin_port = htons(config.local_port);
+		address.sin_addr.s_addr = htonl(INADDR_ANY);
+
+		if ( bind ( sock, (struct sockaddr *)&address, sizeof(address)) ) {
+			syslog(LOG_ERR, "Cannot bind local socket to port %d - exiting",
+			       config.local_port);
+			close(sock);
+			return -1;
+		}
+
+	}
 	if (connect(sock, ai->ai_addr, ai->ai_addrlen)) {
 		syslog(LOG_ERR, "Error connecting to %s: %s - exiting",
 			config.remote_server, strerror(errno));
 		freeaddrinfo(ai);
 		return -1;
 	}
+
+	setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof (int));
+	setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof (int));
+
 	freeaddrinfo(ai);
 	return 0;
 }
@@ -166,16 +244,143 @@
 	return rc;
 }
 
-static int relay_sock(const char *s, size_t len)
+static int ar_write (int sock, const void *buf, int len)
 {
 	int rc;
-
 	do {
-		rc = write(sock, s, len);
+		rc = write(sock, buf, len);
 	} while (rc < 0 && errno == EINTR);
-	if (rc > 0)
-		return 0;
-	return -1;
+	return rc;
+}
+
+static int ar_read (int sock, void *buf, int len)
+{
+	unsigned char *obuf = buf;
+	int rc = 0, r;
+	while (len > 0) {
+		do {
+			r = read(sock, buf, len);
+		} while (r < 0 && errno == EINTR);
+		if (r < 0)
+			return r;
+		if (r == 0)
+			break;
+		rc += r;
+		buf = (void *)((char *)buf + r);
+		len -= r;
+	}
+	return rc;
+}
+
+static int relay_sock_ascii(const char *s, size_t len)
+{
+	int rc;
+
+	rc = ar_write(sock, s, len);
+	if (rc <= 0) {
+		stop = 1;
+		syslog(LOG_ERR, "connection to %s closed unexpectedly - exiting",
+		       config.remote_server);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int relay_sock_managed(const char *s, size_t len)
+{
+	static int sequence_id = 1;
+	int rc;
+	unsigned char header[AUDIT_RMW_HEADER_SIZE];
+	int hver, mver;
+	uint32_t magic, type, rlen, seq;
+	char msg[MAX_AUDIT_MESSAGE_LENGTH+1];
+
+	sequence_id ++;
+	AUDIT_RMW_PACK_HEADER (header, 0, 0, len, sequence_id);
+	rc = ar_write(sock, header, AUDIT_RMW_HEADER_SIZE);
+	if (rc <= 0) {
+		stop = 1;
+		syslog(LOG_ERR, "connection to %s closed unexpectedly - exiting",
+		       config.remote_server);
+		return -1;
+	}
+
+	rc = ar_write(sock, s, len);
+	if (rc <= 0) {
+		stop = 1;
+		syslog(LOG_ERR, "connection to %s closed unexpectedly - exiting",
+		       config.remote_server);
+		return -1;
+	}
+
+	rc = ar_read (sock, header, AUDIT_RMW_HEADER_SIZE);
+	if (rc < 16) {
+		stop = 1;
+		syslog(LOG_ERR, "connection to %s closed unexpectedly - exiting",
+		       config.remote_server);
+		return -1;
+	}
+
+
+	if (! AUDIT_RMW_IS_MAGIC (header, AUDIT_RMW_HEADER_SIZE))
+		/* FIXME: the right thing to do here is close the socket and start a new one.  */
+		return sync_error_handler ("bad magic number");
+
+	AUDIT_RMW_UNPACK_HEADER (header, hver, mver, type, rlen, seq);
+
+	if (rlen > MAX_AUDIT_MESSAGE_LENGTH)
+		return sync_error_handler ("message too long");
+
+	if (rlen > 0
+	    && ar_read (sock, msg, rlen) < rlen)
+		return sync_error_handler ("ran out of data reading reply");
+	msg[rlen] = 0;
+
+	if (seq != sequence_id)
+		/* FIXME: should we read another header and
+		   see if it matches?  If so, we need to deal
+		   with timeouts.  */
+		return sync_error_handler ("mismatched response");
+
+	/* Specific errors we know how to deal with.  */
+
+	if (type == AUDIT_RMW_TYPE_ENDING)
+		return remote_server_ending_handler (msg);
+	if (type == AUDIT_RMW_TYPE_DISKLOW)
+		return remote_disk_low_handler (msg);
+	if (type == AUDIT_RMW_TYPE_DISKFULL)
+		return remote_disk_full_handler (msg);
+	if (type == AUDIT_RMW_TYPE_DISKERROR)
+		return remote_disk_error_handler (msg);
+
+	/* Generic errors.  */
+	if (type & AUDIT_RMW_TYPE_FATALMASK)
+		return generic_remote_error_handler (msg);
+	if (type & AUDIT_RMW_TYPE_WARNMASK)
+		return generic_remote_warning_handler (msg);
+
+	return 0;
+}
+
+static int relay_sock(const char *s, size_t len)
+{
+	int rc;
+
+	switch (config.format)
+	{
+		case F_MANAGED:
+			rc = relay_sock_managed (s, len);
+			break;
+		case F_ASCII:
+			rc = relay_sock_ascii (s, len);
+			break;
+		default:
+			rc = -1;
+			break;
+	}
+
+	return rc;
 }
 
 static int relay_event(const char *s, size_t len)
audisp/plugins/remote/audisp-remote.conf +2 -1
diff -N -U 3 -x .svn -r pristine/audisp/plugins/remote/audisp-remote.conf trunk/audisp/plugins/remote/audisp-remote.conf
@@ -5,8 +5,9 @@
 
 remote_server = 
 port = 60
+#local_port =
 transport = tcp
 mode = immediate
 queue_depth = 20
 fail_action = SYSLOG
-
+format = managed
audisp/plugins/remote/audisp-remote.conf.5 +22 -0
diff -N -U 3 -x .svn -r pristine/audisp/plugins/remote/audisp-remote.conf.5 trunk/audisp/plugins/remote/audisp-remote.conf.5
@@ -11,6 +11,13 @@
 .I port
 This option is an unsigned integer that indicates what port to connect to on the remote machine.
 .TP
+.I local_port
+This option is an unsigned integer that indicates what local port to
+connect from on the local machine.  If unspecified (the default) or
+set to the word
+.I any
+then any available unpriviledged port is used.
+.TP
 .I transport
 This parameter tells the remote logging app how to send events to the remote system. Valid values are
 .IR tcp ", and " ssl ".
@@ -55,7 +62,22 @@
 option will cause the remote logging app to put the computer system in single user mode.
 .I halt
 option will cause the remote logging app to shutdown the computer system.
+.TP
+.I format
+This parameter tells the remote logging app what data format will be
+used for the messages sent over the network.  The default is
+.I managed
+which adds some overhead to ensure each message is properly handled on
+the remote end, and to receive status messages from the remote server.
+If
+.I ascii
+is given instead, each message is a simple ASCII text line with no
+overhead at all.
 
+.SH "NOTES"
+Specifying a local port may make it difficult to restart the audit
+subsystem due to the previous connection being in a TIME_WAIT state,
+if you're reconnecting to and from the same hosts and ports as before.
 .SH "SEE ALSO"
 .BR audispd (8),
 .BR audisp-remote(8).
audisp/plugins/remote/remote-config.c +69 -0

120 lines not on this page · raw message

audisp/plugins/remote/remote-config.h +3 -0
diff -N -U 3 -x .svn -r pristine/audisp/plugins/remote/remote-config.h trunk/audisp/plugins/remote/remote-config.h
@@ -27,16 +27,19 @@
 typedef enum { M_IMMEDIATE, M_STORE_AND_FORWARD  } mode_t;
 typedef enum { T_TCP, T_SSL, T_GSSAPI, T_LABELED } transport_t;
 typedef enum { F_IGNORE, F_SYSLOG, F_EXEC, F_SUSPEND, F_SINGLE, F_HALT } fail_t;
+typedef enum { F_ASCII, F_MANAGED } format_t;
 
 typedef struct remote_conf
 {
 	const char *remote_server;
 	unsigned int port;
+	unsigned int local_port;
 	transport_t transport;
 	mode_t mode;
 	unsigned int queue_depth;
 	fail_t fail_action;
 	const char *fail_exe;
+	format_t format;
 } remote_conf_t;
 
 void clear_config(remote_conf_t *config);
docs/auditd.conf.5 +25 -0
diff -N -U 3 -x .svn -r pristine/docs/auditd.conf.5 trunk/docs/auditd.conf.5
@@ -212,6 +212,26 @@
 option will cause the audit daemon to put the computer system in single user mode.
 .I halt
 option will cause the audit daemon to shutdown the computer system.
+.TP
+.I tcp_listen_port
+This is a numeric value in the range 1..65535 which, if specified,
+causes auditd to listen on the corresponding TCP port for audit
+records from remote systems.
+.TP
+.I tcp_listen_queue
+This is a numeric value which indicates how many pending (requested
+but unaccepted) connections are allowed.  The default is 5.  Setting
+this too small may cause connections to be rejected if too many hosts
+start up at exactly the same time, such as after a power failure.
+.TP
+.I tcp_client_ports
+This parameter may be a single numeric value or two values separated
+by a dash (no spaces allowed).  It indicates which client ports are
+allowed for incoming connections.  If not specified, any port is
+allowed.  Allowed values are 1..65535.  For example, to require the
+client use a priviledged port, specify
+.I 1-1023
+for this parameter.
 
 .SH NOTES
 In a CAPP environment, the audit trail is considered so important that access to system resources must be denied if an audit trail cannot be created. In this environment, it would be suggested that /var/log/audit be on its own partition. This is to ensure that space detection is accurate and that no other process comes along and consumes part of it.
@@ -227,6 +247,11 @@
 The disk_full_action is triggered when no more room exists on the partition. All access should be terminated since no more audit capability exists. This can be set to either single or halt.
 .PP
 The disk_error_action should be set to syslog, single, or halt depending on your local policies regarding handling of hardware malfunctions.
+.PP
+Specifying a single allowed client port may make it difficult for the
+client to restart their audit subsystem, as it will be unable to
+recreate a connection with the same host addresses and ports until the
+connection closure TIME_WAIT state times out.
 
 .SH FILES
 .TP
init.d/auditd.conf +3 -1
diff -N -U 3 -x .svn -r pristine/init.d/auditd.conf trunk/init.d/auditd.conf
@@ -22,4 +22,6 @@
 admin_space_left_action = SUSPEND
 disk_full_action = SUSPEND
 disk_error_action = SUSPEND
-
+#tcp_listen_port = 
+#tcp_listen_queue = 5
+#tcp_client_ports = 1024-65535
lib/libaudit.h +0 -4
diff -N -U 3 -x .svn -r pristine/lib/libaudit.h trunk/lib/libaudit.h
@@ -413,10 +413,6 @@
 	};
 };
 
-struct auditd_reply_list {
-	struct audit_reply reply;
-	struct auditd_reply_list *next;
-};
 //
 // End of ABI control
 //////////////////////////////////////////////////////
lib/private.h +77 -0

83 lines not on this page · raw message

src/Makefile.am +2 -2
diff -N -U 3 -x .svn -r pristine/src/Makefile.am trunk/src/Makefile.am
@@ -27,9 +27,9 @@
 LIBS = -Lmt -lauditmt -Llibev -lev -lrt -lm
 LDADD = -lpthread
 AM_CFLAGS = -D_REENTRANT -D_GNU_SOURCE
-noinst_HEADERS = auditd-config.h auditd-event.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
+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
 
-auditd_SOURCES = auditd.c auditd-event.c auditd-config.c auditd-reconfig.c auditd-sendmail.c auditd-dispatch.c
+auditd_SOURCES = auditd.c auditd-event.c auditd-config.c auditd-reconfig.c auditd-sendmail.c auditd-dispatch.c auditd-listen.c
 auditd_CFLAGS = -fPIE -DPIE -g -D_REENTRANT -D_GNU_SOURCE
 auditd_LDFLAGS = -pie -Wl,-z,relro
 auditd_DEPENDENCIES = mt/libauditmt.a libev/libev.a
src/auditd-config.c +181 -0

211 lines not on this page · raw message

src/auditd-config.h +6 -0
diff -N -U 3 -x .svn -r pristine/src/auditd-config.h trunk/src/auditd-config.h
@@ -70,6 +70,10 @@
 	const char *disk_full_exe;
 	failure_action_t disk_error_action;
 	const char *disk_error_exe;
+	unsigned long tcp_listen_port;
+	unsigned long tcp_listen_queue;
+	unsigned long tcp_client_min_port;
+	unsigned long tcp_client_max_port;
 };
 
 void set_allow_links(int allow);
@@ -80,7 +84,9 @@
 int resolve_node(struct daemon_conf *config);
 
 void init_config_manager(void);
+#ifdef AUDITD_EVENT_H
 int start_config_manager(struct auditd_reply_list *rep);
+#endif
 void shutdown_config(void);
 void free_config(struct daemon_conf *config);
 
src/auditd-event.c +115 -33

189 lines not on this page · raw message

src/auditd-event.h +9 -0
diff -N -U 3 -x .svn -r pristine/src/auditd-event.h trunk/src/auditd-event.h
@@ -25,12 +25,21 @@
 #define AUDITD_EVENT_H
 
 #include "libaudit.h"
+
+struct auditd_reply_list {
+	struct audit_reply reply;
+	struct auditd_reply_list *next;
+	int ack_socket;
+	unsigned long sequence_id;
+};
+
 #include "auditd-config.h"
 
 void shutdown_events(void);
 int init_event(struct daemon_conf *config);
 void resume_logging(void);
 void enqueue_event(struct auditd_reply_list *rep);
+void enqueue_formatted_event(char *msg, int ack_socket, uint32_t sequence_id);
 void *consumer_thread_main(void *arg);
 
 #endif
src/auditd-listen.c +335 -0

335 lines not on this page · raw message

src/auditd-listen.h +30 -0
diff -N -U 3 -x .svn -r pristine/src/auditd-listen.h trunk/src/auditd-listen.h
@@ -0,0 +1,30 @@
+/* auditd-config.h -- 
+ * Copyright 2004-2007 Red Hat Inc., Durham, North Carolina.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Authors:
+ *   DJ Delorie <[email protected]>
+ * 
+ */
+
+#ifndef AUDITD_LISTEN_H
+#define AUDITD_LISTEN_H
+
+int auditd_tcp_listen_init ( struct ev_loop *loop, struct daemon_conf *config );
+void auditd_tcp_listen_uninit ( struct ev_loop *loop );
+
+#endif
src/auditd-reconfig.c +2 -2
diff -N -U 3 -x .svn -r pristine/src/auditd-reconfig.c trunk/src/auditd-reconfig.c
@@ -28,9 +28,9 @@
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
-#include "auditd-config.h"
-#include "auditd-event.h"
 #include "libaudit.h"
+#include "auditd-event.h"
+#include "auditd-config.h"
 #include "private.h"
 
 /* This is the configuration manager code */
src/auditd.c +10 -2
diff -N -U 3 -x .svn -r pristine/src/auditd.c trunk/src/auditd.c
@@ -40,8 +40,8 @@
 #include <getopt.h>
 
 #include "libaudit.h"
-#include "auditd-config.h"
 #include "auditd-event.h"
+#include "auditd-config.h"
 #include "auditd-dispatch.h"
 #include "private.h"
 
@@ -670,7 +670,15 @@
 	ev_signal_init (&sigchld_watcher, child_handler, SIGCHLD);
 	ev_signal_start (loop, &sigchld_watcher);
 
-	ev_loop (loop, 0);
+	if (auditd_tcp_listen_init (loop, &config)) {
+		tell_parent (FAILURE);
+		stop = 1;
+	}
+
+	if (!stop)
+		ev_loop (loop, 0);
+
+	auditd_tcp_listen_uninit (loop);
 
 	/* Write message to log that we are going down */
 
#1 lore raw
Quoted 17 lines · DJ Delorie

Second in a series, a bit bigger than the first one.
(http://www.redhat.com/archives/linux-audit/2008-August/msg00070.html)

The goal of this patch is to add the server side of the remote logging feature. To this end, a new auditd-listener.c is added which listens on a TCP port for connections from other systems' audisp-remote plugins. A new (private) protocol is added which prepends each message with a header, giving length, status, version, and sequence information. Each message begets a reply from the server, so we can pass along status like "disk full" or "ok". Currently, these call a set of stub functions, as the details of performing appropriate actions from the plugin are yet to be decided.

The remote plugin has a new option "format" for "ascii" or "managed" to choose between the old protocol (ascii strings) and the new one (the header with ACK, default).

Quoted 6 lines

The listener will accept either format. It has new options for the listen port, accept queue size, and acceptable client-side ports.

Comments?

DJ

Sorry to be dense, but if it isn't too much trouble would you mind supplying an example use-case for this new capability? I went back and read the supplied link but it isn't clear to me how to take advantage of this, and I suspect it is important.

What I'm getting is that in addition to kernel-generated local events the auditd would also receive signals as well as tcp-based events from other sources. Would this be the way of implementing multi-source audit aggregation or is it something different?

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
author
#2 lore raw
Quoted 5 lines

What I'm getting is that in addition to kernel-generated local events the auditd would also receive signals as well as tcp-based events from other sources. Would this be the way of implementing multi-source audit aggregation or is it something different?

The net result is to aggregate audit logs from many systems onto one central audit server. Remote audit messages have the new "node=" tag on them so you know where they came from.

I.e. you configure audisp-remote.conf like this:

remote_server = 10.2.3.4
port = 1237

And the central server (10.2.3.4 in this example) like this:

tcp_listen_port = 1237

And then the client sends all audit messages to the server, where they're logged to disk.

This is similar to centralized syslog logging.

The event loop change I linked to is a neccessary design change prerequisite to this one, since the listener adds (potentially) many descriptors which will need to be serviced. The loop now services four types of events: local signals, local netlink, the listen socket (for new connections), and client sockets (for incoming audit messages).

#3 lore raw
Quoted 4 lines · DJ Delorie

The net result is to aggregate audit logs from many systems onto one central audit server. Remote audit messages have the new "node=" tag on them so you know where they came from.

The field name was "host", is the "node=" a typo or did the field name change?

Signature · 1 line
John Dennis <[email protected]>
#4 lore raw
Quoted 8 lines · John Dennis
Quoted 4 lines · DJ Delorie

The net result is to aggregate audit logs from many systems onto one central audit server. Remote audit messages have the new "node=" tag on them so you know where they came from.

The field name was "host", is the "node=" a typo or did the field name change?

Mine say "node=".

LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#5 lore raw
Quoted 9 lines · LC Bruzenak
Quoted 7 lines · John Dennis
Quoted 5 lines · DJ Delorie

The net result is to aggregate audit logs from many systems onto one central audit server. Remote audit messages have the new "node=" tag on them so you know where they came from.

Quoted 6 lines
Quoted 3 lines

The field name was "host", is the "node=" a typo or did the field name change?

Mine say "node=".

The "host" field was added to audit records almost a year ago, although if memory serves me correctly you have to enable it as a configuration option. Is the node field redundant with host or did node supercede host?

Signature · 1 line
John Dennis <[email protected]>
#6 lore raw
Quoted 1 line · On Thursday 14 August 2008 19:16:54 John Dennis wrote:

The "host" field was added to audit records almost a year ago,

No, that was "node". "Host" has always been a field filled in by pam when someone is logging in.

-Steve

#8 lore raw
In reply to DJ Delorie
Quoted 14 lines · DJ Delorie
Quoted 4 lines

What I'm getting is that in addition to kernel-generated local events the auditd would also receive signals as well as tcp-based events from other sources. Would this be the way of implementing multi-source audit aggregation or is it something different?

The net result is to aggregate audit logs from many systems onto one central audit server. Remote audit messages have the new "node=" tag on them so you know where they came from.

I.e. you configure audisp-remote.conf like this:

remote_server = 10.2.3.4
port = 1237

Quoted 8 lines

And the central server (10.2.3.4 in this example) like this:

tcp_listen_port = 1237

And then the client sends all audit messages to the server, where they're logged to disk.

This is similar to centralized syslog logging.

Maybe in theory...but a couple of differences matter a bit:
1: Yesterday I saved 95MB of audit data. The past 3 days' syslog is so far under 3.5MB. I believe my audit data will grow more as my system matures and gets tested. I don't know if those numbers are anywhere close to representative or not though.
2: If I lose a portion of syslog data it doesn't hurt me too much usually; not the case if I rely on my audit data to be complete and accurate.

Quoted 7 lines

The event loop change I linked to is a neccessary design change prerequisite to this one, since the listener adds (potentially) many descriptors which will need to be serviced. The loop now services four types of events: local signals, local netlink, the listen socket (for new connections), and client sockets (for incoming audit messages).

Thank you; I get it now.
This is about to get interesting! :)

Not certain why I didn't get it the first time, but for some reason I had not considered sending the events into the auditd loop. I was thinking of just aggregating the logfiles. Now it makes sense.

My one auditd machine gets very busy occasionally - I sometimes drop events (rather than abort for a development machine) even after ratcheting up my event queue to 8K. Often this is due to an error I've introduced with too-general rules, so this is also not definitive.

Now the question is what happens if the network hiccups and I cannot send the events from a client? I could still write the events to the local disk, but them getting them onto the intended aggregator is now tricky right? Will the sender keep track of the last event sent and recover once the connection is restored?

I'm not disputing the approach, just trying to look down the road knowing problems I've experienced myself. There are some definite benefits to this approach I see also - the log files now are "blended" and you don't have to do any special directory hierarchy to accommodate the other events, for one.

OK, so - thanks again for the explanation and I look forward to testing this out soon!

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#9 lore raw
Quoted 18 lines · LC Bruzenak

Thank you; I get it now.
This is about to get interesting! :)

Not certain why I didn't get it the first time, but for some reason I had not considered sending the events into the auditd loop. I was thinking of just aggregating the logfiles. Now it makes sense.

My one auditd machine gets very busy occasionally - I sometimes drop events (rather than abort for a development machine) even after ratcheting up my event queue to 8K. Often this is due to an error I've introduced with too-general rules, so this is also not definitive.

Now the question is what happens if the network hiccups and I cannot send the events from a client? I could still write the events to the local disk, but them getting them onto the intended aggregator is now tricky right? Will the sender keep track of the last event sent and recover once the connection is restored?

Quoted 6 lines

I'm not disputing the approach, just trying to look down the road knowing problems I've experienced myself. There are some definite benefits to this approach I see also - the log files now are "blended" and you don't have to do any special directory hierarchy to accommodate the other events, for one.

This is why the IPA project has selected AMQP (www.amqp.org) as the transport for centralized loggiing (included audit logs). AMQP will queue in persistent storage messages which do not reach their destination until delivery is assured. The thinking was AMQP was too heavy weight a dependency for a simple centralized audit log but makes sense in an enterprise deployment such as IPA.

Signature · 1 line
John Dennis <[email protected]>
#10 lore raw
Quoted 7 lines · John Dennis

This is why the IPA project has selected AMQP (www.amqp.org) as the transport for centralized loggiing (included audit logs). AMQP will queue in persistent storage messages which do not reach their destination until delivery is assured. The thinking was AMQP was too heavy weight a dependency for a simple centralized audit log but makes sense in an enterprise deployment such as IPA.

I see; thanks for the info John.
Steve did mention this previously to me but I didn't get all the implications I guess (dense!).

I do require centralized auditing and I also require (more importantly) not losing any.

I cannot speak for other end-users...but my guess is that if they are using audit and aggregating they probably care about not dropping it, whereas others can just syslog the events if the auditd isn't enabled and then use centralized syslog, right?

AMQP may be heavyweight, however if you start down the road of trying to not lose networked audit data you probably end up somewhere near there anyway...

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#11 lore raw
Quoted 4 lines · On Thursday 14 August 2008 19:50:23 LC Bruzenak wrote:

I cannot speak for other end-users...but my guess is that if they are using audit and aggregating they probably care about not dropping it, whereas others can just syslog the events if the auditd isn't enabled and then use centralized syslog, right?

Does syslog queue unsent messages and recover them?

-Steve

#12 lore raw
Quoted 9 lines · Steve Grubb
Quoted 4 lines · On Thursday 14 August 2008 19:50:23 LC Bruzenak wrote:

I cannot speak for other end-users...but my guess is that if they are using audit and aggregating they probably care about not dropping it, whereas others can just syslog the events if the auditd isn't enabled and then use centralized syslog, right?

Does syslog queue unsent messages and recover them?

-Steve

Not AFAIK...but then again it isn't configurable to panic the machine on failure.

I think you have a good point - this is the first cut and maybe later on institute a "replay daemon" or something which can send events on reconnect.

We will not lose them locally so that's covered. After that it is a different problem.

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#13 lore raw
Quoted 3 lines · On Thursday 14 August 2008 20:22:24 LC Bruzenak wrote:

I think you have a good point - this is the first cut and maybe later on institute a "replay daemon" or something which can send events on reconnect.

Note that all audispd plugins take their input from stdin. At the worst, if you had the time hacks, you could

ausearch --start <time> --end <time> --raw | /sbin.audisp-remote

-Steve

#14 lore raw
Quoted 11 lines · Steve Grubb
Quoted 3 lines · On Thursday 14 August 2008 20:22:24 LC Bruzenak wrote:

I think you have a good point - this is the first cut and maybe later on institute a "replay daemon" or something which can send events on reconnect.

Note that all audispd plugins take their input from stdin. At the worst, if you had the time hacks, you could

ausearch --start <time> --end <time> --raw | /sbin.audisp-remote

-Steve

I like that idea too.
Since we get an ACK on delivery it can probably be automated at some point I'd guess.

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
author
#15 lore raw
Quoted 2 lines

Since we get an ACK on delivery

Right, and the ACK comes from the event logger thread *after* it pushes it out to disk.

#16 lore raw
Quoted 4 lines · DJ Delorie
Quoted 1 line

Since we get an ACK on delivery

Right, and the ACK comes from the event logger thread *after* it pushes it out to disk.

Seems like a workable plan to me.

Thanks again,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#17 lore raw
In reply to LC Bruzenak
Quoted 15 lines · LC Bruzenak
Quoted 2 lines · Steve Grubb
Quoted 1 line · On Thursday 14 August 2008 20:22:24 LC Bruzenak wrote:

I think you have a good point - this is the first cut and maybe

later on

Quoted 4 lines
Quoted 2 lines

institute a "replay daemon" or something which can send events on reconnect.

Note that all audispd plugins take their input from stdin. At the

worst, if

Quoted 5 lines

you had the time hacks, you could

ausearch --start <time> --end <time> --raw | /sbin.audisp-remote

-Steve

Steve,

I have been doing this but I really cannot tell if the audisp-remote connection succeeds; it returns "0" either way.
Would there be an easy way to return a non-zero failure indicator?

Thx,
LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#18 lore raw

Hi LCB,

I hope I answer u correctly...

I would look in your /etc/audisp/audisp-remote.conf file and note the port you communicate on, as an alternate you can grab the port with "lsof -i -nP" or "netstat -taupe". Then you can use tcpdump to watch the connections.

#tcpdump -i eth0 port 1001 --> or what ever port you have setup to the remote data on and the correct nic.

Sounds like this could help u out.

Norman Mark St. Laurent
Conceras | Chief Technology Officer and ISSE

Phone:  703-965-4892
Email:  [email protected]
Web:  http://www.conceras.com

Connect. Collaborate. Conceras.

Quoted 34 lines · LC Bruzenak
Quoted 6 lines · LC Bruzenak
Quoted 4 lines · Steve Grubb
Quoted 2 lines · On Thursday 14 August 2008 20:22:24 LC Bruzenak wrote:

I think you have a good point - this is the first cut and maybe

Quoted 15 lines

later on

Quoted 5 lines
Quoted 3 lines

institute a "replay daemon" or something which can send events on reconnect.

Note that all audispd plugins take their input from stdin. At the

worst, if

Quoted 6 lines

you had the time hacks, you could

ausearch --start <time> --end <time> --raw | /sbin.audisp-remote

-Steve

Steve,

I have been doing this but I really cannot tell if the audisp-remote connection succeeds; it returns "0" either way.
Would there be an easy way to return a non-zero failure indicator?

Thx,
LCB.

#19 lore raw
Quoted 20 lines · Norman Mark St. Laurent

Hi LCB,

I hope I answer u correctly...

I would look in your /etc/audisp/audisp-remote.conf file and note the port you communicate on, as an alternate you can grab the port with "lsof -i -nP" or "netstat -taupe". Then you can use tcpdump to watch the connections.

#tcpdump -i eth0 port 1001 --> or what ever port you have setup to
the remote data on and the correct nic.

Sounds like this could help u out.

Norman Mark St. Laurent
Conceras | Chief Technology Officer and ISSE

Phone:  703-965-4892
Email:  [email protected]
Web:  http://www.conceras.com
Quoted 38 lines

Connect. Collaborate. Conceras.

Quoted 33 lines · LC Bruzenak
Quoted 6 lines · LC Bruzenak
Quoted 4 lines · Steve Grubb
Quoted 2 lines · On Thursday 14 August 2008 20:22:24 LC Bruzenak wrote:

I think you have a good point - this is the first cut and maybe

Quoted 15 lines

later on

Quoted 5 lines
Quoted 3 lines

institute a "replay daemon" or something which can send events on reconnect.

Note that all audispd plugins take their input from stdin. At the

worst, if

Quoted 6 lines

you had the time hacks, you could

ausearch --start <time> --end <time> --raw | /sbin.audisp-remote

-Steve

Steve,

I have been doing this but I really cannot tell if the audisp-remote connection succeeds; it returns "0" either way.
Would there be an easy way to return a non-zero failure indicator?

Thx,
LCB.

Norman,

Thank for the reply but I wasn't quite clear enough.
The context of this is within a recovery script, so I'm concerned that I can get the return value of the audisp-remote within the script to decide if the recovery was successful or if it failed.

I don't think that was clear above; my apologies since the conversation I referenced was > 1 year old.

LCB.

Signature · 2 lines
LC (Lenny) Bruzenak
[email protected]
#20 lore raw
In reply to LC Bruzenak
Quoted 3 lines · LC Bruzenak

I have been doing this but I really cannot tell if the audisp-remote connection succeeds; it returns "0" either way.
Would there be an easy way to return a non-zero failure indicator?

It sounds like a reasonable request. Looking at the source, it does return non-zero on certain things. I think its just a matter of checking the queue size on exit and using that to decide the return value.

-Steve

author
#21 lore raw
In reply to LC Bruzenak
Quoted 3 lines

I do require centralized auditing and I also require (more importantly) not losing any.

The key code is in audisp/plugins/remote/audisp-remote.c

I think I put a couple of FIXMEs in there where the various errors are noted. If you want to put in a queue and retry mechanism, go ahead :-)

Quoted 3 lines

AMQP may be heavyweight, however if you start down the road of trying to not lose networked audit data you probably end up somewhere near there anyway...

You can always buy more paranoia.

#22 lore raw
In reply to LC Bruzenak
Quoted 3 lines · On Thursday 14 August 2008 19:26:49 LC Bruzenak wrote:

My one auditd machine gets very busy occasionally - I sometimes drop events (rather than abort for a development machine) even after ratcheting up my event queue to 8K.

I believe that this is a problem in the audit code. The scheduler changed sometimes around 2.6.25 and I started seeing it when I hadn't previously. I have a real strong idea what the problem is after talk with Chris Wright about it, but am at a loss for how to make it better. I hope to address this in the coming days since adding more load to auditd will make it worse.

Quoted 2 lines

Now the question is what happens if the network hiccups and I cannot send the events from a client?

There will be a couple admin defined actions just like when disk logging has problems. Anyone that wants to enhance what is in this first cut, please send patches.

Quoted 3 lines

I could still write the events to the local disk, but them getting them onto the intended aggregator is now tricky right? Will the sender keep track of the last event sent and recover once the connection is restored?

At first, I think a best effort solution is what we'll have. IPA's delivery service will be a more robust solution with failover capabilities. I do not envision going to that length with auditd.

-Steve

author
#23 lore raw
In reply to LC Bruzenak
Quoted 4 lines
Quoted 2 lines

This is similar to centralized syslog logging.

Maybe in theory...but a couple of differences matter a bit:

Right, I was just trying to get the basic idea across ;-)

Quoted 4 lines

1: Yesterday I saved 95MB of audit data. The past 3 days' syslog is so far under 3.5MB. I believe my audit data will grow more as my system matures and gets tested. I don't know if those numbers are anywhere close to representative or not though.

My machine is doing about 5M/day. Most of it is cron.

Quoted 3 lines

2: If I lose a portion of syslog data it doesn't hurt me too much usually; not the case if I rely on my audit data to be complete and accurate.

Understood.

Quoted 1 line

This is about to get interesting! :)

Let's hope so :-)

Quoted 3 lines

Not certain why I didn't get it the first time, but for some reason I had not considered sending the events into the auditd loop. I was thinking of just aggregating the logfiles. Now it makes sense.

Note that it injects it *after* the plugins are called; the aggregator will not pass along remote messages to its own plugins.

Quoted 2 lines

Now the question is what happens if the network hiccups and I cannot send the events from a client?

The basis for passing failure modes from the plugins back up to auditd is still up for discussion; in the patch those functions are empty. In general, though, if the network hangs, eventually the queues fill up and the usual queue-filled rules apply.

There are three likely failure modes:

* network timeout. Eventually, the queues (and pipes) fill up and local panic sets in.

* network failure (aggregator reboots or restarts, usually) - connection is closed or sync is lost, we know about it immediately. Currently audispd-remote just exits when that happens.

* remote error - the aggregator has an error (disk full, etc) and passes it back to the clients. The clients act on it, but currently those functions are empty.

Of course, a full review of the failure modes and actions will be needed at some point. Plus we have to decide if we want to feed the status back to auditd and use its configuration, or have a separate configuration in audisp-remote, for what to do about each error case.

Quoted 2 lines

Will the sender keep track of the last event sent and recover once the connection is restored?

The event that gets the network error gets lost at the moment (and every event after it), and the code currently doesn't have a "try again" mechanism if it loses connectivity. Again, the whole "what do we do when a problem happens" is still somewhat TBD.

Note that you can still log to the local disk *as well as* to the remote aggregator.

Quoted 2 lines

I'm not disputing the approach, just trying to look down the road knowing problems I've experienced myself.

:-)

Quoted 3 lines

There are some definite benefits to this approach I see also - the log files now are "blended" and you don't have to do any special directory hierarchy to accommodate the other events, for one.

Well, you *could* based on the node= field, if you wanted to code it that way. At least they're no longer on the machine being attacked/saturated/whatever, if/when that happens.

Applied
#24 lore raw
In reply to DJ Delorie
Quoted 5 lines · On Thursday 14 August 2008 17:43:00 DJ Delorie wrote:

Second in a series, a bit bigger than the first one.
(http://www.redhat.com/archives/linux-audit/2008-August/msg00070.html)

The goal of this patch is to add the server side of the remote logging feature.

Applied. Thanks for the patch !

For anyone following along...I will probably ready a release of the audit daemon in the next couple days. There is at least one more patch coming for remote logging and that is to add flow control. DJ says that remote logging is usable now, so be aware that its still being worked on an at least this one is a known issue. I think its important to go ahead with a release because there are a lot of bugs fixed recently and we should start getting some runtime on this new audit code to make sure its stable.

Thanks,
-Steve