1 |
commit: 3942fe38eb32df53e481c95b37ad9d127535ab96 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Nov 15 18:43:32 2011 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Nov 15 19:41:52 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=3942fe38 |
7 |
|
8 |
tests/pxtpax: compare file's and process's pax flags |
9 |
|
10 |
--- |
11 |
configure.ac | 15 ++++++++---- |
12 |
tests/Makefile.am | 29 +------------------------ |
13 |
tests/{ => gnustack}/Makefile.am | 0 |
14 |
tests/{ => gnustack}/bad-gnustack.c | 0 |
15 |
tests/{ => gnustack}/bad32.asm | 0 |
16 |
tests/{ => gnustack}/bad64.asm | 0 |
17 |
tests/pxtpax/Makefile | 15 +++++++++++++ |
18 |
tests/pxtpax/Makefile.am | 7 ++++++ |
19 |
tests/pxtpax/daemon.c | 20 +++++++++++++++++ |
20 |
tests/pxtpax/init.sh | 40 +++++++++++++++++++++++++++++++++++ |
21 |
tests/pxtpax/test.sh | 30 ++++++++++++++++++++++++++ |
22 |
11 files changed, 123 insertions(+), 33 deletions(-) |
23 |
|
24 |
diff --git a/configure.ac b/configure.ac |
25 |
index 044a1da..42c86b6 100644 |
26 |
--- a/configure.ac |
27 |
+++ b/configure.ac |
28 |
@@ -49,10 +49,15 @@ AC_TYPE_UINT16_T |
29 |
# Checks for library functions. |
30 |
AC_FUNC_ERROR_AT_LINE |
31 |
|
32 |
-AC_CONFIG_FILES([Makefile |
33 |
- src/Makefile |
34 |
- scripts/Makefile |
35 |
- doc/Makefile |
36 |
- tests/Makefile]) |
37 |
+AC_CONFIG_FILES([ |
38 |
+ Makefile |
39 |
+ src/Makefile |
40 |
+ scripts/Makefile |
41 |
+ doc/Makefile |
42 |
+ tests/Makefile |
43 |
+ tests/gnustack/Makefile |
44 |
+ tests/gnustack/Makefile |
45 |
+ tests/pxtpax/Makefile |
46 |
+]) |
47 |
|
48 |
AC_OUTPUT |
49 |
|
50 |
diff --git a/tests/Makefile.am b/tests/Makefile.am |
51 |
index b0b054f..9744798 100644 |
52 |
--- a/tests/Makefile.am |
53 |
+++ b/tests/Makefile.am |
54 |
@@ -1,28 +1 @@ |
55 |
-noinst_PROGRAMS = bad-gnustack |
56 |
-bad_gnustack_SOURCES = bad-gnustack.c |
57 |
-bad_gnustack_DEPENDENCIES = bad-asm.o |
58 |
-bad_gnustack_LDADD = bad-asm.o |
59 |
- |
60 |
-EXTRA_DIST = bad64.asm bad32.asm |
61 |
- |
62 |
-ARCH = $(shell uname -m | sed -e 's/i./x/') |
63 |
- |
64 |
-bad-asm.o: bad64.asm bad32.asm |
65 |
- [[ "$(ARCH)" == "x86" ]] && yasm -f elf -m x86 bad32.asm && mv bad32.o bad-asm.o || true |
66 |
- [[ "$(ARCH)" == "x86_64" ]] && yasm -f elf -m amd64 bad64.asm && mv bad64.o bad-asm.o || true |
67 |
- |
68 |
-check_SCRIPTS = test.sh |
69 |
-TEST = $(check_SCRIPTS) |
70 |
- |
71 |
-test.sh: |
72 |
- @echo "================================================================================" |
73 |
- @echo |
74 |
- @echo "Fixing Bad GNU_STACK Elf" |
75 |
- @../src/fix-gnustack -f bad-gnustack |
76 |
- @echo |
77 |
- @echo "Fixed Bad GNU_STACK Elf" |
78 |
- @../src/fix-gnustack bad-gnustack |
79 |
- @echo |
80 |
- @echo "================================================================================" |
81 |
- |
82 |
-CLEANFILES = bad-asm.o test.sh |
83 |
+SUBDIRS = gnustack xtpax |
84 |
|
85 |
diff --git a/tests/Makefile.am b/tests/gnustack/Makefile.am |
86 |
similarity index 100% |
87 |
copy from tests/Makefile.am |
88 |
copy to tests/gnustack/Makefile.am |
89 |
|
90 |
diff --git a/tests/bad-gnustack.c b/tests/gnustack/bad-gnustack.c |
91 |
similarity index 100% |
92 |
rename from tests/bad-gnustack.c |
93 |
rename to tests/gnustack/bad-gnustack.c |
94 |
|
95 |
diff --git a/tests/bad32.asm b/tests/gnustack/bad32.asm |
96 |
similarity index 100% |
97 |
rename from tests/bad32.asm |
98 |
rename to tests/gnustack/bad32.asm |
99 |
|
100 |
diff --git a/tests/bad64.asm b/tests/gnustack/bad64.asm |
101 |
similarity index 100% |
102 |
rename from tests/bad64.asm |
103 |
rename to tests/gnustack/bad64.asm |
104 |
|
105 |
diff --git a/tests/pxtpax/Makefile b/tests/pxtpax/Makefile |
106 |
new file mode 100644 |
107 |
index 0000000..bc2845b |
108 |
--- /dev/null |
109 |
+++ b/tests/pxtpax/Makefile |
110 |
@@ -0,0 +1,15 @@ |
111 |
+ |
112 |
+.PHONY: all |
113 |
+all: test |
114 |
+ |
115 |
+.PHONY: test |
116 |
+test: daemon init.sh test.sh |
117 |
+ @echo "xattr process" |
118 |
+ @$(PWD)/test.sh |
119 |
+ |
120 |
+daemon: daemon.c |
121 |
+ gcc -o $@ $^ |
122 |
+ paxctl-ng -cv $@ |
123 |
+ |
124 |
+clean: |
125 |
+ rm -f daemon daemon.pid |
126 |
|
127 |
diff --git a/tests/pxtpax/Makefile.am b/tests/pxtpax/Makefile.am |
128 |
new file mode 100644 |
129 |
index 0000000..4770a08 |
130 |
--- /dev/null |
131 |
+++ b/tests/pxtpax/Makefile.am |
132 |
@@ -0,0 +1,7 @@ |
133 |
+noinst_PROGRAMS = daemon |
134 |
+daemon_SOURCES = daemon.c |
135 |
+ |
136 |
+EXTRA_DIST = init.sh test.sh |
137 |
+ |
138 |
+check_SCRIPTS = test.sh |
139 |
+TEST = $(check_SCRIPTS) |
140 |
|
141 |
diff --git a/tests/pxtpax/daemon.c b/tests/pxtpax/daemon.c |
142 |
new file mode 100644 |
143 |
index 0000000..3459db9 |
144 |
--- /dev/null |
145 |
+++ b/tests/pxtpax/daemon.c |
146 |
@@ -0,0 +1,20 @@ |
147 |
+#include <stdio.h> |
148 |
+#include <stdlib.h> |
149 |
+#include <unistd.h> |
150 |
+ |
151 |
+int main() |
152 |
+{ |
153 |
+ pid_t p = fork(); |
154 |
+ |
155 |
+ if(p) |
156 |
+ printf("%d\n", p); |
157 |
+ else |
158 |
+ { |
159 |
+ close(STDIN_FILENO); |
160 |
+ close(STDOUT_FILENO); |
161 |
+ close(STDERR_FILENO); |
162 |
+ for(;;) sleep(1); |
163 |
+ } |
164 |
+ |
165 |
+ exit(0) ; |
166 |
+} |
167 |
|
168 |
diff --git a/tests/pxtpax/init.sh b/tests/pxtpax/init.sh |
169 |
new file mode 100755 |
170 |
index 0000000..4013b29 |
171 |
--- /dev/null |
172 |
+++ b/tests/pxtpax/init.sh |
173 |
@@ -0,0 +1,40 @@ |
174 |
+#!/bin/bash |
175 |
+ |
176 |
+PATH=/sbin:/bin |
177 |
+ |
178 |
+PWD=$(pwd) |
179 |
+DAEMON="${PWD}"/daemon |
180 |
+PIDFILE="${PWD}"/daemon.pid |
181 |
+ |
182 |
+start() |
183 |
+{ |
184 |
+ rm -f ${PIDFILE} |
185 |
+ if [ -e ${DAEMON} ] |
186 |
+ then |
187 |
+ PID=$(${DAEMON}) |
188 |
+ if [ "x${PID}" != "x" ] |
189 |
+ then |
190 |
+ echo $PID >> ${PIDFILE} |
191 |
+ fi |
192 |
+ else |
193 |
+ echo "No daemon" |
194 |
+ fi |
195 |
+} |
196 |
+ |
197 |
+stop() |
198 |
+{ |
199 |
+ kill $(cat ${PIDFILE}) |
200 |
+ rm -f ${PIDFILE} |
201 |
+} |
202 |
+ |
203 |
+case "$1" in |
204 |
+ start) |
205 |
+ start |
206 |
+ ;; |
207 |
+ stop) |
208 |
+ stop |
209 |
+ ;; |
210 |
+ *) |
211 |
+ echo "Usage: $0 start | stop" |
212 |
+ ;; |
213 |
+esac |
214 |
|
215 |
diff --git a/tests/pxtpax/test.sh b/tests/pxtpax/test.sh |
216 |
new file mode 100755 |
217 |
index 0000000..6db0e4d |
218 |
--- /dev/null |
219 |
+++ b/tests/pxtpax/test.sh |
220 |
@@ -0,0 +1,30 @@ |
221 |
+#!/bin/bash |
222 |
+ |
223 |
+PWD=$(pwd) |
224 |
+INITSH="${PWD}"/init.sh |
225 |
+DAEMON="${PWD}"/daemon |
226 |
+PIDFILE="${PWD}"/daemon.pid |
227 |
+ |
228 |
+paxctl-ng -cv ${DAEMON} |
229 |
+ |
230 |
+for pf in "p" "P"; do |
231 |
+ for ef in "e" "E"; do |
232 |
+ for mf in "m" "M"; do |
233 |
+ for rf in "r" "R"; do |
234 |
+ for sf in "s" "S"; do |
235 |
+ flags="${pf}${ef}${mf}${rf}${sf}" |
236 |
+ echo -n ${flags} " " |
237 |
+ paxctl-ng -"${flags}" ${DAEMON} 2>&1 1>/dev/null |
238 |
+ ${INITSH} start |
239 |
+ if [ -f "${PIDFILE}" ] |
240 |
+ then |
241 |
+ rflags=$(cat /proc/$(cat ${PIDFILE})/status | grep ^PaX | awk '{ print $2 }') |
242 |
+ echo -n ${rflags} |
243 |
+ ${INITSH} stop |
244 |
+ fi |
245 |
+ echo |
246 |
+ done |
247 |
+ done |
248 |
+ done |
249 |
+ done |
250 |
+done |