1*e0aad1e0Sdp#
2*e0aad1e0Sdp# CDDL HEADER START
3*e0aad1e0Sdp#
4*e0aad1e0Sdp# The contents of this file are subject to the terms of the
5*e0aad1e0Sdp# Common Development and Distribution License (the "License").
6*e0aad1e0Sdp# You may not use this file except in compliance with the License.
7*e0aad1e0Sdp#
8*e0aad1e0Sdp# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*e0aad1e0Sdp# or http://www.opensolaris.org/os/licensing.
10*e0aad1e0Sdp# See the License for the specific language governing permissions
11*e0aad1e0Sdp# and limitations under the License.
12*e0aad1e0Sdp#
13*e0aad1e0Sdp# When distributing Covered Code, include this CDDL HEADER in each
14*e0aad1e0Sdp# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*e0aad1e0Sdp# If applicable, add the following below this CDDL HEADER, with the
16*e0aad1e0Sdp# fields enclosed by brackets "[]" replaced with your own identifying
17*e0aad1e0Sdp# information: Portions Copyright [yyyy] [name of copyright owner]
18*e0aad1e0Sdp#
19*e0aad1e0Sdp# CDDL HEADER END
20*e0aad1e0Sdp#
21*e0aad1e0Sdp
22*e0aad1e0Sdp#
23*e0aad1e0Sdp# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*e0aad1e0Sdp# Use is subject to license terms.
25*e0aad1e0Sdp#
26*e0aad1e0Sdp#ident	"%Z%%M%	%I%	%E% SMI"
27*e0aad1e0Sdp
28*e0aad1e0Sdp#
29*e0aad1e0Sdp# Affirmative test of less privileged user operation.  We do so by running
30*e0aad1e0Sdp# this test case as root, then as a less privileged user.  The output should
31*e0aad1e0Sdp# be exactly the same.
32*e0aad1e0Sdp#
33*e0aad1e0Sdp
34*e0aad1e0Sdpscript()
35*e0aad1e0Sdp{
36*e0aad1e0Sdp	cat <<"EOF"
37*e0aad1e0Sdp
38*e0aad1e0Sdp	BEGIN { trace("trace\n"); }
39*e0aad1e0Sdp	BEGIN { printf("%s\n", "printf"); }
40*e0aad1e0Sdp	BEGIN { printf("strlen(\"strlen\") = %d\n", strlen("strlen")); }
41*e0aad1e0Sdp	BEGIN { x = alloca(10);
42*e0aad1e0Sdp		bcopy("alloca\n", x, 7);
43*e0aad1e0Sdp		trace(stringof(x)); }
44*e0aad1e0Sdp
45*e0aad1e0Sdp	BEGIN { printf("index(\"index\", \"x\") = %d\n",
46*e0aad1e0Sdp	    index("index", "x")); }
47*e0aad1e0Sdp	BEGIN { printf("strchr(\"strchr\", \'t\') = %s\n",
48*e0aad1e0Sdp	    strchr("strchr", 't')); }
49*e0aad1e0Sdp
50*e0aad1e0Sdp	BEGIN { printf("strtok(\"strtok\", \"t\") = %s\n",
51*e0aad1e0Sdp	    strtok("strtok", "t")); }
52*e0aad1e0Sdp	BEGIN { printf("strtok(NULL, \"t\") = %s\n",
53*e0aad1e0Sdp	    strtok(NULL, "t")); }
54*e0aad1e0Sdp	BEGIN { printf("strtok(NULL, \"t\") = %s\n",
55*e0aad1e0Sdp	    strtok(NULL, "t")); }
56*e0aad1e0Sdp	BEGIN { printf("substr(\"substr\", 2, 2) = %s\n",
57*e0aad1e0Sdp	    substr("substr", 2, 2)); }
58*e0aad1e0Sdp	BEGIN { trace(strjoin("str", "join\n")); }
59*e0aad1e0Sdp	BEGIN { trace(basename("dirname/basename")); trace("/"); }
60*e0aad1e0Sdp	BEGIN { trace(dirname("dirname/basename")); }
61*e0aad1e0Sdp
62*e0aad1e0Sdp	BEGIN { exit(0); }
63*e0aad1e0Sdp	ERROR { exit(1); }
64*e0aad1e0SdpEOF
65*e0aad1e0Sdp}
66*e0aad1e0Sdp
67*e0aad1e0Sdpprivout=/tmp/$$.priv_output
68*e0aad1e0Sdpunprivout=/tmp/$$.unpriv_output
69*e0aad1e0Sdp
70*e0aad1e0Sdpscript | /usr/sbin/dtrace -q -s /dev/stdin > $privout
71*e0aad1e0Sdpppriv -s A=basic,dtrace_user $$
72*e0aad1e0Sdpscript | /usr/sbin/dtrace -q -s /dev/stdin > $unprivout
73*e0aad1e0Sdp
74*e0aad1e0Sdpdiff $privout $unprivout
75*e0aad1e0Sdpres=$?
76*e0aad1e0Sdp
77*e0aad1e0Sdp/bin/rm -f $privout $unprivout
78*e0aad1e0Sdp
79*e0aad1e0Sdpexit $res
80