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_035
32 # DESCRIPTION:
33 # Supplemental groups specified for a service method cause that
34 # service's method to be executed with the supplemental group ids
35 # set to those in the set.
36 #
37 # end __stf_assertion__
38 #
39
40 . ${STF_TOOLS}/include/stf.kshlib
41 . ${STF_SUITE}/include/gltest.kshlib
42 . ${STF_SUITE}/include/svc.startd_config.kshlib
43 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
44
45 typeset service_setup=0
46 function cleanup {
47 common_cleanup
48 }
49
50 trap cleanup 0 1 2 15
51
52 readonly ME=$(whence -p ${0})
53 readonly MYLOC=$(dirname ${ME})
54
55 CTX_UID=`getent passwd $ctx_user | cut -f 3 -d:`
56 CTX_GID=`getent group $ctx_group | cut -f 3 -d:`
57
58 typeset SUPPGROUPS=
59 typeset ngroups=0
60 typeset atgr=0
61
62 print -- "--INFO: acquiring the name of 5 groups"
63 while [ $ngroups -lt 5 ]; do
64 gn=`getent group $atgr | cut -d: -f 1`
65 if [ -n "$gn" ]; then
66 ngroups=$((ngroups + 1))
67 if [ -z "$SUPPGROUPS" ]; then
68 SUPPGROUPS=$gn
69 else
70 SUPPGROUPS="$SUPPGROUPS,$gn"
71 fi
72 fi
73 atgr=$((atgr + 1))
74 done
75
76 DATA=$MYLOC
77
78 readonly registration_template=$DATA/service_035.xml
79
80 extract_assertion_info $ME
81
82 # make sure that the svc.startd is running
83 verify_daemon
84 if [ $? -ne 0 ]; then
85 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
86 print -- " continue"
87 exit $STF_UNRESOLVED
88 fi
89
90 # Make sure the environment is clean - the test service isn't running
91 print -- "--INFO: Cleanup any old $test_FMRI state"
92 service_cleanup $test_service
93 if [ $? -ne 0 ]; then
94 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
95 exit $STF_UNRESOLVED
96 fi
97
98 print -- "--INFO: create world read/writeable log file for the service"
99 rm -f $service_log
100 touch $service_log
101 if [ $? -ne 0 ]; then
102 print -- "--DIAG: $assertion: could not create log file"
103 exit $STF_UNRESOLVED
104 fi
105 chmod a+rw $service_log
106 if [ $? -ne 0 ]; then
107 print -- "--DIAG: $assertion: could not make log file world writeable"
108 exit $STF_UNRESOLVED
109 fi
110 chmod a+rwx $RUNDIR
111 if [ $? -ne 0 ]; then
112 print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
113 exit $STF_UNRESOLVED
114 fi
115
116 print -- "--INFO: generating manifest for importation into repository"
117 manifest_generate $registration_template \
118 TEST_SERVICE=$test_service \
119 TEST_INSTANCE=$test_instance \
120 SERVICE_APP=$service_app \
121 LOGFILE=$service_log \
122 TEST_USER=$CTX_UID \
123 TEST_GROUP=$CTX_GID \
124 TEST_ADDGROUPS="$SUPPGROUPS" \
125 STATEFILE=$service_state > $registration_file
126 manifest_zone_clean $registration_file
127
128 print -- "--INFO: Importing service into repository"
129 manifest_purgemd5 $registration_file
130 svccfg -v import $registration_file >$svccfg_errfile 2>&1
131
132 if [ $? -ne 0 ]; then
133 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
134 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
135 exit $STF_UNRESOLVED
136 fi
137 service_setup=1
138
139 print -- "--INFO: Wait for $test_FMRI to come online"
140 service_wait_state $test_FMRI online
141 if [ $? -ne 0 ]; then
142 print -- "--DIAG: $assertion: Service $test_FMRI did not go online"
143 exit $STF_FAIL
144 fi
145
146 print -- "--INFO: Checking start methods suppgroupnames are '$SUPPGROUPS'"
147 line=`grep_logline_entry $test_service $test_instance start suppgroupnames`
148 if [ $? -ne 0 ]; then
149 print -- "--DIAG: Could not find suppgroupnames line from "
150 print -- " start method '${line}'"
151 exit $STF_FAIL
152 fi
153 if [ "$line" != "$SUPPGROUPS" ]; then
154 print -- "--DIAG: $assertion: groups of execution $line wasn't "
155 print -- " $SUPPGROUPS"
156 exit $STF_FAIL
157 fi
158
159 print -- "--INFO: Cleaning up service"
160 cleanup
161
162 exit $STF_PASS