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