1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_5,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
47 # audisp-remote moved in multilib_src_install_all
49 -e "s,/sbin/audisp-remote,${EPREFIX}/usr/sbin/audisp-remote," \
50 "${S}"/audisp/plugins/remote/au-remote.conf || die
52 # Don't build static version of Python module.
53 eapply "${FILESDIR}"/${PN}-2.4.3-python.patch
55 # glibc/kernel upstreams suck with both defining ia64_fpreg
56 # This patch is a horribly workaround that is only valid as long as you
57 # don't need the OTHER definitions in fpu.h.
58 eapply "${FILESDIR}"/${PN}-2.8.4-ia64-compile-fix.patch
60 # there is no --without-golang conf option
61 sed -e "/^SUBDIRS =/s/ @gobind_dir@//" -i bindings/Makefile.am || die
65 # Regenerate autotooling
69 multilib_src_configure() {
70 local ECONF_SOURCE=${S}
71 local my_conf="$(use_enable ldap zos-remote)"
74 --sbindir="${EPREFIX}/sbin" \
75 $(use_enable gssapi gssapi-krb5) \
76 $(use_enable static-libs static) \
81 if multilib_is_native_abi; then
83 mkdir -p "${BUILD_DIR}" || die
84 cd "${BUILD_DIR}" || die
86 if python_is_python3; then
87 econf ${my_conf} --without-python --with-python3
89 econf ${my_conf} --with-python --without-python3
93 use python && python_foreach_impl python_configure
98 tc-export_build_env BUILD_{CC,CPP}
99 export CC_FOR_BUILD="${BUILD_CC}"
100 export CPP_FOR_BUILD="${BUILD_CPP}"
102 multilib-minimal_src_configure
105 multilib_src_compile() {
106 if multilib_is_native_abi; then
111 if python_is_python3; then
113 pydef='USE_PYTHON3=true'
116 pydef='HAVE_PYTHON=true'
119 emake -C "${BUILD_DIR}"/bindings/swig \
120 VPATH="${native_build}/lib" \
121 LIBS="${native_build}/lib/libaudit.la" \
122 _audit_la_LIBADD="${native_build}/lib/libaudit.la" \
123 _audit_la_DEPENDENCIES="${S}/lib/libaudit.h ${native_build}/lib/libaudit.la" \
125 emake -C "${BUILD_DIR}"/bindings/python/python${pysuffix} \
126 VPATH="${S}/bindings/python/python${pysuffix}:${native_build}/bindings/python/python${pysuffix}" \
127 auparse_la_LIBADD="${native_build}/auparse/libauparse.la ${native_build}/lib/libaudit.la" \
131 local native_build="${BUILD_DIR}"
132 use python && python_foreach_impl python_compile
139 multilib_src_install() {
140 if multilib_is_native_abi; then
141 emake DESTDIR="${D}" initdir="$(systemd_get_systemunitdir)" install
145 if python_is_python3; then
147 pydef='USE_PYTHON3=true'
150 pydef='HAVE_PYTHON=true'
153 emake -C "${BUILD_DIR}"/bindings/swig \
154 VPATH="${native_build}/lib" \
155 LIBS="${native_build}/lib/libaudit.la" \
156 _audit_la_LIBADD="${native_build}/lib/libaudit.la" \
157 _audit_la_DEPENDENCIES="${S}/lib/libaudit.h ${native_build}/lib/libaudit.la" \
159 DESTDIR="${D}" install
160 emake -C "${BUILD_DIR}"/bindings/python/python${pysuffix} \
161 VPATH="${S}/bindings/python/python${pysuffix}:${native_build}/bindings/python/python${pysuffix}" \
162 auparse_la_LIBADD="${native_build}/auparse/libauparse.la ${native_build}/lib/libaudit.la" \
164 DESTDIR="${D}" install
167 local native_build=${BUILD_DIR}
168 use python && python_foreach_impl python_install
170 # things like shadow use this so we need to be in /
171 gen_usr_ldscript -a audit auparse
173 emake -C lib DESTDIR="${D}" install
174 emake -C auparse DESTDIR="${D}" install
178 multilib_src_install_all() {
179 dodoc AUTHORS ChangeLog README* THANKS
181 dodoc contrib/{avc_snap,skeleton.c}
182 docinto contrib/plugin
183 dodoc contrib/plugin/*
187 newinitd "${FILESDIR}"/auditd-init.d-2.4.3 auditd
188 newconfd "${FILESDIR}"/auditd-conf.d-2.1.3 auditd
190 [ -f "${ED}"/sbin/audisp-remote ] && \
192 mv "${ED}"/{sbin,usr/sbin}/audisp-remote || die
196 newins "${FILESDIR}"/audit.rules-2.1.3 audit.rules
197 doins "${FILESDIR}"/audit.rules.stop*
200 keepdir /var/log/audit/
202 find "${D}" -name '*.la' -delete || die
205 lockdown_perms "${ED}"
209 # Preserve from the audit-1 series
210 preserve_old_lib /$(get_libdir)/libaudit.so.0
214 lockdown_perms "${EROOT}"
215 # Preserve from the audit-1 series
216 preserve_old_lib_notify /$(get_libdir)/libaudit.so.0
220 # Upstream wants these to have restrictive perms.
221 # Should not || die as not all paths may exist.
223 chmod 0750 "${basedir}"/sbin/au{ditctl,report,dispd,ditd,search,trace} 2>/dev/null
224 chmod 0750 "${basedir}"/var/log/audit/ 2>/dev/null
225 chmod 0640 "${basedir}"/etc/{audit/,}{auditd.conf,audit.rules*} 2>/dev/null