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_010
  32 # DESCRIPTION:
  33 #  A method with a group id specified that does not exist in the group
  34 #  name service shall be executed under that group ID.
  35 #
  36 # end __stf_assertion__
  37 #
  38 
  39 . ${STF_TOOLS}/include/stf.kshlib
  40 . ${STF_SUITE}/include/gltest.kshlib
  41 . ${STF_SUITE}/include/svc.startd_config.kshlib
  42 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  43 
  44 typeset service_setup=0
  45 function cleanup {
  46         common_cleanup
  47 }
  48 
  49 trap cleanup 0 1 2 15
  50 
  51 readonly ME=$(whence -p ${0})
  52 readonly MYLOC=$(dirname ${ME})
  53 
  54 # Find an unused group:
  55 test_id=0
  56 while [ -n "`getent group $test_id`" ]; do
  57         test_id=$((test_id + 1))
  58 done
  59 
  60 DATA=$MYLOC
  61 
  62 readonly registration_template=$DATA/service_010.xml
  63 
  64 extract_assertion_info $ME
  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 chmod a+rwx $RUNDIR
  95 if [ $? -ne 0 ]; then
  96         echo "--DIAG: $assertion: could not make $RUNDIR world rwx"
  97         exit $STF_UNRESOLVED
  98 fi
  99 
 100 echo "--INFO: generating manifest for importation into repository"
 101 manifest_generate $registration_template \
 102         TEST_SERVICE=$test_service \
 103         TEST_INSTANCE=$test_instance \
 104         SERVICE_APP=$service_app \
 105         LOGFILE=$service_log \
 106         TEST_USER=$ctx_user \
 107         TEST_GROUP=$test_id \
 108         STATEFILE=$service_state > $registration_file
 109 manifest_zone_clean $registration_file
 110 
 111 echo "--INFO: Importing service into repository"
 112 manifest_purgemd5 $registration_file
 113 svccfg -v import $registration_file >$svccfg_errfile 2>&1
 114 
 115 if [ $? -ne 0 ]; then
 116         echo "--DIAG: $assertion: Unable to import the service $test_FMRI"
 117         echo "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
 118         exit $STF_UNRESOLVED
 119 fi
 120 service_setup=1
 121 
 122 echo "--INFO: Wait for $test_FMRI to go to online"
 123 service_wait_state $test_FMRI online
 124 if [ $? -ne 0 ]; then
 125         echo "--DIAG: $assertion: Service $test_FMRI did not go to"
 126         echo "  online State was: '$(svcs -H -o STATE $test_FMRI)'"
 127         exit $STF_FAIL
 128 fi
 129 
 130 echo "--INFO: Verifying group id was $test_id"
 131 line=$(grep_logline_entry $test_service $test_instance start groupid)
 132 if [ $? -ne 0 ]; then
 133         echo "--DIAG: $assertion: could not find groupid in the service log"
 134         exit $STF_FAIL
 135 fi
 136 
 137 if [ "$line" != "$test_id" ]; then
 138         echo "--DIAG: $assertion: group id was '$line' instead of '$test_id'"
 139         exit $STF_FAIL
 140 fi
 141 
 142 echo "--INFO: Cleaning up service"
 143 cleanup
 144 
 145 exit $STF_PASS