1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_6,3_7} )
8 inherit autotools multilib multilib-minimal toolchain-funcs preserve-libs python-r1 linux-info systemd usr-ldscript
10 DESCRIPTION="Userspace utilities for storing and processing auditing records"
11 HOMEPAGE="https://people.redhat.com/sgrubb/audit/"
12 SRC_URI="https://people.redhat.com/sgrubb/audit/${P}.tar.gz"
14 LICENSE="GPL-2+ LGPL-2.1+"
16 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~riscv s390 ~sh sparc x86"
17 IUSE="gssapi ldap python static-libs"
18 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
19 # Testcases are pretty useless as they are built for RedHat users/groups and kernels.
22 RDEPEND="gssapi? ( virtual/krb5 )
23 ldap? ( net-nds/openldap )
25 python? ( ${PYTHON_DEPS} )"
27 >=sys-kernel/linux-headers-2.6.34
28 python? ( dev-lang/swig:0 )"
29 # Do not use os-headers as this is linux specific
38 # Do not build GUI tools
40 -e '/AC_CONFIG_SUBDIRS.*system-config-audit/d' \
41 "${S}"/configure.ac || die
43 -e 's,system-config-audit,,g' \
44 "${S}"/Makefile.am || die
45 rm -rf "${S}"/system-config-audit
49 -e '/^AC_OUTPUT/s,audisp/plugins/zos-remote/Makefile,,g' \
50 "${S}"/configure.ac || die
52 -e '/^SUBDIRS/s,zos-remote,,g' \
53 "${S}"/audisp/plugins/Makefile.am || die
56 # Don't build static version of Python module.
57 eapply "${FILESDIR}"/${PN}-2.4.3-python.patch
59 # glibc/kernel upstreams suck with both defining ia64_fpreg
60 # This patch is a horribly workaround that is only valid as long as you
61 # don't need the OTHER definitions in fpu.h.
62 eapply "${FILESDIR}"/${PN}-2.8.4-ia64-compile-fix.patch
64 # there is no --without-golang conf option
65 sed -e "/^SUBDIRS =/s/ @gobind_dir@//" -i bindings/Makefile.am || die
69 # Regenerate autotooling
73 multilib_src_configure() {
74 local ECONF_SOURCE=${S}
76 --sbindir="${EPREFIX}/sbin" \
77 $(use_enable gssapi gssapi-krb5) \
78 $(use_enable static-libs static) \
83 if multilib_is_native_abi; then
85 mkdir -p "${BUILD_DIR}" || die
86 cd "${BUILD_DIR}" || die
88 if python_is_python3; then
89 econf --without-python --with-python3
91 econf --with-python --without-python3
95 use python && python_foreach_impl python_configure
100 tc-export_build_env BUILD_{CC,CPP}
101 export CC_FOR_BUILD="${BUILD_CC}"
102 export CPP_FOR_BUILD="${BUILD_CPP}"
104 multilib-minimal_src_configure
107 multilib_src_compile() {
108 if multilib_is_native_abi; then
113 if python_is_python3; then
115 pydef='USE_PYTHON3=true'
118 pydef='HAVE_PYTHON=true'
121 emake -C "${BUILD_DIR}"/bindings/swig \
122 VPATH="${native_build}/lib" \
123 LIBS="${native_build}/lib/libaudit.la" \
124 _audit_la_LIBADD="${native_build}/lib/libaudit.la" \
125 _audit_la_DEPENDENCIES="${S}/lib/libaudit.h ${native_build}/lib/libaudit.la" \
127 emake -C "${BUILD_DIR}"/bindings/python/python${pysuffix} \
128 VPATH="${S}/bindings/python/python${pysuffix}:${native_build}/bindings/python/python${pysuffix}" \
129 auparse_la_LIBADD="${native_build}/auparse/libauparse.la ${native_build}/lib/libaudit.la" \
133 local native_build="${BUILD_DIR}"
134 use python && python_foreach_impl python_compile
141 multilib_src_install() {
142 if multilib_is_native_abi; then
143 emake DESTDIR="${D}" initdir="$(systemd_get_systemunitdir)" install
147 if python_is_python3; then
149 pydef='USE_PYTHON3=true'
152 pydef='HAVE_PYTHON=true'
155 emake -C "${BUILD_DIR}"/bindings/swig \
156 VPATH="${native_build}/lib" \
157 LIBS="${native_build}/lib/libaudit.la" \
158 _audit_la_LIBADD="${native_build}/lib/libaudit.la" \
159 _audit_la_DEPENDENCIES="${S}/lib/libaudit.h ${native_build}/lib/libaudit.la" \
161 DESTDIR="${D}" install
162 emake -C "${BUILD_DIR}"/bindings/python/python${pysuffix} \
163 VPATH="${S}/bindings/python/python${pysuffix}:${native_build}/bindings/python/python${pysuffix}" \
164 auparse_la_LIBADD="${native_build}/auparse/libauparse.la ${native_build}/lib/libaudit.la" \
166 DESTDIR="${D}" install
169 local native_build=${BUILD_DIR}
170 use python && python_foreach_impl python_install
172 # things like shadow use this so we need to be in /
173 gen_usr_ldscript -a audit auparse
175 emake -C lib DESTDIR="${D}" install
176 emake -C auparse DESTDIR="${D}" install
180 multilib_src_install_all() {
181 dodoc AUTHORS ChangeLog README* THANKS
183 dodoc contrib/{avc_snap,skeleton.c}
184 docinto contrib/plugin
185 dodoc contrib/plugin/*
189 newinitd "${FILESDIR}"/auditd-init.d-2.4.3 auditd
190 newconfd "${FILESDIR}"/auditd-conf.d-2.1.3 auditd
192 [ -f "${ED}"/sbin/audisp-remote ] && \
194 mv "${ED}"/{sbin,usr/sbin}/audisp-remote || die
198 newins "${FILESDIR}"/audit.rules-2.1.3 audit.rules
199 doins "${FILESDIR}"/audit.rules.stop*
202 keepdir /var/log/audit/
204 find "${D}" -name '*.la' -delete || die
207 lockdown_perms "${ED}"
211 # Preserve from the audit-1 series
212 preserve_old_lib /$(get_libdir)/libaudit.so.0
216 lockdown_perms "${EROOT}"
217 # Preserve from the audit-1 series
218 preserve_old_lib_notify /$(get_libdir)/libaudit.so.0
222 # Upstream wants these to have restrictive perms.
223 # Should not || die as not all paths may exist.
225 chmod 0750 "${basedir}"/sbin/au{ditctl,report,dispd,ditd,search,trace} 2>/dev/null
226 chmod 0750 "${basedir}"/var/log/audit/ 2>/dev/null
227 chmod 0640 "${basedir}"/etc/{audit/,}{auditd.conf,audit.rules*} 2>/dev/null