1178476Sjb#!/bin/ksh -p 2178476Sjb# 3178476Sjb# CDDL HEADER START 4178476Sjb# 5178476Sjb# The contents of this file are subject to the terms of the 6178476Sjb# Common Development and Distribution License (the "License"). 7178476Sjb# You may not use this file except in compliance with the License. 8178476Sjb# 9178476Sjb# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178476Sjb# or http://www.opensolaris.org/os/licensing. 11178476Sjb# See the License for the specific language governing permissions 12178476Sjb# and limitations under the License. 13178476Sjb# 14178476Sjb# When distributing Covered Code, include this CDDL HEADER in each 15178476Sjb# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178476Sjb# If applicable, add the following below this CDDL HEADER, with the 17178476Sjb# fields enclosed by brackets "[]" replaced with your own identifying 18178476Sjb# information: Portions Copyright [yyyy] [name of copyright owner] 19178476Sjb# 20178476Sjb# CDDL HEADER END 21178476Sjb# 22178476Sjb 23178476Sjb# 24178476Sjb# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25178476Sjb# Use is subject to license terms. 26178476Sjb# 27178476Sjb 28178476Sjb#ident "%Z%%M% %I% %E% SMI" 29178476Sjb 30178476Sjb############################################################################ 31178476Sjb# ASSERTION: 32178476Sjb# 33178476Sjb# To verify egid of current process 34178476Sjb# 35178476Sjb# 36178476Sjb# SECTION: Scripting 37178476Sjb# 38178476Sjb############################################################################ 39178476Sjb 40178476Sjbif [ $# != 1 ]; then 41178476Sjb echo expected one argument: '<'dtrace-path'>' 42178476Sjb exit 2 43178476Sjbfi 44178476Sjb 45178476Sjbdtrace=$1 46211545Srpaulobname=`/usr/bin/basename $0` 47178476Sjbdfilename=/var/tmp/$bname.$$.d 48178476Sjb 49178476Sjb## Create .d file 50178476Sjb########################################################################## 51178476Sjbcat > $dfilename <<-EOF 52178476Sjb#!$dtrace -qs 53178476Sjb 54178476Sjb 55178476SjbBEGIN 56178476Sjb/\$egid != \$1/ 57178476Sjb{ 58178476Sjb exit(1); 59178476Sjb} 60178476Sjb 61178476SjbBEGIN 62178476Sjb/\$egid == \$1/ 63178476Sjb{ 64178476Sjb exit(0); 65178476Sjb} 66178476SjbEOF 67178476Sjb########################################################################## 68178476Sjb 69178476Sjb 70178476Sjb#chmod 555 the .d file 71178476Sjb 72178476Sjbchmod 555 $dfilename >/dev/null 2>&1 73211545Srpauloif [ $? -ne 0 ]; then 74178476Sjb print -u2 "chmod $dfilename failed" 75178476Sjb exit 1 76178476Sjbfi 77178476Sjb 78178476Sjb#Get the groupid of the calling process using ps 79178476Sjb 80211545Srpaulogroupid=`ps -o pid,pgid | grep "$$ " | awk '{print $2}' 2>/dev/null` 81178476Sjbif [ $? -ne 0 ]; then 82178476Sjb print -u2 "unable to get uid of the current process with pid = $$" 83178476Sjb exit 1 84178476Sjbfi 85178476Sjb 86178476Sjb#Pass groupid as argument to .d file 87178476Sjb$dfilename $groupid >/dev/null 2>&1 88178476Sjb 89178476Sjbif [ $? -ne 0 ]; then 90178476Sjb print -u2 "Error in executing $dfilename" 91178476Sjb exit 1 92178476Sjbfi 93178476Sjb 94178476Sjb#Cleanup leftovers 95178476Sjb 96211545Srpaulo/bin/rm -f $dfilename 97178476Sjbexit 0 98