Home | History | Annotate | Download | only in common_files
      1 #!/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License (the "License").
      7 # You may not use this file except in compliance with the License.
      8 #
      9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10 # or http://www.opensolaris.org/os/licensing.
     11 # See the License for the specific language governing permissions
     12 # and limitations under the License.
     13 #
     14 # When distributing Covered Code, include this CDDL HEADER in each
     15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16 # If applicable, add the following below this CDDL HEADER, with the
     17 # fields enclosed by brackets "[]" replaced with your own identifying
     18 # information: Portions Copyright [yyyy] [name of copyright owner]
     19 #
     20 # CDDL HEADER END
     21 #
     22 #
     23 #ident	"%Z%%M%	%I%	%E% SMI"
     24 #
     25 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     26 # Use is subject to license terms.
     27 #
     28 
     29 KRBCONFTMP=${PKG_INSTALL_ROOT:-/}/etc/krb5/krb5conftmp.$$
     30 
     31 PATH="/usr/bin:/usr/sbin:${PATH}"
     32 export PATH
     33 
     34 while read src dest
     35 do
     36 	if [ ! -f $dest ] ; then
     37 		cp $src $dest
     38 	else
     39 		sed -e "/^[	 ]*___slave_kdcs___/d" \
     40 			-e "/^[	 ]*___domain_mapping___/d" $dest > $KRBCONFTMP
     41 		cp $KRBCONFTMP $dest
     42 		rm -f $KRBCONFTMP
     43 
     44 		# If the existing krb5.conf file is not configured and using
     45 		# the old template (resulting in mis-configuration) then 
     46 		# comment-out the misconfigured entries.
     47 		egrep -s "^[ 	]*default_realm = ___default_realm___" $dest
     48 		if [ $? -eq 0 ] ; then
     49 			sed -e "s/^\([ 	]*default_realm = ___default_realm___\)/#\1/" \
     50 			    -e "s/^\([ 	]*___default_realm___ = {\)/#\1/" \
     51 			    -e "s/^\([ 	]*kdc = ___master_kdc___\)/#\1/" \
     52 			    -e "s/^\([ 	]*kdc = ___slave_kdc.___\)/#\1/g" \
     53 			    -e '/^[ 	]*admin_server = ___master_kdc___/{
     54 			        N
     55 			        s/^\([ 	]*admin_server = ___master_kdc___\)\n\([ 	]*\}\)$/#\1\
     56 #\2/
     57 			    }' \
     58 			    -e "s/^\([ 	]*___domainname___ = ___default_realm___\)/#\1/" \
     59 			    $dest > $KRBCONFTMP
     60 			cp $KRBCONFTMP $dest
     61 			rm -f $KRBCONFTMP
     62 		fi
     63 	fi
     64 done
     65 exit 0
     66