Print this page
7928 Add support for SMF_EXIT_TEMP_TRANSIENT
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/vntsd/svc-vntsd
+++ new/usr/src/cmd/vntsd/svc-vntsd
1 1 #!/sbin/sh
2 2 #
3 3 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
4 4 # Use is subject to license terms.
5 5 #
6 +# Copyright 2017 RackTop Systems.
7 +#
6 8 # CDDL HEADER START
7 9 #
8 10 # The contents of this file are subject to the terms of the
9 11 # Common Development and Distribution License (the "License").
10 12 # You may not use this file except in compliance with the License.
11 13 #
12 14 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13 15 # or http://www.opensolaris.org/os/licensing.
14 16 # See the License for the specific language governing permissions
15 17 # and limitations under the License.
16 18 #
17 19 # When distributing Covered Code, include this CDDL HEADER in each
18 20 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19 21 # If applicable, add the following below this CDDL HEADER, with the
20 22 # fields enclosed by brackets "[]" replaced with your own identifying
21 23 # information: Portions Copyright [yyyy] [name of copyright owner]
22 24 #
23 25 # CDDL HEADER END
24 26 #
25 27 # Start script for vntsd
26 28 #
27 29 # For modifying parameters passed to vntsd, do not edit
28 30 # this script. Instead use svccfg(1m) to modify the SMF
29 31 # repository. For example:
30 32 #
31 33 # svccfg
32 34 # svc:> select ldoms/vntsd
33 35 # svc:/ldoms/vntsd> setprop vntsd/vcc_device = "virtual-console-concentrator@1"
34 36 # svc:/ldoms/vntsd> setprop vntsd/listen_addr = "192.168.1.1"
35 37 # svc:/ldoms/vntsd> setprop vntsd/authorization="true"
36 38 # svc:/ldoms/vntsd> exit
37 39
38 40 . /lib/svc/share/smf_include.sh
39 41
40 42 AUTH_ATTR=/etc/security/auth_attr
41 43 USER_ATTR=/etc/user_attr
42 44 GREP=/usr/bin/grep
43 45 CAT=/usr/bin/cat
44 46 ED=/usr/bin/ed
45 47 SVCCFG=/usr/sbin/svccfg
46 48 SVCPROP=/bin/svcprop
47 49
48 50 #
49 51 # Add LDoms vntsd authorization entries to etc/security/auth_attr if not
50 52 # present. These define authorizations used by LDoms vntsd daemon.
51 53 #
52 54 add_auth_entries()
53 55 {
54 56 # Add entries to auth_attr file, if needed
55 57 $GREP '^solaris.vntsd.:' ${AUTH_ATTR} >/dev/null 2>&1
56 58 if [ $? -ne 0 ] ; then
57 59 $CAT >>${AUTH_ATTR} << EOF
58 60 # Added by svc-vntsd
59 61 solaris.vntsd.:::LDoms vntsd Administration::
60 62 solaris.vntsd.grant:::Delegate LDoms vntsd Administration::
61 63 solaris.vntsd.consoles:::Access All LDoms Guest Consoles::
62 64 # End of svc-vntsd
63 65 EOF
64 66 fi
65 67 }
66 68
67 69 #
68 70 # Add a LDoms user/role entry to etc/user_attr if not present.
69 71 # This defines user/role used by useradd or roleadd.
70 72 #
71 73 add_user_entries()
72 74 {
73 75 #
74 76 # Add entries to user_attr file, if needed.
75 77 #
76 78 $GREP 'solaris.vntsd.grant' ${USER_ATTR} >/dev/null 2>&1
77 79
78 80 if [ $? -ne 0 ] ; then
79 81
80 82 $GREP '^root' ${USER_ATTR} | $GREP 'auths=' >/dev/null 2>&1
81 83 if [ $? -eq 0 ] ; then
82 84 #
83 85 # Add vntsd attribute to an existing root entry.
84 86 #
85 87 $ED -s ${USER_ATTR} <<- EOF > /dev/null 2>&1
86 88 g/^root.*auths\=/s/^roo.*auths\=/&solaris.vntsd.grant,/
87 89 w
88 90 q
89 91 EOF
90 92 else
91 93 #
92 94 # Add a root entry with vntsd attribute.
93 95 #
94 96 $CAT >>${USER_ATTR} << EOF
95 97 # Added by svc-vntsd
96 98 root::::type=normal;auths=solaris.vntsd.grant;lock_after_retries=0
97 99 # End of svc-vntsd
98 100 EOF
99 101 fi
100 102 fi
101 103 }
102 104
103 105 #
104 106 # Update 'vntsd' authorizations in the relevant files. Note that adding these
105 107 # entries from this smf script rather than from the pkg install scripts,
106 108 # ensures that they are added only if the vntsd service is being enabled; and
107 109 # hence avoids adding these entries unnecessarily into client guest domains.
108 110 # The functions check before adding, that the entries are not already present.
109 111 #
110 112 add_auth_entries
111 113 add_user_entries
112 114
113 115 vcc_device=`$SVCPROP -p vntsd/vcc_device $SMF_FMRI 2>/dev/null`
114 116 if [ -z "$vcc_device" ]; then
115 117 vcc_device="virtual-console-concentrator@0"
116 118 fi
117 119 args="-i $vcc_device"
118 120
119 121 listen_addr=`$SVCPROP -p vntsd/listen_addr $SMF_FMRI 2>/dev/null`
120 122 if [ -n "$listen_addr" ]; then
121 123 args="$args -p $listen_addr"
122 124 fi
123 125
124 126 timeout=`$SVCPROP -p vntsd/timeout_minutes $SMF_FMRI 2>/dev/null`
125 127 if [ -n "$timeout" ]; then
126 128 args="$args -t $timeout"
127 129 fi
128 130
129 131 auth=`$SVCPROP -p vntsd/authorization $SMF_FMRI 2>/dev/null`
130 132 if [ "$auth" = "true" ]; then
131 133 args="$args -A"
132 134 fi
133 135
134 136 #
135 137 # If we don't have a vcc device we don't want to try to start vntsd. By default
136 138 # newer versions of the factory settings will try to start vntsd by default.
↓ open down ↓ |
121 lines elided |
↑ open up ↑ |
137 139 # Since we may be installed on a machine with an older firmware we need to make
138 140 # sure that we don't try to start if the virtual console concentrator is not
139 141 # present.
140 142 #
141 143 VNTSD_DEV='/devices/virtual-devices@100/channel-devices@200/virtual-console-concentrator@0:ctl'
142 144 if [ ! -c "$VNTSD_DEV" ]; then
143 145 echo "The Virtual Network Terminal Server service has been disabled" \
144 146 "because the system has no virtual console concentrator (vcc)" \
145 147 "device."
146 148 /usr/sbin/svcadm disable -t "$SMF_FMRI"
147 - sleep 5 &
148 - exit $SMF_EXIT_OK
149 + exit $SMF_EXIT_TEMP_TRANSIENT
149 150 fi
150 151
151 152 if [ -x /usr/lib/ldoms/vntsd ]; then
152 153 /usr/lib/ldoms/vntsd $args
153 154 rc=$?
154 155 if [ $rc -ne 0 ]; then
155 156 # if vntsd exited in error with status 1, let SMF restart it
156 157 # otherwise we want it to go into maintenance.
157 158 if [ $rc -eq 1 ]; then
158 159 exit $SMF_ERR_OTHER
159 160 else
160 161 exit $SMF_ERR_FATAL
161 162 fi
162 163 fi
163 164 else
164 165 echo "WARNING: /usr/lib/ldoms/vntsd is missing or not executable" >& 2
165 166 exit $SMF_EXIT_ERR_CONFIG
166 167 fi
167 168
168 169 exit $SMF_EXIT_OK
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX