svc-labeld revision 583b61f62d9b9c5ac6bbc290b4e91263dfb202b4
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#!/sbin/sh
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# CDDL HEADER START
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# The contents of this file are subject to the terms of the
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# Common Development and Distribution License (the "License").
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# You may not use this file except in compliance with the License.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# or http://www.opensolaris.org/os/licensing.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# See the License for the specific language governing permissions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# and limitations under the License.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# When distributing Covered Code, include this CDDL HEADER in each
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# If applicable, add the following below this CDDL HEADER, with the
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# fields enclosed by brackets "[]" replaced with your own identifying
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# information: Portions Copyright [yyyy] [name of copyright owner]
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# CDDL HEADER END
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# Use is subject to license terms.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#ident "%Z%%M% %I% %E% SMI"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica. /lib/svc/share/smf_include.sh
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaROOT_PATH=""
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaif [ $# -gt 1 ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ $# -ne 3 -o "$2" != "-R" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid syntax"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "$3" != "/" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica ROOT_PATH=$3
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricafi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaif [ -n "$ROOT_PATH" -a "$1" != "start" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid syntax: -R allowed for start method only"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricafi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaif [ -n "$ROOT_PATH" -a ! -d "$ROOT_PATH" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid -R rootpath dir specified"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricafi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaif smf_is_nonglobalzone; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: not supported in a local zone"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricafi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4ajrewrite_logindev()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj from="$1"
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj to="$2"
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj # Comment out audio, usb, removable-media, and hotpluggable device
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj # entries in /etc/logindevperm.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica LOGINDEVPERM=$ROOT_PATH/etc/logindevperm
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj if [ ! -f $LOGINDEVPERM ]; then
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj return
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj for line in \
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj "/dev/console 0600 /dev/sound/" \
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj "/dev/console 0400 /dev/removable-media/" \
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj "/dev/console 0400 /dev/hotpluggable/" \
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj "/dev/console 0600 /dev/usb/\[0-9a-f\]" \
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj ; do
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj sed -e "s!^$from$line!$to$line!" $LOGINDEVPERM > /tmp/tmp.$$
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj cp /tmp/tmp.$$ $LOGINDEVPERM
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj done
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj rm -f /tmp/tmp.$$
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj}
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4ajdo_logindev()
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj{
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj rewrite_logindev "" "#"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricado_otherservices()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Setup dependent services
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica cat >> $ROOT_PATH/var/svc/profile/upgrade <<\__ENABLE_OTHERS
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm enable -s svc:/network/tnd:default
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm enable -s svc:/system/tsol-zones:default
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svccfg -s svc:/application/x11/x11-server \
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica setprop options/tcp_listen = true
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm enable svc:/network/rpc/rstat:default
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica__ENABLE_OTHERS
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricado_bsmconv()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Run bsmconv so audit and device allocation is enabled by
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # default with Trusted Extensions.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "$ROOT_PATH" = "/" -o "$ROOT_PATH" = "" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica BSMDIR=""
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica else
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica BSMDIR=$ROOT_PATH
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "Running bsmconv ..."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo `TEXTDOMAIN="SUNW_OST_OSCMD" gettext "y"` | \
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica $ROOT_PATH/etc/security/bsmconv $ROOT_PATH
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricado_nscd()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# For Trusted Extensions, make nscd service transient in local zones.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricacat >> $ROOT_PATH/var/svc/profile/upgrade <<\_DEL_LOCAL_NSCD
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ `/sbin/zonename` != "global" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica nscd="svc:/system/name-service-cache"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica duration=""
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if /bin/svcprop -q -c -p startd/duration $nscd ; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica duration=`/bin/svcprop -c -p startd/duration $nscd`
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "$duration" != "transient" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svccfg -s $nscd addpg startd framework
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svccfg -s $nscd setprop \
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica startd/duration = astring: transient
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svccfg -s $nscd setprop stop/exec = :true
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm refresh $nscd
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica_DEL_LOCAL_NSCD
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricado_bootupd()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -f $ROOT_PATH/platform/`/sbin/uname -m`/boot_archive ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -z "$ROOT_PATH" -o "$ROOT_PATH" = "/" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /sbin/bootadm update-archive
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica else
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /sbin/bootadm update-archive -R $ROOT_PATH
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
8700009e2cc8cb186241e1fdd74973da1121ee4cricasetup_tx_changes(){
8700009e2cc8cb186241e1fdd74973da1121ee4crica#
8700009e2cc8cb186241e1fdd74973da1121ee4crica# No comments or blanks lines allowed in entries below
8700009e2cc8cb186241e1fdd74973da1121ee4crica#
8700009e2cc8cb186241e1fdd74973da1121ee4cricacat > ${TX_ENTRIES} << EOF
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtlogin account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtlogin account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtsession account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtsession account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricagdm account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricagdm account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricaxscreensaver account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricaxscreensaver account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricapasswd account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricapasswd account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtpasswd account requisite pam_roles.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricadtpasswd account required pam_unix_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricaother account required pam_tsol_account.so.1
8700009e2cc8cb186241e1fdd74973da1121ee4cricaEOF
8700009e2cc8cb186241e1fdd74973da1121ee4crica}
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4cricado_addpam()
8700009e2cc8cb186241e1fdd74973da1121ee4crica{
8700009e2cc8cb186241e1fdd74973da1121ee4crica PAM_TMP=/tmp/pam_conf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica TX_ENTRIES=$PAM_TMP/sct.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica PAM_DEST=$ROOT_PATH/etc/pam.conf
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica mkdir $PAM_TMP || exit $SMF_EXIT_ERR_FATAL
8700009e2cc8cb186241e1fdd74973da1121ee4crica setup_tx_changes
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica # verify that pam.conf file exists...
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ ! -f ${PAM_DEST} ]; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: ${PAM_DEST} not found; aborting"
8700009e2cc8cb186241e1fdd74973da1121ee4crica exit $SMF_EXIT_ERR_FATAL
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica #
8700009e2cc8cb186241e1fdd74973da1121ee4crica # Update pam.conf to append Trusted Extensions entries if not
8700009e2cc8cb186241e1fdd74973da1121ee4crica # already present.
8700009e2cc8cb186241e1fdd74973da1121ee4crica #
8700009e2cc8cb186241e1fdd74973da1121ee4crica rm -f /tmp/pamconf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica while read e1 e2 e3 e4 e5
8700009e2cc8cb186241e1fdd74973da1121ee4crica do
8700009e2cc8cb186241e1fdd74973da1121ee4crica # If this is the 'other' entry, add it unless it already
8700009e2cc8cb186241e1fdd74973da1121ee4crica # exists.
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ $e1 = "other" ]; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica grep \
8700009e2cc8cb186241e1fdd74973da1121ee4crica"^[# ]*$e1[ ][ ]*$e2[ ][ ]*$e3[ ][ ]*$e4" \
8700009e2cc8cb186241e1fdd74973da1121ee4crica $PAM_DEST >/dev/null 2>&1
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ $? = 1 ] ; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica # Doesn't exist, enter into pam.conf
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$e1\t$e2 $e3\t\t$e4 $e5" \
8700009e2cc8cb186241e1fdd74973da1121ee4crica >> /tmp/pamconf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica else
8700009e2cc8cb186241e1fdd74973da1121ee4crica # Add other entries unless they already have a
8700009e2cc8cb186241e1fdd74973da1121ee4crica # stack of their own.
8700009e2cc8cb186241e1fdd74973da1121ee4crica grep "^[# ]*$e1[ ][ ]*$e2[ ]" \
8700009e2cc8cb186241e1fdd74973da1121ee4crica $PAM_DEST >/dev/null 2>&1
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ $? = 1 ] ; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$e1\t$e2 $e3\t\t$e4 $e5" \
8700009e2cc8cb186241e1fdd74973da1121ee4crica >> /tmp/pamconf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica done < ${TX_ENTRIES}
8700009e2cc8cb186241e1fdd74973da1121ee4crica # Append TX lines if any were not present already.
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ -f /tmp/pamconf.$$ ] ; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "# Entries for Trusted Extensions" >> $PAM_DEST
8700009e2cc8cb186241e1fdd74973da1121ee4crica cat /tmp/pamconf.$$ >> $PAM_DEST
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: updating $PAM_DEST entries for Trusted Extensions;"
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: please examine/update any new entries"
8700009e2cc8cb186241e1fdd74973da1121ee4crica rm -f /tmp/pamconf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica rm -rf $PAM_TMP
8700009e2cc8cb186241e1fdd74973da1121ee4crica}
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4cricado_pamremove()
8700009e2cc8cb186241e1fdd74973da1121ee4crica{
8700009e2cc8cb186241e1fdd74973da1121ee4crica PAM_TMP=/tmp/pam_conf.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica TX_ENTRIES=$PAM_TMP/sct.$$
8700009e2cc8cb186241e1fdd74973da1121ee4crica PAM_DEST=$ROOT_PATH/etc/pam.conf
8700009e2cc8cb186241e1fdd74973da1121ee4crica TMPFILE=$PAM_TMP/pam.conf
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica mkdir $PAM_TMP || exit $SMF_EXIT_ERR_FATAL
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica # verify that pam.conf file exists...
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ ! -f ${PAM_DEST} ]; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: ${PAM_DEST} not found; aborting"
8700009e2cc8cb186241e1fdd74973da1121ee4crica exit $SMF_EXIT_ERR_FATAL
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica grep '^[a-z].*pam_tsol_account' $PAM_DEST > /dev/null 2>&1
8700009e2cc8cb186241e1fdd74973da1121ee4crica if [ $? -ne 0 ]; then
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: pam_tsol_account module not present,"
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: No changes were made to $PAM_DEST."
8700009e2cc8cb186241e1fdd74973da1121ee4crica return
8700009e2cc8cb186241e1fdd74973da1121ee4crica fi
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica grep -v pam_tsol_account $PAM_DEST > $TMPFILE
8700009e2cc8cb186241e1fdd74973da1121ee4crica echo "$0: $PAM_DEST "tsol" entries removed"
8700009e2cc8cb186241e1fdd74973da1121ee4crica cp $TMPFILE $PAM_DEST
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica rm -rf $PAM_TMP
8700009e2cc8cb186241e1fdd74973da1121ee4crica}
8700009e2cc8cb186241e1fdd74973da1121ee4crica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricado_commonstart()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Updating $ROOT_PATH/etc/system..."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ ! -f ${ROOT_PATH}/etc/system ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica touch ${ROOT_PATH}/etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Set sys_labeling in etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep -v "sys_labeling=" ${ROOT_PATH}/etc/system > /tmp/etc.system.$$
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "set sys_labeling=1" >> /tmp/etc.system.$$
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica mv /tmp/etc.system.$$ ${ROOT_PATH}/etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "set sys_labeling=1" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ $? -ne 0 ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: ERROR: cannot set sys_labeling in $ROOT_PATH/etc/system"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_FATAL
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Setup dependent services
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_otherservices
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_logindev
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_bsmconv
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_nscd
8700009e2cc8cb186241e1fdd74973da1121ee4crica do_addpam
8700009e2cc8cb186241e1fdd74973da1121ee4crica
8700009e2cc8cb186241e1fdd74973da1121ee4crica do_bootupd
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricadaemon_start()
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica{
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # If a labeld door exists, check for a labeld process and exit
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # if the daemon is already running.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -r /var/tsol/doors/labeld ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if /usr/bin/pgrep -x -u 0 -P 1 labeld >/dev/null 2>&1; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: labeld is already running"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_FATAL
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/bin/rm -f /var/tsol/doors/labeld
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/lib/labeld
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica}
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaPATH=/usr/sbin:/usr/bin; export PATH
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricacase "$1" in
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica'start')
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -z "$ROOT_PATH" -o "$ROOT_PATH" = "/" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # native
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -z "$SMF_FMRI" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: this script can only be invoked by smf(5)"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_NOSMF
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica tx_enabled=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "$tx_enabled" = "false" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # A sign of trying temporary enablement...no-no
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Temporarily enabling Trusted Extensions is not allowed."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if (smf_is_system_labeled); then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica daemon_start
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_OK
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Make changes to enable Trusted Extensions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "^set sys_labeling=1" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ $? -eq 0 ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: already enabled. Exiting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_OK
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "`/usr/sbin/zoneadm list -c`" != "global" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Must remove zones before enabling Trusted Extensions."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_commonstart
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # start daemon proccess so our service doesn't go into
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # maintenance state
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica daemon_start
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Started. Must reboot and configure Trusted Extensions."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica else
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Support jumpstart etc
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Make changes to enable Trusted Extensions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "^set sys_labeling=1" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ $? -eq 0 ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: already enabled. Exiting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_OK
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Setup dependent services
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica cat >> $ROOT_PATH/var/svc/profile/upgrade <<\__TRUSTED_ENABLE
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm enable -s svc:/system/labeld:default
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica__TRUSTED_ENABLE
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_commonstart
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Started. Must configure Trusted Extensions before booting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica ;;
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica'stop')
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica tx_enabled=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "$tx_enabled" = "true" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/bin/pkill -x -u 0 -P 1 -z `smf_zonename` labeld
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_OK
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ "`/usr/sbin/zoneadm list -c`" != "global" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Must remove zones before disabling Trusted Extensions."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_CONFIG
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Stop Trusted services.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm disable svc:/system/tsol-zones:default 2>/dev/null
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm disable svc:/network/tnd:default 2>/dev/null
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj # Uncomment audio, usb, removable-media, and hotpluggable device
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj # entries in /etc/logindevperm.
583b61f62d9b9c5ac6bbc290b4e91263dfb202b4aj rewrite_logindev "#" ""
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Remove sys_labeling from /etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep -v "sys_labeling" ${ROOT_PATH}/etc/system > /tmp/etc.system.$$
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica mv /tmp/etc.system.$$ ${ROOT_PATH}/etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "sys_labeling" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ $? -eq 0 ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: ERROR: cannot remove sys_labeling in $ROOT_PATH/etc/system"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit $SMF_EXIT_ERR_FATAL
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica fi
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
8700009e2cc8cb186241e1fdd74973da1121ee4crica do_pamremove
8700009e2cc8cb186241e1fdd74973da1121ee4crica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica do_bootupd
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/bin/pkill -x -u 0 -P 1 -z `smf_zonename` labeld
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Stopped. Will take effect at next boot."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica ;;
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica*)
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "Usage: $0 { start | stop }"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica exit 1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica ;;
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaesac
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricaexit $SMF_EXIT_OK
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica