Files
mirror_zfs/scripts/paxcheck.sh
T

44 lines
1.2 KiB
Bash
Raw Normal View History

2016-10-29 07:10:00 +08:00
#!/bin/sh
2021-05-22 01:45:40 +02:00
if ! command -v scanelf > /dev/null; then
2016-10-29 07:10:00 +08:00
echo "scanelf (from pax-utils) is required for these checks." >&2
exit 3
fi
RET=0
# check for exec stacks
2017-03-09 10:20:15 -08:00
OUT=$(scanelf -qyRAF '%e %p' "$1")
2016-10-29 07:10:00 +08:00
if [ "${OUT}" != "" ]; then
2016-10-29 07:10:00 +08:00
RET=2
echo "The following files contain writable and executable sections"
echo " Files with such sections will not work properly (or at all!) on some"
echo " architectures/operating systems."
echo " For more information, see:"
echo " https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart"
echo
echo "${OUT}"
echo
fi
# check for TEXTRELS
2017-03-09 10:20:15 -08:00
OUT=$(scanelf -qyRAF '%T %p' "$1")
2016-10-29 07:10:00 +08:00
if [ "${OUT}" != "" ]; then
2016-10-29 07:10:00 +08:00
RET=2
echo "The following files contain runtime text relocations"
echo " Text relocations force the dynamic linker to perform extra"
echo " work at startup, waste system resources, and may pose a security"
echo " risk. On some architectures, the code may not even function"
echo " properly, if at all."
echo " For more information, see:"
echo " https://wiki.gentoo.org/wiki/Hardened/HOWTO_locate_and_fix_textrels"
echo
echo "${OUT}"
echo
fi
exit "$RET"