blob: eb8592d34bce1fcf38223ab0a5749a67e6bb6572 [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001DESCRIPTION = "Provides file integrity checking and log file monitoring/analysis"
2HOMEPAGE = "http://www.la-samhna.de/samhain/"
Patrick Williams03907ee2022-05-01 06:28:52 -05003LICENSE = "GPL-2.0-only"
Brad Bishop19323692019-04-05 15:28:33 -04004LIC_FILES_CHKSUM = "file://LICENSE;md5=8ca43cbc842c2336e835926c2166c28b"
5
Andrew Geisslerd5838332022-05-27 11:33:10 -05006PV = "4.4.9"
Brad Bishop19323692019-04-05 15:28:33 -04007
Andrew Geisslerf31b8bd2020-11-30 19:54:56 -06008SRC_URI = "https://la-samhna.de/archive/samhain_signed-${PV}.tar.gz \
9 file://${INITSCRIPT_NAME}.init \
10 file://${INITSCRIPT_NAME}.default \
11 file://samhain.service \
Brad Bishop19323692019-04-05 15:28:33 -040012 file://samhain-mips64-aarch64-dnmalloc-hash-fix.patch \
13 file://samhain-samhainrc.patch \
14 file://samhain-samhainrc-fix-files-dirs-path.patch \
15 file://samhain-pid-path.patch \
16 file://samhain-sha256-big-endian.patch \
17 file://samhain-configure-add-option-for-ps.patch \
18 file://samhain-avoid-searching-host-for-postgresql.patch \
19 file://samhain-add-LDFLAGS-variable-for-samhain_setpwd.patch \
Andrew Geissler1fe918a2020-05-15 14:16:47 -050020 file://fix-build-with-new-version-attr.patch \
Andrew Geissler9d3cc052021-03-31 13:36:22 -050021 file://samhain-fix-initializer-element-is-not-constant.patch \
Brad Bishop19323692019-04-05 15:28:33 -040022 "
23
Andrew Geisslerd5838332022-05-27 11:33:10 -050024SRC_URI[sha256sum] = "dd85bf2f90db3ce616a09608e650f3707a4d69aa1e1fe718f8b359ce0aafc198"
Brad Bishop19323692019-04-05 15:28:33 -040025
26UPSTREAM_CHECK_URI = "https://www.la-samhna.de/samhain/archive.html"
27UPSTREAM_CHECK_REGEX = "samhain_signed-(?P<pver>(\d+(\.\d+)+))\.tar"
28
29S = "${WORKDIR}/samhain-${PV}"
30
31inherit autotools-brokensep update-rc.d pkgconfig systemd
32
33SAMHAIN_PORT ??= "49777"
34SAMHAIN_SERVER ??= "NULL"
35
36INITSCRIPT_NAME = "${BPN}"
37INITSCRIPT_PARAMS ?= "defaults"
38
39SYSTEMD_PACKAGES = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -050040SYSTEMD_SERVICE:${PN} = "${INITSCRIPT_NAME}.service"
Brad Bishop19323692019-04-05 15:28:33 -040041SYSTEMD_AUTO_ENABLE = "disable"
42
43# mode mapping:
44# BPN MODE_NAME SAMHAIN_MODE
45# samhain-standalone standalone no
46# samhain-client client client
47# samhain-server server server
48MODE_NAME = "${@d.getVar('BPN').split('-')[1]}"
49SAMHAIN_MODE = "${@oe.utils.ifelse(d.getVar('MODE_NAME') == 'standalone', 'no', '${MODE_NAME}')}"
50
51# supports mysql|postgresql|oracle|odbc but postgresql is the only one available
52
53PACKAGECONFIG ??= "postgresql ps \
54 ${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'ipv6', '', d)} \
55 ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit', '', d)} \
56 ${@bb.utils.contains('DISTRO_FEATURES', 'acl', 'acl', '', d)} \
57"
58
59PACKAGECONFIG[postgresql] = "--with-database=postgresql --enable-xml-log PGSQL_INC_DIR=${STAGING_INCDIR} PGSQL_LIB_DIR=${STAGING_LIBDIR}, , postgresql"
60PACKAGECONFIG[suidcheck] = "--enable-suidcheck, , "
61PACKAGECONFIG[logwatch] = "--enable-login-watch, , "
62PACKAGECONFIG[mounts] = "--enable-mounts-check, , "
63PACKAGECONFIG[userfiles] = "--enable-userfiles, , "
64PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
65PACKAGECONFIG[selinux] = "--enable-selinux, --disable-selinux, libselinux attr"
66PACKAGECONFIG[acl] = " --enable-posix-acl , --disable-posix-acl, acl"
67PACKAGECONFIG[audit] = "ac_cv_header_auparse_h=yes,ac_cv_header_auparse_h=no,audit"
68PACKAGECONFIG[ps] = "--with-ps-path=${base_bindir}/ps,,,procps"
69
Patrick Williams213cb262021-08-07 19:21:33 -050070EXTRA_OEMAKE:append:aarch64 = " CPPFLAGS+=-DCONFIG_ARCH_AARCH64=1"
71EXTRA_OEMAKE:append:mips64 = " CPPFLAGS+=-DCONFIG_ARCH_MIPS64=1"
Andrew Geissler1fe918a2020-05-15 14:16:47 -050072
Brad Bishop19323692019-04-05 15:28:33 -040073do_unpack_samhain() {
74 cd ${WORKDIR}
75 tar -xzvf samhain-${PV}.tar.gz
76}
77
Patrick Williams213cb262021-08-07 19:21:33 -050078python do_unpack:append() {
Brad Bishop19323692019-04-05 15:28:33 -040079 bb.build.exec_func('do_unpack_samhain', d)
80}
81
Patrick Williams213cb262021-08-07 19:21:33 -050082do_configure:prepend:arm() {
Brad Bishop19323692019-04-05 15:28:33 -040083 export sh_cv___va_copy=yes
84}
85
Patrick Williams213cb262021-08-07 19:21:33 -050086do_configure:prepend:aarch64() {
Brad Bishop19323692019-04-05 15:28:33 -040087 export sh_cv___va_copy=yes
88}
89
90# If we use oe_runconf in do_configure() it will by default
91# use the prefix --oldincludedir=/usr/include which is not
92# recognized by Samhain's configure script and would invariably
93# throw back the error "unrecognized option: --oldincludedir=/usr/include"
Patrick Williams213cb262021-08-07 19:21:33 -050094do_configure:prepend () {
Brad Bishop19323692019-04-05 15:28:33 -040095 cat << EOF > ${S}/config-site.${BP}
96ssp_cv_lib=no
97sh_cv_va_copy=yes
98EOF
99 export CONFIG_SITE=${S}/config-site.${BP}
100}
101
102do_configure () {
103 autoconf -f
104 ./configure \
105 --build=${BUILD_SYS} \
106 --host=${HOST_SYS} \
107 --target=${TARGET_SYS} \
108 --prefix=${prefix} \
109 --exec_prefix=${exec_prefix} \
110 --bindir=${bindir} \
111 --sbindir=${sbindir} \
112 --libexecdir=${libexecdir} \
113 --datadir=${datadir} \
114 --sysconfdir=${sysconfdir} \
115 --sharedstatedir=${sharedstatedir} \
116 --localstatedir=${localstatedir} \
117 --libdir=${libdir} \
118 --includedir=${includedir} \
119 --infodir=${infodir} \
120 --mandir=${mandir} \
121 --enable-network=${SAMHAIN_MODE} \
122 --with-pid-file=${localstatedir}/run/samhain.pid \
123 --with-data-file=${localstatedir}/lib/samhain/samhain_file \
Brad Bishop19323692019-04-05 15:28:33 -0400124 ${EXTRA_OECONF}
125}
126
Patrick Williams213cb262021-08-07 19:21:33 -0500127do_compile:prepend:libc-musl () {
Brad Bishop19323692019-04-05 15:28:33 -0400128 sed -i 's/^#define HAVE_MALLOC_H.*//' ${B}/config.h
129}
130
131# Install the init script, it's default file, and the extraneous
132# documentation.
Patrick Williams213cb262021-08-07 19:21:33 -0500133do_install:append () {
Brad Bishop19323692019-04-05 15:28:33 -0400134 oe_runmake install DESTDIR='${D}' INSTALL=install-boot
135
136 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.init \
137 ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
138
139 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.default \
140 ${D}${sysconfdir}/default/${INITSCRIPT_NAME}
141
142 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
143 if [ "${SAMHAIN_MODE}" = "no" ]; then
144 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/samhain.service
145 else
146 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/${BPN}.service
147 fi
148 install -D -m 0755 ${WORKDIR}/${BPN}.init ${D}/${libexecdir}/${BPN}
149 sed -i -e 's,@LIBDIR@,${libexecdir},' \
150 -e 's,@SAMHAIN_HELPER@,${BPN},' \
151 -e 's,@MODE_NAME@,${MODE_NAME},' \
152 ${D}${systemd_system_unitdir}/samhain*.service
153 fi
154
155 install -d ${D}${docdir}/${BPN}
156 cp -r docs/* ${D}${docdir}/${BPN}
157 cp -r scripts ${D}${docdir}/${BPN}
158 install -d -m 755 ${D}${localstatedir}/samhain
159
160 # Prevent QA warnings about installed ${localstatedir}/run
161 if [ -d ${D}${localstatedir}/run ]; then
162 rmdir ${D}${localstatedir}/run
163 fi
Andrew Geissler1fe918a2020-05-15 14:16:47 -0500164
165 rm -rf ${D}${localstatedir}/log
Brad Bishop19323692019-04-05 15:28:33 -0400166}
167
Patrick Williams213cb262021-08-07 19:21:33 -0500168FILES:${PN} += "${systemd_system_unitdir}"