xref: /titanic_52/usr/src/cmd/cmd-crypto/scripts/r.kmfconf (revision 431deaa01ac039d796fdfaf86b909a75e7d9ac48)
1*431deaa0Shylee#
2*431deaa0Shylee# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
3*431deaa0Shylee# Use is subject to license terms.
4*431deaa0Shylee#
5*431deaa0Shylee# CDDL HEADER START
6*431deaa0Shylee#
7*431deaa0Shylee# The contents of this file are subject to the terms of the
8*431deaa0Shylee# Common Development and Distribution License (the "License").
9*431deaa0Shylee# You may not use this file except in compliance with the License.
10*431deaa0Shylee#
11*431deaa0Shylee# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
12*431deaa0Shylee# or http://www.opensolaris.org/os/licensing.
13*431deaa0Shylee# See the License for the specific language governing permissions
14*431deaa0Shylee# and limitations under the License.
15*431deaa0Shylee#
16*431deaa0Shylee# When distributing Covered Code, include this CDDL HEADER in each
17*431deaa0Shylee# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
18*431deaa0Shylee# If applicable, add the following below this CDDL HEADER, with the
19*431deaa0Shylee# fields enclosed by brackets "[]" replaced with your own identifying
20*431deaa0Shylee# information: Portions Copyright [yyyy] [name of copyright owner]
21*431deaa0Shylee#
22*431deaa0Shylee# CDDL HEADER END
23*431deaa0Shylee#
24*431deaa0Shylee# ident	"%Z%%M%	%I%	%E% SMI"
25*431deaa0Shylee#
26*431deaa0Shylee# Removal class action script for "kmfconf" class files.
27*431deaa0Shylee#
28*431deaa0Shylee# This script removes entries belonging to the package from the
29*431deaa0Shylee# /etc/crypto/kmf.conf file.
30*431deaa0Shylee#
31*431deaa0Shylee
32*431deaa0Shyleepkg_start="# Start $PKGINST"
33*431deaa0Shyleepkg_end="# End $PKGINST"
34*431deaa0Shyleetmpfile=/tmp/$$kmfconf
35*431deaa0Shyleeerror=no
36*431deaa0Shylee
37*431deaa0Shyleewhile read dest
38*431deaa0Shyleedo
39*431deaa0Shylee	# For multiple input files; exit if error occurred in preious
40*431deaa0Shylee	# input file.
41*431deaa0Shylee	if [ "$error" = yes ]
42*431deaa0Shylee	then
43*431deaa0Shylee		echo "$0: failed to update $lastdest for $PKGINST."
44*431deaa0Shylee		exit 2
45*431deaa0Shylee	fi
46*431deaa0Shylee	lastdest=$dest
47*431deaa0Shylee
48*431deaa0Shylee	# Strip all entries belonging to this package
49*431deaa0Shylee	start=0
50*431deaa0Shylee	end=0
51*431deaa0Shylee	egrep -s "$pkg_start" $dest && start=1
52*431deaa0Shylee	egrep -s "$pkg_end" $dest && end=1
53*431deaa0Shylee
54*431deaa0Shylee	if [ $start -ne $end ] ; then
55*431deaa0Shylee		echo "$0: missing Start or End delimiters for $PKGINST in \
56*431deaa0Shylee		    $dest."
57*431deaa0Shylee		echo "$0: $dest may be corrupted and was not updated."
58*431deaa0Shylee		error=yes
59*431deaa0Shylee		continue
60*431deaa0Shylee	fi
61*431deaa0Shylee
62*431deaa0Shylee	if [ $start -eq 1 ]
63*431deaa0Shylee    	then
64*431deaa0Shylee		sed -e "/$pkg_start/,/$pkg_end/d" $dest > $tmpfile || error=yes
65*431deaa0Shylee		if [ "$error" = no ]
66*431deaa0Shylee                then
67*431deaa0Shylee			mv $tmpfile $dest || error=yes
68*431deaa0Shylee		fi
69*431deaa0Shylee		rm -f $tmpfile
70*431deaa0Shylee	else
71*431deaa0Shylee		echo "$0: WARNING - no entries found in $dest for $PKGINST."
72*431deaa0Shylee		exit 0
73*431deaa0Shylee	fi
74*431deaa0Shyleedone
75*431deaa0Shylee
76*431deaa0Shyleeif [ "$error" = yes ]
77*431deaa0Shyleethen
78*431deaa0Shylee	echo "$0: ERROR - failed to update $lastdest for $PKGINST."
79*431deaa0Shylee	exit 2
80*431deaa0Shyleefi
81*431deaa0Shyleeexit 0
82