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 2008 Sun Microsystems, Inc. All rights reserved. 26 # Use is subject to license terms. 27 # 28 29 PATH="/usr/bin:/usr/sbin:${PATH}" 30 export PATH 31 32 while read src dest 33 do 34 if [ ! -f $dest ] ; then 35 cp $src $dest 36 else 37 # This updates the header information. Note that there's a 38 # long-standing bug that was introduced by the fix for CR 39 # 1094626. All systems that have been upgraded at least once 40 # since 1993 are missing the "nobody" entry. There's no good 41 # way to know, though, whether a missing entry is due to that 42 # bug or due to intentional configuration, so we don't 43 # correct it here. We just don't make it worse. 44 # 45 # From the source file, take everything before the "nobody" 46 # line. If there's no "nobody" line, take the whole thing. 47 # From the destination, take everything after the initial 48 # comment block. The "netname" comment is the end of the 49 # traditional comment block, so start after there if present 50 # (keeping the user's added comments, if any), or with the 51 # first non-comment line. 52 tmpfile=/tmp/policyconf.$$ 53 ( 54 cat $src 55 echo SWITCH 56 cat $dest 57 ) | nawk ' 58 /^nobody / && state == 0 { state=1 } 59 /^SWITCH$/ { state=2; next } 60 /^[^#]/ && state == 2 { state=3 } 61 /^# netname / && state == 2 { state=3; next } 62 state == 0 || state == 3 { print $0 } 63 ' > $tmpfile 64 cmp -s $tmpfile $dest || cp $tmpfile $dest 65 rm -f $tmpfile 66 fi 67 done 68 69 exit 0 70