blob: 6a2eb08556f20cb38fa3ade83a5435e4abec6448 [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/"
3LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://LICENSE;md5=8ca43cbc842c2336e835926c2166c28b"
5
Andrew Geissler8b139282021-03-05 15:22:30 -06006PV = "4.4.3"
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 \
Brad Bishop19323692019-04-05 15:28:33 -040021 "
22
Andrew Geissler8b139282021-03-05 15:22:30 -060023SRC_URI[sha256sum] = "3e57574036d5055e9557ec5095818b419ea6c4365370fc2ccce1e9f87f9fad08"
Brad Bishop19323692019-04-05 15:28:33 -040024
25UPSTREAM_CHECK_URI = "https://www.la-samhna.de/samhain/archive.html"
26UPSTREAM_CHECK_REGEX = "samhain_signed-(?P<pver>(\d+(\.\d+)+))\.tar"
27
28S = "${WORKDIR}/samhain-${PV}"
29
30inherit autotools-brokensep update-rc.d pkgconfig systemd
31
32SAMHAIN_PORT ??= "49777"
33SAMHAIN_SERVER ??= "NULL"
34
35INITSCRIPT_NAME = "${BPN}"
36INITSCRIPT_PARAMS ?= "defaults"
37
38SYSTEMD_PACKAGES = "${PN}"
39SYSTEMD_SERVICE_${PN} = "${INITSCRIPT_NAME}.service"
40SYSTEMD_AUTO_ENABLE = "disable"
41
42# mode mapping:
43# BPN MODE_NAME SAMHAIN_MODE
44# samhain-standalone standalone no
45# samhain-client client client
46# samhain-server server server
47MODE_NAME = "${@d.getVar('BPN').split('-')[1]}"
48SAMHAIN_MODE = "${@oe.utils.ifelse(d.getVar('MODE_NAME') == 'standalone', 'no', '${MODE_NAME}')}"
49
50# supports mysql|postgresql|oracle|odbc but postgresql is the only one available
51
52PACKAGECONFIG ??= "postgresql ps \
53 ${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'ipv6', '', d)} \
54 ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux audit', '', d)} \
55 ${@bb.utils.contains('DISTRO_FEATURES', 'acl', 'acl', '', d)} \
56"
57
58PACKAGECONFIG[postgresql] = "--with-database=postgresql --enable-xml-log PGSQL_INC_DIR=${STAGING_INCDIR} PGSQL_LIB_DIR=${STAGING_LIBDIR}, , postgresql"
59PACKAGECONFIG[suidcheck] = "--enable-suidcheck, , "
60PACKAGECONFIG[logwatch] = "--enable-login-watch, , "
61PACKAGECONFIG[mounts] = "--enable-mounts-check, , "
62PACKAGECONFIG[userfiles] = "--enable-userfiles, , "
63PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
64PACKAGECONFIG[selinux] = "--enable-selinux, --disable-selinux, libselinux attr"
65PACKAGECONFIG[acl] = " --enable-posix-acl , --disable-posix-acl, acl"
66PACKAGECONFIG[audit] = "ac_cv_header_auparse_h=yes,ac_cv_header_auparse_h=no,audit"
67PACKAGECONFIG[ps] = "--with-ps-path=${base_bindir}/ps,,,procps"
68
Andrew Geissler1fe918a2020-05-15 14:16:47 -050069EXTRA_OEMAKE_append_aarch64 = " CPPFLAGS+=-DCONFIG_ARCH_AARCH64=1"
70EXTRA_OEMAKE_append_mips64 = " CPPFLAGS+=-DCONFIG_ARCH_MIPS64=1"
71
Brad Bishop19323692019-04-05 15:28:33 -040072do_unpack_samhain() {
73 cd ${WORKDIR}
74 tar -xzvf samhain-${PV}.tar.gz
75}
76
77python do_unpack_append() {
78 bb.build.exec_func('do_unpack_samhain', d)
79}
80
81do_configure_prepend_arm() {
82 export sh_cv___va_copy=yes
83}
84
85do_configure_prepend_aarch64() {
86 export sh_cv___va_copy=yes
87}
88
89# If we use oe_runconf in do_configure() it will by default
90# use the prefix --oldincludedir=/usr/include which is not
91# recognized by Samhain's configure script and would invariably
92# throw back the error "unrecognized option: --oldincludedir=/usr/include"
93do_configure_prepend () {
94 cat << EOF > ${S}/config-site.${BP}
95ssp_cv_lib=no
96sh_cv_va_copy=yes
97EOF
98 export CONFIG_SITE=${S}/config-site.${BP}
99}
100
101do_configure () {
102 autoconf -f
103 ./configure \
104 --build=${BUILD_SYS} \
105 --host=${HOST_SYS} \
106 --target=${TARGET_SYS} \
107 --prefix=${prefix} \
108 --exec_prefix=${exec_prefix} \
109 --bindir=${bindir} \
110 --sbindir=${sbindir} \
111 --libexecdir=${libexecdir} \
112 --datadir=${datadir} \
113 --sysconfdir=${sysconfdir} \
114 --sharedstatedir=${sharedstatedir} \
115 --localstatedir=${localstatedir} \
116 --libdir=${libdir} \
117 --includedir=${includedir} \
118 --infodir=${infodir} \
119 --mandir=${mandir} \
120 --enable-network=${SAMHAIN_MODE} \
121 --with-pid-file=${localstatedir}/run/samhain.pid \
122 --with-data-file=${localstatedir}/lib/samhain/samhain_file \
Brad Bishop19323692019-04-05 15:28:33 -0400123 ${EXTRA_OECONF}
124}
125
126do_compile_prepend_libc-musl () {
127 sed -i 's/^#define HAVE_MALLOC_H.*//' ${B}/config.h
128}
129
130# Install the init script, it's default file, and the extraneous
131# documentation.
132do_install_append () {
133 oe_runmake install DESTDIR='${D}' INSTALL=install-boot
134
135 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.init \
136 ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
137
138 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.default \
139 ${D}${sysconfdir}/default/${INITSCRIPT_NAME}
140
141 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
142 if [ "${SAMHAIN_MODE}" = "no" ]; then
143 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/samhain.service
144 else
145 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/${BPN}.service
146 fi
147 install -D -m 0755 ${WORKDIR}/${BPN}.init ${D}/${libexecdir}/${BPN}
148 sed -i -e 's,@LIBDIR@,${libexecdir},' \
149 -e 's,@SAMHAIN_HELPER@,${BPN},' \
150 -e 's,@MODE_NAME@,${MODE_NAME},' \
151 ${D}${systemd_system_unitdir}/samhain*.service
152 fi
153
154 install -d ${D}${docdir}/${BPN}
155 cp -r docs/* ${D}${docdir}/${BPN}
156 cp -r scripts ${D}${docdir}/${BPN}
157 install -d -m 755 ${D}${localstatedir}/samhain
158
159 # Prevent QA warnings about installed ${localstatedir}/run
160 if [ -d ${D}${localstatedir}/run ]; then
161 rmdir ${D}${localstatedir}/run
162 fi
Andrew Geissler1fe918a2020-05-15 14:16:47 -0500163
164 rm -rf ${D}${localstatedir}/log
Brad Bishop19323692019-04-05 15:28:33 -0400165}
166
167FILES_${PN} += "${systemd_system_unitdir}"