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, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #
     24 #ident	"%Z%%M%	%I%	%E% SMI"
     25 #
     26 # Copyright 1994-2003 Sun Microsystems, Inc.  All rights reserved.
     27 # Use is subject to license terms.
     28 #
     29 
     30 CLEANUP_FILE=/tmp/CLEANUP
     31 PATH="/usr/bin:/usr/sbin:${PATH}"
     32 export PATH
     33 
     34 add_nobrowse_option()
     35 {
     36 	sed -e "s%^/net		-hosts		-nosuid$%/net		-hosts		-nosuid,nobrowse%" \
     37 	    -e "s%^/home		auto_home$%/home		auto_home	-nobrowse%" \
     38 		${dest} > /tmp/am.$$
     39 
     40 	#
     41 	# Is there a '/net' entry?
     42 	#
     43 	grep -s "^[ 	]*/net[ 	\\]" /tmp/am.$$ > /dev/null 2>&1
     44 	if [ $? = 0 ]; then
     45 		#
     46 		# Did we not update the /net entry because it did not
     47 		# match exactly what we expected?
     48 		#
     49 		grep -s "^/net		-hosts		-nosuid,nobrowse$" \
     50 			/tmp/am.$$ > /dev/null 2>&1
     51 		if [ $? != 0 ]; then
     52 			echo "'/net' entry in ${dest} map was not updated to include '-nobrowse' option." >> ${CLEANUP_FILE}
     53 		fi
     54 	fi
     55 
     56 	#
     57 	# Is there a '/home' entry?
     58 	#
     59 	grep -s "^[ 	]*/home[ 	\\]" /tmp/am.$$ > /dev/null 2>&1
     60 	if [ $? = 0 ]; then
     61 		#
     62 		# Did we not update the /home entry because it did not
     63 		# match exactly what we expected?
     64 		#
     65 		grep -s "^/home		auto_home	-nobrowse$" \
     66 			/tmp/am.$$ > /dev/null 2>&1
     67 		if [ $? != 0 ]; then
     68 			echo "'/home' entry in ${dest} map was not updated to include '-nobrowse' option." >> ${CLEANUP_FILE}
     69 		fi
     70 	fi
     71 
     72 	cp /tmp/am.$$ ${dest}
     73 	rm -f /tmp/am.$$
     74 }
     75 
     76 while read src dest
     77 do
     78 	if [ ! -f $dest ] ; then
     79 		cp $src $dest
     80 	else
     81 		grep '^[ ]*/xfn' $dest 2>&1 >/dev/null 
     82 		if [ $? = 0 ]; then
     83 			# Remove /xfn entry
     84 			sed '/^[ ]*\/xfn\>/d' $dest > /tmp/am.$$
     85 			cp /tmp/am.$$ $dest
     86 			rm -f /tmp/am.$$
     87 			# Remove /xfn directory if not in use
     88 			rmdir $BASEDIR/xfn >/dev/null 2>&1
     89 		fi
     90 		add_nobrowse_option
     91 	fi
     92 done
     93 exit 0
     94