1#!/bin/sh
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# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23#
24
25#
26# This script is invoked by isaexec-governed executable wrappers from within
27# s10-branded zones.  It circumvents the native isaexec so that native wrappers
28# will function correctly.
29#
30# All native executables must be run using the native linker.
31# By default, the kernel loads the linker at /lib/ld.so.1, which
32# in an s10 zone is the s10 linker.  Hence when we run the native
33# executable below, we explicitly specify /.SUNWnative/lib/ld.so.1 as our 32-
34# bit linker and /.SUNWnative/lib/64/ld.so.1 as our 64-bit linker.
35# For convience we define "n" to be the native path prefix.
36# The initial s10_native argument is used as a way to tell the brand
37# emulation that it needs to set up the process to run as an unbranded
38# process.
39#
40# If this script gets setup with a mode that makes it suid, then things won't
41# work because the script will be running with the incorrect name.
42#
43# The code in s10_native() which which cleans up the initial arguments for
44# a wrapped command relies on a well formatted argument list.  It assumes that
45# the -e options immediately follow the native ld.so.1 command and that these
46# options are contiguous with no extra spaces.  If additional non -e ld.so.1
47# options are added here, that code must also be updated.
48#
49n=/.SUNWnative
50
51bname=`/usr/bin/basename $0`
52dname=`/usr/bin/dirname $0`
53echo $dname | /usr/bin/grep "^/" >/dev/null || dname=`/bin/pwd`/$dname
54dname=`(cd $dname 2>/dev/null && /bin/pwd 2>/dev/null)`
55arch64=/
56LC_ALL=C /usr/bin/file $n/$dname/$bname | /usr/bin/grep "64-bit" \
57    >/dev/null && arch64=/64/
58
59exec $n/usr/lib/brand/solaris10/s10_native \
60    $n/lib${arch64}ld.so.1 \
61    -e LD_NOENVIRON=1 \
62    -e LD_NOCONFIG=1 \
63    -e LD_PRELOAD_32=s10_npreload.so.1 \
64    -e LD_PRELOAD_64=s10_npreload.so.1 \
65    -e LD_LIBRARY_PATH_32="$n/lib:$n/usr/lib:$n/usr/lib/mps" \
66    -e LD_LIBRARY_PATH_64="$n/lib/64:$n/usr/lib/64:$n/usr/lib/mps/64" \
67    $n$dname/$bname "$@"
68