svc-allocate revision 269f47de02761bab3b7b28e2007a2bac34f629cc
f743002678eb67b99bbc29fee116b65d9530fec0wrowe#! /bin/sh
80833bb9a1bf25dcf19e814438a4b311d2e1f4cffuankg#
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem#
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# CDDL HEADER START
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic#
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# The contents of this file are subject to the terms of the
1337c7673efc1f80f634139fbad7cbb98a0dc657ylavic# Common Development and Distribution License (the "License").
4da61833a1cbbca94094f9653fd970582b97a72etrawick# You may not use this file except in compliance with the License.
4da61833a1cbbca94094f9653fd970582b97a72etrawick#
4da61833a1cbbca94094f9653fd970582b97a72etrawick# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4da61833a1cbbca94094f9653fd970582b97a72etrawick# or http://www.opensolaris.org/os/licensing.
4da61833a1cbbca94094f9653fd970582b97a72etrawick# See the License for the specific language governing permissions
4789804be088bcd86ae637a29cdb7fda25169521jailletc# and limitations under the License.
4789804be088bcd86ae637a29cdb7fda25169521jailletc#
4789804be088bcd86ae637a29cdb7fda25169521jailletc# When distributing Covered Code, include this CDDL HEADER in each
4789804be088bcd86ae637a29cdb7fda25169521jailletc# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e50c3026198fd496f183cda4c32a202925476778covener# If applicable, add the following below this CDDL HEADER, with the
e50c3026198fd496f183cda4c32a202925476778covener# fields enclosed by brackets "[]" replaced with your own identifying
e50c3026198fd496f183cda4c32a202925476778covener# information: Portions Copyright [yyyy] [name of copyright owner]
5b88c8507d5ef6d0c4cfbc78230294968175b638minfrin#
5b88c8507d5ef6d0c4cfbc78230294968175b638minfrin# CDDL HEADER END
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic#
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic# Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
6c3b9cebb551140fbb25d58bae08b539b3802133ylavic#
4f29b65ab4b547ad5dbe506e2d0ff5d12ead9247ylavic
4f29b65ab4b547ad5dbe506e2d0ff5d12ead9247ylavic. /lib/svc/share/smf_include.sh
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavic
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavicDEVALLOC=/etc/security/device_allocate
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavicDEVMAPS=/etc/security/device_maps
0a0df13b7f1f4f1a74fe295253d89ca3911b301aylavicDEVFSADM=/usr/sbin/devfsadm
69301145375a889e7e37caf7cc7321ac0f91801erpluemMKDEVALLOC=/usr/sbin/mkdevalloc
69301145375a889e7e37caf7cc7321ac0f91801erpluemMKDEVMAPS=/usr/sbin/mkdevmaps
69301145375a889e7e37caf7cc7321ac0f91801erpluemHALFDI=/etc/hal/fdi/policy/30user/90-solaris-device-allocation.fdi
506bfe33206b2fece40ef25f695af39dd4130facjkaluza
506bfe33206b2fece40ef25f695af39dd4130facjkaluza# dev_allocation_convert
506bfe33206b2fece40ef25f695af39dd4130facjkaluza# All the real work gets done in this function
506bfe33206b2fece40ef25f695af39dd4130facjkaluza
d58a848a016d401b965111e50ef829e1641f7834minfrindev_allocation_convert()
d58a848a016d401b965111e50ef829e1641f7834minfrin{
d58a848a016d401b965111e50ef829e1641f7834minfrin#
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sf# If allocation already configured, just return
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sf#
2e6f4d654c96c98b761fb012fd25c5d5b1558c44sfif [ -f ${HALFDI} -a -f ${DEVALLOC} -a -f ${DEVMAPS} ]; then
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic return
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavicfi
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic# Prevent automount of removable and hotpluggable volume
17e6c95f3b22d18acdf8380fb26a8d0e10c80767ylavic# by forcing volume.ignore HAL property on all such volumes.
e8bd80a4bb88199d2f9a24a50345688e52d9c116ylavicif [ ! -f ${HALFDI} ]; then
e8bd80a4bb88199d2f9a24a50345688e52d9c116ylavic cat > ${HALFDI} <<FDI
e8bd80a4bb88199d2f9a24a50345688e52d9c116ylavic<?xml version="1.0" encoding="UTF-8"?>
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic<deviceinfo version="0.2">
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <device>
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <match key="info.capabilities" contains="volume">
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <match key="@block.storage_device:storage.removable" bool="true">
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <merge key="volume.ignore" type="bool">true</merge>
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic </match>
330e16bea8fe9cace4de90c349750c03dfb1fe64ylavic <match key="@block.storage_device:storage.hotpluggable" bool="true">
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener <merge key="volume.ignore" type="bool">true</merge>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener </match>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener </match>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener </device>
d7205b1a86c51c27b71a2c458dc453fd53a261c1covener</deviceinfo>
44ff304057225e944e220e981d434a046d14cf06covenerFDI
44ff304057225e944e220e981d434a046d14cf06covenerfi
44ff304057225e944e220e981d434a046d14cf06covener
44ff304057225e944e220e981d434a046d14cf06covener# Initialize device allocation
5d1ba75b8794925e67591c209085a49279791de9covener
5d1ba75b8794925e67591c209085a49279791de9covener
5d1ba75b8794925e67591c209085a49279791de9covener# Need to determine if Trusted Extensions is enabled.
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand# Check the setting in etc/system (other methods won't work
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand# because TX is likely not yet fully active.)
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrand#
032982212dbcc7c3cce95bf89c503bb56e185ac7kbrandgrep "^[ ]*set[ ][ ]*sys_labeling[ ]*=[ ]*1" \
caad2986f81ab263f7af41467dd622dc9add17f3ylavic /etc/system > /dev/null 2>&1
caad2986f81ab263f7af41467dd622dc9add17f3ylavic
caad2986f81ab263f7af41467dd622dc9add17f3ylavicif [ $? = 0 ]; then
caad2986f81ab263f7af41467dd622dc9add17f3ylavic # Trusted Extensions is enabled (but possibly not yet booted).
45a10d38e6051fd7bdf9d742aaae633d97ff02abjailletc ${DEVFSADM} -e
f7317ff316c2b141feea31bddb74d5d3fa1584edjortonelse
f7317ff316c2b141feea31bddb74d5d3fa1584edjorton if [ ! -f ${DEVALLOC} ]; then
2165214331e4afafca4048f66f303d0253d7b001covener echo "DEVICE_ALLOCATION=ON" > $DEVALLOC
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem ${MKDEVALLOC} >> $DEVALLOC
a34684a59b60a4173c25035d0c627ef17e6dc215rpluem fi
1e2d421a36999d292042a5539971070d54aa6c63ylavic if [ ! -f ${DEVMAPS} ]; then
1e2d421a36999d292042a5539971070d54aa6c63ylavic ${MKDEVMAPS} > $DEVMAPS
1e2d421a36999d292042a5539971070d54aa6c63ylavic fi
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedoohfi
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh}
fa7ed98b9dc94c5845cf845aea0a44ecacd290c9humbedooh
0b67eb8568cd58bb77082703951679b42cf098actrawickdev_allocation_unconvert()
0b67eb8568cd58bb77082703951679b42cf098actrawick{
0b67eb8568cd58bb77082703951679b42cf098actrawick # Turn off device allocation.
0b67eb8568cd58bb77082703951679b42cf098actrawick ${DEVFSADM} -d
5ef3c61605a3a021ff71f488983cb0065f8e1a79covener /usr/bin/rm -f $DEVALLOC $DEVMAPS
fb1985a97912b25ec6564c73e610a31e5fc6e25fcovener # Restore default policy for removable and hotpluggable volumes
09c87c777bed1655621bb20e1c46cb6b1a63279dcovener /usr/bin/rm -f $HALFDI
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic}
6502b7b32f980cc2093bb3ebce37e5e4dc68fba4ylavic
3060ce7f798fbda7999cd4ddf89b525d2b294185covenercase "$1" in
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic'start')
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic dev_allocation_convert
c1a63b8fad09c419c1a64f75993feb8a343a6801ylavic deallocate -Is
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc ;;
e6b4bd1113567627ab6bb6c6a7105e1e01a7d889jailletc'stop')
e466c40e1801982602ee0200c9e8b61cc148742djailletc state=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI 2>/dev/null`
e466c40e1801982602ee0200c9e8b61cc148742djailletc if [ "$state" = "true" ] ; then
457468b82e59d01eba00dd9d0817309c8f5e414ejim exit $SMF_EXIT_OK
457468b82e59d01eba00dd9d0817309c8f5e414ejim fi
457468b82e59d01eba00dd9d0817309c8f5e414ejim dev_allocation_unconvert
04983e3bd1754764eec7d6bb772fe3b0bf391771jorton ;;
04983e3bd1754764eec7d6bb772fe3b0bf391771jortonesac
15890c9306ba98f6fc243e15a3c4778ddc7d773erpluem
15660979a30d251681463de2e0584853890082accovenerexit $SMF_EXIT_OK
15660979a30d251681463de2e0584853890082accovener