diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2011-11-15 13:43:32 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2011-11-15 14:41:52 -0500 |
commit | 3942fe38eb32df53e481c95b37ad9d127535ab96 (patch) | |
tree | 23438578d6b28087f77c259026cee24493fd446d | |
parent | src/{fix-gnustack.c,paxctl-ng.c}: fix exit code (diff) | |
download | elfix-3942fe38eb32df53e481c95b37ad9d127535ab96.tar.gz elfix-3942fe38eb32df53e481c95b37ad9d127535ab96.tar.bz2 elfix-3942fe38eb32df53e481c95b37ad9d127535ab96.zip |
tests/pxtpax: compare file's and process's pax flags
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | tests/Makefile.am | 29 | ||||
-rw-r--r-- | tests/gnustack/Makefile.am | 28 | ||||
-rw-r--r-- | tests/gnustack/bad-gnustack.c (renamed from tests/bad-gnustack.c) | 0 | ||||
-rw-r--r-- | tests/gnustack/bad32.asm (renamed from tests/bad32.asm) | 0 | ||||
-rw-r--r-- | tests/gnustack/bad64.asm (renamed from tests/bad64.asm) | 0 | ||||
-rw-r--r-- | tests/pxtpax/Makefile | 15 | ||||
-rw-r--r-- | tests/pxtpax/Makefile.am | 7 | ||||
-rw-r--r-- | tests/pxtpax/daemon.c | 20 | ||||
-rwxr-xr-x | tests/pxtpax/init.sh | 40 | ||||
-rwxr-xr-x | tests/pxtpax/test.sh | 30 |
11 files changed, 151 insertions, 33 deletions
diff --git a/configure.ac b/configure.ac index 044a1da..42c86b6 100644 --- a/configure.ac +++ b/configure.ac @@ -49,10 +49,15 @@ AC_TYPE_UINT16_T # Checks for library functions. AC_FUNC_ERROR_AT_LINE -AC_CONFIG_FILES([Makefile - src/Makefile - scripts/Makefile - doc/Makefile - tests/Makefile]) +AC_CONFIG_FILES([ + Makefile + src/Makefile + scripts/Makefile + doc/Makefile + tests/Makefile + tests/gnustack/Makefile + tests/gnustack/Makefile + tests/pxtpax/Makefile +]) AC_OUTPUT diff --git a/tests/Makefile.am b/tests/Makefile.am index b0b054f..9744798 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,28 +1 @@ -noinst_PROGRAMS = bad-gnustack -bad_gnustack_SOURCES = bad-gnustack.c -bad_gnustack_DEPENDENCIES = bad-asm.o -bad_gnustack_LDADD = bad-asm.o - -EXTRA_DIST = bad64.asm bad32.asm - -ARCH = $(shell uname -m | sed -e 's/i./x/') - -bad-asm.o: bad64.asm bad32.asm - [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 bad32.asm && mv bad32.o bad-asm.o || true - [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 bad64.asm && mv bad64.o bad-asm.o || true - -check_SCRIPTS = test.sh -TEST = $(check_SCRIPTS) - -test.sh: - @echo "================================================================================" - @echo - @echo "Fixing Bad GNU_STACK Elf" - @../src/fix-gnustack -f bad-gnustack - @echo - @echo "Fixed Bad GNU_STACK Elf" - @../src/fix-gnustack bad-gnustack - @echo - @echo "================================================================================" - -CLEANFILES = bad-asm.o test.sh +SUBDIRS = gnustack xtpax diff --git a/tests/gnustack/Makefile.am b/tests/gnustack/Makefile.am new file mode 100644 index 0000000..b0b054f --- /dev/null +++ b/tests/gnustack/Makefile.am @@ -0,0 +1,28 @@ +noinst_PROGRAMS = bad-gnustack +bad_gnustack_SOURCES = bad-gnustack.c +bad_gnustack_DEPENDENCIES = bad-asm.o +bad_gnustack_LDADD = bad-asm.o + +EXTRA_DIST = bad64.asm bad32.asm + +ARCH = $(shell uname -m | sed -e 's/i./x/') + +bad-asm.o: bad64.asm bad32.asm + [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 bad32.asm && mv bad32.o bad-asm.o || true + [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 bad64.asm && mv bad64.o bad-asm.o || true + +check_SCRIPTS = test.sh +TEST = $(check_SCRIPTS) + +test.sh: + @echo "================================================================================" + @echo + @echo "Fixing Bad GNU_STACK Elf" + @../src/fix-gnustack -f bad-gnustack + @echo + @echo "Fixed Bad GNU_STACK Elf" + @../src/fix-gnustack bad-gnustack + @echo + @echo "================================================================================" + +CLEANFILES = bad-asm.o test.sh diff --git a/tests/bad-gnustack.c b/tests/gnustack/bad-gnustack.c index fa7bcf5..fa7bcf5 100644 --- a/tests/bad-gnustack.c +++ b/tests/gnustack/bad-gnustack.c diff --git a/tests/bad32.asm b/tests/gnustack/bad32.asm index 8020ac7..8020ac7 100644 --- a/tests/bad32.asm +++ b/tests/gnustack/bad32.asm diff --git a/tests/bad64.asm b/tests/gnustack/bad64.asm index 1164095..1164095 100644 --- a/tests/bad64.asm +++ b/tests/gnustack/bad64.asm diff --git a/tests/pxtpax/Makefile b/tests/pxtpax/Makefile new file mode 100644 index 0000000..bc2845b --- /dev/null +++ b/tests/pxtpax/Makefile @@ -0,0 +1,15 @@ + +.PHONY: all +all: test + +.PHONY: test +test: daemon init.sh test.sh + @echo "xattr process" + @$(PWD)/test.sh + +daemon: daemon.c + gcc -o $@ $^ + paxctl-ng -cv $@ + +clean: + rm -f daemon daemon.pid diff --git a/tests/pxtpax/Makefile.am b/tests/pxtpax/Makefile.am new file mode 100644 index 0000000..4770a08 --- /dev/null +++ b/tests/pxtpax/Makefile.am @@ -0,0 +1,7 @@ +noinst_PROGRAMS = daemon +daemon_SOURCES = daemon.c + +EXTRA_DIST = init.sh test.sh + +check_SCRIPTS = test.sh +TEST = $(check_SCRIPTS) diff --git a/tests/pxtpax/daemon.c b/tests/pxtpax/daemon.c new file mode 100644 index 0000000..3459db9 --- /dev/null +++ b/tests/pxtpax/daemon.c @@ -0,0 +1,20 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int main() +{ + pid_t p = fork(); + + if(p) + printf("%d\n", p); + else + { + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + for(;;) sleep(1); + } + + exit(0) ; +} diff --git a/tests/pxtpax/init.sh b/tests/pxtpax/init.sh new file mode 100755 index 0000000..4013b29 --- /dev/null +++ b/tests/pxtpax/init.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +PATH=/sbin:/bin + +PWD=$(pwd) +DAEMON="${PWD}"/daemon +PIDFILE="${PWD}"/daemon.pid + +start() +{ + rm -f ${PIDFILE} + if [ -e ${DAEMON} ] + then + PID=$(${DAEMON}) + if [ "x${PID}" != "x" ] + then + echo $PID >> ${PIDFILE} + fi + else + echo "No daemon" + fi +} + +stop() +{ + kill $(cat ${PIDFILE}) + rm -f ${PIDFILE} +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + *) + echo "Usage: $0 start | stop" + ;; +esac diff --git a/tests/pxtpax/test.sh b/tests/pxtpax/test.sh new file mode 100755 index 0000000..6db0e4d --- /dev/null +++ b/tests/pxtpax/test.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +PWD=$(pwd) +INITSH="${PWD}"/init.sh +DAEMON="${PWD}"/daemon +PIDFILE="${PWD}"/daemon.pid + +paxctl-ng -cv ${DAEMON} + +for pf in "p" "P"; do + for ef in "e" "E"; do + for mf in "m" "M"; do + for rf in "r" "R"; do + for sf in "s" "S"; do + flags="${pf}${ef}${mf}${rf}${sf}" + echo -n ${flags} " " + paxctl-ng -"${flags}" ${DAEMON} 2>&1 1>/dev/null + ${INITSH} start + if [ -f "${PIDFILE}" ] + then + rflags=$(cat /proc/$(cat ${PIDFILE})/status | grep ^PaX | awk '{ print $2 }') + echo -n ${rflags} + ${INITSH} stop + fi + echo + done + done + done + done +done |