Skip to contentSkip to conversation

audit: migrate from meta-selinux

PATCH New Armin Kuster 1 participant 2 messages May 13, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 audit: migrate from meta-selinux

Move audit to a more common layer to simplify integration.

---
 ...tue-functions-for-strndupa-rawmemchr.patch | 133 +++++++++++++++
 .../Fixed-swig-host-contamination-issue.patch |  57 +++++++
 .../audit/audit/audit-volatile.conf           |   1 +
 meta-oe/recipes-security/audit/audit/auditd   | 153 ++++++++++++++++++
 .../audit/audit/auditd.service                |  28 ++++
 meta-oe/recipes-security/audit/audit_2.8.5.bb | 105 ++++++++++++
 meta-oe/recipes-security/audit/audit_3.0.1.bb | 109 +++++++++++++
 7 files changed, 586 insertions(+)
 create mode 100644 meta-oe/recipes-security/audit/audit/Add-substitue-functions-for-strndupa-rawmemchr.patch
 create mode 100644 meta-oe/recipes-security/audit/audit/Fixed-swig-host-contamination-issue.patch
 create mode 100644 meta-oe/recipes-security/audit/audit/audit-volatile.conf
 create mode 100644 meta-oe/recipes-security/audit/audit/auditd
 create mode 100644 meta-oe/recipes-security/audit/audit/auditd.service
 create mode 100644 meta-oe/recipes-security/audit/audit_2.8.5.bb
 create mode 100644 meta-oe/recipes-security/audit/audit_3.0.1.bb
meta-oe/recipes-security/audit/audit/Add-substitue-functions-for-strndupa-rawmemchr.patch new file +133 -0
new file mode 100644
index 000000000..bb6c61e80
@@ -0,0 +1,133 @@
+From bdcdc3dff4469aac88e718bd15958d5ed4b9392a Mon Sep 17 00:00:00 2001
+From: Steve Grubb <[email protected]>
+Date: Tue, 26 Feb 2019 18:33:33 -0500
+Subject: [PATCH] Add substitue functions for strndupa & rawmemchr
+
+Upstream-Status: Backport
+[https://github.com/linux-audit/audit-userspace/commit/d579a08bb1cde71f939c13ac6b2261052ae9f77e]
+---
+ auparse/auparse.c   | 12 +++++++++++-
+ auparse/interpret.c |  9 ++++++++-
+ configure.ac        | 14 +++++++++++++-
+ src/ausearch-lol.c  | 12 +++++++++++-
+ 4 files changed, 43 insertions(+), 4 deletions(-)
+
+diff --git a/auparse/auparse.c b/auparse/auparse.c
+index 650db02..2e1c737 100644
+--- a/auparse/auparse.c
++++ b/auparse/auparse.c
+@@ -1,5 +1,5 @@
+ /* auparse.c --
+- * Copyright 2006-08,2012-17 Red Hat Inc., Durham, North Carolina.
++ * Copyright 2006-08,2012-19 Red Hat Inc., Durham, North Carolina.
+  * All Rights Reserved.
+  *
+  * This library is free software; you can redistribute it and/or
+@@ -1118,6 +1118,16 @@ static int str2event(char *s, au_event_t *e)
+ 	return 0;
+ }
+ 
++#ifndef HAVE_STRNDUPA
++static inline char *strndupa(const char *old, size_t n)
++{
++	size_t len = strnlen(old, n);
++	char *tmp = alloca(len + 1);
++	tmp[len] = 0;
++	return memcpy(tmp, old, len);
++}
++#endif
++
+ /* Returns 0 on success and 1 on error */
+ static int extract_timestamp(const char *b, au_event_t *e)
+ {
+diff --git a/auparse/interpret.c b/auparse/interpret.c
+index 51c4a5e..67b7b77 100644
+--- a/auparse/interpret.c
++++ b/auparse/interpret.c
+@@ -853,6 +853,13 @@ err_out:
+ 		return print_escaped(id->val);
+ }
+ 
++// rawmemchr is faster. Let's use it if we have it.
++#ifdef HAVE_RAWMEMCHR
++#define STRCHR rawmemchr
++#else
++#define STRCHR strchr
++#endif
++
+ static const char *print_proctitle(const char *val)
+ {
+ 	char *out = (char *)print_escaped(val);
+@@ -863,7 +870,7 @@ static const char *print_proctitle(const char *val)
+ 		// Proctitle has arguments separated by NUL bytes
+ 		// We need to write over the NUL bytes with a space
+ 		// so that we can see the arguments
+-		while ((ptr  = rawmemchr(ptr, '\0'))) {
++		while ((ptr  = STRCHR(ptr, '\0'))) {
+ 			if (ptr >= end)
+ 				break;
+ 			*ptr = ' ';
+diff --git a/configure.ac b/configure.ac
+index 54bdbf1..aef07fb 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1,7 +1,7 @@
+ dnl
+ define([AC_INIT_NOTICE],
+ [### Generated automatically using autoconf version] AC_ACVERSION [
+-### Copyright 2005-18 Steve Grubb <[email protected]>
++### Copyright 2005-19 Steve Grubb <[email protected]>
+ ###
+ ### Permission is hereby granted, free of charge, to any person obtaining a
+ ### copy of this software and associated documentation files (the "Software"),
+@@ -72,6 +72,18 @@ dnl; posix_fallocate is used in audisp-remote
+ AC_CHECK_FUNCS([posix_fallocate])
+ dnl; signalfd is needed for libev
+ AC_CHECK_FUNC([signalfd], [], [ AC_MSG_ERROR([The signalfd system call is necessary for auditd]) ])
++dnl; check if rawmemchr is available
++AC_CHECK_FUNCS([rawmemchr])
++dnl; check if strndupa is available
++AC_LINK_IFELSE(
++  [AC_LANG_SOURCE(
++    [[
++      #define _GNU_SOURCE
++      #include <string.h>
++      int main() { (void) strndupa("test", 10); return 0; }]])],
++ [AC_DEFINE(HAVE_STRNDUPA, 1, [Let us know if we have it or not])],
++ []
++)
+ 
+ ALLWARNS=""
+ ALLDEBUG="-g"
+diff --git a/src/ausearch-lol.c b/src/ausearch-lol.c
+index 5d17a72..758c33e 100644
+--- a/src/ausearch-lol.c
++++ b/src/ausearch-lol.c
+@@ -1,6 +1,6 @@
+ /*
+ * ausearch-lol.c - linked list of linked lists library
+-* Copyright (c) 2008,2010,2014,2016 Red Hat Inc., Durham, North Carolina.
++* Copyright (c) 2008,2010,2014,2016,2019 Red Hat Inc., Durham, North Carolina.
+ * All Rights Reserved. 
+ *
+ * This software may be freely redistributed and/or modified under the
+@@ -152,6 +152,16 @@ static int compare_event_time(event *e1, event *e2)
+ 	return 0;
+ }
+ 
++#ifndef HAVE_STRNDUPA
++static inline char *strndupa(const char *old, size_t n)
++{
++	size_t len = strnlen(old, n);
++	char *tmp = alloca(len + 1);
++	tmp[len] = 0;
++	return memcpy(tmp, old, len);
++}
++#endif
++
+ /*
+  * This function will look at the line and pick out pieces of it.
+  */
+-- 
+2.7.4
+
meta-oe/recipes-security/audit/audit/Fixed-swig-host-contamination-issue.patch new file +57 -0

57 lines not on this page · raw message

meta-oe/recipes-security/audit/audit/audit-volatile.conf new file +1 -0
new file mode 100644
index 000000000..9cbe1547a
@@ -0,0 +1 @@
+d  /var/log/audit 0750 root root -
meta-oe/recipes-security/audit/audit/auditd new file +153 -0

153 lines not on this page · raw message

meta-oe/recipes-security/audit/audit/auditd.service new file +28 -0
new file mode 100644
index 000000000..06c63f0e5
@@ -0,0 +1,28 @@
+[Unit]
+Description=Security Auditing Service
+DefaultDependencies=no
+After=local-fs.target systemd-tmpfiles-setup.service
+Before=sysinit.target shutdown.target
+Conflicts=shutdown.target
+ConditionKernelCommandLine=!audit=0
+
+[Service]
+Type=forking
+PIDFile=/run/auditd.pid
+ExecStart=/sbin/auditd
+## To use augenrules, uncomment the next line and comment/delete the auditctl line.
+## NOTE: augenrules expect any rules to be added to /etc/audit/rules.d/
+#ExecStartPost=-/sbin/augenrules --load
+ExecStartPost=-/sbin/auditctl -R /etc/audit/audit.rules
+# By default we don't clear the rules on exit.
+# To enable this, uncomment the next line.
+#ExecStopPost=/sbin/auditctl -R /etc/audit/audit-stop.rules
+
+### Security Settings ###
+MemoryDenyWriteExecute=true
+LockPersonality=true
+ProtectControlGroups=true
+ProtectKernelModules=true
+
+[Install]
+WantedBy=multi-user.target
meta-oe/recipes-security/audit/audit_2.8.5.bb new file +105 -0

105 lines not on this page · raw message

meta-oe/recipes-security/audit/audit_3.0.1.bb new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 packagegroup-meta-oe: add audit to pkg grp

---
 meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb | 1 +
 1 file changed, 1 insertion(+)
meta-oe/recipes-core/packagegroups/packagegroup-meta-oe.bb +1 -0
index e9493fe27..2bc638ca8 100644
@@ -697,6 +697,7 @@ RDEPENDS_packagegroup-meta-oe-security ="\
     ${@bb.utils.contains("DISTRO_FEATURES", "pam", "passwdqc", "", d)} \
     softhsm \
     tomoyo-tools \
+    auditd \
 "
 
 RDEPENDS_packagegroup-meta-oe-shells ="\
Signature · 1 line
2.25.1