svc-labeld revision f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# CDDL HEADER START
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# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# See the License for the specific language governing permissions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# and limitations under the License.
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# CDDL HEADER END
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# Use is subject to license terms.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica#ident "%Z%%M% %I% %E% SMI"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid syntax"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid syntax: -R allowed for start method only"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: invalid -R rootpath dir specified"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: not supported in a local zone"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Comment out audio and usb device entries in /etc/logindevperm.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -f $LOGINDEVPERM ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica line="\/dev\/console 0600 \/dev\/usb\/\[0-9a-f\]+\[.\]\[0-9a-f\]+\/\[0-9\]+\/\*"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica cat >> $ROOT_PATH/var/svc/profile/upgrade <<\__ENABLE_OTHERS
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica /usr/sbin/svcadm enable -s svc:/system/tsol-zones:default
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Run bsmconv so audit and device allocation is enabled by
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica# For Trusted Extensions, make nscd service transient in local zones.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01ricacat >> $ROOT_PATH/var/svc/profile/upgrade <<\_DEL_LOCAL_NSCD
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -f $ROOT_PATH/platform/`/sbin/uname -m`/boot_archive ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ ! -f ${ROOT_PATH}/etc/system ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep -v "sys_labeling=" ${ROOT_PATH}/etc/system > /tmp/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 # If a labeld door exists, check for a labeld process and exit
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if /usr/bin/pgrep -x -u 0 -P 1 labeld >/dev/null 2>&1; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -z "$SMF_FMRI" ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: this script can only be invoked by smf(5)"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica tx_enabled=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # A sign of trying temporary enablement...no-no
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Temporarily enabling Trusted Extensions is not allowed."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Make changes to enable Trusted Extensions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "^set sys_labeling=1" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: already enabled. Exiting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Must remove zones before enabling Trusted Extensions."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # start daemon proccess so our service doesn't go into
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # maintenance state
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Started. Must reboot and configure Trusted Extensions."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Support jumpstart etc
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Make changes to enable Trusted Extensions
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "^set sys_labeling=1" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: already enabled. Exiting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Setup dependent services
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica cat >> $ROOT_PATH/var/svc/profile/upgrade <<\__TRUSTED_ENABLE
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Started. Must configure Trusted Extensions before booting."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica tx_enabled=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Must remove zones before disabling Trusted Extensions."
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 # Uncomment audio and usb device entries in /etc/logindevperm.
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica if [ -f $LOGINDEVPERM ]; then
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica line="\/dev\/console 0600 \/dev\/usb\/\[0-9a-f\]+\[.\]\[0-9a-f\]+\/\[0-9\]+\/\*"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica # Remove sys_labeling from /etc/system
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep -v "sys_labeling" ${ROOT_PATH}/etc/system > /tmp/etc.system.$$
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica grep "sys_labeling" ${ROOT_PATH}/etc/system > /dev/null 2>&1
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: ERROR: cannot remove sys_labeling in $ROOT_PATH/etc/system"
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "$0: Stopped. Will take effect at next boot."
f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01rica echo "Usage: $0 { start | stop }"