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