aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/audit/simple
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/audit/simple')
-rw-r--r--src/plugins/audit/simple/Makefile.in27
-rw-r--r--src/plugins/audit/simple/au_simple_main.c263
-rw-r--r--src/plugins/audit/simple/deps15
-rw-r--r--src/plugins/audit/simple/k5audit.exports1
4 files changed, 306 insertions, 0 deletions
diff --git a/src/plugins/audit/simple/Makefile.in b/src/plugins/audit/simple/Makefile.in
new file mode 100644
index 0000000..54961c4
--- /dev/null
+++ b/src/plugins/audit/simple/Makefile.in
@@ -0,0 +1,27 @@
+mydir=plugins$(S)audit$(S)simple
+BUILDTOP=$(REL)..$(S)..$(S)..
+
+LIBBASE=k5audit
+LIBMAJOR=1
+LIBMINOR=1
+RELDIR=../plugins/audit/simple
+
+#Depends on libkrb5 and libkrb5support.
+SHLIB_EXPDEPS= $(KRB5_BASE_DEPLIBS)
+SHLIB_EXPLIBS= $(KRB5_BASE_LIBS)
+
+STOBJLISTS= OBJS.ST ../OBJS.ST
+STLIBOBJS= au_simple_main.o
+
+SRCS= $(srcdir)/au_simple_main.c
+
+all-unix:: all-liblinks
+install-unix:: install-libs
+clean-unix:: clean-liblinks clean-libs clean-libobjs
+
+clean::
+ $(RM) au_simple_main.o kdc_j_encode.o
+ $(RM) lib$(LIBBASE)$(SO_EXT)
+
+@libnover_frag@
+@libobj_frag@
diff --git a/src/plugins/audit/simple/au_simple_main.c b/src/plugins/audit/simple/au_simple_main.c
new file mode 100644
index 0000000..87a2c55
--- /dev/null
+++ b/src/plugins/audit/simple/au_simple_main.c
@@ -0,0 +1,263 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/* plugins/audit/au_simple_main.c - Sample Audit plugin implementation */
+/*
+ * Copyright (C) 2013 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * This is a demo implementation of Audit JSON-based module.
+ * It utilizes MIT Kerberos <kdc_j_encode.h> routines for JSON processing and
+ * the Fedora/Debian libaudit library for audit logs.
+ */
+
+#include <k5-int.h>
+#include <krb5/audit_plugin.h>
+#include <libaudit.h>
+#include <kdc_j_encode.h>
+
+krb5_error_code
+audit_simple_initvt(krb5_context context, int maj_ver, int min_ver,
+ krb5_plugin_vtable vtable);
+
+struct krb5_audit_moddata_st {
+ int fd;
+};
+
+/* Open connection to the audit system. Returns 0 on success. */
+static krb5_error_code
+open_au(krb5_audit_moddata *auctx_out)
+{
+ krb5_error_code ret;
+ int fd = 0;
+ krb5_audit_moddata auctx;
+
+ auctx = k5calloc(1, sizeof(*auctx), &ret);
+ if (ret)
+ return ENOMEM;
+ fd = audit_open();
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ auctx->fd = fd;
+ *auctx_out = auctx;
+
+ return 0;
+}
+
+/* Close connection to the audit system. Returns 0 on success. */
+static krb5_error_code
+close_au(krb5_audit_moddata auctx)
+{
+ int fd = auctx->fd;
+
+ audit_close(fd);
+ return 0;
+}
+
+/* Log KDC-start event. Returns 0 on success. */
+static krb5_error_code
+j_kdc_start(krb5_audit_moddata auctx, krb5_boolean ev_success)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_START;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_kdc_start(ev_success, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log KDC-stop event. Returns 0 on success. */
+static krb5_error_code
+j_kdc_stop(krb5_audit_moddata auctx, krb5_boolean ev_success)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_END;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_kdc_stop(ev_success, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log AS_REQ event. Returns 0 on success */
+static krb5_error_code
+j_as_req(krb5_audit_moddata auctx, krb5_boolean ev_success,
+ krb5_audit_state *state)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_AUTH;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_as_req(ev_success, state, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log TGS_REQ event. Returns 0 on success */
+static krb5_error_code
+j_tgs_req(krb5_audit_moddata auctx, krb5_boolean ev_success,
+ krb5_audit_state *state)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_AUTH;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_tgs_req(ev_success, state, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log S4U2SELF event. Returns 0 on success */
+static krb5_error_code
+j_tgs_s4u2self(krb5_audit_moddata auctx, krb5_boolean ev_success,
+ krb5_audit_state *state)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_AUTH;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_tgs_s4u2self(ev_success, state, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log S4U2PROXY event. Returns 0 on success */
+static krb5_error_code
+j_tgs_s4u2proxy(krb5_audit_moddata auctx, krb5_boolean ev_success,
+ krb5_audit_state *state)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_AUTH;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_tgs_s4u2proxy(ev_success, state, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+/* Log user-to-user event. Returns 0 on success */
+static krb5_error_code
+j_tgs_u2u(krb5_audit_moddata auctx, krb5_boolean ev_success,
+ krb5_audit_state *state)
+{
+ krb5_error_code ret = 0;
+ int local_type = AUDIT_USER_AUTH;
+ int fd = auctx->fd;
+ char *jout = NULL;
+
+ if (fd < 0)
+ return KRB5_PLUGIN_NO_HANDLE; /* audit module is unavailable */
+
+ ret = kau_j_tgs_u2u(ev_success, state, &jout);
+ if (ret)
+ return ret;
+ if (audit_log_user_message(fd, local_type, jout,
+ NULL, NULL, NULL, ev_success) <= 0)
+ ret = EIO;
+ free(jout);
+ return ret;
+}
+
+krb5_error_code
+audit_simple_initvt(krb5_context context, int maj_ver,
+ int min_ver, krb5_plugin_vtable vtable)
+{
+ krb5_audit_vtable vt;
+
+ if (maj_ver != 1)
+ return KRB5_PLUGIN_VER_NOTSUPP;
+
+ vt = (krb5_audit_vtable)vtable;
+ vt->name = "simple";
+ vt->open = open_au;
+ vt->close = close_au;
+ vt->kdc_start = j_kdc_start;
+ vt->kdc_stop = j_kdc_stop;
+ vt->as_req = j_as_req;
+ vt->tgs_req = j_tgs_req;
+ vt->tgs_s4u2self = j_tgs_s4u2self;
+ vt->tgs_s4u2proxy = j_tgs_s4u2proxy;
+ vt->tgs_u2u = j_tgs_u2u;
+ return 0;
+}
diff --git a/src/plugins/audit/simple/deps b/src/plugins/audit/simple/deps
new file mode 100644
index 0000000..84d4f04
--- /dev/null
+++ b/src/plugins/audit/simple/deps
@@ -0,0 +1,15 @@
+#
+# Generated makefile dependencies follow.
+#
+au_simple_main.so au_simple_main.po $(OUTPRE)au_simple_main.$(OBJEXT): \
+ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/kdc_j_encode.h \
+ $(BUILDTOP)/include/krb5/audit_plugin.h $(BUILDTOP)/include/krb5/krb5.h \
+ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \
+ $(COM_ERR_DEPS) $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \
+ $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \
+ $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \
+ $(top_srcdir)/include/k5-plugin.h $(top_srcdir)/include/k5-thread.h \
+ $(top_srcdir)/include/k5-trace.h $(top_srcdir)/include/krb5.h \
+ $(top_srcdir)/include/krb5/authdata_plugin.h $(top_srcdir)/include/krb5/plugin.h \
+ $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
+ au_simple_main.c
diff --git a/src/plugins/audit/simple/k5audit.exports b/src/plugins/audit/simple/k5audit.exports
new file mode 100644
index 0000000..2070538
--- /dev/null
+++ b/src/plugins/audit/simple/k5audit.exports
@@ -0,0 +1 @@
+audit_simple_initvt