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 2007 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # libmapid02.sh - libmapid tests for the following configuration:
  28 #
  29 #       NFSMAPID_DOMAIN   DNS TXT RR      DNS domain  NIS domain
  30 #       ===============   ==============  ==========  ==========
  31 #       No                Yes             Yes         Yes
  32 #
  33 
  34 [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
  35 
  36 # set up script execution environment
  37 . ./dom_env
  38 
  39 # should run as root
  40 is_root "$NAME{setup}:" "All tests for domain affected"
  41 
  42 # comment out NFSMAPID_DOMAIN string in /etc/default/nfs
  43 comm_domain_default_nfs
  44 
  45 # refresh nfsmapid
  46 mapid_service refresh $TIMEOUT "failed to refresh mapid service" \
  47     "ERROR" || exit $UNINITIATED
  48 
  49 # start libmapid_syscfgd.ksh on the background
  50 libmapid_syscfgd >/dev/null 2>&1 &
  51 sleep 2
  52 ins=$(ps -ef | grep libmapid_syscfgd | grep -v grep | wc -l)
  53 (( "$ins" == 1 ))
  54 ckreturn $? "$ins instances of libmapid_syscfgd found" /dev/null "ERROR" \
  55     || exit $UNINITIATED
  56 
  57 # assertion list
  58 ASSERTIONS=${ASSERTIONS:-"a b c"}
  59 
  60 # generate assertion descriptions
  61 gen_assert_desc $NAME "as_"
  62 
  63 #
  64 # Assertion definition
  65 #
  66 
  67 # as_a: No domain in /etc/default/nfs, DNS up, TXT RR present, call 
  68 #       mapid_get_domain(), get TXT RR
  69 function as_a {
  70         [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
  71 
  72         exp=$txt_rr
  73         assertion a "$(get_assert_desc a)" $exp
  74 
  75         # Get mapid domain
  76         act=$(./get_domain)
  77         ckreturn $? "get_domain utility failed" /dev/null "UNRESOLVED" \
  78            || return $UNRESOLVED
  79 
  80         # check assertion
  81         ckres2 "get_domain" "$act" "$exp" "domains differ" || return $FAIL
  82 }
  83 
  84 # as_b: No domain in /etc/default/nfs, DNS up, TXT RR present, call
  85 #       mapid_derive_domain(), get TXT RR
  86 function as_b {
  87         [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
  88 
  89         exp=$txt_rr
  90         assertion b "$(get_assert_desc b)" $exp
  91 
  92         # Get mapid domain
  93         act=$(./derive_domain_dl)
  94         ckreturn $? "derive_domain_dl utility failed" /dev/null "UNRESOLVED" \
  95            || return $UNRESOLVED
  96 
  97         # check assertion
  98         ckres2 "derive_domain_dl" "$act" "$exp" "domains differ" || return $FAIL
  99 }
 100 
 101 # as_c: No domain in /etc/default/nfs, then it is added, the callback function
 102 #       passed to mapid_reeval_domain() is invoked
 103 function as_c {
 104         [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
 105 
 106         exp=0
 107         assertion c "$(get_assert_desc c)" $exp
 108 
 109         # setup and check callback function is called
 110         ./reeval_callback libmapid_modify_nfscfg libmapid_restore_nfscfg \
 111             >$LOGFILE 2>&1
 112 
 113         # Check Assertion
 114         ckres2 "reeval_callback" $? $exp "mapid_reeval_domain() failed" \
 115             $LOGFILE || return $FAIL
 116 }
 117 
 118 #
 119 # Run assertions
 120 #
 121 
 122 echo "\nLIBMAPID02 Starting Assertions\n"
 123 
 124 for i in $ASSERTIONS
 125 do
 126         eval as_${i} || print_state
 127 done
 128 
 129 echo "\nLIBMAPID02 assertions finished!\n"
 130 
 131 # notify libmapid_syscfgd.ksh to exit
 132 touch $TMPDIR/.libmapid/libmapid_quit
 133 wait_now 10 "! pgrep -z $(zonename) libmapid_syscfgd >/dev/null"