1266986Smarkj# 2266986Smarkj# CDDL HEADER START 3266986Smarkj# 4266986Smarkj# The contents of this file are subject to the terms of the 5266986Smarkj# Common Development and Distribution License (the "License"). 6266986Smarkj# You may not use this file except in compliance with the License. 7266986Smarkj# 8266986Smarkj# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9266986Smarkj# or http://www.opensolaris.org/os/licensing. 10266986Smarkj# See the License for the specific language governing permissions 11266986Smarkj# and limitations under the License. 12266986Smarkj# 13266986Smarkj# When distributing Covered Code, include this CDDL HEADER in each 14266986Smarkj# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15266986Smarkj# If applicable, add the following below this CDDL HEADER, with the 16266986Smarkj# fields enclosed by brackets "[]" replaced with your own identifying 17266986Smarkj# information: Portions Copyright [yyyy] [name of copyright owner] 18266986Smarkj# 19266986Smarkj# CDDL HEADER END 20266986Smarkj# 21266986Smarkj 22266986Smarkj# 23266986Smarkj# Copyright (c) 2012, Joyent, Inc. All rights reserved. 24266986Smarkj# 25266986Smarkj 26266986Smarkj# 27266986Smarkj# First, make sure that we can successfully enable the io provider 28266986Smarkj# 29266986Smarkjif ! dtrace -P io -n BEGIN'{exit(0)}' > /dev/null 2>&1 ; then 30266986Smarkj echo failed to enable io provider with full privs 31266986Smarkj exit 1 32266986Smarkjfi 33266986Smarkj 34266986Smarkjppriv -s A=basic,dtrace_proc,dtrace_user $$ 35266986Smarkj 36266986Smarkj# 37266986Smarkj# Now make sure that we cannot enable the io provider with reduced privs 38266986Smarkj# 39266986Smarkjif ! dtrace -x errtags -P io -n BEGIN'{exit(1)}' 2>&1 | \ 40266986Smarkj grep D_PDESC_ZERO > /dev/null 2>&1 ; then 41266986Smarkj echo successfully enabled the io provider with reduced privs 42266986Smarkj exit 1 43266986Smarkjfi 44266986Smarkj 45266986Smarkj# 46266986Smarkj# Keeping our reduced privs, we want to assure that we can see every provider 47266986Smarkj# that we think we should be able to see -- and that we can see curpsinfo 48266986Smarkj# state but can't otherwise see arguments. 49266986Smarkj# 50266986Smarkj/usr/sbin/dtrace -wq -Cs /dev/stdin <<EOF 51266986Smarkj 52266986Smarkjint seen[string]; 53266986Smarkjint err; 54266986Smarkj 55266986Smarkj#define CANENABLE(provider) \ 56266986Smarkjprovider::: \ 57266986Smarkj/err == 0 && progenyof(\$pid) && !seen["provider"]/ \ 58266986Smarkj{ \ 59266986Smarkj trace(arg0); \ 60266986Smarkj printf("\nsuccessful trace of arg0 in %s:%s:%s:%s\n", \ 61266986Smarkj probeprov, probemod, probefunc, probename); \ 62266986Smarkj exit(++err); \ 63266986Smarkj} \ 64266986Smarkj \ 65266986Smarkjprovider::: \ 66266986Smarkj/progenyof(\$pid)/ \ 67266986Smarkj{ \ 68266986Smarkj seen["provider"]++; \ 69266986Smarkj} \ 70266986Smarkj \ 71266986Smarkjprovider::: \ 72266986Smarkj/progenyof(\$pid)/ \ 73266986Smarkj{ \ 74266986Smarkj errstr = "provider"; \ 75266986Smarkj this->ignore = stringof(curpsinfo->pr_psargs); \ 76266986Smarkj errstr = ""; \ 77266986Smarkj} \ 78266986Smarkj \ 79266986SmarkjEND \ 80266986Smarkj/err == 0 && !seen["provider"]/ \ 81266986Smarkj{ \ 82266986Smarkj printf("no probes from provider\n"); \ 83266986Smarkj exit(++err); \ 84266986Smarkj} \ 85266986Smarkj \ 86266986SmarkjEND \ 87266986Smarkj/err == 0/ \ 88266986Smarkj{ \ 89266986Smarkj printf("saw %d probes from provider\n", seen["provider"]); \ 90266986Smarkj} 91266986Smarkj 92266986SmarkjCANENABLE(proc) 93266986SmarkjCANENABLE(sched) 94266986SmarkjCANENABLE(vminfo) 95266986SmarkjCANENABLE(sysinfo) 96266986Smarkj 97266986SmarkjBEGIN 98266986Smarkj{ 99266986Smarkj /* 100266986Smarkj * We'll kick off a system of a do-nothing command -- which should be 101266986Smarkj * enough to kick proc, sched, vminfo and sysinfo probes. 102266986Smarkj */ 103266986Smarkj system("echo > /dev/null"); 104266986Smarkj} 105266986Smarkj 106266986SmarkjERROR 107266986Smarkj/err == 0 && errstr != ""/ 108266986Smarkj{ 109266986Smarkj printf("fatal error: couldn't read curpsinfo->pr_psargs in "); 110266986Smarkj printf("%s-provided probe\n", errstr); 111266986Smarkj exit(++err); 112266986Smarkj} 113266986Smarkj 114266986Smarkjproc:::exit 115266986Smarkj/progenyof(\$pid)/ 116266986Smarkj{ 117266986Smarkj exit(0); 118266986Smarkj} 119266986Smarkj 120266986Smarkjtick-10ms 121266986Smarkj/i++ > 500/ 122266986Smarkj{ 123266986Smarkj printf("exit probe did not seem to fire\n"); 124266986Smarkj exit(++err); 125266986Smarkj} 126266986SmarkjEOF 127