1 #! /usr/bin/ksh -p
   2 #
   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 
  28 #
  29 # start __stf_assertion__
  30 #
  31 # ASSERTION: context_037
  32 # DESCRIPTION:
  33 #  svc.startd will not start a method using the limit privilege set
  34 #  specified by the limit_privileges attribute of the
  35 #  method_credential element if the set specified does not conform
  36 #  to a privilege set, but will instead transition it to maintenance
  37 #  mode.
  38 #
  39 # end __stf_assertion__
  40 #
  41 
  42 . ${STF_TOOLS}/include/stf.kshlib
  43 . ${STF_SUITE}/include/gltest.kshlib
  44 . ${STF_SUITE}/include/svc.startd_config.kshlib
  45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  46 
  47 typeset service_setup=0
  48 function cleanup {
  49         common_cleanup
  50 }
  51 
  52 trap cleanup 0 1 2 15
  53 
  54 readonly ME=$(whence -p ${0})
  55 readonly MYLOC=$(dirname ${ME})
  56 
  57 DATA=$MYLOC
  58 
  59 readonly registration_template=$DATA/service_037.xml
  60 
  61 extract_assertion_info $ME
  62 
  63 # construct a privileges string that is invalid
  64 typeset limitprivs="winged_flying_lemurs"
  65 
  66 # make sure that the svc.startd is running
  67 verify_daemon
  68 if [ $? -ne 0 ]; then
  69         echo "--DIAG: $assertion: svc.startd is not executing. Cannot "
  70         echo "  continue"
  71         exit $STF_UNRESOLVED
  72 fi
  73 
  74 # Make sure the environment is clean - the test service isn't running
  75 echo "--INFO: Cleanup any old $test_FMRI state"
  76 service_cleanup $test_service
  77 if [ $? -ne 0 ]; then
  78         echo "--DIAG: $assertion: cleanup of a previous instance failed"
  79         exit $STF_UNRESOLVED
  80 fi
  81 
  82 echo "--INFO: create world read/writeable log file for the service"
  83 rm -f $service_log
  84 touch $service_log
  85 if [ $? -ne 0 ]; then
  86         echo "--DIAG: $assertion: could not create log file"
  87         exit $STF_UNRESOLVED
  88 fi
  89 chmod a+rw $service_log
  90 if [ $? -ne 0 ]; then
  91         echo "--DIAG: $assertion: could not make log file world writeable"
  92         exit $STF_UNRESOLVED
  93 fi
  94 
  95 echo "--INFO: Make sure the $RUNDIR is world r/w/x"
  96 chmod a+rwx $RUNDIR
  97 if [ $? -ne 0 ]; then
  98         echo "--DIAG: $assertion: could not make $RUNDIR mode 777"
  99         exit $STF_UNRESOLVED
 100 fi
 101 
 102 echo "--INFO: generating manifest for importation into repository"
 103 manifest_generate $registration_template \
 104         TEST_SERVICE=$test_service \
 105         TEST_INSTANCE=$test_instance \
 106         SERVICE_APP=$service_app \
 107         LOGFILE=$service_log \
 108         LIMIT_PRIVSET="$limitprivs" \
 109         STATEFILE=$service_state > $registration_file
 110 manifest_zone_clean $registration_file
 111 
 112 echo "--INFO: Importing service into repository"
 113 manifest_purgemd5 $registration_file
 114 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 115 
 116 if [ $? -ne 0 ]; then
 117         echo "--DIAG: $assertion: Unable to import the service $test_FMRI"
 118         echo "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 119         exit $STF_UNRESOLVED
 120 fi
 121 service_setup=1
 122 
 123 echo "--INFO: Wait for $test_FMRI to enter maintenance mode"
 124 service_wait_state $test_FMRI maintenance
 125 if [ $? -ne 0 ]; then
 126         echo "--DIAG: $assertion: Service $test_FMRI did not go to maintenance"
 127         echo "  it is in '$(svcs -H -o STATE $test_FMRI)' mode."
 128         exit $STF_FAIL
 129 fi
 130 
 131 echo "--INFO: Cleaning up service"
 132 cleanup
 133 
 134 exit $STF_PASS