19910SCasper.Dik@Sun.COM#! /usr/bin/sh 29910SCasper.Dik@Sun.COM# 39910SCasper.Dik@Sun.COM# CDDL HEADER START 49910SCasper.Dik@Sun.COM# 59910SCasper.Dik@Sun.COM# The contents of this file are subject to the terms of the 69910SCasper.Dik@Sun.COM# Common Development and Distribution License (the "License"). 79910SCasper.Dik@Sun.COM# You may not use this file except in compliance with the License. 89910SCasper.Dik@Sun.COM# 99910SCasper.Dik@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 109910SCasper.Dik@Sun.COM# or http://www.opensolaris.org/os/licensing. 119910SCasper.Dik@Sun.COM# See the License for the specific language governing permissions 129910SCasper.Dik@Sun.COM# and limitations under the License. 139910SCasper.Dik@Sun.COM# 149910SCasper.Dik@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each 159910SCasper.Dik@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 169910SCasper.Dik@Sun.COM# If applicable, add the following below this CDDL HEADER, with the 179910SCasper.Dik@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying 189910SCasper.Dik@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner] 199910SCasper.Dik@Sun.COM# 209910SCasper.Dik@Sun.COM# CDDL HEADER END 219910SCasper.Dik@Sun.COM# 229910SCasper.Dik@Sun.COM 239910SCasper.Dik@Sun.COM# 24*13091Snathan.bush@oracle.com# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 259910SCasper.Dik@Sun.COM# 269910SCasper.Dik@Sun.COM 279910SCasper.Dik@Sun.COM. /lib/svc/share/smf_include.sh 289910SCasper.Dik@Sun.COM 299910SCasper.Dik@Sun.COMfiles='/etc/user_attr /etc/security/auth_attr /etc/security/exec_attr 309910SCasper.Dik@Sun.COM /etc/security/prof_attr' 319910SCasper.Dik@Sun.COM 329910SCasper.Dik@Sun.COMPKGINST= 339910SCasper.Dik@Sun.COMexport PKGINST 349910SCasper.Dik@Sun.COM 359910SCasper.Dik@Sun.COMirbac=/usr/sadm/install/scripts/i.rbac 369910SCasper.Dik@Sun.COM 379910SCasper.Dik@Sun.COMif [ ! -x $irbac ] 389910SCasper.Dik@Sun.COMthen 399910SCasper.Dik@Sun.COM echo "${irbac}: not found." 409910SCasper.Dik@Sun.COM exit $SMF_EXIT_ERR_FATAL 419910SCasper.Dik@Sun.COMfi 429910SCasper.Dik@Sun.COM 439910SCasper.Dik@Sun.COMcase "$1" in 449910SCasper.Dik@Sun.COMstart|refresh) 459910SCasper.Dik@Sun.COM ;; 469910SCasper.Dik@Sun.COMstop) 479910SCasper.Dik@Sun.COM exit $SMF_EXIT_OK;; 489910SCasper.Dik@Sun.COM*) 499910SCasper.Dik@Sun.COM echo "Usage: $0 { start | refresh | stop }" 509910SCasper.Dik@Sun.COM exit $SMF_EXIT_ERR_FATAL;; 519910SCasper.Dik@Sun.COMesac 529910SCasper.Dik@Sun.COM 53*13091Snathan.bush@oracle.comtmp_rbac=`/usr/bin/mktemp -d /tmp/rbac.XXXXXX` 54*13091Snathan.bush@oracle.comif [ -z "$tmp_rbac" ] 55*13091Snathan.bush@oracle.comthen 56*13091Snathan.bush@oracle.com echo "Could not create temporary directory." 57*13091Snathan.bush@oracle.com exit $SMF_EXIT_ERR_FATAL 58*13091Snathan.bush@oracle.comfi 59*13091Snathan.bush@oracle.comtmp_frag=$tmp_rbac/frag 60*13091Snathan.bush@oracle.comtmp_file=$tmp_rbac/file 61*13091Snathan.bush@oracle.com 629910SCasper.Dik@Sun.COMfor f in $files 639910SCasper.Dik@Sun.COMdo 649910SCasper.Dik@Sun.COM d=${f}.d 659910SCasper.Dik@Sun.COM if [ ! -d ${d} ] 669910SCasper.Dik@Sun.COM then 679910SCasper.Dik@Sun.COM # No directory, nothing to do 689910SCasper.Dik@Sun.COM continue 699910SCasper.Dik@Sun.COM fi 7011510SJoep.Vesseur@Sun.COM # cache user/owner of file to update 7111510SJoep.Vesseur@Sun.COM ownergroup=`ls -ln $f | awk '{printf("%s:%s\n", $3, $4);'}` 729910SCasper.Dik@Sun.COM # 739910SCasper.Dik@Sun.COM # List all the files in the directory and the destination file 74*13091Snathan.bush@oracle.com # in the order of their timestamp. Older files are displayed 75*13091Snathan.bush@oracle.com # first. If a fragment file is listed before the destination 76*13091Snathan.bush@oracle.com # file, it is an older fragment that has already been processed. 77*13091Snathan.bush@oracle.com # If a fragment file is listed after the destination file, it is 78*13091Snathan.bush@oracle.com # new, and the destination file must be updated. 799910SCasper.Dik@Sun.COM # 80*13091Snathan.bush@oracle.com # Comments are processed separately from the other file contents. 81*13091Snathan.bush@oracle.com # For new fragments only, the comments are processed as they are 82*13091Snathan.bush@oracle.com # encountered. For all fragments, the non-comment contents are 83*13091Snathan.bush@oracle.com # saved in a temporary file. After all fragments have been 84*13091Snathan.bush@oracle.com # processed, and only if new fragments were found, the contents 85*13091Snathan.bush@oracle.com # of the temporary file are processed. This ensures that older 86*13091Snathan.bush@oracle.com # but still valid entries are retained in the destination file. 87*13091Snathan.bush@oracle.com # 88*13091Snathan.bush@oracle.com /usr/bin/rm -f $tmp_file 89*13091Snathan.bush@oracle.com new_frag=0 9011510SJoep.Vesseur@Sun.COM update=0 91*13091Snathan.bush@oracle.com for frag in `ls -tr $f $d/* 2> /dev/null` 929910SCasper.Dik@Sun.COM do 939910SCasper.Dik@Sun.COM if [ "$frag" = "$f" ] 949910SCasper.Dik@Sun.COM then 95*13091Snathan.bush@oracle.com new_frag=1 96*13091Snathan.bush@oracle.com continue 979910SCasper.Dik@Sun.COM fi 989910SCasper.Dik@Sun.COM if [ -f "$frag" ] 999910SCasper.Dik@Sun.COM then 100*13091Snathan.bush@oracle.com if [ $new_frag -eq 1 ] 101*13091Snathan.bush@oracle.com then 102*13091Snathan.bush@oracle.com /usr/bin/rm -f $tmp_frag 103*13091Snathan.bush@oracle.com /usr/bin/grep '^#' $frag > $tmp_frag 104*13091Snathan.bush@oracle.com update=1 105*13091Snathan.bush@oracle.com echo $tmp_frag $f | $irbac 106*13091Snathan.bush@oracle.com fi 107*13091Snathan.bush@oracle.com /usr/bin/grep -v '^#' $frag >> $tmp_file 1089910SCasper.Dik@Sun.COM fi 1099910SCasper.Dik@Sun.COM done 11011510SJoep.Vesseur@Sun.COM if [ $update -eq 1 ] 11111510SJoep.Vesseur@Sun.COM then 112*13091Snathan.bush@oracle.com echo $tmp_file $f | $irbac 11311510SJoep.Vesseur@Sun.COM chown $ownergroup $f 11411510SJoep.Vesseur@Sun.COM fi 1159910SCasper.Dik@Sun.COMdone 1169910SCasper.Dik@Sun.COM 117*13091Snathan.bush@oracle.com/usr/bin/rm -rf $tmp_rbac 118*13091Snathan.bush@oracle.com 1199910SCasper.Dik@Sun.COMexit $SMF_EXIT_OK 120