PageRenderTime 24ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/privs/tst.unpriv_funcs.ksh

https://github.com/blacklion/GEOM-Events
Korn Shell | 79 lines | 37 code | 12 blank | 30 comment | 0 complexity | bd51676181354d8f16a16a3096bf15fd MD5 | raw file
  1. #
  2. # CDDL HEADER START
  3. #
  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.
  7. #
  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.
  12. #
  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]
  18. #
  19. # CDDL HEADER END
  20. #
  21. #
  22. # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  23. # Use is subject to license terms.
  24. #
  25. #ident "%Z%%M% %I% %E% SMI"
  26. #
  27. # Affirmative test of less privileged user operation. We do so by running
  28. # this test case as root, then as a less privileged user. The output should
  29. # be exactly the same.
  30. #
  31. script()
  32. {
  33. cat <<"EOF"
  34. BEGIN { trace("trace\n"); }
  35. BEGIN { printf("%s\n", "printf"); }
  36. BEGIN { printf("strlen(\"strlen\") = %d\n", strlen("strlen")); }
  37. BEGIN { x = alloca(10);
  38. bcopy("alloca\n", x, 7);
  39. trace(stringof(x)); }
  40. BEGIN { printf("index(\"index\", \"x\") = %d\n",
  41. index("index", "x")); }
  42. BEGIN { printf("strchr(\"strchr\", \'t\') = %s\n",
  43. strchr("strchr", 't')); }
  44. BEGIN { printf("strtok(\"strtok\", \"t\") = %s\n",
  45. strtok("strtok", "t")); }
  46. BEGIN { printf("strtok(NULL, \"t\") = %s\n",
  47. strtok(NULL, "t")); }
  48. BEGIN { printf("strtok(NULL, \"t\") = %s\n",
  49. strtok(NULL, "t")); }
  50. BEGIN { printf("substr(\"substr\", 2, 2) = %s\n",
  51. substr("substr", 2, 2)); }
  52. BEGIN { trace(strjoin("str", "join\n")); }
  53. BEGIN { trace(basename("dirname/basename")); trace("/"); }
  54. BEGIN { trace(dirname("dirname/basename")); }
  55. BEGIN { exit(0); }
  56. ERROR { exit(1); }
  57. EOF
  58. }
  59. privout=/tmp/$$.priv_output
  60. unprivout=/tmp/$$.unpriv_output
  61. script | /usr/sbin/dtrace -q -s /dev/stdin > $privout
  62. ppriv -s A=basic,dtrace_user $$
  63. script | /usr/sbin/dtrace -q -s /dev/stdin > $unprivout
  64. diff $privout $unprivout
  65. res=$?
  66. /bin/rm -f $privout $unprivout
  67. exit $res