# This is a 'e' type class action delivery script (simplified) based off: # # @(#)i.script 1.16 07/07/02 SMI # # @(#)simplified_i.e_script.DEFLT 1.1 08/01/18 # # Simplified merge version. Lookup i_casfcs() function for instructions. # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # placeholder for pkg i.CAS: BEGIN i_casfcs() { ### drop the package's CAS here and reaplce its 'exit 0' with 'return 0' ### do so with care though to make sure there are no one time actions outside ### the while loop to be merged at the bottom of this script instead #!/bin/sh # # ident "@(#)i.group 1.9 07/01/08 SMI" # # Copyright 2007 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 # # Strip off any leading "/a" # dest_file=`echo $dest | sed "s=^/a/=/="` # # Add the sysadmin group (gid 14) to support admintool # grep '^sysadmin:.*:14:.*' $dest 2>&1 >/dev/null if [ $? = 0 ] ; then /usr/bin/true elif grep '^sysadmin:' $dest 2>&1 >/dev/null; then cur_name="sysadmin" echo "SYSADMIN_NOT_14 $dest_file none" >> /tmp/CLEANUP echo "sysadmin::14:" >> $dest elif grep ':14:' $dest 2>&1 >/dev/null; then cur_name=`grep ':14:' $dest | awk -F: '{print $1}'` echo "GROUP14_IN_USE $dest_file none" >> /tmp/CLEANUP echo "sysadmin::14:" >> $dest else # add the group echo "sysadmin::14:" >> $dest fi # # Add the 'nogroup' group from 4.x so that people don't # assign it to a regular user and confuse themselves # NOGROUP_LINE="nogroup::65534:" if grep "$NOGROUP_LINE" $dest 2>&1 >/dev/null; then : else printf '/^noaccess::60002:\na\n%s\n.\nw\nq\n' \ "$NOGROUP_LINE" | ed -s $dest > /dev/null fi # Remove redundant /etc/group entries that overlap with # primary groups from /etc/passwd sed ' /^root:/s/\([:,]\)root,/\1/; /^root:/s/,root$//; /^root:/s/:root$/:/; /^bin:/s/\([:,]\)bin,/\1/; /^bin:/s/,bin$//; /^bin:/s/:bin$/:/; /^sys:/s/\([:,]\)sys,/\1/; /^sys:/s/,sys$//; /^sys:/s/:sys$/:/; /^adm:/s/\([:,]\)adm,/\1/; /^adm:/s/,adm$//; /^adm:/s/:adm$/:/; /^tty:/s/\([:,]\)tty,/\1/; /^tty:/s/,tty$//; /^tty:/s/:tty$/:/; /^uucp:/s/\([:,]\)uucp,/\1/; /^uucp:/s/,uucp$//; /^uucp:/s/:uucp$/:/; /^nuucp:/s/\([:,]\)nuucp,/\1/; /^nuucp:/s/,nuucp$//; /^nuucp:/s/:nuucp$/:/; /^daemon:/s/\([:,]\)daemon,/\1/; /^daemon:/s/,daemon$//; /^daemon:/s/:daemon$/:/; /^smmsp:/s/\([:,]\)smmsp,/\1/; /^smmsp:/s/,smmsp$//; /^smmsp:/s/:smmsp$/:/; /^lp:/s/\([:,]\)lp,/\1/; /^lp:/s/,lp$//; /^lp:/s/:lp$/:/' $dest > /tmp/g.$$ && cp /tmp/g.$$ $dest rm -f /tmp/g.$$ #add 'root' to user-list of group1 # line 1,2: skip any line with root in the user field # line 3: users already in list, add "root," # line 4: no users in list, add "root" sed ' /[:,]root,/b /[:,]root$/b s/:1:\([^:][^:]*\)$/:1:root,\1/; s/:1:$/:1:root/; ' $dest > /tmp/g.$$ && cp /tmp/g.$$ $dest rm -f /tmp/g.$$ # # Add the 'smmsp' group for sendmail 8.12 # SMMSPGROUP_LINE="smmsp::25:" if grep "$SMMSPGROUP_LINE" $dest 2>&1 >/dev/null; then : else printf '/^nogroup::65534:\na\n%s\n.\nw\nq\n' \ "$SMMSPGROUP_LINE" | ed -s $dest > /dev/null fi # # Add the 'gdm' group if it doesn't already exist. # GDMGROUP_LINE="gdm::50:" cur_name=`awk -F: '$3 == 50 {print $1}' $dest` if [ ! -z "$cur_name" -a "$cur_name" != "gdm" ]; then echo "ERROR: Reserved GID 50 already assigned" \ "to '$cur_name'" >> /tmp/CLEANUP elif grep "$GDMGROUP_LINE" $dest 2>&1 >/dev/null; then : else printf '/^smmsp::25:\na\n%s\n.\nw\nq\n' \ "$GDMGROUP_LINE" | ed -s $dest > /dev/null fi # # Add the 'webservd' group if it doesn't already exist. # WEBSERVDGROUP_LINE="webservd::80:" cur_name=`awk -F: '$3 == 80 {print $1}' $dest` if [ ! -z "$cur_name" -a "$cur_name" != "webservd" ]; then echo "ERROR: Reserved GID 80 already assigned" \ "to '$cur_name'" >> /tmp/CLEANUP elif grep "$WEBSERVDGROUP_LINE" $dest 2>&1 >/dev/null; then : else printf '/^gdm::50:\na\n%s\n.\nw\nq\n' \ "$WEBSERVDGROUP_LINE" | ed -s $dest > /dev/null fi # # Add the 'postgres' group if it doesn't already exist. # POSTGRESGROUP_LINE="postgres::90:" cur_name=`awk -F: '$3 == 90 {print $1}' $dest` cur_id=`awk -F: '$1 == "postgres" {print $3}' $dest` if [ ! -z "$cur_name" -a "$cur_name" != "postgres" ]; then echo "ERROR: Reserved GID 90 already assigned" \ "to '$cur_name'" >> /tmp/CLEANUP elif [ ! -z "$cur_id" -a "$cur_id" != "90" ]; then echo "NOTE: postgres group already assigned" \ "to id '$cur_id'" >> /tmp/CLEANUP elif grep "$POSTGRESGROUP_LINE" $dest 2>&1 >/dev/null; then : else printf '/^webservd::80:\na\n%s\n.\nw\nq\n' \ "$POSTGRESGROUP_LINE" | ed -s $dest > /dev/null fi fi done return 0 } # placeholder for pkg i.CAS: END # "e" backout magic definitions BEGIN DIFF="/usr/bin/diff" OLD_PATCH_SEPARATOR="___Old_File_Diff_Separator_aBcDeFgHiJkLmN___OjK___5924894_6548915___" # "e" backout magic definitions END PATH=/usr/sadm/bin:$PATH ECHO="/usr/bin/echo" SED="/usr/bin/sed" PKGPROTO="/usr/bin/pkgproto" EXPR="/usr/bin/expr" # used by dirname MKDIR="/usr/bin/mkdir" CP="/usr/bin/cp" RM="/usr/bin/rm" MV="/usr/bin/mv" KSH="/usr/bin/ksh" DIRNAME="/usr/bin/dirname" BASENAME="/usr/bin/basename" PATCH_COMMON_LIB="/usr/lib/patch/patch_common_lib" SAFEMODE_FAILED="Exiting! Patch deferred activation failed" recovery="no" Pn=$$ procIdCtr=0 CMDS_USED="$KSH $ECHO $SED $PKGPROTO $EXPR $MKDIR $CP $RM $MV" LIBS_USED="" if [ "$PKG_INSTALL_ROOT" = "/" ]; then PKG_INSTALL_ROOT="" fi # Check to see if this is a patch installation retry. if [ "$INTERRUPTION" = "yes" ]; then if [ -d "$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST" ] || [ -d "$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST" ]; then recovery="yes" fi fi if [ -n "$PATCH_BUILD_DIR" -a -d "$PATCH_BUILD_DIR" ]; then BUILD_DIR="$PATCH_BUILD_DIR/$SUNW_PATCHID.$PKGINST" else BUILD_DIR="$PKG_INSTALL_ROOT/var/tmp/$SUNW_PATCHID.$PKGINST" fi FILE_DIR=$BUILD_DIR/files RELOC_DIR=$FILE_DIR/reloc ROOT_DIR=$FILE_DIR/root BO_Deletes=$FILE_DIR/deletes PROGNAME=`basename $0` if [ "$PATCH_PROGRESSIVE" = "true" ]; then PATCH_NO_UNDO="true" fi # Since this is generic, figure out the class. Class=`echo $PROGNAME | nawk ' { print substr($0, 3) }'` if [ "$SAFEMODE_INSTALL" = "true" -a "$Class" = "none" ] ; then if [ ! -s "$PATCH_COMMON_LIB" ]; then puttext "$SAFEMODE_FAILED" exit 1 fi . $PATCH_COMMON_LIB InitSafemode || { puttext $SAFEMODE_FAILED exit 1 } fi # Since this is an update, $BASEDIR is guaranteed to be correct BD=${BASEDIR:-/} cd $BD # # First, figure out the dynamic libraries that can trip us up. # if [ -z "$PKG_INSTALL_ROOT" ]; then if [ -x /usr/bin/ldd ]; then LIB_LIST=`/usr/bin/ldd $CMDS_USED | sort -u | nawk ' $1 ~ /\// { continue; } { printf "%s ", $3 } '` else LIB_LIST="/usr/lib/libc.so.1 /usr/lib/libdl.so.1 /usr/lib/libw.so.1 /usr/lib/libintl.so.1 /usr/lib/libgen.so.1 /usr/lib/libadm.so.1 /usr/lib/libelf.so.1" fi fi # # Now read the list of files in this class to be replaced. If the file # is already in place, then this is a change and we need to copy it # over to the build directory if undo is allowed. If it's a new entry # (No $dst), then it goes in the deletes file for the backout package. # LD_LIB_DIR=$PKG_INSTALL_ROOT/var/tmp/LDLIB.$$ procIdCtr=0 while read src dst; do if [ -z "$PKG_INSTALL_ROOT" ]; then Chk_Path=$dst for library in $LIB_LIST; do if [ "$Chk_Path" = "$library" ]; then if [ ! -d "$LD_LIB_DIR" ]; then $MKDIR $LD_LIB_DIR fi $CP $dst $LD_LIB_DIR LD_LIBRARY_PATH=$LD_LIB_DIR export LD_LIBRARY_PATH fi done fi if [ "$PATCH_PROGRESSIVE" = "true" ]; then # If this is being used in an old-style patch, insert # the old-style script commands here. #XXXOld_CommandsXXX# echo >/dev/null # dummy fi if [ "${PATCH_NO_UNDO}" != "true" ]; then # # Here we construct the path to the appropriate source # tree for the build. First we try to strip BASEDIR. If # there's no BASEDIR in the path, we presume that it is # absolute and construct the target as an absolute path # by stripping PKG_INSTALL_ROOT. FS_Path is the path to # the file on the file system (for deletion purposes). # Build_Path is the path to the object in the build # environment. # # The following rootPath variable accounts for a BASEDIR # that is used as a regular variable within the path and # not as a variable that a path needs to be relocated to. rootPath=`$ECHO $src | $SED s@"$INST_DATADIR/$PKGINST"@@ | \ nawk -F/ '{print $2}'` if [ "$rootPath" = "root" ]; then FS_Path=$dst elif [ "$BD" = "/" ]; then FS_Path=`$ECHO $dst | $SED s@"$BD"@@` else FS_Path=`$ECHO $dst | $SED "s|^$BD/||"` fi # If it's an absolute path the attempt to strip the # BASEDIR will have failed. if [ "$dst" = "$FS_Path" ]; then if [ -z "$PKG_INSTALL_ROOT" ]; then FS_Path=$dst Build_Path="$ROOT_DIR$dst" else Build_Path="$ROOT_DIR"`echo $dst | \ $SED "s|$PKG_INSTALL_ROOT||"` FS_Path=`echo $dst | \ $SED "s|$PKG_INSTALL_ROOT||"` fi else Build_Path="$RELOC_DIR/$FS_Path" fi if [ -f "$dst" ]; then # If this is replacing something cd $FILE_DIR # # Construct the prototype file entry. We replace # the pointer to the filesystem object with the # build directory object. # $PKGPROTO -c $Class $dst=$FS_Path | \ $SED -e "s|^f |e |" \ -e "s|=$dst|=$Build_Path|" >> \ $BUILD_DIR/prototype # Now copy over the file if [ "$recovery" = "no" ]; then DirName=`dirname $Build_Path` $MKDIR -p $DirName $CP -p $dst $Build_Path else # If this file is already in the build area skip it if [ -f "$Build_Path" ]; then cd $BD continue else DirName=`dirname $Build_Path` if [ ! -d "$DirName" ]; then $MKDIR -p $DirName fi $CP -p $dst $Build_Path fi fi cd $BD else # It's brand new $ECHO $FS_Path >> $BO_Deletes fi fi # If special processing is required for each src/dst pair, # add that here. # #XXXSpecial_CommandsXXX# # # "e" backout magic prepare BEGIN DST_EXIST="false" if [ "${PATCH_NO_UNDO}" != "true" ]; then if [ -f "${dst}" ] ; then DST_EXIST="true" else DST_EXIST="false" fi if [ "${DST_EXIST}" = "true" ] ; then #Save original file $MKDIR -p "`dirname $Build_Path`" $CP "${dst}" "$Build_Path.orig" $CP "${dst}" "$Build_Path.old_and_patch" fi fi # "e" backout magic prepare END #call merged script echo $src $dst | i_casfcs procIdCtr=`expr $procIdCtr + 1` # "e" backout magic store BEGIN if [ "${DST_EXIST}" = "true" ] ; then echo "${OLD_PATCH_SEPARATOR}" >> "$Build_Path.old_and_patch" $DIFF -C 3 "$Build_Path.orig" "$dst" >> "$Build_Path.old_and_patch" if [ "$?" -ne 0 ] ; then #Create a repository for original file and diff in the undo package $ECHO "e $Class $FS_Path.old_and_patch=$Build_Path.old_and_patch" >>$BUILD_DIR/prototype #Make sure this file does not remain on the system after the backout $ECHO "$FS_Path.old_and_patch" >>"$BO_Deletes" fi fi # "e" backout magic store END done # If additional operations are required for this package, place # those package-specific commands here. #XXXSpecial_CommandsXXX# # # Release the dynamic libraries # if [ -d "$LD_LIB_DIR" ]; then $RM -fr $LD_LIB_DIR fi exit 0