2N/A#!/bin/ksh -p
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A#
2N/A# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A#
2N/A# s10 boot script.
2N/A#
2N/A# The arguments to this script are the zone name and the zonepath.
2N/A#
2N/A
2N/A. /usr/lib/brand/solaris10/common.ksh
2N/A
2N/AZONENAME=$1
2N/AZONEPATH=$2
2N/AZONEROOT=$ZONEPATH/root
2N/A
2N/Aw_missing=$(gettext "Warning: \"%s\" is not installed in the global zone\n")
2N/A
2N/Aarch=$(uname -p)
2N/Aif [ "$arch" = "i386" ]; then
2N/A ARCH32=i86
2N/A ARCH64=amd64
2N/Aelif [ "$arch" = "sparc" ]; then
2N/A ARCH32=sparcv7
2N/A ARCH64=sparcv9
2N/Aelse
2N/A echo "Unsupported architecture: $arch"
2N/A exit 2
2N/Afi
2N/A
2N/A#
2N/A# Run cluster hook
2N/A#
2N/Acall_cluster_hook boot "$@" || exit $?
2N/A
2N/A#
2N/A# Run the s10_support boot hook.
2N/A#
2N/A/usr/lib/brand/solaris10/s10_support boot $ZONENAME
2N/Aif (( $? != 0 )); then
2N/A exit 1
2N/Afi
2N/A
2N/ABRANDDIR=/.SUNWnative/usr/lib/brand/solaris10;
2N/AFILEDIR=$BRANDDIR/files;
2N/AEXIT_CODE=1
2N/A
2N/A#
2N/A# Replace the specified file in the booting zone with a wrapper script that
2N/A# invokes s10_isaexec_wrapper. This is a convenience function that reduces
2N/A# clutter and code duplication.
2N/A#
2N/A# Parameters:
2N/A# $1 The full path of the file to replace (e.g., /sbin/ifconfig)
2N/A# $2 The access mode of the replacement file in hex (e.g., 0555)
2N/A# $3 The name of the replacement file's owner (e.g., root:bin)
2N/A# $4 Optional: the full path of the native file
2N/A#
2N/A# NOTE: The checks performed in the 'if' statement below are not generic: they
2N/A# depend on the success of the zone filesystem structure validation performed
2N/A# above to ensure that intermediate directories exist and aren't symlinks.
2N/A#
2N/Areplace_with_native() {
2N/A typeset path_dname="$ZONEROOT/"$(dirname $1)
2N/A typeset native_path="$4"
2N/A
2N/A if [[ -n $native_path ]]; then
2N/A [[ ! -f $native_path ]] && printf "$w_missing" \
2N/A "$native_path"
2N/A native_path=$(dirname $4)
2N/A else
2N/A [[ ! -f $1 ]] && printf "$w_missing" "$1"
2N/A fi
2N/A
2N/A if [ ! -h $path_dname -a -d $path_dname ]; then
2N/A safe_replace "$ZONEROOT/$1" "$BRANDDIR/s10_isaexec_wrapper" \
2N/A "$2" "$3" remove "$native_path"
2N/A fi
2N/A}
2N/A
2N/Areplace_with_native_py() {
2N/A path_dname="$ZONEROOT/"$(dirname $1)
2N/A
2N/A [ ! -f $1 ] && printf "$w_missing" "$1"
2N/A
2N/A if [ ! -h $path_dname -a -d $path_dname ]; then
2N/A safe_replace $ZONEROOT/$1 $BRANDDIR/s10_python_wrapper $2 $3 \
2N/A remove
2N/A fi
2N/A}
2N/A
2N/A#
2N/A# Create a new wrapper script that invokes s10_isaexec_wrapper in the
2N/A# brand (for a non-existing s10c file) pointing to the native brand file.
2N/A#
2N/A# This function assumes there is no s10 version of the replacement file,
2N/A# so there is nothing to back up.
2N/A#
2N/A# Parameters:
2N/A# $1 The full path of the wrapper file to create
2N/A# $2 The access mode of the replacement file in hex (e.g., 0555)
2N/A# $3 The name of the replacement file's owner (e.g., root:bin)
2N/A#
2N/Awrap_with_native() {
2N/A
2N/A [ ! -f $1 ] && printf "$w_missing" "$1"
2N/A
2N/A path_dname="$ZONEROOT/"$(dirname $1)
2N/A if [ ! -h $path_dname -a -d $path_dname -a ! -f $ZONEROOT/$1 ]; then
2N/A safe_wrap $ZONEROOT/$1 $BRANDDIR/s10_isaexec_wrapper $2 $3
2N/A fi
2N/A}
2N/A
2N/A#
2N/A# Before we boot we validate and fix, if necessary, the required files within
2N/A# the zone. These modifications can be lost if a patch is applied within the
2N/A# zone, so we validate and fix the zone every time it boots.
2N/A#
2N/A
2N/A#
2N/A# BINARY REPLACEMENT
2N/A#
2N/A# This section of the boot script is responsible for replacing Solaris 10
2N/A# binaries within the booting zone with Nevada binaries. This is a two-step
2N/A# process: First, the directory structure of the zone is validated to ensure
2N/A# that binary replacement will proceed safely. Second, Solaris 10 binaries
2N/A# are replaced with Nevada binaries.
2N/A#
2N/A# Here's an example. Suppose that you want to replace /usr/bin/zcat with the
2N/A# Nevada /usr/bin/zcat binary. Then you should do the following:
2N/A#
2N/A# 1. Go to the section below labeled "STEP ONE" and add the following
2N/A# two lines:
2N/A#
2N/A# safe_dir /usr
2N/A# safe_dir /usr/bin
2N/A#
2N/A# These lines ensure that both /usr and /usr/bin are directories
2N/A# within the booting zone that can be safely accessed by the global
2N/A# zone.
2N/A# 2. Go to the section below labeled "STEP TWO" and add the following
2N/A# line:
2N/A#
2N/A# replace_with_native /usr/bin/zcat 0555 root:bin
2N/A#
2N/A# Details about the binary replacement procedure can be found in the Solaris 10
2N/A# Containers Developer Guide.
2N/A#
2N/A
2N/A#
2N/A# STEP ONE
2N/A#
2N/A# Validate that the zone filesystem looks like we expect it to.
2N/A#
2N/Asafe_dir /lib
2N/Asafe_dir /lib/svc
2N/Asafe_dir /lib/svc/method
2N/Asafe_dir /lib/svc/share
2N/Asafe_dir /usr
2N/Asafe_dir /usr/bin
2N/Asafe_dir /usr/lib
2N/Asafe_dir /usr/lib/autofs
2N/Asafe_dir /usr/lib/fs
2N/Asafe_dir /usr/lib/fs/autofs
2N/Asafe_dir /usr/lib/fs/ufs
2N/Asafe_dir /usr/lib/fs/zfs
2N/Asafe_dir /usr/lib/inet
2N/Asafe_dir /usr/lib/zfs
2N/Asafe_dir /usr/sbin
2N/Asafe_dir /usr/lib/ipf/$ARCH64
2N/Asafe_dir /usr/sbin/$ARCH64
2N/Asafe_dir /sbin
2N/Asafe_dir /var
2N/Asafe_dir /var/svc
2N/A
2N/A#
2N/A# Some of the native networking daemons such as in.mpathd are
2N/A# expected under /lib/inet
2N/A#
2N/Amkdir -m 0755 -p $ZONEROOT/lib/inet
2N/Achown root:bin $ZONEROOT/lib/inet
2N/Asafe_dir /lib/inet
2N/A
2N/A#
2N/A# Some of the native services expect /system/volatile; link it.
2N/A# to /etc/svc/volatile. /var/run will also be mounted on
2N/A# /etc/svc/volatile by s10_fs_minimal. This allows native
2N/A# services to open doors in /var/run via system/volatile.
2N/A#
2N/Asafe_dir /system
2N/Arm -f $ZONEROOT/system/volatile
2N/Aln -s ../etc/svc/volatile $ZONEROOT/system/volatile
2N/A
2N/A#
2N/A# STEP TWO
2N/A#
2N/A# Replace Solaris 10 binaries with Nevada binaries.
2N/A#
2N/A
2N/A#
2N/A# Replace various network-related programs with native wrappers.
2N/A#
2N/Areplace_with_native /sbin/dhcpagent 0555 root:bin
2N/Areplace_with_native /sbin/dhcpinfo 0555 root:bin
2N/Areplace_with_native /sbin/ifconfig 0555 root:bin
2N/Areplace_with_native /usr/bin/netstat 0555 root:bin
2N/Areplace_with_native /usr/lib/inet/in.ndpd 0555 root:bin
2N/Areplace_with_native /usr/sbin/in.routed 0555 root:bin
2N/Areplace_with_native /usr/sbin/snoop 0555 root:bin
2N/Areplace_with_native /usr/sbin/if_mpadm 0555 root:bin
2N/Areplace_with_native /usr/lib/inet/in.mpathd 0555 root:bin /lib/inet/in.mpathd
2N/A
2N/A#
2N/A# Replace IPFilter commands with native wrappers
2N/A#
2N/Areplace_with_native /usr/lib/ipf/$ARCH64/ipftest 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ipf 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ipfs 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ipfstat 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ipmon 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ipnat 0555 root:bin
2N/Areplace_with_native /usr/sbin/$ARCH64/ippool 0555 root:bin
2N/A
2N/A#
2N/A# Create wrapper at /lib/inet/in.mpathd as well because native ifconfig
2N/A# looks up in.mpathd under /lib/inet.
2N/A#
2N/Awrap_with_native /lib/inet/in.mpathd 0555 root:bin
2N/A
2N/A# Create native wrapper for /sbin/ipmpstat
2N/Awrap_with_native /sbin/ipmpstat 0555 root:bin
2N/A
2N/A#
2N/A# Create ipmgmtd wrapper to native binary in s10 container
2N/A# and copy ipmgmt service method.
2N/A#
2N/Awrap_with_native /lib/inet/ipmgmtd 0555 root:bin
2N/Asafe_copy /lib/svc/method/net-ipmgmt \
2N/A $ZONEROOT/lib/svc/method/net-ipmgmt
2N/A
2N/A#
2N/A# Create wrapper for native netcfgd.
2N/A#
2N/Awrap_with_native /lib/inet/netcfgd 0555 root:bin
2N/A
2N/A#
2N/A# To handle certain IPMP configurations, we need updated
2N/A# net-physical method script and updated net_include.sh
2N/A#
2N/Afilename=$ZONEROOT/lib/svc/method/net-physical
2N/Asafe_backup $filename $filename.pre_p2v
2N/Asafe_copy /usr/lib/brand/solaris10/s10_net_physical $filename
2N/Afilename=$ZONEROOT/lib/svc/share/net_include.sh
2N/Asafe_backup $filename $filename.pre_p2v
2N/Asafe_copy /usr/lib/brand/solaris10/s10_net_include.sh $filename
2N/Afilename=$ZONEROOT/sbin/umountall
2N/Asafe_backup $filename $filename.pre_p2v
2N/Asafe_copy /usr/lib/brand/solaris10/s10_umountall $filename
2N/A
2N/A#
2N/A# To make updates to /var, wrap the s10 fs-minimal script.
2N/A# Make sure the most recent version of fs minimal is backed up
2N/A# so that s10_fs_minimal uses is the up-to-date version.
2N/A#
2N/Afilename=$ZONEROOT/lib/svc/method/fs-minimal
2N/Aif [[ ! -f $filename || -h $filename ]] ; then
2N/A fail_fatal "$e_not_file" "$filename"
2N/Afi
2N/Agrep THIS_IS_SOLARIS10_BRAND_FS_MINIMAL $filename >/dev/null 2>&1
2N/Aif (( $? != 0 )) ; then
2N/A safe_rm $filename.pre_p2v
2N/A safe_backup $filename $filename.pre_p2v
2N/Afi
2N/Asafe_copy /usr/lib/brand/solaris10/s10_fs_minimal $filename
2N/A#
2N/A# PSARC 2009/306 removed the ND_SET/ND_GET ioctl's for modifying
2N/A# IP/TCP/UDP/SCTP/ICMP tunables. If S10 ndd(1M) is used within an
2N/A# S10 container, the kernel will return EINVAL. So we need this.
2N/A#
2N/Areplace_with_native /usr/sbin/ndd 0555 root:bin
2N/A
2N/A#
2N/A# Replace various ZFS-related programs with native wrappers. These commands
2N/A# either link with libzfs, dlopen libzfs or link with libraries that link
2N/A# or dlopen libzfs. Commands which fall into these categories but which can
2N/A# only be used in the global zone are not wrapped. The libdiskmgt dm_in_use
2N/A# code uses libfs, but only the zpool_in_use() -> zpool_read_label() code path.
2N/A# That code does not issue ioctls on /dev/zfs and does not need wrapping.
2N/A#
2N/Areplace_with_native /sbin/zfs 0555 root:bin
2N/Areplace_with_native /sbin/zpool 0555 root:bin
2N/Areplace_with_native /usr/lib/fs/ufs/quota 0555 root:bin /usr/sbin/quota
2N/Areplace_with_native /usr/lib/fs/zfs/fstyp 0555 root:bin
2N/Areplace_with_native /usr/lib/zfs/availdevs 0555 root:bin
2N/Areplace_with_native /usr/sbin/df 0555 root:bin
2N/Areplace_with_native /usr/xpg4/bin/df 0555 root:bin
2N/Areplace_with_native /usr/sbin/zstreamdump 0555 root:bin
2N/Areplace_with_native_py /usr/lib/zfs/pyzfs.py 0555 root:bin
2N/A
2N/A#
2N/A# Replace automount and automountd with native wrappers.
2N/A#
2N/Areplace_with_native /usr/lib/fs/autofs/automount 0555 root:bin
2N/Areplace_with_native /usr/lib/autofs/automountd 0555 root:bin
2N/A
2N/A#
2N/A# Replace rstatd with native, as it depends on struct mib2_ipAddrEntry_t
2N/A#
2N/Areplace_with_native /usr/lib/netsvc/rstat/rpc.rstatd root:bin
2N/A
2N/A# Replace truss and mdb with their native counterparts. The architecture
2N/A# specific versions are updated, as truss and mdb will exec these directly
2N/A# when the current binary does not match the target process.
2N/A#
2N/Areplace_with_native /usr/bin/$ARCH32/mdb 0555 root:bin
2N/Areplace_with_native /usr/bin/$ARCH64/mdb 0555 root:bin
2N/Areplace_with_native /usr/bin/$ARCH32/truss 0555 root:bin
2N/Areplace_with_native /usr/bin/$ARCH64/truss 0555 root:bin
2N/A
2N/A#
2N/A# The class-specific dispadmin(1M) and priocntl(1) binaries must be native
2N/A# wrappers, and we must have all of the ones the native zone does. This
2N/A# allows new scheduling classes to appear without causing dispadmin and
2N/A# priocntl to be unhappy.
2N/A#
2N/Arm -rf $ZONEROOT/usr/lib/class
2N/Amkdir $ZONEROOT/usr/lib/class || exit 1
2N/A
2N/Afind /usr/lib/class -type d -o -type f | while read x; do
2N/A [ -d $x ] && mkdir -p -m 755 $ZONEROOT$x
2N/A [ -f $x ] && wrap_with_native $x 0555 root:bin
2N/Adone
2N/A
2N/A#
2N/A# END OF STEP TWO
2N/A#
2N/A
2N/A#
2N/A# Replace add_drv and rem_drv with /usr/bin/true so that pkgs/patches which
2N/A# install or remove drivers will work. NOTE: add_drv and rem_drv are hard
2N/A# linked to isaexec so we want to remove the current executable and
2N/A# then copy true so that we don't clobber isaexec.
2N/A#
2N/Afilename=$ZONEROOT/usr/sbin/add_drv
2N/A[ ! -f $filename.pre_p2v ] && safe_backup $filename $filename.pre_p2v
2N/Arm -f $filename
2N/Asafe_copy $ZONEROOT/usr/bin/true $filename
2N/A
2N/Afilename=$ZONEROOT/usr/sbin/rem_drv
2N/A[ ! -f $filename.pre_p2v ] && safe_backup $filename $filename.pre_p2v
2N/Arm -f $filename
2N/Asafe_copy $ZONEROOT/usr/bin/true $filename
2N/A
2N/Aexit 0