#!/bin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # #ident "%Z%%M% %I% %E% SMI" # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # PATH="/usr/bin:/usr/sbin:${PATH}" export PATH while read src dest do if [ ! -f $dest ] ; then cp $src $dest else # This updates the header information. Note that there's a # long-standing bug that was introduced by the fix for CR # 1094626. All systems that have been upgraded at least once # since 1993 are missing the "nobody" entry. There's no good # way to know, though, whether a missing entry is due to that # bug or due to intentional configuration, so we don't # correct it here. We just don't make it worse. # # From the source file, take everything before the "nobody" # line. If there's no "nobody" line, take the whole thing. # From the destination, take everything after the initial # comment block. The "netname" comment is the end of the # traditional comment block, so start after there if present # (keeping the user's added comments, if any), or with the # first non-comment line. tmpfile=/tmp/policyconf.$$ ( cat $src echo SWITCH cat $dest ) | nawk ' /^nobody / && state == 0 { state=1 } /^SWITCH$/ { state=2; next } /^[^#]/ && state == 2 { state=3 } /^# netname / && state == 2 { state=3; next } state == 0 || state == 3 { print $0 } ' > $tmpfile cmp -s $tmpfile $dest || cp $tmpfile $dest rm -f $tmpfile fi done exit 0