Skip to content

Commit

Permalink
Merge pull request #280 from michal42/verify-fs-fixes
Browse files Browse the repository at this point in the history
verify-fs fixes
  • Loading branch information
EldoreiJK committed Jun 29, 2018
2 parents fdf2271 + 08a40ad commit b1222a3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions tools/verify-fs.in
Expand Up @@ -35,30 +35,31 @@ die () {
is_tree_empty () {
local dir excludes
dir=${1}
shift 1

# build chain of -not -path foo -or -not -path bar from args
shift 1
[[ -n ${1} ]] && excludes="-not -path '${1}'"
shift 1
while [[ -n ${1} ]]; do
excludes="${excludes} -or -not -path '${1}'"
excludes=("${excludes[@]}" -path "$dir/$1" -prune -or)
shift 1
done

[[ $(find "${dir}" -xdev -type f ${excludes} | wc -l) == 0 ]]

[[ $(find "${dir}" -xdev "${excludes[@]}" -type f -print | wc -l) == 0 ]]
}

log () {
/usr/bin/logger -i -p security.err -t "verify-fs" "${@}"
if $interactive; then
echo "$@" >&2
else
/usr/bin/logger -i -p security.err -t "verify-fs" "${@}"
fi
}

cat_default () {
if [[ ! -f "${DEFAULT}" ]]; then
cat <<EOF
bin:
sbin:
lib:
lib:modules
lib64:
usr:local
EOF
Expand All @@ -78,15 +79,20 @@ EOF
die "Can't find images ${IMAGES}"

## 1.) Verify the images
pushd "${IMAGES}"
pushd "${IMAGES}" >/dev/null
for ROOTFS in *.squashfs; do

/usr/bin/md5sum -c "${ROOTFS}.md5" 2>/dev/null || \
log "Bad integrity of ${ROOTFS}, checksum is not valid"

done
popd
popd >/dev/null

if tty -s; then
interactive=true
else
interactive=false
fi
## 2.) Verify the overlayfs
cat_default | while read LINE; do
TREE=${LINE%%:*}
Expand Down

0 comments on commit b1222a3

Please sign in to comment.