33 trap cleanup EXIT
34
35 ## Tests of manipulating a running process (ourselves)
36
37 self_set() {
38 echo "Set (self)"
39 /usr/bin/psecflags -s aslr $$
40
41 cat > expected <<EOF
42 I: aslr
43 EOF
44
45 /usr/bin/psecflags $$ | grep I: > output
46 diff -u expected output || exit 1
47 }
48
49 self_add() {
50 echo "Add (self)"
51 /usr/bin/psecflags -s current,noexecstack $$
52 cat > expected <<EOF
53 I: aslr, noexecstack
54 EOF
55
56 /usr/bin/psecflags $$ | grep I: > output
57 diff -u expected output || exit 1
58 }
59
60 self_remove() {
61 echo "Remove (self)"
62 /usr/bin/psecflags -s current,-aslr $$
63 cat > expected <<EOF
64 I: noexecstack
65 EOF
66
67 /usr/bin/psecflags $$ | grep I: > output
68 diff -u expected output || exit 1
69 }
70
71 self_all() {
72 echo "All (self)"
73 /usr/bin/psecflags -s all $$
93 /usr/bin/psecflags -s aslr -e sleep 10000 &
94 pid=$!
95 cat > expected <<EOF
96 E: aslr
97 I: aslr
98 EOF
99 /usr/bin/psecflags $pid | grep '[IE]:' > output
100 kill $pid
101 diff -u expected output || exit 1
102 }
103
104 child_add() {
105 echo "Add (child)"
106
107 typeset pid;
108
109 /usr/bin/psecflags -s aslr $$
110 /usr/bin/psecflags -s current,noexecstack -e sleep 10000 &
111 pid=$!
112 cat > expected <<EOF
113 E: aslr, noexecstack
114 I: aslr, noexecstack
115 EOF
116 /usr/bin/psecflags $pid | grep '[IE]:' > output
117 kill $pid
118 /usr/bin/psecflags -s none $$
119 diff -u expected output || exit 1
120 }
121
122 child_remove() {
123 echo "Remove (child)"
124
125 typeset pid;
126
127 /usr/bin/psecflags -s aslr $$
128 /usr/bin/psecflags -s current,-aslr -e sleep 10000 &
129 pid=$!
130 cat > expected <<EOF
131 E: none
132 I: none
133 EOF
134 /usr/bin/psecflags $pid | grep '[IE]:' > output
|
33 trap cleanup EXIT
34
35 ## Tests of manipulating a running process (ourselves)
36
37 self_set() {
38 echo "Set (self)"
39 /usr/bin/psecflags -s aslr $$
40
41 cat > expected <<EOF
42 I: aslr
43 EOF
44
45 /usr/bin/psecflags $$ | grep I: > output
46 diff -u expected output || exit 1
47 }
48
49 self_add() {
50 echo "Add (self)"
51 /usr/bin/psecflags -s current,noexecstack $$
52 cat > expected <<EOF
53 I: aslr,noexecstack
54 EOF
55
56 /usr/bin/psecflags $$ | grep I: > output
57 diff -u expected output || exit 1
58 }
59
60 self_remove() {
61 echo "Remove (self)"
62 /usr/bin/psecflags -s current,-aslr $$
63 cat > expected <<EOF
64 I: noexecstack
65 EOF
66
67 /usr/bin/psecflags $$ | grep I: > output
68 diff -u expected output || exit 1
69 }
70
71 self_all() {
72 echo "All (self)"
73 /usr/bin/psecflags -s all $$
93 /usr/bin/psecflags -s aslr -e sleep 10000 &
94 pid=$!
95 cat > expected <<EOF
96 E: aslr
97 I: aslr
98 EOF
99 /usr/bin/psecflags $pid | grep '[IE]:' > output
100 kill $pid
101 diff -u expected output || exit 1
102 }
103
104 child_add() {
105 echo "Add (child)"
106
107 typeset pid;
108
109 /usr/bin/psecflags -s aslr $$
110 /usr/bin/psecflags -s current,noexecstack -e sleep 10000 &
111 pid=$!
112 cat > expected <<EOF
113 E: aslr,noexecstack
114 I: aslr,noexecstack
115 EOF
116 /usr/bin/psecflags $pid | grep '[IE]:' > output
117 kill $pid
118 /usr/bin/psecflags -s none $$
119 diff -u expected output || exit 1
120 }
121
122 child_remove() {
123 echo "Remove (child)"
124
125 typeset pid;
126
127 /usr/bin/psecflags -s aslr $$
128 /usr/bin/psecflags -s current,-aslr -e sleep 10000 &
129 pid=$!
130 cat > expected <<EOF
131 E: none
132 I: none
133 EOF
134 /usr/bin/psecflags $pid | grep '[IE]:' > output
|