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