#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
export LANG=C
# The labeled_parseNet function is used by functions in this file
# and by txzonemgr. So changes must be verified in both places.
# The function takes either a zonecfg net or anet resource, passed in
# via $net. It parses the keywords, and sets the following variables:
#
# ipaddr - the IP address, including the cidr suffix if present
# defaultrouter -if present
# physical - the corresponding global zone interface
typeset alpha
ipaddr="..."
linkname="..."
vlan_id="..."
shift 1
while (( $# > 1)) do
case $1 in
"lower-link:")
physical=$2
;;
"physical:")
physical=$2
;;
"address:")
if [ $2 != "..." ]; then
ipaddr="$2"
fi
;;
"allowed-address:")
if [ $2 != "..." ]; then
ipaddr="$2"
fi
;;
"defrouter:")
defrouter="$2"
;;
"linkname:")
linkname=$2
;;
"vlan-id:")
vlan_id=$2
;;
esac
shift 1
done
#
# If address is a hostname, return IP address
#
if [[ ! -z $alpha ]]; then
if [[ -z $ipaddr ]] ; then
ipaddr="..."
fi
fi
}
# The _getIPconfig function is only used in this file.
# It is used to determine the hostname and IP address
# of the labeled zone. In addition to the variables set
# by labeled_parseNet, it also sets the variable $hostname.
typeset hostattr
typeset cidr
else
fi
if [[ ! -n $net ]]; then
ipaddr=127.0.0.1
return 1
fi
if [ $ipaddr = ... ]; then
ipaddr=127.0.0.1
return 1
fi
if [[ -n $hostattr ]]; then
return 0
else
if [[ -n $cidr ]]; then
# remove the optional cidr suffix
# which is input to getNetmask()
fi
if [ $? = 0 ]; then
else
fi
return 0
fi
}
# The labeled_unsharePasswed function removes the passwd and shadow
# lofs mounts that are part of the shared name service configuration.
# This function is also called by txzonemgr so changes must be
# verified in both files.
}
# The labeled_sharePasswed function sets the passwd and shadow
# lofs mounts that are part of the shared name service configuration.
# This function is also called by txzonemgr so changes must be
# verified in both files.
if [ $? -eq 1 ] ; then
zonecfg -z $1 "add fs; \
set type=lofs; \
add options ro; \
fi
if [ $? -eq 1 ] ; then
zonecfg -z $1 "add fs; \
set type=lofs; \
add options ro; \
fi
}
#
# The _auto_home function automates NFS sharing of the minimum labeled
# home directory with higher lableled zones. Reading the lowest
# labeled home directory is required by updatehome(1).
#
# An auto_home_<zonename> automap entry is created and stored in
#
# Although zone administrators can configure their own automount
# entries, it is done automatically here to make things easier.
#
typeset ZONE_ETC_DIR=$l_zonepath/root/etc
typeset AUTOMOUNTDIR=/var/tsol/doors/automount
if [ -f $NSCD_INDICATOR -a $1 = clone ] ; then
fi
fi
# Find the labeled zone corresponding to the minimum label
typeset minzone_entry=$(grep ${DEFAULTLABEL} $TNZONECFG)
if [[ ! -n $minzone_entry ]]; then
return
fi
typeset minzone=$(echo $minzone_entry|cut -d: -f1)
typeset am=auto_home_$minzone
# If the current zone has the minimum label,
# check if its home directories can be shared.
# An explicit IP address assignment is required
# for a zone to be a multilevel NFS server.
_getIPconfig || return
# Save the automount entry for other zones to import
if [ ! -d $AUTOMOUNTDIR ] ; then
fi
>> $AUTOMOUNTDIR/$am
# Configure multilevel NFS ports if
# this hasn't been done already.
add mlp_private=111/udp;\
else
# If an automount map exists, then copy it into the higher
# labeled zone.
if [ -f $AUTOMOUNTDIR/$am ]; then
mountpoint="/zone/${minzone}/home"
# Add map to auto_master if necessary
if [ $? != 0 ] ;then
entry="$mountpoint $am -nobrowse"
echo $entry >> $ZONE_ETC_DIR/auto_master
fi
else
rm $ZONE_ETC_DIR/$am 2>/dev/null
fi
fi
}
# The labeled_printsysconfig function generates a custom
# SC profile for a labeled zone using properies from the
# zone's configuration file and global zone settings.
typeset fmtsvc='<service name="%s" version="1" type="service">\n<instance name="%s" enabled="true">\n'
typeset fmtgrp='<property_group name="%s" type="%s">\n'
typeset fmtval='<propval name="%s" type="%s" value="%s"/>\n'
typeset fmtendsvc='</property_group>\n</instance>\n</service>\n'
print '<service_bundle type="profile" name="system configuration">'
if [ $ldap = true ] ; then
print '</property_group>'
profPwd=$(ldapclient list | \
fi
typeset locale=$(svcprop -p environment/LANG system/environment:init 2>/dev/null)
fi
print '</property_group>'
done
fi
print '</service_bundle>'
}
# The labeled_reconfigure function is used to generate a
# a customized SC profile for a cloned zone, and to setup
# some nameservice-specific properties for the user account.
# It is called by the common clone code when the user runs zoneadm
# without specifying a SC profile for a labeled zone.
# $1 specifies how much to configure.
# possible values are "system,identity,network,location,users"
#
# $2 specifies if the unconfiguration should be destructive
# possible values are --destructive and null
# Returns 0 if successful, and 1 if mount failure
if [ -f $NSCD_INDICATOR ] ; then
else
fi
# change "system" to "users" when partial
# reconfiguration is supported
if [ $zonestate != mounted ] ; then
return 1
fi
typeset configured SCPROFILE ZONE_PROFILE_DIR
# A zone can't be unconfigured until it is configured
# so if the config service has no log file yet we assume
# if has never been configured, and we can just place
# the profile in the site directory.
if [ ! -f $configured ]; then
chmod 400 $SCPROFILE
typeset SC_CONFIG_BASE=$(basename $SCPROFILE)
-c /system/volatile/$SC_CONFIG_BASE $2"
fi
return $?
}
# The labeled_configure function is used to setup the
# some nameservice-specific properties for the user account.
# It is called by common pkgcreatezone code after a labeled zone
# has been installed, to set up user account properties
if [ -f $NSCD_INDICATOR ] ; then
else
fi
}
# The labeled_makeSCprofile() function is used to create
# a customized SC profile for a new labeled zone.
# It is called by the common pkgcreatezone code when user runs
# zoneadm without specifying a SC profile for a labeled zone.
# The pathname of the new SC profile is set in
# the variable $temp_scprofile which is then passed to
# auto-install in the common pkgcreatezone code.
if [[ -z $temp_scprofile ]]; then
print "$f_mktemp"
fi
}