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