12633Sahl#!/bin/ksh -p 22633Sahl# 32633Sahl# CDDL HEADER START 42633Sahl# 52633Sahl# The contents of this file are subject to the terms of the 62633Sahl# Common Development and Distribution License (the "License"). 72633Sahl# You may not use this file except in compliance with the License. 82633Sahl# 92633Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102633Sahl# or http://www.opensolaris.org/os/licensing. 112633Sahl# See the License for the specific language governing permissions 122633Sahl# and limitations under the License. 132633Sahl# 142633Sahl# When distributing Covered Code, include this CDDL HEADER in each 152633Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162633Sahl# If applicable, add the following below this CDDL HEADER, with the 172633Sahl# fields enclosed by brackets "[]" replaced with your own identifying 182633Sahl# information: Portions Copyright [yyyy] [name of copyright owner] 192633Sahl# 202633Sahl# CDDL HEADER END 212633Sahl# 222633Sahl 232633Sahl# 242633Sahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 252633Sahl# Use is subject to license terms. 262633Sahl# 272633Sahl 282633Sahl#ident "%Z%%M% %I% %E% SMI" 292633Sahl 302633Sahl############################################################################ 312633Sahl# ASSERTION: 322633Sahl# 332633Sahl# To verify egid of current process 342633Sahl# 352633Sahl# 362633Sahl# SECTION: Scripting 372633Sahl# 382633Sahl############################################################################ 392633Sahl 40*2804Stomeeif [ $# != 1 ]; then 41*2804Stomee echo expected one argument: '<'dtrace-path'>' 42*2804Stomee exit 2 43*2804Stomeefi 44*2804Stomee 45*2804Stomeedtrace=$1 462633Sahlbname=`/bin/basename $0` 472633Sahldfilename=/var/tmp/$bname.$$.d 482633Sahl 492633Sahl## Create .d file 502633Sahl########################################################################## 512633Sahlcat > $dfilename <<-EOF 52*2804Stomee#!$dtrace -qs 532633Sahl 542633Sahl 552633SahlBEGIN 562633Sahl/\$egid != \$1/ 572633Sahl{ 582633Sahl exit(1); 592633Sahl} 602633Sahl 612633SahlBEGIN 622633Sahl/\$egid == \$1/ 632633Sahl{ 642633Sahl exit(0); 652633Sahl} 662633SahlEOF 672633Sahl########################################################################## 682633Sahl 692633Sahl 702633Sahl#chmod 555 the .d file 712633Sahl 722633Sahlchmod 555 $dfilename >/dev/null 2>&1 732633Sahlif [ &? -ne 0 ]; then 742633Sahl print -u2 "chmod $dfilename failed" 752633Sahl exit 1 762633Sahlfi 772633Sahl 782633Sahl#Get the groupid of the calling process using ps 792633Sahl 802633Sahlgroupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null` 812633Sahlif [ $? -ne 0 ]; then 822633Sahl print -u2 "unable to get uid of the current process with pid = $$" 832633Sahl exit 1 842633Sahlfi 852633Sahl 862633Sahl#Pass groupid as argument to .d file 872633Sahl$dfilename $groupid >/dev/null 2>&1 88*2804Stomee 892633Sahlif [ $? -ne 0 ]; then 902633Sahl print -u2 "Error in executing $dfilename" 912633Sahl exit 1 922633Sahlfi 932633Sahl 942633Sahl#Cleanup leftovers 952633Sahl 962633Sahl/usr/bin/rm -f $dfilename 972633Sahlexit 0 98