Index: /trunk/src/VBox/Installer/solaris/vboxconfig.sh
===================================================================
--- /trunk/src/VBox/Installer/solaris/vboxconfig.sh	(revision 37788)
+++ /trunk/src/VBox/Installer/solaris/vboxconfig.sh	(revision 37789)
@@ -71,4 +71,5 @@
 DESC_VBOXUSB="USB"
 
+UPDATEBOOTARCHIVE=0
 REMOTEINST=0
 FATALOP=fatal
@@ -227,9 +228,9 @@
     if test "$REMOTEINST" -eq 1 || test -z "$HOST_OS_MINORVERSION" || test -z "$HOST_OS_MAJORVERSION"; then
         if test -f "$PKG_INSTALL_ROOT/etc/release"; then
-            HOST_OS_MAJORVERSION=`cat $PKG_INSTALL_ROOT/etc/release | grep "Solaris 10"`
+            HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | grep "Solaris 10"`
             if test -n "$HOST_OS_MAJORVERSION"; then
                 HOST_OS_MAJORVERSION="5.10"
             else
-                HOST_OS_MAJORVERSION=`cat $PKG_INSTALL_ROOT/etc/release | egrep "snv_|oi_"`
+                HOST_OS_MAJORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | egrep "snv_|oi_"`
                 if test -n "$HOST_OS_MAJORVERSION"; then
                     HOST_OS_MAJORVERSION="5.11"
@@ -237,5 +238,5 @@
             fi
             if test "$HOST_OS_MAJORVERSION" != "5.10"; then
-                HOST_OS_MINORVERSION=`cat $PKG_INSTALL_ROOT/etc/release | tr ' ' '\n' | egrep 'snv_|oi_' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9]//"`
+                HOST_OS_MINORVERSION=`cat "$PKG_INSTALL_ROOT/etc/release" | tr ' ' '\n' | egrep 'snv_|oi_' | sed -e "s/snv_//" -e "s/oi_//" -e "s/[^0-9]//"`
             else
                 HOST_OS_MINORVERSION=""
@@ -281,4 +282,18 @@
 }
 
+# update_boot_archive()
+# cannot fail
+update_boot_archive()
+{
+    infoprint "Updating the boot archive..."
+    if test "$REMOTEINST" -eq 0; then
+        $BIN_BOOTADM update-archive > /dev/null
+    else
+        $BIN_BOOTADM update-archive -R "$PKG_INSTALL_ROOT" > /dev/null
+    fi
+    UPDATEBOOTARCHIVE=0
+}
+
+
 # module_added(modname)
 # returns 1 if added, 0 otherwise
@@ -292,5 +307,5 @@
     # Add a space at end of module name to make sure we have a perfect match to avoid
     # any substring matches: e.g "vboxusb" & "vboxusbmon"
-    loadentry=`cat $PKG_INSTALL_ROOT/etc/name_to_major | grep "$1 "`
+    loadentry=`cat "$PKG_INSTALL_ROOT/etc/name_to_major" | grep "$1 "`
     if test -z "$loadentry"; then
         return 1
@@ -373,4 +388,5 @@
     module_added $modname
     if test "$?" -eq 0; then
+        UPDATEBOOTARCHIVE=1
         if test "$ISIPS" != "$IPSOP"; then
             $BIN_REMDRV $BASEDIR_OPT $modname
@@ -496,7 +512,7 @@
     # Add vboxdrv to devlink.tab
     if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
-        sed -e '/name=vboxdrv/d' $PKG_INSTALL_ROOT/etc/devlink.tab > $PKG_INSTALL_ROOT/etc/devlink.vbox
-        echo "type=ddi_pseudo;name=vboxdrv	\D" >> $PKG_INSTALL_ROOT/etc/devlink.vbox
-        mv -f $PKG_INSTALL_ROOT/etc/devlink.vbox $PKG_INSTALL_ROOT/etc/devlink.tab
+        sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+        echo "type=ddi_pseudo;name=vboxdrv	\D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+        mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
     else
         errorprint "Missing $PKG_INSTALL_ROOT/etc/devlink.tab, aborting install"
@@ -550,7 +566,7 @@
 
             # Add vboxusbmon to devlink.tab
-            sed -e '/name=vboxusbmon/d' $PKG_INSTALL_ROOT/etc/devlink.tab > $PKG_INSTALL_ROOT/etc/devlink.vbox
-            echo "type=ddi_pseudo;name=vboxusbmon	\D" >> $PKG_INSTALL_ROOT/etc/devlink.vbox
-            mv -f $PKG_INSTALL_ROOT/etc/devlink.vbox $PKG_INSTALL_ROOT/etc/devlink.tab
+            sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+            echo "type=ddi_pseudo;name=vboxusbmon	\D" >> "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+            mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
 
             # Create the device link for non-remote installs
@@ -590,16 +606,16 @@
 
     # Remove vboxdrv from devlink.tab
-    if test -f $PKG_INSTALL_ROOT/etc/devlink.tab; then
-        devlinkfound=`cat $PKG_INSTALL_ROOT/etc/devlink.tab | grep vboxdrv`
+    if test -f "$PKG_INSTALL_ROOT/etc/devlink.tab"; then
+        devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxdrv`
         if test -n "$devlinkfound"; then
-            sed -e '/name=vboxdrv/d' $PKG_INSTALL_ROOT/etc/devlink.tab > $PKG_INSTALL_ROOT/etc/devlink.vbox
-            mv -f $PKG_INSTALL_ROOT/etc/devlink.vbox $PKG_INSTALL_ROOT/etc/devlink.tab
+            sed -e '/name=vboxdrv/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+            mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
         fi
 
         # Remove vboxusbmon from devlink.tab
-        devlinkfound=`cat $PKG_INSTALL_ROOT/etc/devlink.tab | grep vboxusbmon`
+        devlinkfound=`cat "$PKG_INSTALL_ROOT/etc/devlink.tab" | grep vboxusbmon`
         if test -n "$devlinkfound"; then
-            sed -e '/name=vboxusbmon/d' $PKG_INSTALL_ROOT/etc/devlink.tab > $PKG_INSTALL_ROOT/etc/devlink.vbox
-            mv -f $PKG_INSTALL_ROOT/etc/devlink.vbox $PKG_INSTALL_ROOT/etc/devlink.tab
+            sed -e '/name=vboxusbmon/d' "$PKG_INSTALL_ROOT/etc/devlink.tab" > "$PKG_INSTALL_ROOT/etc/devlink.vbox"
+            mv -f "$PKG_INSTALL_ROOT/etc/devlink.vbox" "$PKG_INSTALL_ROOT/etc/devlink.tab"
         fi
     fi
@@ -628,12 +644,12 @@
     # remove devlinks
     if test -h "$PKG_INSTALL_ROOT/dev/vboxdrv" || test -f "$PKG_INSTALL_ROOT/dev/vboxdrv"; then
-        rm -f $PKG_INSTALL_ROOT/dev/vboxdrv
+        rm -f "$PKG_INSTALL_ROOT/dev/vboxdrv"
     fi
     if test -h "$PKG_INSTALL_ROOT/dev/vboxusbmon" || test -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"; then
-        rm -f $PKG_INSTALL_ROOT/dev/vboxusbmon
+        rm -f "$PKG_INSTALL_ROOT/dev/vboxusbmon"
     fi
 
     # unpatch nwam/dhcpagent fix
-    nwamfile=$PKG_INSTALL_ROOT/etc/nwam/llp
+    nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
     nwambackupfile=$nwamfile.vbox
     if test -f "$nwamfile"; then
@@ -643,9 +659,17 @@
 
     # remove netmask configuration
-    nmaskfile=$PKG_INSTALL_ROOT/etc/inet/netmasks
+    if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
+        nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
+    else
+        nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
+    fi
     nmaskbackupfile=$nmaskfile.vbox
     if test -f "$nmaskfile"; then
         sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
         mv -f $nmaskbackupfile $nmaskfile
+    fi
+
+    if test $UPDATEBOOTARCHIVE -eq 1; then
+        update_boot_archive
     fi
 
@@ -794,5 +818,5 @@
         if test -f "$DIR_CONF/vboxnet.conf"; then
             # nwam/dhcpagent fix
-            nwamfile=$PKG_INSTALL_ROOT/etc/nwam/llp
+            nwamfile="$PKG_INSTALL_ROOT/etc/nwam/llp"
             nwambackupfile=$nwamfile.vbox
             if test -f "$nwamfile"; then
@@ -820,8 +844,8 @@
                     # a copy of the actual file, repair that behaviour here.
                     recreatelink=0
-                    if test -h $PKG_INSTALL_ROOT/etc/netmasks; then
-                        nmaskfile=$PKG_INSTALL_ROOT/etc/inet/netmasks
+                    if test -h "$PKG_INSTALL_ROOT/etc/netmasks"; then
+                        nmaskfile="$PKG_INSTALL_ROOT/etc/inet/netmasks"
                     else
-                        nmaskfile=$PKG_INSTALL_ROOT/etc/netmasks
+                        nmaskfile="$PKG_INSTALL_ROOT/etc/netmasks"
                         recreatelink=1
                     fi
@@ -831,4 +855,14 @@
                     if test -f $nmaskfile; then
                         sed -e '/#VirtualBox_SectionStart/,/#VirtualBox_SectionEnd/d' $nmaskfile > $nmaskbackupfile
+
+                        if test $recreatelink -eq 1; then
+                            # Check after removing our settings if /etc/netmasks is identifcal to /etc/inet/netmasks 
+                            anydiff=`diff $nmaskbackupfile "$PKG_INSTALL_ROOT/etc/inet/netmasks"`
+                            if test ! -z $anydiff; then
+                                # User may have some custom settings in /etc/netmasks, don't overwrite /etc/netmasks!
+                                recreatelink=2
+                            fi
+                        fi                        
+
                         echo "#VirtualBox_SectionStart" >> $nmaskbackupfile
                         inst=0
@@ -844,6 +878,12 @@
                         # Recreate /etc/netmasks as a link if necessary
                         if test $recreatelink -eq 1; then
-                            cp -f $PKG_INSTALL_ROOT/etc/netmasks $PKG_INSTALL_ROOT/etc/inet/netmasks
-                            ln -sf ./inet/netmasks $PKG_INSTALL_ROOT/etc/netmasks
+                            rm -f "$PKG_INSTALL_ROOT/etc/netmasks"
+                            ln -sf ./inet/netmasks "$PKG_INSTALL_ROOT/etc/netmasks"
+                        elif test $recreatelink -eq 2; then
+                            warnprint "/etc/netmasks is a symlink (to /etc/inet/netmasks) that older"
+                            warnprint "VirtualBox installers incorrectly overwrote. Now the contents"
+                            warnprint "of /etc/netmasks and /etc/inet/netmasks differ, therefore "
+                            warnprint "VirtualBox will not attempt to overwrite /etc/netmasks as a"
+                            warnprint "symlink to /etc/inet/netmasks. Please resolve this manually."
                         fi
                     fi
@@ -855,5 +895,5 @@
         fi
 
-        if test -f $PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml || test -f $PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml; then
+        if test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-webservice.xml" || test -f "$PKG_INSTALL_ROOT/var/svc/manifest/application/virtualbox/virtualbox-zoneaccess.xml"; then
             infoprint "Configuring services..."
             if test "$REMOTEINST" -eq 1; then
@@ -876,5 +916,5 @@
         # and icons. There is still some delay until the GUI picks it up,
         # but that cannot be helped.
-        if test -d $PKG_INSTALL_ROOT/usr/share/icons; then
+        if test -d "$PKG_INSTALL_ROOT/usr/share/icons"; then
             infoprint "Installing MIME types and icons..."
             if test "$REMOTEINST" -eq 0; then
@@ -925,12 +965,6 @@
         fi
 
-        # Update boot archive
-        infoprint "Updating the boot archive..."
-        if test "$REMOTEINST" -eq 0; then
-            $BIN_BOOTADM update-archive > /dev/null
-        else
-            $BIN_BOOTADM update-archive -R $PKG_INSTALL_ROOT > /dev/null
-        fi
-
+        update_boot_archive
+    
         return 0
     else
