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