svc-rbac revision 8d0bff0b85e6c35d0d862cff1607cded58bf2341
30N/A#! /usr/bin/sh
30N/A#
30N/A# CDDL HEADER START
30N/A#
30N/A# The contents of this file are subject to the terms of the
30N/A# Common Development and Distribution License (the "License").
30N/A# You may not use this file except in compliance with the License.
30N/A#
30N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
30N/A# or http://www.opensolaris.org/os/licensing.
30N/A# See the License for the specific language governing permissions
30N/A# and limitations under the License.
30N/A#
30N/A# When distributing Covered Code, include this CDDL HEADER in each
30N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
30N/A# If applicable, add the following below this CDDL HEADER, with the
30N/A# fields enclosed by brackets "[]" replaced with your own identifying
30N/A# information: Portions Copyright [yyyy] [name of copyright owner]
30N/A#
30N/A# CDDL HEADER END
30N/A#
30N/A
30N/A#
30N/A# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
30N/A#
58N/A
58N/A. /lib/svc/share/smf_include.sh
58N/A
30N/Afiles='/etc/user_attr /etc/security/auth_attr /etc/security/exec_attr
1016N/A /etc/security/prof_attr'
30N/A
58N/APKGINST=
58N/Aexport PKGINST
58N/A
58N/Airbac=/usr/sadm/install/scripts/i.rbac
58N/A
667N/Aif [ ! -x $irbac ]
58N/Athen
1016N/A echo "${irbac}: not found."
320N/A exit $SMF_EXIT_ERR_FATAL
320N/Afi
490N/A
664N/Acase "$1" in
664N/Astart|refresh)
1026N/A ;;
112N/Astop)
570N/A exit $SMF_EXIT_OK;;
30N/A*)
30N/A echo "Usage: $0 { start | refresh | stop }"
30N/A exit $SMF_EXIT_ERR_FATAL;;
58N/Aesac
30N/A
418N/Atmp_rbac=`/usr/bin/mktemp -d /tmp/rbac.XXXXXX`
58N/Aif [ -z "$tmp_rbac" ]
456N/Athen
30N/A echo "Could not create temporary directory."
320N/A exit $SMF_EXIT_ERR_FATAL
320N/Afi
30N/Atmp_frag=$tmp_rbac/frag
30N/Atmp_file=$tmp_rbac/file
77N/A
77N/Afor f in $files
77N/Ado
77N/A d=${f}.d
30N/A if [ ! -d ${d} ]
30N/A then
30N/A # No directory, nothing to do
30N/A continue
30N/A fi
77N/A # cache user/owner of file to update
77N/A ownergroup=`ls -ln $f | awk '{printf("%s:%s\n", $3, $4);'}`
30N/A #
30N/A # List all the files in the directory and the destination file
58N/A # in the order of their timestamp. Older files are displayed
145N/A # first. If a fragment file is listed before the destination
145N/A # file, it is an older fragment that has already been processed.
145N/A # If a fragment file is listed after the destination file, it is
145N/A # new, and the destination file must be updated.
145N/A #
58N/A # Comments are processed separately from the other file contents.
77N/A # For new fragments only, the comments are processed as they are
490N/A # encountered. For all fragments, the non-comment contents are
490N/A # saved in a temporary file. After all fragments have been
490N/A # processed, and only if new fragments were found, the contents
490N/A # of the temporary file are processed. This ensures that older
490N/A # but still valid entries are retained in the destination file.
490N/A #
490N/A /usr/bin/rm -f $tmp_file
490N/A new_frag=0
490N/A update=0
490N/A for frag in `ls -tr $f $d/* 2> /dev/null`
490N/A do
490N/A if [ "$frag" = "$f" ]
490N/A then
993N/A new_frag=1
993N/A continue
993N/A fi
993N/A if [ -f "$frag" ]
993N/A then
993N/A if [ $new_frag -eq 1 ]
993N/A then
993N/A /usr/bin/rm -f $tmp_frag
77N/A /usr/bin/grep '^#' $frag > $tmp_frag
77N/A update=1
77N/A echo $tmp_frag $f | $irbac
77N/A fi
58N/A /usr/bin/grep -v '^#' $frag >> $tmp_file
145N/A fi
58N/A done
58N/A if [ $update -eq 1 ]
77N/A then
77N/A echo $tmp_file $f | $irbac
77N/A chown $ownergroup $f
77N/A fi
30N/Adone
58N/A
58N/A/usr/bin/rm -rf $tmp_rbac
58N/A
58N/Aexit $SMF_EXIT_OK
58N/A