svc-allocate revision 269f47de02761bab3b7b28e2007a2bac34f629cc
1028N/A#! /bin/sh
1028N/A#
1108N/A#
1028N/A# CDDL HEADER START
1028N/A#
951N/A# The contents of this file are subject to the terms of the
951N/A# Common Development and Distribution License (the "License").
951N/A# You may not use this file except in compliance with the License.
951N/A#
951N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
951N/A# or http://www.opensolaris.org/os/licensing.
951N/A# See the License for the specific language governing permissions
951N/A# and limitations under the License.
951N/A#
951N/A# When distributing Covered Code, include this CDDL HEADER in each
951N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
951N/A# If applicable, add the following below this CDDL HEADER, with the
951N/A# fields enclosed by brackets "[]" replaced with your own identifying
951N/A# information: Portions Copyright [yyyy] [name of copyright owner]
951N/A#
951N/A# CDDL HEADER END
951N/A#
951N/A# Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
951N/A#
951N/A
951N/A. /lib/svc/share/smf_include.sh
951N/A
951N/ADEVALLOC=/etc/security/device_allocate
951N/ADEVMAPS=/etc/security/device_maps
1097N/ADEVFSADM=/usr/sbin/devfsadm
1425N/AMKDEVALLOC=/usr/sbin/mkdevalloc
1425N/AMKDEVMAPS=/usr/sbin/mkdevmaps
951N/AHALFDI=/etc/hal/fdi/policy/30user/90-solaris-device-allocation.fdi
951N/A
951N/A# dev_allocation_convert
951N/A# All the real work gets done in this function
951N/A
951N/Adev_allocation_convert()
1274N/A{
951N/A#
951N/A# If allocation already configured, just return
1407N/A#
1274N/Aif [ -f ${HALFDI} -a -f ${DEVALLOC} -a -f ${DEVMAPS} ]; then
951N/A return
951N/Afi
951N/A
951N/A# Prevent automount of removable and hotpluggable volume
951N/A# by forcing volume.ignore HAL property on all such volumes.
951N/Aif [ ! -f ${HALFDI} ]; then
1097N/A cat > ${HALFDI} <<FDI
1029N/A<?xml version="1.0" encoding="UTF-8"?>
1425N/A<deviceinfo version="0.2">
1425N/A <device>
951N/A <match key="info.capabilities" contains="volume">
951N/A <match key="@block.storage_device:storage.removable" bool="true">
951N/A <merge key="volume.ignore" type="bool">true</merge>
951N/A </match>
1029N/A <match key="@block.storage_device:storage.hotpluggable" bool="true">
1029N/A <merge key="volume.ignore" type="bool">true</merge>
951N/A </match>
951N/A </match>
951N/A </device>
951N/A</deviceinfo>
951N/AFDI
951N/Afi
951N/A
1028N/A# Initialize device allocation
951N/A
951N/A
951N/A# Need to determine if Trusted Extensions is enabled.
951N/A# Check the setting in etc/system (other methods won't work
951N/A# because TX is likely not yet fully active.)
951N/A#
951N/Agrep "^[ ]*set[ ][ ]*sys_labeling[ ]*=[ ]*1" \
951N/A /etc/system > /dev/null 2>&1
951N/A
951N/Aif [ $? = 0 ]; then
951N/A # Trusted Extensions is enabled (but possibly not yet booted).
951N/A ${DEVFSADM} -e
951N/Aelse
951N/A if [ ! -f ${DEVALLOC} ]; then
951N/A echo "DEVICE_ALLOCATION=ON" > $DEVALLOC
951N/A ${MKDEVALLOC} >> $DEVALLOC
968N/A fi
968N/A if [ ! -f ${DEVMAPS} ]; then
951N/A ${MKDEVMAPS} > $DEVMAPS
951N/A fi
951N/Afi
951N/A}
951N/A
951N/Adev_allocation_unconvert()
951N/A{
951N/A # Turn off device allocation.
951N/A ${DEVFSADM} -d
951N/A /usr/bin/rm -f $DEVALLOC $DEVMAPS
951N/A # Restore default policy for removable and hotpluggable volumes
951N/A /usr/bin/rm -f $HALFDI
951N/A}
951N/A
case "$1" in
'start')
dev_allocation_convert
deallocate -Is
;;
'stop')
state=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI 2>/dev/null`
if [ "$state" = "true" ] ; then
exit $SMF_EXIT_OK
fi
dev_allocation_unconvert
;;
esac
exit $SMF_EXIT_OK