Print this page
    
4360 Fix SMF methods and other scripts which rely on the system shell to use /sbin/sh
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/cmd/allocate/svc-allocate
          +++ new/usr/src/cmd/allocate/svc-allocate
   1      -#! /bin/sh
        1 +#! /sbin/sh
   2    2  #
   3    3  #
   4    4  # CDDL HEADER START
   5    5  #
   6    6  # The contents of this file are subject to the terms of the
   7    7  # Common Development and Distribution License (the "License").
   8    8  # You may not use this file except in compliance with the License.
   9    9  #
  10   10  # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  11   11  # or http://www.opensolaris.org/os/licensing.
  12   12  # See the License for the specific language governing permissions
  13   13  # and limitations under the License.
  14   14  #
  15   15  # When distributing Covered Code, include this CDDL HEADER in each
  16   16  # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  17   17  # If applicable, add the following below this CDDL HEADER, with the
  18   18  # fields enclosed by brackets "[]" replaced with your own identifying
  19   19  # information: Portions Copyright [yyyy] [name of copyright owner]
  20   20  #
  21   21  # CDDL HEADER END
  22   22  #
  23   23  # Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24  #
  25   25  
  26   26  . /lib/svc/share/smf_include.sh
  27   27  
  28   28  DEVALLOC=/etc/security/device_allocate
  29   29  DEVMAPS=/etc/security/device_maps
  30   30  DEVFSADM=/usr/sbin/devfsadm
  31   31  MKDEVALLOC=/usr/sbin/mkdevalloc
  32   32  MKDEVMAPS=/usr/sbin/mkdevmaps
  33   33  HALFDI=/etc/hal/fdi/policy/30user/90-solaris-device-allocation.fdi
  34   34  
  35   35  # dev_allocation_convert
  36   36  #       All the real work gets done in this function
  37   37  
  38   38  dev_allocation_convert()
  39   39  {
  40   40  #
  41   41  # If allocation already configured, just return
  42   42  #
  43   43  if [ -f ${HALFDI} -a -f ${DEVALLOC} -a -f ${DEVMAPS} ]; then
  44   44      return
  45   45  fi
  46   46  
  47   47  # Prevent automount of removable and hotpluggable volume
  48   48  # by forcing volume.ignore HAL property on all such volumes.
  49   49  if [ ! -f ${HALFDI} ]; then
  50   50          cat > ${HALFDI} <<FDI
  51   51  <?xml version="1.0" encoding="UTF-8"?>
  52   52  <deviceinfo version="0.2">
  53   53    <device>
  54   54      <match key="info.capabilities" contains="volume">
  55   55        <match key="@block.storage_device:storage.removable" bool="true">
  56   56          <merge key="volume.ignore" type="bool">true</merge>
  57   57        </match>
  58   58        <match key="@block.storage_device:storage.hotpluggable" bool="true">
  59   59          <merge key="volume.ignore" type="bool">true</merge>
  60   60        </match>
  61   61      </match>
  62   62    </device>
  63   63  </deviceinfo>
  64   64  FDI
  65   65  fi
  66   66  
  67   67  # Initialize device allocation
  68   68  
  69   69  
  70   70  # Need to determine if Trusted Extensions is enabled.
  71   71  # Check the setting in etc/system (other methods won't work 
  72   72  # because TX is likely not yet fully active.)
  73   73  #
  74   74  grep "^[        ]*set[  ][      ]*sys_labeling[         ]*=[    ]*1" \
  75   75      /etc/system > /dev/null 2>&1
  76   76  
  77   77  if [ $? = 0 ]; then
  78   78          # Trusted Extensions is enabled (but possibly not yet booted).
  79   79          ${DEVFSADM} -e
  80   80  else
  81   81          if [ ! -f ${DEVALLOC} ]; then
  82   82                  echo "DEVICE_ALLOCATION=ON" > $DEVALLOC
  83   83                  ${MKDEVALLOC} >> $DEVALLOC
  84   84          fi
  85   85          if [ ! -f ${DEVMAPS} ]; then
  86   86                  ${MKDEVMAPS} > $DEVMAPS
  87   87          fi
  88   88  fi
  89   89  }
  90   90  
  91   91  dev_allocation_unconvert()
  92   92  {
  93   93          # Turn off device allocation.
  94   94          ${DEVFSADM} -d
  95   95          /usr/bin/rm -f $DEVALLOC $DEVMAPS
  96   96          # Restore default policy for removable and hotpluggable volumes
  97   97          /usr/bin/rm -f $HALFDI
  98   98  }
  99   99  
 100  100  case "$1" in
 101  101  'start')
 102  102          dev_allocation_convert
 103  103          deallocate -Is
 104  104          ;;
 105  105  'stop')
 106  106          state=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI 2>/dev/null`
 107  107          if [ "$state" = "true" ] ; then
 108  108                  exit $SMF_EXIT_OK
 109  109          fi
 110  110          dev_allocation_unconvert
 111  111          ;;
 112  112  esac
 113  113  
 114  114  exit $SMF_EXIT_OK 
  
    | ↓ open down ↓ | 103 lines elided | ↑ open up ↑ | 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX