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 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 
     26 PATH="/usr/bin:/usr/sbin:${PATH}"
     27 export PATH
     28 
     29 while read src dest
     30 do
     31 	if [ ! -f $dest ] ; then
     32 		cp $src $dest
     33 	else
     34 		#
     35 		# 2.6 & earlier versions had an smtp entry; remove it.
     36 		#
     37 		# Some accounts used to be shipped with "NP" they are now
     38 		# shipped as "*LK*" since they shouldn't be able to run
     39 		# cron jobs or login.
     40 		sed '	/^smtp:/d;
     41 			/^nobody:/s/:NP:/:*LK*:/;
     42 			/^nobody4:/s/:NP:/:*LK*:/;
     43 			/^noaccess/s/:NP:/:*LK*:/;' $dest > /tmp/d.$$
     44 		cp /tmp/d.$$ $dest
     45 		rm -f /tmp/d.$$
     46 
     47 		#
     48 		# Add the 'nobody' user from 4.x so that people don't
     49 		# assign it to a regular user and confuse themselves
     50 		#
     51 		NOBODY4_LINE="nobody4:*LK*:6445::::::"
     52 		if grep "^nobody4:" $dest 2>&1 >/dev/null; then
     53 			:
     54 		else
     55 			printf '/^noaccess:*LK*\na\n%s\n.\nw\nq\n' \
     56 				"$NOBODY4_LINE" | ed -s $dest > /dev/null
     57 		fi
     58 
     59 		#
     60 		# Add the 'smmsp' user for sendmail 8.12
     61 		#
     62 		SMMSP_LINE="smmsp:NP:6445::::::"
     63 		if grep "$SMMSP_LINE" $dest 2>&1 >/dev/null; then
     64 			:
     65 		else
     66 			printf '/^nobody4:*LK*\na\n%s\n.\nw\nq\n' \
     67 				"$SMMSP_LINE" | ed -s $dest > /dev/null
     68 		fi
     69 
     70 		#
     71 		# Add the 'gdm' reserved user if it doesn't exist.
     72 		#
     73 		GDM_LINE="gdm:*LK*:::::::"
     74 		if grep "^gdm:" $dest 2>&1 >/dev/null; then
     75 			:
     76 		else
     77 			printf '/^listen:\*LK\*\na\n%s\n.\nw\nq\n' \
     78 				"$GDM_LINE" | ed -s $dest > /dev/null
     79 		fi
     80 
     81 		#
     82 		# Add the 'webservd' reserved user if it doesn't exist.
     83 		#
     84 		WEBSERVD_LINE="webservd:*LK*:::::::"
     85 		if grep "^webservd:" $dest 2>&1 >/dev/null; then
     86 			:
     87 		else
     88 			printf '/^gdm:\*LK\*\na\n%s\n.\nw\nq\n' \
     89 				"$WEBSERVD_LINE" | ed -s $dest > /dev/null
     90 		fi
     91 
     92 		#
     93 		# Add the 'postgres' reserved user if it doesn't exist.
     94 		#
     95 		POSTGRES_LINE="postgres:NP:::::::"
     96 		if grep "^postgres:" $dest 2>&1 >/dev/null; then
     97 			:
     98 		else
     99 			printf '/^webservd:\*LK\*\na\n%s\n.\nw\nq\n' \
    100 			    "$POSTGRES_LINE" | ed -s $dest > /dev/null
    101 		fi
    102 
    103 
    104 
    105   	 	#
    106                 # Add the 'mysql' reserved user if it doesn't exist.
    107                 #
    108                 MYSQL_LINE="mysql:NP:::::::"
    109                 if grep "^mysql:" $dest 2>&1 >/dev/null; then
    110                         :
    111                 else
    112                         printf '/^postgres:\*LK\*\na\n%s\n.\nw\nq\n' \
    113                             "$MYSQL_LINE" | ed -s $dest > /dev/null
    114                 fi
    115 	
    116 
    117 
    118 		#
    119 		# Add the 'svctag' reserved user if it doesn't exist.
    120 		#
    121 		SVCTAG_LINE="svctag:*LK*:6445::::::"
    122 		if grep "^svctag:" $dest 2>&1 >/dev/null; then
    123 			:
    124 		else
    125 			printf '/^postgres:NP\na\n%s\n.\nw\nq\n' \
    126 			    "$SVCTAG_LINE" | ed -s $dest > /dev/null
    127 		fi
    128 
    129 		#
    130 		# Add the 'dladm' reserved user if it doesn't exist.
    131 		#
    132 		DLADM_LINE="dladm:*LK*:::::::"
    133 		if grep "^dladm:" $dest 2>&1 >/dev/null; then
    134 			:
    135 		else
    136 			printf '/^nuucp:NP\na\n%s\n.\nw\nq\n' \
    137 				"$DLADM_LINE" | ed -s $dest > /dev/null
    138 		fi
    139 
    140 		#
    141 		# Add the 'xvm' reserved user if it doesn't exist.
    142 		#
    143 		XVM_LINE="xvm:*LK*:::::::"
    144 		if grep "^xvm:" $dest 2>&1 >/dev/null; then
    145 			:
    146 		else
    147 			printf '/^gdm:\*LK\*\na\n%s\n.\nw\nq\n' \
    148 				"$XVM_LINE" | ed -s $dest > /dev/null
    149 		fi
    150 
    151 		#
    152 		# Add the 'zfssnap' reserved user if it doesn't exist.
    153 		#
    154 		ZFSSNAP_LINE="zfssnap:NP:::::::"
    155 		if grep "^zfssnap:" $dest 2>&1 > /dev/null; then
    156 			:
    157 		else
    158 			printf '/^gdm:\*LK\*\na\n%s\n.\nw\nq\n' \
    159 				"$ZFSSNAP_LINE" | ed -s $dest > /dev/null
    160 		fi
    161 		#
    162 		# Add the 'openldap' reserved user if it doesn't exist.
    163 		#
    164 		OPENLDAP_LINE="openldap:*LK*:::::::"
    165 		if grep "^openldap:" $dest 2>&1 >/dev/null; then
    166 			:
    167 		else
    168 			printf '/^mysql:NP\na\n%s\n.\nw\nq\n' \
    169 				"$OPENLDAP_LINE" | ed -s $dest > /dev/null
    170 		fi
    171 	fi
    172 done
    173 
    174 exit 0
    175