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.
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.
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]
22 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
25 .
/lib
/svc
/share
/smf_include.sh
29 if [ $# -ne 3 -o "$2" != "-R" ]; then
30 echo "$0: invalid syntax"
31 exit $SMF_EXIT_ERR_CONFIG
33 if [ "$3" != "/" ]; then
37 if [ -n "$ROOT_PATH" -a "$1" != "start" ]; then
38 echo "$0: invalid syntax: -R allowed for start method only"
39 exit $SMF_EXIT_ERR_CONFIG
41 if [ -n "$ROOT_PATH" -a ! -d "$ROOT_PATH" ]; then
42 echo "$0: invalid -R rootpath dir specified"
43 exit $SMF_EXIT_ERR_CONFIG
46 if smf_is_nonglobalzone
; then
47 echo "$0: not supported in a local zone"
48 exit $SMF_EXIT_ERR_CONFIG
55 # Comment out audio, usb, removable-media, and hotpluggable device
56 # entries in /etc/logindevperm.
57 LOGINDEVPERM
=$ROOT_PATH/etc
/logindevperm
58 if [ ! -f $LOGINDEVPERM ]; then
63 "/dev/removable-media/" \
64 "/dev/hotpluggable/" \
65 "/dev/usb/\[0-9a-f\]" \
67 sed -e "s!^$from\([^# ]\{1,\}[ }\{1,\}[0-9]\{1,\}[ ]\{1,\}\)$line!$to\1$line!" \
68 $LOGINDEVPERM > /tmp
/tmp.$$
69 cp /tmp
/tmp.$$
$LOGINDEVPERM
76 rewrite_logindev
"" "#"
81 # Setup dependent services
82 cat >> $ROOT_PATH/var
/svc
/profile
/upgrade
<<\__ENABLE_OTHERS
83 /usr
/sbin
/svcadm
enable -s svc
:/network
/tnd
:default
84 /usr
/sbin
/svcadm
enable -s svc
:/system
/tsol-zones
:default
85 /usr
/sbin
/svcadm
enable svc
:/network
/rpc
/rstat
:default
92 # Ensure auditing and device allocation are enabled by
93 # default with Trusted Extensions.
94 if [ "$ROOT_PATH" = "/" -o "$ROOT_PATH" = "" ]; then
95 /usr
/sbin
/svcadm
enable -s svc
:/system
/device
/allocate
:default
96 echo "Starting auditd ..."
99 cat >> $ROOT_PATH/var
/svc
/profile
/upgrade
<<\_ENABLE_AUDITD
101 /usr
/sbin
/svcadm
enable -s svc
:/system
/device
/allocate
:default
108 # For Trusted Extensions, make nscd service transient in local zones.
109 cat >> $ROOT_PATH/var
/svc
/profile
/upgrade
<<\_DEL_LOCAL_NSCD
110 if [ `/sbin/zonename` != "global" ]; then
111 nscd
="svc:/system/name-service-cache"
113 if /bin
/svcprop
-q -c -p startd
/duration
$nscd ; then
114 duration
=`/bin/svcprop -c -p startd/duration $nscd`
116 if [ "$duration" != "transient" ]; then
117 /usr
/sbin
/svccfg
-s $nscd addpg startd framework
118 /usr
/sbin
/svccfg
-s $nscd setprop \
119 startd
/duration
= astring
: transient
120 /usr
/sbin
/svccfg
-s $nscd setprop stop
/exec = :true
121 /usr
/sbin
/svcadm refresh
$nscd
129 if [ -f $ROOT_PATH/platform
/`/sbin/uname -m`/boot_archive
]; then
130 if [ -z "$ROOT_PATH" -o "$ROOT_PATH" = "/" ]; then
131 /sbin
/bootadm update-archive
133 /sbin
/bootadm update-archive
-R $ROOT_PATH
140 # No comments or blanks lines allowed in entries below
142 cat > ${TX_ENTRIES} << EOF
143 dtlogin account requisite pam_roles.so.1
144 dtlogin account required pam_unix_account.so.1
145 dtsession account requisite pam_roles.so.1
146 dtsession account required pam_unix_account.so.1
147 gdm account requisite pam_roles.so.1
148 gdm account required pam_unix_account.so.1
149 xscreensaver account requisite pam_roles.so.1
150 xscreensaver account required pam_unix_account.so.1
151 passwd account requisite pam_roles.so.1
152 passwd account required pam_unix_account.so.1
153 dtpasswd account requisite pam_roles.so.1
154 dtpasswd account required pam_unix_account.so.1
155 tsoljds-tstripe account requisite pam_roles.so.1
156 tsoljds-tstripe account required pam_unix_account.so.1
157 other account required pam_tsol_account.so.1
163 PAM_TMP
=/tmp
/pam_conf.$$
164 TX_ENTRIES
=$PAM_TMP/sct.$$
165 PAM_DEST
=$ROOT_PATH/etc
/pam.conf
167 mkdir
$PAM_TMP ||
exit $SMF_EXIT_ERR_FATAL
170 # verify that pam.conf file exists...
171 if [ ! -f ${PAM_DEST} ]; then
172 echo "$0: ${PAM_DEST} not found; aborting"
173 exit $SMF_EXIT_ERR_FATAL
177 # Update pam.conf to append Trusted Extensions entries if not
180 rm -f /tmp
/pamconf.$$
181 while read e1 e2 e3 e4 e5
183 # If this is the 'other' entry, add it unless it already
185 if [ $e1 = "other" ]; then
187 "^[# ]*$e1[ ][ ]*$e2[ ][ ]*$e3[ ][ ]*$e4" \
188 $PAM_DEST >/dev
/null
2>&1
190 # Doesn't exist, enter into pam.conf
191 echo "$e1\t$e2 $e3\t\t$e4 $e5" \
195 # Add other entries unless they already have a
196 # stack of their own.
197 grep "^[# ]*$e1[ ][ ]*$e2[ ]" \
198 $PAM_DEST >/dev
/null
2>&1
200 echo "$e1\t$e2 $e3\t\t$e4 $e5" \
205 # Append TX lines if any were not present already.
206 if [ -f /tmp
/pamconf.$$
] ; then
207 echo "# Entries for Trusted Extensions" >> $PAM_DEST
208 cat /tmp
/pamconf.$$
>> $PAM_DEST
209 echo "$0: updating $PAM_DEST entries for Trusted Extensions;"
210 echo "$0: please examine/update any new entries"
211 rm -f /tmp
/pamconf.$$
219 PAM_TMP
=/tmp
/pam_conf.$$
220 TX_ENTRIES
=$PAM_TMP/sct.$$
221 PAM_DEST
=$ROOT_PATH/etc
/pam.conf
222 TMPFILE
=$PAM_TMP/pam.conf
224 mkdir
$PAM_TMP ||
exit $SMF_EXIT_ERR_FATAL
226 # verify that pam.conf file exists...
227 if [ ! -f ${PAM_DEST} ]; then
228 echo "$0: ${PAM_DEST} not found; aborting"
229 exit $SMF_EXIT_ERR_FATAL
233 grep '^[a-z].*pam_tsol_account' $PAM_DEST > /dev
/null
2>&1
234 if [ $?
-ne 0 ]; then
235 echo "$0: pam_tsol_account module not present,"
236 echo "$0: No changes were made to $PAM_DEST."
240 grep -v pam_tsol_account
$PAM_DEST > $TMPFILE
241 echo "$0: $PAM_DEST "tsol
" entries removed"
242 cp $TMPFILE $PAM_DEST
249 echo "$0: Updating $ROOT_PATH/etc/system..."
250 if [ ! -f ${ROOT_PATH}/etc
/system
]; then
251 touch ${ROOT_PATH}/etc
/system
254 # Set sys_labeling in etc/system
255 grep -v "sys_labeling=" ${ROOT_PATH}/etc
/system
> /tmp
/etc.system.$$
256 echo "set sys_labeling=1" >> /tmp
/etc.system.$$
257 mv /tmp
/etc.system.$$
${ROOT_PATH}/etc
/system
258 grep "set sys_labeling=1" ${ROOT_PATH}/etc
/system
> /dev
/null
2>&1
259 if [ $?
-ne 0 ]; then
260 echo "$0: ERROR: cannot set sys_labeling in $ROOT_PATH/etc/system"
261 exit $SMF_EXIT_ERR_FATAL
264 # Setup dependent services
275 do_servicetag_register
()
278 SOL_ARCH
=`/sbin/uname -p`
279 SOL_VERS
=`/sbin/uname -r`
280 TX_PROD_URN
="urn:uuid:fc720df3-410f-11dc-9b8e-080020a9ed93"
282 if [ ! -x /usr
/bin
/stclient
]; then
286 # if already registered then do nothing more here
287 inst
=`/usr/bin/svcprop -p labeld/svctag_inst $SMF_FMRI 2>/dev/null`
288 if [ -n "$inst" ]; then
289 # this instance id was saved in a SMF property
290 /usr
/bin
/stclient
-g -i $inst -r $ROOTDIR >/dev
/null
2>&1
292 # matching service tag found, so do nothing
295 # no match for instance id saved in SMF property
296 /usr
/sbin
/svccfg
-s $SMF_FMRI delprop \
298 /usr
/sbin
/svcadm refresh
$SMF_FMRI
303 # fall through: no service tag, or does not match saved instance id
305 # determine the urn of the parent (Solaris)
309 SOL_PROD_URN
="-F urn:uuid:6df19e63-7ef5-11db-a4bd-080020a9ed93"
312 SOL_PROD_URN
="-F urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113"
316 # add the service tag
317 RC
=`/usr/bin/stclient -a -p "Solaris Trusted Extensions" \
318 -e $SOL_VERS -t $TX_PROD_URN -P Solaris $SOL_PROD_URN \
319 -m Sun -A $SOL_ARCH -z global -S $0 -r $ROOTDIR`
321 # save instance id in SMF property
322 inst
=`echo "$RC" | grep -i urn|awk -F= '{print $2}'`
323 /usr
/sbin
/svccfg
-s $SMF_FMRI setprop \
324 labeld
/svctag_inst
= astring
: "$inst"
325 /usr
/sbin
/svcadm refresh
$SMF_FMRI
329 do_servicetag_delete
()
331 if [ ! -x /usr
/bin
/stclient
]; then
335 inst
=`/usr/bin/svcprop -p labeld/svctag_inst $SMF_FMRI 2>/dev/null`
337 if [ -n "$inst" ]; then
339 /usr
/bin
/stclient
-d -i $inst
340 # delete saved instance id
341 /usr
/sbin
/svccfg
-s $SMF_FMRI delprop labeld
/svctag_inst
342 /usr
/sbin
/svcadm refresh
$SMF_FMRI
349 # If a labeld door exists, check for a labeld process and exit
350 # if the daemon is already running.
351 if [ -r /var
/tsol
/doors
/labeld
]; then
352 if /usr
/bin
/pgrep
-x -u 0 -P 1 labeld
>/dev
/null
2>&1; then
353 echo "$0: labeld is already running"
354 exit $SMF_EXIT_ERR_FATAL
357 /usr
/bin
/rm -f /var
/tsol
/doors
/labeld
361 PATH
=/usr
/sbin
:/usr
/bin
; export PATH
365 if [ -z "$ROOT_PATH" -o "$ROOT_PATH" = "/" ]; then
368 if [ -z "$SMF_FMRI" ]; then
369 echo "$0: this script can only be invoked by smf(5)"
370 exit $SMF_EXIT_ERR_NOSMF
373 tx_enabled
=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
374 if [ "$tx_enabled" = "false" ]; then
375 # A sign of trying temporary enablement...no-no
376 echo "$0: Temporarily enabling Trusted Extensions is not allowed."
377 exit $SMF_EXIT_ERR_CONFIG
380 if (smf_is_system_labeled
); then
381 do_servicetag_register
/
386 # Make changes to enable Trusted Extensions
387 grep "^set sys_labeling=1" ${ROOT_PATH}/etc
/system
> /dev
/null
2>&1
388 if [ $?
-eq 0 ]; then
389 echo "$0: already enabled. Exiting."
393 if [ "`/usr/sbin/zoneadm list -c`" != "global" ]; then
394 echo "$0: Must remove zones before enabling Trusted Extensions."
395 exit $SMF_EXIT_ERR_CONFIG
400 do_servicetag_register
/
402 # start daemon proccess so our service doesn't go into
406 echo "$0: Started. Must reboot and configure Trusted Extensions."
408 # Support jumpstart etc
410 # Make changes to enable Trusted Extensions
411 grep "^set sys_labeling=1" ${ROOT_PATH}/etc
/system
> /dev
/null
2>&1
412 if [ $?
-eq 0 ]; then
413 echo "$0: already enabled. Exiting."
417 # Setup dependent services
418 cat >> $ROOT_PATH/var
/svc
/profile
/upgrade
<<\__TRUSTED_ENABLE
419 /usr
/sbin
/svcadm
enable -s svc
:/system
/labeld
:default
423 do_servicetag_register
$ROOT_PATH
424 echo "$0: Started. Must configure Trusted Extensions before booting."
429 tx_enabled
=`/usr/bin/svcprop -c -p general/enabled $SMF_FMRI`
430 if [ "$tx_enabled" = "true" ]; then
431 /usr
/bin
/pkill
-x -u 0 -P 1 -z `smf_zonename` labeld
435 if [ "`/usr/sbin/zoneadm list -c`" != "global" ]; then
436 echo "$0: Must remove zones before disabling Trusted Extensions."
437 exit $SMF_EXIT_ERR_CONFIG
440 # Stop Trusted services.
441 /usr
/sbin
/svcadm disable svc
:/system
/tsol-zones
:default
2>/dev
/null
442 /usr
/sbin
/svcadm disable svc
:/network
/tnd
:default
2>/dev
/null
444 # Uncomment audio, usb, removable-media, and hotpluggable device
445 # entries in /etc/logindevperm.
446 rewrite_logindev
"#" ""
448 # Remove sys_labeling from /etc/system
449 grep -v "sys_labeling" ${ROOT_PATH}/etc
/system
> /tmp
/etc.system.$$
450 mv /tmp
/etc.system.$$
${ROOT_PATH}/etc
/system
451 grep "sys_labeling" ${ROOT_PATH}/etc
/system
> /dev
/null
2>&1
452 if [ $?
-eq 0 ]; then
453 echo "$0: ERROR: cannot remove sys_labeling in $ROOT_PATH/etc/system"
454 exit $SMF_EXIT_ERR_FATAL
462 /usr
/bin
/pkill
-x -u 0 -P 1 -z `smf_zonename` labeld
463 echo "$0: Stopped. Will take effect at next boot."
467 echo "Usage: $0 { start | stop }"