1dbdc225aSJohn Levon#!/bin/bash 2dbdc225aSJohn Levon# 3dbdc225aSJohn Levon# This file and its contents are supplied under the terms of the 4dbdc225aSJohn Levon# Common Development and Distribution License ("CDDL"), version 1.0. 5dbdc225aSJohn Levon# You may only use this file in accordance with the terms of version 6dbdc225aSJohn Levon# 1.0 of the CDDL. 7dbdc225aSJohn Levon# 8dbdc225aSJohn Levon# A full copy of the text of the CDDL should have accompanied this 9dbdc225aSJohn Levon# source. A copy of the CDDL is also available via the Internet at 10dbdc225aSJohn Levon# http://www.illumos.org/license/CDDL. 11dbdc225aSJohn Levon# 12dbdc225aSJohn Levon# Copyright 2019 Joyent, Inc. 13*e43afc96SRobert Mustacchi# Copyright 2021 Oxide Computer Company 14dbdc225aSJohn Levon# 15dbdc225aSJohn Levon 16dbdc225aSJohn Levon# 17dbdc225aSJohn Levon# badseg intentionally core-dumps. It does a setrlimit(), but we need to 18dbdc225aSJohn Levon# prevent global core dumps too: we'll do this by blocking the path for 19dbdc225aSJohn Levon# badseg_exec, but let other processes core dump still just in case. 20dbdc225aSJohn Levon# 21dbdc225aSJohn Levon 22dbdc225aSJohn Levonset -e 23dbdc225aSJohn Levonset -x 24dbdc225aSJohn Levon 25dbdc225aSJohn Levonold_enabled=$(/usr/bin/svcprop -p config_params/global_enabled coreadm) 26dbdc225aSJohn Levonold_pattern=$(/usr/bin/svcprop -p config_params/global_pattern coreadm) 27dbdc225aSJohn Levonold_log=$(/usr/bin/svcprop -p config_params/global_log_enabled coreadm) 28dbdc225aSJohn Levon 29dbdc225aSJohn Levonmkfile 1m /var/cores/badseg_exec 30dbdc225aSJohn Levoncoreadm -e global -d log -g /var/cores/%f/%p 31dbdc225aSJohn Levon# let it settle 32dbdc225aSJohn Levonsleep 3 33dbdc225aSJohn Levon 34dbdc225aSJohn Levon$(dirname $0)/badseg_exec || true 35dbdc225aSJohn Levon 36*e43afc96SRobert Mustacchi# 37*e43afc96SRobert Mustacchi# If this property is set to the empty string (e.g. unset, but the property is 38*e43afc96SRobert Mustacchi# present), svcprop will return that as "". If we don't special case this, we 39*e43afc96SRobert Mustacchi# will then pass that literal string back to coreadm as an actual path, which is 40*e43afc96SRobert Mustacchi# invalid. 41*e43afc96SRobert Mustacchi# 42*e43afc96SRobert Mustacchiif [[ "$old_pattern" == '""' ]]; then 43*e43afc96SRobert Mustacchi coreadm -g '' 44*e43afc96SRobert Mustacchielse 45*e43afc96SRobert Mustacchi coreadm -g "$old_pattern" 46*e43afc96SRobert Mustacchifi 47dbdc225aSJohn Levon 48*e43afc96SRobert Mustacchiif [[ "$old_enabled" == "true" ]]; then 49dbdc225aSJohn Levon coreadm -e global 50dbdc225aSJohn Levonfi 51dbdc225aSJohn Levon 52*e43afc96SRobert Mustacchiif [[ "$old_log" == "true" ]]; then 53dbdc225aSJohn Levon coreadm -e log 54dbdc225aSJohn Levonfi 55dbdc225aSJohn Levon 56dbdc225aSJohn Levonrm -f /var/cores/badseg_exec 57