blob: 944bf0d0b755d0993f160221b6ec25a13d6107ec [file] [log] [blame]
Richard Marian Thomaiyar14fddef2018-07-13 23:55:56 +05301DESCRIPTION = "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
6
7SRC_URI = "http://la-samhna.de/archive/samhain_signed-${PV}.tar.gz \
8 file://samhain-cross-compile.patch \
9 file://samhain-mips64-aarch64-dnmalloc-hash-fix.patch \
10 file://samhain-samhainrc.patch \
11 file://samhain-samhainrc-fix-files-dirs-path.patch \
12 file://samhain-pid-path.patch \
13 file://samhain-sha256-big-endian.patch \
14 file://samhain-configure-add-option-for-ps.patch \
15 file://samhain-avoid-searching-host-for-postgresql.patch \
16 file://samhain-add-LDFLAGS-variable-for-samhain_setpwd.patch \
17 file://${INITSCRIPT_NAME}.init \
18 file://${INITSCRIPT_NAME}.default \
19 file://samhain.service \
20 "
21
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022SRC_URI[md5sum] = "a00e99375675fc6e50cca3e208f5207e"
23SRC_URI[sha256sum] = "8551dc3b0851889a2b979097e9c02309b40d48b4659f02efe7fe525ce8361a0d"
24
25UPSTREAM_CHECK_URI = "https://www.la-samhna.de/samhain/archive.html"
26UPSTREAM_CHECK_REGEX = "samhain_signed-(?P<pver>(\d+(\.\d+)+))\.tar"
Richard Marian Thomaiyar14fddef2018-07-13 23:55:56 +053027
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
69do_unpack_samhain() {
70 cd ${WORKDIR}
71 tar -xzvf samhain-${PV}.tar.gz
72}
73
74python do_unpack_append() {
75 bb.build.exec_func('do_unpack_samhain', d)
76}
77
78do_configure_prepend_arm() {
79 export sh_cv___va_copy=yes
80}
81
82do_configure_prepend_aarch64() {
83 export sh_cv___va_copy=yes
84}
85
86# If we use oe_runconf in do_configure() it will by default
87# use the prefix --oldincludedir=/usr/include which is not
88# recognized by Samhain's configure script and would invariably
89# throw back the error "unrecognized option: --oldincludedir=/usr/include"
90do_configure_prepend () {
91 cat << EOF > ${S}/config-site.${BP}
92ssp_cv_lib=no
93sh_cv_va_copy=yes
94EOF
95 export CONFIG_SITE=${S}/config-site.${BP}
96}
97
98do_configure () {
99 autoconf -f
100 ./configure \
101 --build=${BUILD_SYS} \
102 --host=${HOST_SYS} \
103 --target=${TARGET_SYS} \
104 --prefix=${prefix} \
105 --exec_prefix=${exec_prefix} \
106 --bindir=${bindir} \
107 --sbindir=${sbindir} \
108 --libexecdir=${libexecdir} \
109 --datadir=${datadir} \
110 --sysconfdir=${sysconfdir} \
111 --sharedstatedir=${sharedstatedir} \
112 --localstatedir=${localstatedir} \
113 --libdir=${libdir} \
114 --includedir=${includedir} \
115 --infodir=${infodir} \
116 --mandir=${mandir} \
117 --enable-network=${SAMHAIN_MODE} \
118 --with-pid-file=${localstatedir}/run/samhain.pid \
119 --with-data-file=${localstatedir}/lib/samhain/samhain_file \
120 ${EXTRA_OECONF}
121}
122
123do_compile_prepend_libc-musl () {
124 sed -i 's/^#define HAVE_MALLOC_H.*//' ${B}/config.h
125}
126
127# Install the init script, it's default file, and the extraneous
128# documentation.
129do_install_append () {
130 oe_runmake install DESTDIR='${D}' INSTALL=install-boot
131
132 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.init \
133 ${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
134
135 install -D -m 755 ${WORKDIR}/${INITSCRIPT_NAME}.default \
136 ${D}${sysconfdir}/default/${INITSCRIPT_NAME}
137
138 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
139 if [ "${SAMHAIN_MODE}" = "no" ]; then
140 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/samhain.service
141 else
142 install -D -m 0644 ${WORKDIR}/samhain.service ${D}/${systemd_system_unitdir}/${BPN}.service
143 fi
144 install -D -m 0755 ${WORKDIR}/${BPN}.init ${D}/${libexecdir}/${BPN}
145 sed -i -e 's,@LIBDIR@,${libexecdir},' \
146 -e 's,@SAMHAIN_HELPER@,${BPN},' \
147 -e 's,@MODE_NAME@,${MODE_NAME},' \
148 ${D}${systemd_system_unitdir}/samhain*.service
149 fi
150
151 install -d ${D}${docdir}/${BPN}
152 cp -r docs/* ${D}${docdir}/${BPN}
153 cp -r scripts ${D}${docdir}/${BPN}
154 install -d -m 755 ${D}${localstatedir}/samhain
155
156 # Prevent QA warnings about installed ${localstatedir}/run
157 if [ -d ${D}${localstatedir}/run ]; then
158 rmdir ${D}${localstatedir}/run
159 fi
160}
161
162FILES_${PN} += "${systemd_system_unitdir}"