Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame^] | 1 | # |
| 2 | # Copyright 2022 Armin Kuster <akuster808@gmail.com> |
| 3 | # |
| 4 | # This class creates the initial aide database durning |
| 5 | # the build cycle allowing for that set being skipped during boot |
| 6 | # It has an additional benefit of having not being tamper with |
| 7 | # after build. |
| 8 | # |
| 9 | # To have the aide db created during build |
| 10 | # 1. Extend local.conf: |
| 11 | # INHERIT += "adie-init-db" |
| 12 | # |
| 13 | # These are the defaults as defined in aide-base.bbclass |
| 14 | # They can be overriden in your local.conf or other distro include |
| 15 | # |
| 16 | # To define where the share directory should be. |
| 17 | # STAGING_AIDE_DIR = "${TMPDIR}/work-shared/${MACHINE}/aida" |
| 18 | # |
| 19 | # To define which directories should be inclued in a scan |
| 20 | # AIDE_INCLUDE_DIRS ?= "/lib" |
| 21 | # |
| 22 | # To exclude directories and files from being scanned |
| 23 | # AIDE_SKIP_DIRS ?= "/lib/modules/.\*" |
| 24 | # |
| 25 | # To controll if a db init should happen at postint |
| 26 | # AIDE_SCAN_POSTINIT ?= "0" |
| 27 | # |
| 28 | # To cotroll if a db recan should be run at postinit |
| 29 | # AIDE_RESCAN_POSTINIT ?= "0" |
| 30 | |
| 31 | inherit aide-base |
| 32 | |
| 33 | aide_init_db() { |
| 34 | for dir in ${AIDE_INCLUDE_DIRS}; do |
| 35 | echo "${IMAGE_ROOTFS}${dir} NORMAL" >> ${STAGING_AIDE_DIR}/aide.conf |
| 36 | done |
| 37 | for dir in ${AIDE_SKIP_DIRS}; do |
| 38 | echo "!${IMAGE_ROOTFS}${dir}" >> ${STAGING_AIDE_DIR}/aide.conf |
| 39 | done |
| 40 | |
| 41 | |
| 42 | ${STAGING_AIDE_DIR}/bin/aide -c ${STAGING_AIDE_DIR}/aide.conf --init |
| 43 | gunzip ${STAGING_AIDE_DIR}/lib/aide.db.gz |
| 44 | # strip out native path |
| 45 | sed -i -e 's:${IMAGE_ROOTFS}::' ${STAGING_AIDE_DIR}/lib/aide.db |
| 46 | gzip -9 ${STAGING_AIDE_DIR}/lib/aide.db |
| 47 | cp -f ${STAGING_AIDE_DIR}/lib/aide.db.gz ${IMAGE_ROOTFS}${libdir}/aide |
| 48 | } |
| 49 | |
| 50 | EXTRA_IMAGEDEPENDS:append = " aide-native" |
| 51 | |
| 52 | ROOTFS_POSTPROCESS_COMMAND:append = " aide_init_db;" |