17c478bd9Sstevel@tonic-gate#!/bin/ksh -p 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*20c1c355SRod Evans# Common Development and Distribution License (the "License"). 7*20c1c355SRod Evans# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 22*20c1c355SRod Evans# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate 247c478bd9Sstevel@tonic-gateusage() { 257c478bd9Sstevel@tonic-gate cat 1>&2 << 'EOF' 267c478bd9Sstevel@tonic-gateusage: whocalls [sl:] <funcname> <utility> [utility arguments] 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate whocalls will audit all function bindings between <utility> and any library 297c478bd9Sstevel@tonic-gate it utilizes. Each time the function <funcname> is called, a stack 307c478bd9Sstevel@tonic-gate backtrace is displayed 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate -l <wholib> 337c478bd9Sstevel@tonic-gate specify an alternate who.so to use. 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate -s When available, examine and use the .symtab symbol table 367c478bd9Sstevel@tonic-gate for local symbols (more expensive). 377c478bd9Sstevel@tonic-gateEOF 387c478bd9Sstevel@tonic-gate} 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gateoptlet="sl:" 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gateif [[ $# -lt 2 ]]; then 437c478bd9Sstevel@tonic-gate usage 447c478bd9Sstevel@tonic-gate exit 1 457c478bd9Sstevel@tonic-gatefi 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gatewholib32="/usr/lib/link_audit/32/who.so.1" 487c478bd9Sstevel@tonic-gatewholib64="/usr/lib/link_audit/64/who.so.1" 497c478bd9Sstevel@tonic-gatedetail="" 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gatewhile getopts $optlet c 527c478bd9Sstevel@tonic-gatedo 537c478bd9Sstevel@tonic-gate case $c in 547c478bd9Sstevel@tonic-gate l) 557c478bd9Sstevel@tonic-gate wholib32="$OPTARG" 567c478bd9Sstevel@tonic-gate wholib64="$OPTARG" 577c478bd9Sstevel@tonic-gate ;; 587c478bd9Sstevel@tonic-gate s) 597c478bd9Sstevel@tonic-gate detail="1" 607c478bd9Sstevel@tonic-gate ;; 617c478bd9Sstevel@tonic-gate \?) 627c478bd9Sstevel@tonic-gate usage 637c478bd9Sstevel@tonic-gate exit 1 647c478bd9Sstevel@tonic-gate ;; 657c478bd9Sstevel@tonic-gate esac 667c478bd9Sstevel@tonic-gatedone 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1` 697c478bd9Sstevel@tonic-gatefunc=$1 707c478bd9Sstevel@tonic-gateshift 1 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gateLD_AUDIT_32="$wholib32" \ 737c478bd9Sstevel@tonic-gateLD_AUDIT_64="$wholib64" \ 747c478bd9Sstevel@tonic-gateWHO_DETAIL="$detail" \ 757c478bd9Sstevel@tonic-gateWHOCALLS="$func" \ 767c478bd9Sstevel@tonic-gate"$@" 777c478bd9Sstevel@tonic-gateexit 0 78