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# Class action script for "kmfconf" class files. 27*431deaa0Shylee# 28*431deaa0Shylee# This script appends the input file from the package to the 29*431deaa0Shylee# /etc/crypto/kmf.conf file. 30*431deaa0Shylee# 31*431deaa0Shylee# The syntax of the input file is 32*431deaa0Shylee# keystore:modulepath=path[;option=option_str] 33*431deaa0Shylee# 34*431deaa0Shylee# 35*431deaa0Shyleepkg_start="# Start $PKGINST" 36*431deaa0Shyleepkg_end="# End $PKGINST" 37*431deaa0Shyleetmpfile=/tmp/$$kmfconf 38*431deaa0Shyleeerror=no 39*431deaa0Shylee 40*431deaa0Shyleewhile read src dest 41*431deaa0Shyleedo 42*431deaa0Shylee [ "$src" = /dev/null ] && continue 43*431deaa0Shylee 44*431deaa0Shylee if [ -f "$dest" ] 45*431deaa0Shylee then 46*431deaa0Shylee # For multiple input files; exit if error occurred in previous 47*431deaa0Shylee # input file. 48*431deaa0Shylee if [ "$error" = yes ] 49*431deaa0Shylee then 50*431deaa0Shylee echo "$0: failed to update $lastdest for $PKGINST." 51*431deaa0Shylee exit 2 52*431deaa0Shylee fi 53*431deaa0Shylee lastdest=$dest 54*431deaa0Shylee 55*431deaa0Shylee # 56*431deaa0Shylee # If the package has been already installed, remove old entries 57*431deaa0Shylee # 58*431deaa0Shylee start=0; 59*431deaa0Shylee end=0; 60*431deaa0Shylee egrep -s "$pkg_start" $dest && start=1 61*431deaa0Shylee egrep -s "$pkg_end" $dest && end=1 62*431deaa0Shylee 63*431deaa0Shylee if [ $start -ne $end ] 64*431deaa0Shylee then 65*431deaa0Shylee echo "$0: missing Start or End delimiters for \ 66*431deaa0Shylee $PKGINST in $dest." 67*431deaa0Shylee echo "$0: $dest may be corrupted and was not updated." 68*431deaa0Shylee error=yes 69*431deaa0Shylee continue 70*431deaa0Shylee fi 71*431deaa0Shylee 72*431deaa0Shylee if [ $start -eq 1 ] 73*431deaa0Shylee then 74*431deaa0Shylee sed -e "/$pkg_start/,/$pkg_end/d" $dest > $tmpfile \ 75*431deaa0Shylee || error=yes 76*431deaa0Shylee else 77*431deaa0Shylee cp $dest $tmpfile || error=yes 78*431deaa0Shylee fi 79*431deaa0Shylee 80*431deaa0Shylee # 81*431deaa0Shylee # Check the input file syntax (should at least contain 82*431deaa0Shylee # ":module_path="). Then append the input entries with the 83*431deaa0Shylee #scc package delimiters. 84*431deaa0Shylee # 85*431deaa0Shylee line_count=`wc -l $src | awk '{ print $1}'` 86*431deaa0Shylee file_count=`grep ":modulepath=" $src | wc -l` 87*431deaa0Shylee if [ $line_count -ne $file_count ] 88*431deaa0Shylee then 89*431deaa0Shylee echo "$0: Syntax Error - $src for $PKGINST." 90*431deaa0Shylee error=yes 91*431deaa0Shylee continue 92*431deaa0Shylee else 93*431deaa0Shylee echo "$pkg_start" >> $tmpfile || error=yes 94*431deaa0Shylee cat $src >> $tmpfile || error=yes 95*431deaa0Shylee echo "$pkg_end" >> $tmpfile || error=yes 96*431deaa0Shylee fi 97*431deaa0Shylee 98*431deaa0Shylee # Install the updated config file and clean up the tmp file 99*431deaa0Shylee if [ "$error" = no ] 100*431deaa0Shylee then 101*431deaa0Shylee mv $tmpfile $dest || error=yes 102*431deaa0Shylee fi 103*431deaa0Shylee rm -f $tmpfile 104*431deaa0Shylee else 105*431deaa0Shylee echo "$0: ERROR - $dest doesn't exist for $PKGINST." 106*431deaa0Shylee exit 2 107*431deaa0Shylee fi 108*431deaa0Shyleedone 109*431deaa0Shylee 110*431deaa0Shyleeif [ "$error" = yes ] 111*431deaa0Shyleethen 112*431deaa0Shylee echo "$0: ERROR - failed to update $lastdest for $PKGINST." 113*431deaa0Shylee exit 2 114*431deaa0Shyleefi 115*431deaa0Shylee 116*431deaa0Shyleeexit 0 117