Print this page
11903 secflags_elfdump.sh test needs coreadm setting
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/test/os-tests/tests/secflags/secflags_elfdump.sh
+++ new/usr/src/test/os-tests/tests/secflags/secflags_elfdump.sh
1 1 #! /usr/bin/ksh
2 2 #
3 3 #
4 4 # This file and its contents are supplied under the terms of the
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 6 # You may only use this file in accordance with the terms of version
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 #
15 15 # Copyright 2015, Richard Lowe.
16 16 # Copyright 2019 Joyent, Inc.
17 17 #
18 18
19 19 mkdir /tmp/secflags-test.$$
20 20 cd /tmp/secflags-test.$$
21 21
22 22 /usr/bin/psecflags -s aslr -e sleep 100000 &
23 23 pid=$!
24 -coreadm -p core $pid # We need to be able to reliably find the core
24 +# Make sure we generate a kernel core we can find
25 +coreadm -p core $pid
26 +enabled=$(/usr/bin/svcprop -p config_params/process_enabled coreadm)
27 +coreadm_restore=""
28 +if [[ "$enabled" = "false" ]]; then
29 + coreadm_restore="/usr/bin/coreadm -d process"
30 + coreadm -e process
31 +fi
25 32
26 33 cleanup() {
27 34 kill $pid >/dev/null 2>&1
28 35 cd /
29 36 rm -fr /tmp/secflags-test.$$
37 +
38 + $coreadm_restore
30 39 }
31 40
32 41 trap cleanup EXIT
33 42
34 43 # We need to wait for sleep to get exec()ed
35 44 sleep 1
36 45
37 46 ## gcore-produced core
38 47 gcore $pid >/dev/null
39 48
40 49 cat > gcore-expected.$$ <<EOF
41 50 namesz: 0x5
42 51 descsz: 0x28
43 52 type: [ NT_SECFLAGS ]
44 53 name:
45 54 CORE\0
46 55 desc: (prsecflags_t)
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
47 56 pr_version: 1
48 57 pr_effective: [ ASLR ]
49 58 pr_inherit: [ ASLR ]
50 59 pr_lower: 0
51 60 pr_upper: [ ASLR FORBIDNULLMAP NOEXECSTACK ]
52 61 EOF
53 62
54 63 /usr/bin/elfdump -n core.${pid} | grep -B5 -A5 prsecflags_t > gcore-output.$$
55 64
56 65 if ! diff -u gcore-expected.$$ gcore-output.$$; then
66 + $coreadm_restore
57 67 exit 1;
58 68 fi
59 69
60 70 ## kernel-produced core
61 71 kill -SEGV $pid
62 72 wait $pid >/dev/null 2>&1
73 +$coreadm_restore
63 74
64 75 cat > core-expected.$$ <<EOF
65 76 namesz: 0x5
66 77 descsz: 0x28
67 78 type: [ NT_SECFLAGS ]
68 79 name:
69 80 CORE\0
70 81 desc: (prsecflags_t)
71 82 pr_version: 1
72 83 pr_effective: [ ASLR ]
73 84 pr_inherit: [ ASLR ]
74 85 pr_lower: 0
75 86 pr_upper: [ ASLR FORBIDNULLMAP NOEXECSTACK ]
76 87 EOF
77 88
78 89 /usr/bin/elfdump -n core | grep -B5 -A5 prsecflags_t > core-output.$$
79 90
80 91 if ! diff -u core-expected.$$ core-output.$$; then
81 92 exit 1;
82 93 fi
83 94
84 95 exit 0
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX