xref: /titanic_51/usr/src/lib/brand/solaris10/cmd/s10_isaexec_wrapper.sh (revision 470d303b1a2b5dd82fea111b8cb0f7bef480a055)
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#
43n=/.SUNWnative
44
45bname=`/usr/bin/basename $0`
46dname=`/usr/bin/dirname $0`
47echo $dname | /usr/bin/grep "^/" >/dev/null || dname=`/bin/pwd`/$dname
48dname=`(cd $dname 2>/dev/null && /bin/pwd 2>/dev/null)`
49arch64=/
50LC_ALL=C /usr/bin/file $n/$dname/$bname | /usr/bin/grep "64-bit" \
51    >/dev/null && arch64=/64/
52
53# This wrapper is running in the S10 zone so there is no L10N for the
54# following error msg.
55if [ ! -f $n$dname/$bname ]; then
56	echo "Error: \"$dname/$bname\" is not installed in the global zone"
57	exit 1
58fi
59
60exec $n/usr/lib/brand/solaris10/s10_native \
61    $n/lib${arch64}ld.so.1 \
62    -e LD_NOENVIRON=1 \
63    -e LD_NOCONFIG=1 \
64    -e LD_PRELOAD_32=s10_npreload.so.1 \
65    -e LD_PRELOAD_64=s10_npreload.so.1 \
66    -e LD_LIBRARY_PATH_32="$n/lib:$n/usr/lib:$n/usr/lib/mps" \
67    -e LD_LIBRARY_PATH_64="$n/lib/64:$n/usr/lib/64:$n/usr/lib/mps/64" \
68    $n$dname/$bname "$@"
69