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_006
32 # DESCRIPTION:
33 # Attempting to start a service with an invalid privilege set
34 # will result in an error. svc.startd will re-attempt to start
35 # the service until the error threshold is reached and, at that
36 # point, the service will be placed into maintenance state.
37 #
38 # end __stf_assertion__
39 #
40
41 . ${STF_TOOLS}/include/stf.kshlib
42 . ${STF_SUITE}/include/gltest.kshlib
43 . ${STF_SUITE}/include/svc.startd_config.kshlib
44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
45
46 typeset service_setup=0
47 function cleanup {
48 common_cleanup
49 }
50
51 trap cleanup 0 1 2 15
52
53 readonly ME=$(whence -p ${0})
54 readonly MYLOC=$(dirname ${ME})
55
56 CTX_UID=`getent passwd $ctx_user | cut -f 3 -d:`
57 CTX_GID=`getent group $ctx_group | cut -f 3 -d:`
58
59 DATA=$MYLOC
60
61 readonly registration_template=$DATA/service_006.xml
62
63 extract_assertion_info $ME
64
65 # make sure that the svc.startd is running
66 verify_daemon
67 if [ $? -ne 0 ]; then
68 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
69 print -- " continue"
70 exit $STF_UNRESOLVED
71 fi
72
73 # Make sure the environment is clean - the test service isn't running
74 print -- "--INFO: Cleanup any old $test_FMRI state"
75 service_cleanup $test_service
76 if [ $? -ne 0 ]; then
77 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
78 exit $STF_UNRESOLVED
79 fi
80
81 print -- "--INFO: create world read/writeable log file for the service"
82 rm -f $service_log
83 touch $service_log
84 if [ $? -ne 0 ]; then
85 print -- "--DIAG: $assertion: could not create log file"
86 exit $STF_UNRESOLVED
87 fi
88 chmod a+rw $service_log
89 if [ $? -ne 0 ]; then
90 print -- "--DIAG: $assertion: could not make log file world writeable"
91 exit $STF_UNRESOLVED
92 fi
93 chmod a+rwx $RUNDIR
94 if [ $? -ne 0 ]; then
95 print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
96 exit $STF_UNRESOLVED
97 fi
98
99 print -- "--INFO: generating manifest for importation into repository"
100 manifest_generate $registration_template \
101 TEST_SERVICE=$test_service \
102 TEST_INSTANCE=$test_instance \
103 SERVICE_APP=$service_app \
104 LOGFILE=$service_log \
105 TEST_USER=$ctx_user \
106 TEST_GROUP=$ctx_group \
107 STATEFILE=$service_state > $registration_file
108
109 print -- "--INFO: Importing service into repository"
110 manifest_purgemd5 $registration_file
111 svccfg -v import $registration_file >$svccfg_errfile 2>&1
112
113 if [ $? -ne 0 ]; then
114 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
115 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
116 exit $STF_UNRESOLVED
117 fi
118 service_setup=1
119
120 print -- "--INFO: Wait for $test_FMRI to go to maintenance"
121 service_wait_state $test_FMRI maintenance
122 if [ $? -ne 0 ]; then
123 print -- "--DIAG: $assertion: Service $test_FMRI did not go to"
124 print -- " maintenance"
125 exit $STF_FAIL
126 fi
127
128 print -- "--INFO: Cleaning up service"
129 cleanup
130
131 exit $STF_PASS