Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | DESCRIPTION = "Provides file integrity checking and log file monitoring/analysis" |
| 2 | HOMEPAGE = "http://www.la-samhna.de/samhain/" |
| 3 | LICENSE = "GPLv2" |
| 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=8ca43cbc842c2336e835926c2166c28b" |
| 5 | |
Andrew Geissler | f31b8bd | 2020-11-30 19:54:56 -0600 | [diff] [blame] | 6 | PV = "4.4.2" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 7 | |
Andrew Geissler | f31b8bd | 2020-11-30 19:54:56 -0600 | [diff] [blame] | 8 | SRC_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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 12 | 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 Geissler | 1fe918a | 2020-05-15 14:16:47 -0500 | [diff] [blame] | 20 | file://fix-build-with-new-version-attr.patch \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | " |
| 22 | |
Andrew Geissler | f31b8bd | 2020-11-30 19:54:56 -0600 | [diff] [blame] | 23 | SRC_URI[sha256sum] = "2bb2750b32646be32517d0b2259402559c72b96979800f6c33774fcdea327fff" |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | |
| 25 | UPSTREAM_CHECK_URI = "https://www.la-samhna.de/samhain/archive.html" |
| 26 | UPSTREAM_CHECK_REGEX = "samhain_signed-(?P<pver>(\d+(\.\d+)+))\.tar" |
| 27 | |
| 28 | S = "${WORKDIR}/samhain-${PV}" |
| 29 | |
| 30 | inherit autotools-brokensep update-rc.d pkgconfig systemd |
| 31 | |
| 32 | SAMHAIN_PORT ??= "49777" |
| 33 | SAMHAIN_SERVER ??= "NULL" |
| 34 | |
| 35 | INITSCRIPT_NAME = "${BPN}" |
| 36 | INITSCRIPT_PARAMS ?= "defaults" |
| 37 | |
| 38 | SYSTEMD_PACKAGES = "${PN}" |
| 39 | SYSTEMD_SERVICE_${PN} = "${INITSCRIPT_NAME}.service" |
| 40 | SYSTEMD_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 |
| 47 | MODE_NAME = "${@d.getVar('BPN').split('-')[1]}" |
| 48 | SAMHAIN_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 | |
| 52 | PACKAGECONFIG ??= "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 | |
| 58 | PACKAGECONFIG[postgresql] = "--with-database=postgresql --enable-xml-log PGSQL_INC_DIR=${STAGING_INCDIR} PGSQL_LIB_DIR=${STAGING_LIBDIR}, , postgresql" |
| 59 | PACKAGECONFIG[suidcheck] = "--enable-suidcheck, , " |
| 60 | PACKAGECONFIG[logwatch] = "--enable-login-watch, , " |
| 61 | PACKAGECONFIG[mounts] = "--enable-mounts-check, , " |
| 62 | PACKAGECONFIG[userfiles] = "--enable-userfiles, , " |
| 63 | PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6," |
| 64 | PACKAGECONFIG[selinux] = "--enable-selinux, --disable-selinux, libselinux attr" |
| 65 | PACKAGECONFIG[acl] = " --enable-posix-acl , --disable-posix-acl, acl" |
| 66 | PACKAGECONFIG[audit] = "ac_cv_header_auparse_h=yes,ac_cv_header_auparse_h=no,audit" |
| 67 | PACKAGECONFIG[ps] = "--with-ps-path=${base_bindir}/ps,,,procps" |
| 68 | |
Andrew Geissler | 1fe918a | 2020-05-15 14:16:47 -0500 | [diff] [blame] | 69 | EXTRA_OEMAKE_append_aarch64 = " CPPFLAGS+=-DCONFIG_ARCH_AARCH64=1" |
| 70 | EXTRA_OEMAKE_append_mips64 = " CPPFLAGS+=-DCONFIG_ARCH_MIPS64=1" |
| 71 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 72 | do_unpack_samhain() { |
| 73 | cd ${WORKDIR} |
| 74 | tar -xzvf samhain-${PV}.tar.gz |
| 75 | } |
| 76 | |
| 77 | python do_unpack_append() { |
| 78 | bb.build.exec_func('do_unpack_samhain', d) |
| 79 | } |
| 80 | |
| 81 | do_configure_prepend_arm() { |
| 82 | export sh_cv___va_copy=yes |
| 83 | } |
| 84 | |
| 85 | do_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" |
| 93 | do_configure_prepend () { |
| 94 | cat << EOF > ${S}/config-site.${BP} |
| 95 | ssp_cv_lib=no |
| 96 | sh_cv_va_copy=yes |
| 97 | EOF |
| 98 | export CONFIG_SITE=${S}/config-site.${BP} |
| 99 | } |
| 100 | |
| 101 | do_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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 123 | ${EXTRA_OECONF} |
| 124 | } |
| 125 | |
| 126 | do_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. |
| 132 | do_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 Geissler | 1fe918a | 2020-05-15 14:16:47 -0500 | [diff] [blame] | 163 | |
| 164 | rm -rf ${D}${localstatedir}/log |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | FILES_${PN} += "${systemd_system_unitdir}" |