xref: /onnv-gate/usr/src/lib/libsecdb/svc-rbac (revision 11510)
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*11510SJoep.Vesseur@Sun.COM# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
259910SCasper.Dik@Sun.COM# Use is subject to license terms.
269910SCasper.Dik@Sun.COM#
279910SCasper.Dik@Sun.COM
289910SCasper.Dik@Sun.COM. /lib/svc/share/smf_include.sh
299910SCasper.Dik@Sun.COM
309910SCasper.Dik@Sun.COMfiles='/etc/user_attr /etc/security/auth_attr /etc/security/exec_attr
319910SCasper.Dik@Sun.COM    /etc/security/prof_attr'
329910SCasper.Dik@Sun.COM
339910SCasper.Dik@Sun.COMPKGINST=
349910SCasper.Dik@Sun.COMexport PKGINST
359910SCasper.Dik@Sun.COM
369910SCasper.Dik@Sun.COMirbac=/usr/sadm/install/scripts/i.rbac
379910SCasper.Dik@Sun.COM
389910SCasper.Dik@Sun.COMif [ ! -x $irbac ]
399910SCasper.Dik@Sun.COMthen
409910SCasper.Dik@Sun.COM	echo "${irbac}: not found."
419910SCasper.Dik@Sun.COM	exit $SMF_EXIT_ERR_FATAL
429910SCasper.Dik@Sun.COMfi
439910SCasper.Dik@Sun.COM
449910SCasper.Dik@Sun.COMcase "$1" in
459910SCasper.Dik@Sun.COMstart|refresh)
469910SCasper.Dik@Sun.COM	;;
479910SCasper.Dik@Sun.COMstop)
489910SCasper.Dik@Sun.COM	exit $SMF_EXIT_OK;;
499910SCasper.Dik@Sun.COM*)
509910SCasper.Dik@Sun.COM	echo "Usage: $0 { start | refresh | stop }"
519910SCasper.Dik@Sun.COM	exit $SMF_EXIT_ERR_FATAL;;
529910SCasper.Dik@Sun.COMesac
539910SCasper.Dik@Sun.COM
549910SCasper.Dik@Sun.COMfor f in $files
559910SCasper.Dik@Sun.COMdo
569910SCasper.Dik@Sun.COM	d=${f}.d
579910SCasper.Dik@Sun.COM	if [ ! -d ${d} ]
589910SCasper.Dik@Sun.COM	then
599910SCasper.Dik@Sun.COM		# No directory, nothing to do
609910SCasper.Dik@Sun.COM		continue
619910SCasper.Dik@Sun.COM	fi
62*11510SJoep.Vesseur@Sun.COM	# cache user/owner of file to update
63*11510SJoep.Vesseur@Sun.COM	ownergroup=`ls -ln $f | awk '{printf("%s:%s\n", $3, $4);'}`
649910SCasper.Dik@Sun.COM	#
659910SCasper.Dik@Sun.COM	# List all the files in the directory and the destination file
669910SCasper.Dik@Sun.COM	# in the order of their timestamp.  Most recent files are
679910SCasper.Dik@Sun.COM	# displayed first.  When we find the destination file, we're
689910SCasper.Dik@Sun.COM	# done as the rest of the files are older and they are already
699910SCasper.Dik@Sun.COM	# incorporated.
709910SCasper.Dik@Sun.COM	#
71*11510SJoep.Vesseur@Sun.COM	update=0
729910SCasper.Dik@Sun.COM	for frag in `ls -t $f $d/* 2> /dev/null`
739910SCasper.Dik@Sun.COM	do
749910SCasper.Dik@Sun.COM		if [ "$frag" = "$f" ]
759910SCasper.Dik@Sun.COM		then
769910SCasper.Dik@Sun.COM			break
779910SCasper.Dik@Sun.COM		fi
789910SCasper.Dik@Sun.COM		if [ -f "$frag" ]
799910SCasper.Dik@Sun.COM		then
80*11510SJoep.Vesseur@Sun.COM			update=1
819910SCasper.Dik@Sun.COM			echo $frag $f | $irbac
829910SCasper.Dik@Sun.COM		fi
839910SCasper.Dik@Sun.COM	done
84*11510SJoep.Vesseur@Sun.COM	if [ $update -eq 1 ]
85*11510SJoep.Vesseur@Sun.COM	then
86*11510SJoep.Vesseur@Sun.COM		chown $ownergroup $f
87*11510SJoep.Vesseur@Sun.COM	fi
889910SCasper.Dik@Sun.COMdone
899910SCasper.Dik@Sun.COM
909910SCasper.Dik@Sun.COMexit $SMF_EXIT_OK
91