1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28#ident "@(#)tst.egid.ksh 1.1 06/08/28 SMI" 29 30############################################################################ 31# ASSERTION: 32# 33# To verify egid of current process 34# 35# 36# SECTION: Scripting 37# 38############################################################################ 39 40if [ -f /usr/lib/dtrace/darwin.d ]; then 41bname=`/usr/bin/basename $0` 42else 43bname=`/bin/basename $0` 44fi 45dfilename=/var/tmp/$bname.$$.d 46 47## Create .d file 48########################################################################## 49cat > $dfilename <<-EOF 50#!/usr/sbin/dtrace -qs 51 52 53BEGIN 54/\$egid != \$1/ 55{ 56 exit(1); 57} 58 59BEGIN 60/\$egid == \$1/ 61{ 62 exit(0); 63} 64EOF 65########################################################################## 66 67 68#chmod 555 the .d file 69 70chmod 555 $dfilename >/dev/null 2>&1 71if [ $? -ne 0 ]; then 72 print -u2 "chmod $dfilename failed" 73 exit 1 74fi 75 76#Get the groupid of the calling process using ps 77 78groupid=`ps -o pid,gid | grep "$$ " | awk '{print $2}' 2>/dev/null` 79if [ $? -ne 0 ]; then 80 print -u2 "unable to get uid of the current process with pid = $$" 81 exit 1 82fi 83 84#Pass groupid as argument to .d file 85$dfilename $groupid >/dev/null 2>&1 86if [ $? -ne 0 ]; then 87 print -u2 "Error in executing $dfilename" 88 exit 1 89fi 90 91#Cleanup leftovers 92 93if [ -f /usr/lib/dtrace/darwin.d ]; then 94/bin/rm -f $dfilename 95else 96/usr/bin/rm -f $dfilename 97fi 98exit 0 99