1 #!/bin/bash
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12 # Copyright 2019 Joyent, Inc.
13 #
14
15 #
16 # badseg intentionally core-dumps. It does a setrlimit(), but we need to
17 # prevent global core dumps too: we'll do this by blocking the path for
18 # badseg_exec, but let other processes core dump still just in case.
19 #
20
21 set -e
22 set -x
23
24 old_enabled=$(/usr/bin/svcprop -p config_params/global_enabled coreadm)
25 old_pattern=$(/usr/bin/svcprop -p config_params/global_pattern coreadm)
26 old_log=$(/usr/bin/svcprop -p config_params/global_log_enabled coreadm)
27
28 mkfile 1m /var/cores/badseg_exec
29 coreadm -e global -d log -g /var/cores/%f/%p
30 # let it settle
31 sleep 3
32
33 $(dirname $0)/badseg_exec || true
34
35 coreadm -g "$old_pattern"
36
37 if [[ "$old_enabled" = "true" ]]; then
38 coreadm -e global
39 fi
40
41 if [[ "$old_log" = "true" ]]; then
42 coreadm -e log
43 fi
44
45 rm -f /var/cores/badseg_exec