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 # libmapid03.sh - libmapid tests for the following configuration:
28 #
29 # NFSMAPID_DOMAIN DNS TXT RR DNS domain NIS domain
30 # =============== ============== ========== ==========
31 # No No 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 # restart DNS server
46 dns_service disable $TIMEOUT "failed to disable dns service" \
47 "UNRESOLVED" || exit $UNINITIATED
48
49 # refresh nfsmapid
50 mapid_service refresh $TIMEOUT "failed to refresh mapid service" \
51 "ERROR" || exit $UNINITIATED
52
53 # start libmapid_syscfgd.ksh on the background
54 libmapid_syscfgd >/dev/null 2>&1 &
55 sleep 2
56 ins=$(ps -ef | grep libmapid_syscfgd | grep -v grep | wc -l)
57 (( "$ins" == 1 ))
58 ckreturn $? "$ins instances of libmapid_syscfgd found" /dev/null "ERROR" \
59 || exit $UNINITIATED
60
61 # assertion list
62 ASSERTIONS=${ASSERTIONS:-"a b c"}
63
64 # generate assertion descriptions
65 gen_assert_desc $NAME "as_"
66
67 #
68 # Assertion definition
69 #
70
71 # as_a: No domain in /etc/default/nfs, DNS down, call mapid_get_domain(),
72 # get domain from /etc/resolv.conf
73 function as_a {
74 [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
75
76 exp=$dns_domain
77 assertion a "$(get_assert_desc a)" $exp
78
79 # Get mapid domain
80 act=$(./get_domain)
81 ckreturn $? "get_domain utility failed" /dev/null "UNRESOLVED" \
82 || return $UNRESOLVED
83
84 # check assertion
85 ckres2 "get_domain" "$act" "$exp" "domains differ" || return $FAIL
86 }
87
88 # as_b: No domain in /etc/default/nfs, DNS down, call mapid_derive_domain(),
89 # get domain from /etc/resolv.conf
90 function as_b {
91 [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
92
93 exp=$dns_domain
94 assertion b "$(get_assert_desc b)" $exp
95
96 # Get mapid domain
97 act=$(./derive_domain_dl)
98 ckreturn $? "derive_domain_dl utility failed" /dev/null "UNRESOLVED" \
99 || return $UNRESOLVED
100
101 # check assertion
102 ckres2 "derive_domain_dl" "$act" "$exp" "domains differ" || return $FAIL
103 }
104
105 # as_c: No domain in /etc/default/nfs, DNS server down. Then server up, TXT
106 # RR present, the callback function passed to mapid_reeval_domain()
107 # is invoked
108 function as_c {
109 [[ -n "$DEBUG" ]] && [[ $DEBUG != 0 ]] && set -x
110
111 exp=0
112 assertion c "$(get_assert_desc c)" $exp
113
114 # setup and check callback function is called
115 ./reeval_callback libmapid_start_dns libmapid_shutdown_dns \
116 >$LOGFILE 2>&1
117
118 # Check Assertion
119 ckres2 "reeval_callback" $? $exp "mapid_reeval_domain() failed" \
120 $LOGFILE || return $FAIL
121 }
122
123 #
124 # Run assertions
125 #
126
127 echo "\nLIBMAPID03 Starting Assertions\n"
128
129 for i in $ASSERTIONS
130 do
131 eval as_${i} || print_state
132 done
133
134 echo "\nLIBMAPID03 assertions finished!\n"
135
136 # notify libmapid_syscfgd.ksh to exit
137 touch $TMPDIR/.libmapid/libmapid_quit
138 wait_now 10 "! pgrep -z $(zonename) libmapid_syscfgd >/dev/null"