diff -ru /opt/SUNWut.orig/bin/utselect /opt/SUNWut/bin/utselect
--- /opt/SUNWut.orig/bin/utselect	2007-08-02 00:43:59.000000000 +0200
+++ /opt/SUNWut/bin/utselect	2007-09-28 21:35:27.000000000 +0200
@@ -223,7 +223,11 @@
 	}
 	set env(LC_ALL) "C"
 
-	set lf [open "|$path/utswitch -l | sort +2nr" r]
+	if [[ "$(uname)" = "Linux" ]]; then
+		 set lf [open "|$path/utswitch -l | sort -nrk 2" r]
+	else
+		set lf [open "|$path/utswitch -l | sort +2nr" r]
+	fi
 
 	if [info exists tmpLC_ALL] {
 		set env(LC_ALL) $tmpLC_ALL
diff -ru /opt/SUNWut.orig/bin/utset /opt/SUNWut/bin/utset
--- /opt/SUNWut.orig/bin/utset	2007-08-02 00:44:02.000000000 +0200
+++ /opt/SUNWut/bin/utset	2007-09-28 21:35:27.000000000 +0200
@@ -851,7 +851,7 @@
       print "$R $S"
     done
   ) |
-  (export LC_ALL=C; sort -t 'x' +0 -1n +1 -2n +2 -3n)
+  (export LC_ALL=C; sort -t 'x' -k 1,1n -k 2,2n -k 3,3n )
 
   exit 0
 fi
diff -ru /opt/SUNWut.orig/bin/utwho /opt/SUNWut/bin/utwho
--- /opt/SUNWut.orig/bin/utwho	2007-08-02 00:43:59.000000000 +0200
+++ /opt/SUNWut/bin/utwho	2007-09-28 21:35:27.000000000 +0200
@@ -142,7 +142,7 @@
 			print disp, name
 	}' $sessfiles | sort >$TMP/map2.$$
 
-join -j 1 $TMP/map1.$$ $TMP/map2.$$ | sort +1 > $TMP/map4.$$
+join -j 1 $TMP/map1.$$ $TMP/map2.$$ | sort -k 1 > $TMP/map4.$$
 
 if [ $connected = "false" ]
 then
diff -ru /opt/SUNWut.orig/lib/dhcp/isc/dhcp_config_linux /opt/SUNWut/lib/dhcp/isc/dhcp_config_linux
--- /opt/SUNWut.orig/lib/dhcp/isc/dhcp_config_linux	2007-08-02 00:44:01.000000000 +0200
+++ /opt/SUNWut/lib/dhcp/isc/dhcp_config_linux	2007-09-28 21:35:27.000000000 +0200
@@ -7,7 +7,11 @@
 #
 
 UTDHCPDIR="$ETCDIR"/net/dhcp
-DHCPDCONF=/etc/dhcpd.conf
+if [[ -f "/etc/dhcp3/dhcpd.conf" ]]; then
+	DHCPDCONF=/etc/dhcp3/dhcpd.conf
+else
+	DHCPDCONF=/etc/dhcpd.conf
+fi
 UTDHCPFILE="$UTDHCPDIR"/utdhcp
 OPTIONSFILENAME="SunRay-options"
 OPTIONSFILE="$UTDHCPDIR"/"$OPTIONSFILENAME"
@@ -30,12 +34,16 @@
 DUMMY_SUBNET_COMMENT="# Sun Ray: dummy subnet to support DHCP clients on remote subnets"
 
 CheckChrooted() {
-	grep $CHROOTKEY $SYSDHCPD | grep -i yes 2>/dev/null 1>&2
-	if [[ $? -eq 0 ]]; then
-		CHROOTED=true
+	if [[ -f $SYSDHCPD ]]; then
+		grep $CHROOTKEY $SYSDHCPD | grep -i yes 2>/dev/null 1>&2
+		if [[ $? -eq 0 ]]; then
+			CHROOTED=true
+		else
+			CHROOTED=false
+		fi
 	else
 		CHROOTED=false
-	fi	
+	fi
 }
 
 GenerateOptionsDHCPDBlock() {
diff -ru /opt/SUNWut.orig/lib/dhcp/isc/utdhcpservice /opt/SUNWut/lib/dhcp/isc/utdhcpservice
--- /opt/SUNWut.orig/lib/dhcp/isc/utdhcpservice	2007-08-02 00:44:01.000000000 +0200
+++ /opt/SUNWut/lib/dhcp/isc/utdhcpservice	2007-09-28 21:35:27.000000000 +0200
@@ -49,10 +49,19 @@
 
 # names of files and directories that will be touched by this script
 #
-DHCP_CONFIG="/etc/dhcpd.conf";
+if [[ -f "/etc/dhcp3/dhcpd.conf" ]]; then
+	DHCP_CONFIG="/etc/dhcp3/dhcpd.conf"
+else
+	DHCP_CONFIG="/etc/dhcpd.conf"
+fi
 DHCP_CONFIG_SAMPLE_RHAS="/usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample";
 DHCP_CONFIG_SAMPLE_SLES="/usr/share/doc/packages/dhcp-server/dhcpd.conf";
-DHCP_DIR="/var/lib/dhcp";
+DHCP_CONFIG_SAMPLE_DEB="/usr/share/doc/dhcp3-server/examples/dhcpd.conf";
+if [[ -d "/var/lib/dhcp3" ]]; then
+	DHCP_DIR=/var/lib/dhcp3
+else
+	DHCP_DIR="/var/lib/dhcp"
+fi
 TMPDIR="/var/opt/SUNWut/tmp"
 CORONA_NAME="SunRay";
 CORONA_TITLE="Sun Ray";
@@ -72,6 +81,7 @@
 typeset DHCP_RUNNING=true
 typeset DHCP_PACKAGE_RH="dhcp"
 typeset DHCP_PACKAGE_SU="dhcp-server"
+typeset DHCP_PACKAGE_DEB="dhcp3-server"
 typeset DHCP_PACKAGE="DHCP"
 typeset DHCP_STATE="online"
 
@@ -93,7 +103,12 @@
     typeset PACKAGE="${DHCP_PACKAGE}"
     if $DHCP_INSTALLED ; then
       # get the actual package name including version and release
-      PACKAGE="$(rpm -q ${DHCP_PACKAGE} 2> /dev/null)"
+	DPKG=$(which dpkg1)
+	if [[ -f "$DPKG" ]]; then
+	  PACKAGE="$(dpkg -l | grep dhcp3-server | awk '{print $2$3}' 2> /dev/null)"
+	else
+ 	  PACKAGE="$(rpm -q ${DHCP_PACKAGE} 2> /dev/null)"
+	fi
     fi
     if ! $DHCP_RUNNING && [ $DHCP_STATE != "unconfigured" ] ; then
       DHCP_STATE="disabled"
@@ -118,12 +133,18 @@
           DHCP_CONFIG_SAMPLE=${DHCP_CONFIG_SAMPLE_RHAS}
        elif [ -f ${DHCP_CONFIG_SAMPLE_SLES} ]; then
            DHCP_CONFIG_SAMPLE=${DHCP_CONFIG_SAMPLE_SLES}
+       elif [ -f ${DHCP_CONFIG_SAMPLE_DEB} ]; then
+           DHCP_CONFIG_SAMPLE=${DHCP_CONFIG_SAMPLE_DEB}
        fi
        diff ${DHCP_CONFIG} ${DHCP_CONFIG_SAMPLE} > /dev/null 2>&1
        if [[ $? == 0 ]]; then
             mv ${DHCP_CONFIG} ${DHCP_CONFIG}.sunray
        else
-	   dhcpd -t > /dev/null 2>&1
+           if [[ -f "/usr/sbin/dhcpd3" ]]; then
+       		dhcpd3 -t > /dev/null 2>&1
+	   else
+		   dhcpd -t > /dev/null 2>&1
+	   fi
 	   if [[ $? == 0 ]]; then
 		cat > ${DHCP_CONFIG}.$$ <<-!
 # ${SUNRAY_FILE_MARK} /etc/dhcpd.conf
@@ -204,7 +225,11 @@
       return 3
     fi
 
-    /etc/init.d/dhcpd start > /dev/null 2>&1
+    if [[ -f /etc/init.d/dhcp3-server ]]; then
+        /etc/init.d/dhcp3-server start > /dev/null 2>&1
+    else
+        /etc/init.d/dhcpd start > /dev/null 2>&1
+    fi 
     return $?
 }
 
@@ -212,8 +237,11 @@
     if ! $DHCP_ENABLED ; then
       return 3
     fi
-
-    /etc/init.d/dhcpd stop > /dev/null 2>&1
+    if [[ -f /etc/init.d/dhcp3-server ]]; then
+        /etc/init.d/dhcp3-server  stop > /dev/null 2>&1
+    else
+        /etc/init.d/dhcpd stop > /dev/null 2>&1
+    fi
     return $?
 }
 
@@ -221,8 +249,11 @@
     if ! $DHCP_ENABLED ; then
       return 3
     fi
-
-    /etc/init.d/dhcpd restart > /dev/null 2>&1
+    if [[ -f /etc/init.d/dhcp3-server ]]; then
+        /etc/init.d/dhcp3-server  restart > /dev/null 2>&1
+    else
+        /etc/init.d/dhcpd restart > /dev/null 2>&1
+    fi
     return $?
 }
 
@@ -233,11 +264,16 @@
 if [[ $? -ne 0 ]] ; then
   ${UT_BASEDIR}/lib/utprodinfo -t installed ${DHCP_PACKAGE_SU} 2>/dev/null 1>&2
   if [[ $? -ne 0 ]]; then
-    DHCP_INSTALLED=false
-    DHCP_ENABLED=false
-    DHCP_CONFIGURED=false
-    DHCP_RUNNING=false
-    DHCP_STATE="uninstalled"
+    ${UT_BASEDIR}/lib/utprodinfo -t installed ${DHCP_PACKAGE_DEB} 2>/dev/null 1>&2
+    if [[ $? -ne 0 ]]; then
+      DHCP_INSTALLED=false
+      DHCP_ENABLED=false
+      DHCP_CONFIGURED=false
+      DHCP_RUNNING=false
+      DHCP_STATE="uninstalled"
+    else
+      DHCP_PACKAGE=${DHCP_PACKAGE_DEB}
+    fi
   else
     DHCP_PACKAGE=${DHCP_PACKAGE_SU}
   fi
@@ -262,8 +298,11 @@
     	if [[ $? != 0 ]] ; then
       	    DHCP_CONFIGURED=false	# Interface / subnet not defined
     	fi
-
-    	/etc/init.d/dhcpd status 2> /dev/null | grep "running" >/dev/null 2>&1
+        if [[ -f "/etc/init.d/dhcp3-server" ]]; then
+            /etc/init.d/dhcp3-server status 2> /dev/null | grep "running" >/dev/null 2>&1
+        else
+	    /etc/init.d/dhcpd status 2> /dev/null | grep "running" >/dev/null 2>&1
+	fi
     	if [[ $? -ne 0 ]]; then
       	    DHCP_RUNNING=false
     	fi
diff -ru /opt/SUNWut.orig/lib/iu_modules/M08GDM /opt/SUNWut/lib/iu_modules/M08GDM
--- /opt/SUNWut.orig/lib/iu_modules/M08GDM	2007-08-02 01:45:17.000000000 +0200
+++ /opt/SUNWut/lib/iu_modules/M08GDM	2007-09-28 21:35:27.000000000 +0200
@@ -307,7 +307,7 @@
 #
 if IsInstallRequired; then
 	# when installing, pick up the build number from the rpm in the CD image
-	typeset TMP_NAME=`/bin/ls -1tr ${GDM_DIR}/${GDM_NAME}-${GDM_VERSION}-?*.i386.rpm | tail -1`
+	typeset TMP_NAME=`/bin/ls -1tr ${GDM_DIR}/${GDM_NAME}-${GDM_VERSION}-?*.i386.rpm | tail -n 1`
 	TMP_NAME=${TMP_NAME##*-}
 	export GDM_RELEASE=${TMP_NAME%%.*}
 else
diff -ru /opt/SUNWut.orig/lib/iu_modules/M10SunDS /opt/SUNWut/lib/iu_modules/M10SunDS
--- /opt/SUNWut.orig/lib/iu_modules/M10SunDS	2007-08-02 01:45:17.000000000 +0200
+++ /opt/SUNWut/lib/iu_modules/M10SunDS	2007-09-28 21:35:27.000000000 +0200
@@ -98,7 +98,7 @@
           # NOTE: head -2 to deal with the case the first line is blank.
           # we need only to know if there is anything under the subtree.
           #
-          ANY=$(ldapsearch -b "$BASE" -s one "objectclass=*" dn 2>&- | head -2)
+          ANY=$(ldapsearch -b "$BASE" -s one "objectclass=*" dn 2>&- | head -n 2)
           search_st=$?
           if [[ $search_st -eq 0 ]]; then
             # subtree exists, check if empty
diff -ru /opt/SUNWut.orig/lib/iu_modules/M40AuthMgr /opt/SUNWut/lib/iu_modules/M40AuthMgr
--- /opt/SUNWut.orig/lib/iu_modules/M40AuthMgr	2007-08-02 01:45:18.000000000 +0200
+++ /opt/SUNWut/lib/iu_modules/M40AuthMgr	2007-09-28 21:35:27.000000000 +0200
@@ -260,19 +260,19 @@
 
     # try to set keyval to uncommented pair first
     old_keyval=$(grep "=" $oldfile 2>&- |
-        grep "^[ 	]*${key}[= 	]" | tail -1)
+        grep "^[ 	]*${key}[= 	]" | tail -n 1)
     # if no uncommented pair, take the last commented pair
     [[ -z "$old_keyval" ]] && \
       old_keyval=$(grep "=" $oldfile 2>&- |
-      grep "^[# 	]*${key}[= 	]" | tail -1)
+      grep "^[# 	]*${key}[= 	]" | tail -n 1)
 
     # try to set keyval to uncommented pair first
     new_keyval=$(grep "=" $newfile 2>&- |
-        grep "^[ 	]*${key}[= 	]" | tail -1)
+        grep "^[ 	]*${key}[= 	]" | tail -n 1)
     # if no uncommented pair, take the last commented pair
     [[ -z "$new_keyval" ]] && \
       new_keyval=$(grep "=" $newfile 2>&- |
-      grep "^[# 	]*${key}[= 	]" | tail -1)
+      grep "^[# 	]*${key}[= 	]" | tail -n 1)
 
 #
 # Check if this parameter does not have to be modified
diff -ru /opt/SUNWut.orig/lib/support_lib/iu_lib /opt/SUNWut/lib/support_lib/iu_lib
--- /opt/SUNWut.orig/lib/support_lib/iu_lib	2007-08-02 01:45:20.000000000 +0200
+++ /opt/SUNWut/lib/support_lib/iu_lib	2007-09-28 21:36:10.000000000 +0200
@@ -183,8 +183,8 @@
 
     for patchid in $all_patches; do
       print -n "... checking patch ${patchid} ... "
-      exist=$(grep "${patchid}-[0-9][0-9]" ${showrev_p} | head -1)
-      patch=$(\ls -1 "$dir" 2>&- | grep "^${patchid}" | tail -1)
+      exist=$(grep "${patchid}-[0-9][0-9]" ${showrev_p} | head -n -1)
+      patch=$(\ls -1 "$dir" 2>&- | grep "^${patchid}" | tail -n -1)
       pkgs=$(cd "${dir}/${patch}" 2>&-; \ls -1 */pkginfo 2>&- | 
         sed -e 's:/pkginfo::g')
 
diff -ru /opt/SUNWut.orig/lib/support_lib/sras_config /opt/SUNWut/lib/support_lib/sras_config
--- /opt/SUNWut.orig/lib/support_lib/sras_config	2007-08-02 01:45:20.000000000 +0200
+++ /opt/SUNWut/lib/support_lib/sras_config	2007-09-28 21:47:43.000000000 +0200
@@ -392,13 +392,13 @@
 		else
 			if [[ $APACHE_INSTALLED == "both" ]]; then
 				if [[ $OS == "Linux" ]]; then
-					if ! ReplyIsYes "\nThere is an instance of Apache detected in both" \
+					if ! ReplyIsYes "\nThere is an istance of Apache detected in both" \
 				      	      "\n/etc/httpd and /usr/apache.  The default is /etc/httpd." \
 				      	      "\nWould you like to use this instance?  Answering \"no\"" \
 				      	      "\nwill configure the /usr/apache instance." ; then
 						APACHETMP="$ETC_OPT_UT"/http/templates/apache.tpl
-  						APACHECTL="/usr/apache/bin/apachectl"	
-						APACHEDIR="/usr/apache/conf"
+  						APACHECTL="/usr/bin/apache2ctl"	
+						APACHEDIR="/etc/apache2"
 						APACHECFG="$APACHEDIR"/httpd.conf
 					fi
 					UT_LOCATION=$APACHEDIR
@@ -581,6 +581,13 @@
 		rm -f /etc/opt/SUNWut/http/auto.start
 	fi
 	print ${APACHECTL} > /etc/opt/SUNWut/http/auto.start
+       if [[ -f /etc/default/apache2 ]]; then
+               . /etc/default/apache2
+               if [[ "$NO_START" = "1" ]]; then
+                       echo "# 0 = start on boot; 1 = don't start on boot" > /etc/default/apache2
+                       echo "NO_START=0" >> /etc/default/apache2
+               fi
+       fi
 }
 
 RemoveAutoStart()
@@ -906,6 +913,8 @@
 	if [[ $OS == "Linux" ]]; then
 		if [[ -f /etc/httpd/conf/magic || -f /etc/httpd/magic ]]; then
 			HTTPD_SCRIPT=/usr/sbin/httpd
+                elif [[ -f /etc/apache2/magic ]]; then
+                        HTTPD_SCRIPT=/usr/sbin/apache2
 		fi
 	fi
 
@@ -948,6 +957,8 @@
 			BUNDLED_MAGIC=/etc/httpd/conf/magic
 		elif [[ -f /etc/httpd/magic ]]; then
 			BUNDLED_MAGIC=/etc/httpd/magic
+                elif [[ -f /etc/apache2/magic ]]; then
+                        BUNDLED_MAGIC=/etc/apache2/magic
 		fi
 		;;
 	esac
@@ -1078,11 +1089,26 @@
 			fi
                 	STATUS=1
         	fi
+
+	# Check for apache in Debian/Ubuntu location
+	elif [[ -f /etc/apache2/magic ]]; then
+		APACHEDIR="/etc/apache2"
+		APACHETMP="$ETC_OPT_UT"/http/templates/apache.tpl.debian
+		APACHECTL="/etc/init.d/apache2"
 	fi
         ;;
   esac
   if [[ -n $APACHEDIR ]]; then
-  	APACHECFG="$APACHEDIR"/httpd.conf
+       if [[ "$OS" = "Linux" ]]; then
+               . /etc/lsb-release
+               if [[ "$DISTRIB_ID" = "Ubuntu" ]] || [[ "$DISTRIB_ID" = "Debian" ]]; then
+                       APACHECFG="$APACHEDIR"/apache2.conf
+               else
+                       APACHECFG="$APACHEDIR"/httpd.conf
+               fi
+       else
+               APACHECFG="$APACHEDIR"/httpd.conf
+       fi
   fi
   ApacheInstalled
 
diff -ru /opt/SUNWut.orig/lib/support_lib/upgrade_lib /opt/SUNWut/lib/support_lib/upgrade_lib
--- /opt/SUNWut.orig/lib/support_lib/upgrade_lib	2007-08-02 01:45:20.000000000 +0200
+++ /opt/SUNWut/lib/support_lib/upgrade_lib	2007-09-28 21:35:27.000000000 +0200
@@ -56,9 +56,9 @@
   for key in $(awk -F= '{ print $1 }' $oldfile 2>&- | grep -v "^#" |
       sort -u); do
     old_keyval=$(grep "^[ 	]*$key[= 	]" $oldfile 2>&- |
-        tail -1)
+        tail -n 1)
     new_keyval=$(grep "^[ 	]*$key[= 	]" $newfile 2>&- |
-        tail -1)
+        tail -n 1)
     if [[ -n "$old_keyval" && -n "$new_keyval" ]]; then
       if [[ "$old_keyval" != "$new_keyval" ]]; then
         DoUpgrade "$key" "$old_keyval" "$new_keyval" "$newfile"
@@ -116,7 +116,7 @@
   fi
   for key in $(grep -v "^#" "$oldfile" 2>&- | awk -F= '{ print $1 }' |
       sort -u); do
-    line=$(grep "^${key}[ 	=]" "$oldfile" 2>&- | tail -1)
+    line=$(grep "^${key}[ 	=]" "$oldfile" 2>&- | tail -n 1)
     grep "$line" "$newfile" 2>&1 >/dev/null || \
       DoAppend "$line" "$newfile"
   done
@@ -564,7 +564,7 @@
     return 1
   fi
 
-  _RETURN_VAL=$(ls -1 ${TARFILE}* | tail -1)
+  _RETURN_VAL=$(ls -1 ${TARFILE}* | tail -n 1)
 
   return 0
 
diff -ru /opt/SUNWut.orig/lib/utadmingid /opt/SUNWut/lib/utadmingid
--- /opt/SUNWut.orig/lib/utadmingid	2007-08-02 00:44:00.000000000 +0200
+++ /opt/SUNWut/lib/utadmingid	2007-09-28 21:35:27.000000000 +0200
@@ -15,7 +15,7 @@
 ETCDIR="/etc/opt/SUNWut"
 UTADMINPW=${ETCDIR}/utadmin.pw
 if [ -f $UTADMINPW ] ; then
-	WEBGUI_GROUP=`/bin/ls -gn $UTADMINPW | /bin/awk '{print $3}' `
+	WEBGUI_GROUP=`/bin/ls -gn $UTADMINPW | awk '{print $3}' `
 fi
 WEBGUI_GROUP=${WEBGUI_GROUP:-root}
 print $WEBGUI_GROUP
diff -ru /opt/SUNWut.orig/lib/utctl.d/features/utcompatlinksctl /opt/SUNWut/lib/utctl.d/features/utcompatlinksctl
--- /opt/SUNWut.orig/lib/utctl.d/features/utcompatlinksctl	2007-08-02 00:43:56.000000000 +0200
+++ /opt/SUNWut/lib/utctl.d/features/utcompatlinksctl	2007-09-28 21:35:27.000000000 +0200
@@ -103,11 +103,11 @@
 	COMPATLINK_LIBGDBM=$LIB_COMPATLINKS/${LIBGDBM##*/}
 
 	LIBLDAP=/usr/lib/libldap.so.199
-	COMPATLIB_LIBLDAP=/usr/lib/libldap-2.2.so.7
+	COMPATLIB_LIBLDAP=/usr/lib/libldap-2.3.so.0
 	COMPATLINK_LIBLDAP=$LIB_COMPATLINKS/${LIBLDAP##*/}
 
 	LIBLBER=/usr/lib/liblber.so.199
-	COMPATLIB_LIBLBER=/usr/lib/liblber-2.2.so.7
+	COMPATLIB_LIBLBER=/usr/lib/liblber-2.3.so.0
 	COMPATLINK_LIBLBER=$LIB_COMPATLINKS/${LIBLBER##*/}
 }
 
diff -ru /opt/SUNWut.orig/lib/utctl.d/features/utcronctl /opt/SUNWut/lib/utctl.d/features/utcronctl
--- /opt/SUNWut.orig/lib/utctl.d/features/utcronctl	2007-08-02 00:43:55.000000000 +0200
+++ /opt/SUNWut/lib/utctl.d/features/utcronctl	2007-09-28 21:35:27.000000000 +0200
@@ -37,13 +37,13 @@
 		return
 	fi
 
-	(set +e; head -1 $CRONFILE | \
+	(set +e; head -n 1 $CRONFILE | \
 	    grep "^# DO NOT EDIT THIS FILE - edit the master and reinstall" \
 	    > /dev/null 2>&1)
 	if [ $? -eq 0 ]; then
 		# comment exists, remove them
 		cat /dev/null >$TMPFILE_COMM
-		head -3 $CRONFILE | sed \
+		head -n 3 $CRONFILE | sed \
 		-e "/^# DO NOT EDIT THIS FILE - edit the master and reinstall/d" \
 		-e "/^# (\/[^ ]* installed/d" \
 		-e "/^# (Cron version/d" >> $TMPFILE_COMM
diff -ru /opt/SUNWut.orig/lib/utdmsession /opt/SUNWut/lib/utdmsession
--- /opt/SUNWut.orig/lib/utdmsession	2007-08-02 00:43:54.000000000 +0200
+++ /opt/SUNWut/lib/utdmsession	2007-09-28 21:35:27.000000000 +0200
@@ -26,7 +26,7 @@
 #exec 2>&1 2>/var/tmp/utdmsession.$$       # Debug
 #set -x
 
-MOD="`/bin/basename $0`"
+MOD="`basename $0`"
 USAGE="usage: $MOD [-c|-d] Xdisplay [-z tag]"
 UTMNT_DIRLOCK=".session"
 
diff -ru /opt/SUNWut.orig/lib/utdtsession /opt/SUNWut/lib/utdtsession
--- /opt/SUNWut.orig/lib/utdtsession	2007-08-02 00:43:57.000000000 +0200
+++ /opt/SUNWut/lib/utdtsession	2007-09-28 21:35:27.000000000 +0200
@@ -268,7 +268,7 @@
 		# running 'ps'.
 		#
 		(print -n "add :$dpy . " ; /usr/bin/mcookie) | \
-		    /usr/X11R6/bin/xauth -q -f $authfile source -
+		    /usr/bin/xauth -q -f $authfile source -
 	fi
 }
 
@@ -528,7 +528,7 @@
 	# so that a new session can be created.
 
 	# get the existing session ID
-	oldsid=$(head -1 $tif)
+	oldsid=$(head -n 1 $tif)
 
 	# get the existing session type
 	OLD_SESSION_TYPE=""
diff -ru /opt/SUNWut.orig/lib/utprodinfo /opt/SUNWut/lib/utprodinfo
--- /opt/SUNWut.orig/lib/utprodinfo	2007-08-02 01:45:16.000000000 +0200
+++ /opt/SUNWut/lib/utprodinfo	2007-09-28 21:35:27.000000000 +0200
@@ -73,6 +73,8 @@
 set -A SunOS_Mapped_Sed
 # Mapped parameter query format for the Linux packaging utility
 set -A Linux_Mapped_Param
+# Mapped parameter query format for the dpkg packaging utility
+set -A Debian_Mapped_Param
 # Maximum number of parameters allowed
 typeset -i MAXParam=1
 
@@ -80,42 +82,51 @@
 Param[${MAXParam}]="BASEDIR"
 SunOS_Mapped_Param[${MAXParam}]="BASEDIR"
 Linux_Mapped_Param[${MAXParam}]="%{INSTALLPREFIX}"
+Debian_Mapped_Param[${MAXParam}]="INSTALLPREFIX"
 let MAXParam+=1
 # --- VERSION - version number with the build info.  Ex: 2.0_37.b
 Param[${MAXParam}]="VERSION"
 SunOS_Mapped_Param[${MAXParam}]="VERSION"
 SunOS_Mapped_Sed[${MAXParam}]="s/\([0-9]\{1,\}\.[0-9]\{1,\}_[0-9]\{1,2\}\.\{0,1\}[a-z]\{0,1\}\),.*/\1/"
 Linux_Mapped_Param[${MAXParam}]="%{VERSION}_%{RELEASE}"
+Debian_Mapped_Param[${MAXParam}]="DEBVERSION"
 let MAXParam+=1
 # --- PSTAMP - product timestamp
 Param[${MAXParam}]="PSTAMP"
 SunOS_Mapped_Param[${MAXParam}]="PSTAMP"
 Linux_Mapped_Param[${MAXParam}]="%{BUILDTIME:date}"
+Debian_Mapped_Param[${MAXParam}]=""
 let MAXParam+=1
 # --- NAME - description of the package.
 Param[${MAXParam}]="NAME"
 SunOS_Mapped_Param[${MAXParam}]="NAME"
 Linux_Mapped_Param[${MAXParam}]="%{SUMMARY}"
+Debian_Mapped_Param[${MAXParam}]='${Description;40}'
 let MAXParam+=1
 # --- PRODVERS - product version without the build info.  Ex: 2.0
 Param[${MAXParam}]="PRODVERS"
 SunOS_Mapped_Param[${MAXParam}]="SUNW_PRODVERS"
 Linux_Mapped_Param[${MAXParam}]="%{VERSION}"
+Debian_Mapped_Param[${MAXParam}]="DEBPRODVERS"
 let MAXParam+=1
 # --- PKGNAME - package name. Ex: SUNWuto
 Param[${MAXParam}]="PKGNAME"
 SunOS_Mapped_Param[${MAXParam}]="PKGINST"
 Linux_Mapped_Param[${MAXParam}]="%{NAME}"
+Debian_Mapped_Param[${MAXParam}]='${Package}\\n'
 let MAXParam+=1
 # --- INSTDATE - date the package is installed on the system.
 Param[${MAXParam}]="INSTDATE"
 SunOS_Mapped_Param[${MAXParam}]="INSTDATE"
 Linux_Mapped_Param[${MAXParam}]="%{INSTALLTIME:date}"
+Debian_Mapped_Param[${MAXParam}]=""
 let MAXParam+=1
 # --- PATCHLIST - list of patches installed for this package.
 Param[${MAXParam}]="PATCHLIST"
 SunOS_Mapped_Param[${MAXParam}]="PATCHLIST"
 Linux_Mapped_Param[${MAXParam}]=""
+Debian_Mapped_Param[${MAXParam}]=""
+
 let MAXParam+=1
 
 
@@ -154,14 +165,22 @@
 			# add key name manipulation sed script
 			SEDLIST="${SEDLIST} -e s/^${SunOS_Mapped_Param[${1}]}=/${Param[${1}]}=/"
 		fi
-	else
-		if [[ -n "${Linux_Mapped_Param[${1}]}" ]]; then
+	elif [[ ${PREFIX} = "Debian" ]]; then
+		if [[ -n "${Debian_Mapped_Param[${1}]}" ]]; then
 			if ${2}; then
-				MAPPEDLIST="${MAPPEDLIST}${Param[${1}]}=${Linux_Mapped_Param[${1}]}\\n"
+				MAPPEDLIST="${MAPPEDLIST}${Param[${1}]}=${Debian_Mapped_Param[${1}]}\\n"
 			else
-				MAPPEDLIST="${Linux_Mapped_Param[${1}]}\\n"
+				MAPPEDLIST="${Debian_Mapped_Param[${1}]}\\n"
 			fi
 		fi
+	else
+                if [[ -n "${Linux_Mapped_Param[${1}]}" ]]; then
+                        if ${2}; then
+                                MAPPEDLIST="${MAPPEDLIST}${Param[${1}]}=${Linux_Mapped_Param[${1}]}\\n"
+                        else
+                                MAPPEDLIST="${Linux_Mapped_Param[${1}]}\\n"
+                        fi
+                fi
 	fi
 }
 
@@ -321,6 +340,14 @@
 	return $?
 }
 
+Debian_dispAll() {
+       $DEBUG
+        # NOTE: must sort first so that we can return the exit code from grep
+	dpkg -l | grep "Sun Ray"
+	return $?
+}
+
+
 #
 # dispParams - displays the parameter information in key-value form.
 # $1 - package name
@@ -343,6 +370,43 @@
 	return 0
 }
 
+Debian_dispParams() {
+        $DEBUG
+        if ! ${PREFIX}_testPkg installed $PKGNAME; then
+                # package not installed;
+                print -u2 "${ERROR_PREF} package $PKGNAME not installed"
+                return 1
+        fi
+
+        buildParamList "$@"
+        if [[ $? -eq 1 ]]; then
+                # found no params, just return
+                return 0
+        fi
+
+	# This is becaue the alien converted packaged are lowercase
+	DEB="`echo "${PKGNAME}" | tr '[A-Z]' '[a-z]'`"
+	VERSION=""
+	PRODVERS=""
+
+	# The below is a bit of a hack to get the correct informtin out of dpkg-query
+	# it always returns /opt as the basedir
+
+	if [ "`echo "${MAPPEDLIST}"|grep "DEBVERSION"`" ]; then
+		VERSION="`dpkg-query -f '${Version}\n' -W "${DEB}" | sed -e 's/-/_/'`"
+	fi
+	if [ "`echo "${MAPPEDLIST}"|grep "DEBPRODVERS"`" ]; then
+		PRODVERS="`dpkg-query -f '${Version}\n' -W "${DEB}" | sed -e 's/-.*$//'`"
+	fi
+
+	QL="`echo "${MAPPEDLIST}"|sed -e 's/INSTALLPREFIX/\/opt/g' -e "s/DEBVERSION/${VERSION}/g" -e "s/DEBPRODVERS/${PRODVERS}/g"`"
+	if [ "`echo "${QL}"|grep '\\$'`" ]; then
+		dpkg-query -f "${QL}" -W "${DEB}"
+	else
+		echo "${QL}"
+	fi
+        return 0
+}
 
 #
 # testPkg - test the condition specified on the package.
@@ -375,6 +439,34 @@
 	return 1
 }
 
+Debian_testPkg() {
+        $DEBUG
+        if [[ $# -ne 2 ]]; then
+                return 1
+        fi
+	DEB="`echo "$2" | tr '[A-Z]' '[a-z]'`"
+        case $1 in
+        "installed")    # package installed, could be either partial or complete
+                dpkg-query -W $DEB > /dev/null 2>&1
+                return $?;;
+        "partial")      # package partially installed
+                #
+                # rpm does not understand the concept of partially installed packages.
+                # So, for now, we always return 1 (ie. false) since it can never be
+                # partially installed packages.
+                #
+                return 1;;
+        "complete")     # package completely installed
+		# dpkg format does not have a verify option, this will return if installed even partially
+                dpkg-query -q $DEB > /dev/null 2>&1
+                return $?;;
+        esac
+
+        # invalid test condition
+        print -u2 "${ERROR_PREF} invalid test operation \"$1\"."
+        return 1
+}
+
 
 PREFIX=`uname -s`
 if [[ -z "$PREFIX" ]]; then
@@ -382,6 +474,12 @@
 	print -u2 "${ERROR_PREF} unable to determince the OS running on this system."
 	exit 1
 fi
+if [[ "$PREFIX" = "Linux" ]]; then
+	. /etc/lsb-release
+        if [[ "$DISTRIB_ID" = "Ubuntu" ]] || [[ "$DISTRIB_ID" = "Debian" ]]; then
+		PREFIX="Debian"
+	fi
+fi
 
 OPMODE=""
 SUBOP=""
diff -ru /opt/SUNWut.orig/lib/utwebadmin /opt/SUNWut/lib/utwebadmin
--- /opt/SUNWut.orig/lib/utwebadmin	2007-08-02 01:36:34.000000000 +0200
+++ /opt/SUNWut/lib/utwebadmin	2007-09-28 21:35:27.000000000 +0200
@@ -99,6 +99,10 @@
         fi
     done
 
+    # in Debian, /etc/shells starts with a comment and therefore 
+    # this stupid script results in 'SU_SHELL=-s #'  
+    SU_SHELL="-s /bin/ksh"
+
 else
     echo "Not supported on detected OS ${OS}." 1>&2
     exit $EXIT_FAILURE
diff -ru /opt/SUNWut.orig/lib/utxinit /opt/SUNWut/lib/utxinit
--- /opt/SUNWut.orig/lib/utxinit	2007-08-02 00:44:00.000000000 +0200
+++ /opt/SUNWut/lib/utxinit	2007-09-28 21:35:27.000000000 +0200
@@ -101,7 +101,7 @@
 then
 
 	XSERVER="/bin/false"
-	for XSERVERBIN in /usr/openwin/bin/Xsun /usr/X11R6/bin/Xnewt ; do
+	for XSERVERBIN in /usr/openwin/bin/Xsun /usr/bin/Xnewt ; do
 		if [ -x $XSERVERBIN ] ; then
 			XSERVER=$XSERVERBIN
 			break
diff -ru /opt/SUNWut.orig/lib/utxsun /opt/SUNWut/lib/utxsun
--- /opt/SUNWut.orig/lib/utxsun	2007-08-02 00:44:00.000000000 +0200
+++ /opt/SUNWut/lib/utxsun	2007-09-28 21:35:27.000000000 +0200
@@ -8,7 +8,7 @@
 INFODIR=/var/opt/SUNWut
 RESDIR=$INFODIR/dispinfo
 SUNWUTBIN=/opt/SUNWut/bin
-XSUN=/usr/X11R6/bin/Xnewt
+XSUN=/usr/bin/Xnewt
 # XSERVER can be 1 of Xsun  (on sparc with openwin)
 #                     Xnewt (on linux with mit-based static server)
 #                     Xorg  (on linux with xorg-based static server)
@@ -30,12 +30,17 @@
 # fontpath is for a particular system. We'll grep through the
 # XF86Config file. For FCS we'll do this at install time and
 # keep the path in a file.
-if [[ -f /etc/X11/XF86Config ]] ; then
+if [[ -f /etc/X11/xorg.conf ]]; then
+	XCFG_FILE=/etc/X11/xorg.conf
+else
+	XCFG_FILE=/etc/X11/XF86Config
+fi
+if [[ -f $XCFG_FILE ]] ; then
 	# match lines with FontPath that are not commented out,
 	# accumulate the path, but remove double quotes before appending:
 	FONTPATH=$($AWK '$1 == "FontPath" { fp = fp "," substr($2,2,length($2)-2) } \
                         END { print substr(fp,2) } \
-                        ' /etc/X11/XF86Config)
+                        ' $XCFG_FILE)
 	if [ x$FONTPATH != x ] ; then
 		XMOREOPTS="-fp $FONTPATH"
 	fi
diff -ru /opt/SUNWut.orig/lib/xmgr/gdm/add-dpy /opt/SUNWut/lib/xmgr/gdm/add-dpy
--- /opt/SUNWut.orig/lib/xmgr/gdm/add-dpy	2007-08-02 00:43:58.000000000 +0200
+++ /opt/SUNWut/lib/xmgr/gdm/add-dpy	2007-09-28 21:35:27.000000000 +0200
@@ -64,7 +64,7 @@
 xcdesc="DisplayManager.*_%d.exportList: SUN_SUNRAY_TOKEN=$token CORONA_TOKEN=$token"
 if [ "$type" = normal ]
 then
-	xsdesc=":%d SunRay local /usr/X11R6/bin/Xnewt :%d"
+	xsdesc=":%d SunRay local /usr/bin/Xnewt :%d"
 else
 	xsdesc="# :%d RESERVED"
 fi
diff -ru /opt/SUNWut.orig/lib/xmgr/gdm/notify /opt/SUNWut/lib/xmgr/gdm/notify
--- /opt/SUNWut.orig/lib/xmgr/gdm/notify	2007-08-02 00:43:58.000000000 +0200
+++ /opt/SUNWut/lib/xmgr/gdm/notify	2007-09-28 21:35:27.000000000 +0200
@@ -9,7 +9,11 @@
 
 verbose=0
 umask 0022
-DMNAME=gdm-binary
+if [[ -f "/usr/sbin/gdm" ]]; then
+	DMNAME=gdm
+else
+	DMNAME=gdm-binary
+fi
 unset LD_LIBRARY_PATH
 BASE=/etc/opt/SUNWut/basedir
 SUNWUTLIB=$BASE/lib
diff -ru /opt/SUNWut.orig/lib/xmgr/gdm/reset-dpy /opt/SUNWut/lib/xmgr/gdm/reset-dpy
--- /opt/SUNWut.orig/lib/xmgr/gdm/reset-dpy	2007-08-02 00:43:58.000000000 +0200
+++ /opt/SUNWut/lib/xmgr/gdm/reset-dpy	2007-09-28 21:35:27.000000000 +0200
@@ -10,7 +10,11 @@
 
 CONFIGDIR=$1
 CONFIGXDIR=$CONFIGDIR/xconfig
-DMNAME=gdm-binary
+if [[ -f "/usr/sbin/gdm" ]]; then
+	DMNAME=gdm
+else
+	DMNAME=gdm-binary
+fi
 
 # Note - we start MINDISP at 11 using gdm for linux. It gets around bug
 # 5057552, which is actually caused by lax privileges defined by 
diff -ru /opt/SUNWut.orig/sbin/utadm /opt/SUNWut/sbin/utadm
--- /opt/SUNWut.orig/sbin/utadm	2007-08-02 00:44:01.000000000 +0200
+++ /opt/SUNWut/sbin/utadm	2007-09-28 21:35:27.000000000 +0200
@@ -5,7 +5,6 @@
 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-
 #
 #  Configuring SunRay interfaces:
 #  ------------------------------
@@ -219,17 +218,28 @@
 		else
 		  NETWORKS="${ETC_OPT_UT}/net/networks";
 		fi
-		DHCPCONFIG="/etc/dhcpd.conf"
+		if [[ -f "/etc/dhcp3/dhcpd.conf" ]]; then
+			DHCPCONFIG="/etc/dhcp3/dhcpd.conf"
+		else
+			DHCPCONFIG="/etc/dhcpd.conf"
+		fi
 		GREP=grep	# XXX need to figure out which <===
-		INIT_DHCP="/etc/init.d/dhcpd";
+		if [[ -f "/etc/init.d/dhcp3-server" ]]; then
+			INIT_DHCP="/etc/init.d/dhcp3-server"
+		else
+			INIT_DHCP="/etc/init.d/dhcpd"
+		fi
 		if [[ -d "/etc/sysconfig/network-scripts" ]] ; then
 		  IFCONFIG_SCRIPT="/etc/sysconfig/network-scripts/ifcfg-"
 		  IFCONFIG_BOOT="ONBOOT=yes"
 		  BOOTPROTO=none
-		else
-		  IFCONFIG_SCRIPT="/etc/sysconfig/network/ifcfg-"
-		  IFCONFIG_BOOT="STARTMODE=onboot"
+		elif [[ -f "/etc/network/interfaces" ]] ; then
+		  IFCONFIG_SCRIPT="/etc/network/interfaces"
 		  BOOTPROTO=static
+		else
+                  IFCONFIG_SCRIPT="/etc/sysconfig/network/ifcfg-"
+                  IFCONFIG_BOOT="STARTMODE=onboot"
+                  BOOTPROTO=static
 		fi
 		IFCFG_INET="";
 
@@ -984,6 +994,10 @@
   # get the intf's symbolic name
   INTF_NAME=`getent hosts ${INTF_IPA} | awk '{print $2}'`;
   if [ -z "${INTF_NAME}" ]; then
+    # Work around for bug in Ubuntu getent Launchpad BugID 28585
+    INTF_NAME=`getent hosts | grep -w ${INTF_IPA} | awk '{print $2}'`
+  fi
+  if [ -z "${INTF_NAME}" ]; then
     print -u2 "Error: host name for ${INTF_IPA} not found"
     exit 1;
   fi
@@ -1138,8 +1152,40 @@
     ifconfig ${INTF} "${IPADDR}" up netmask "${NETMASK}" broadcast ${BROADCAST};
     RC=$?
     if [[ ${RC} -eq 0 ]] ; then
-      rm -f ${TMPDIR}/tmpfile.$$;
-      cat > ${TMPDIR}/tmpfile.$$ <<-!
+      . /etc/lsb-release 2 > /dev/null
+      if [[ "$DISTRIB_ID" = "Ubuntu" ]] || [[ "$DISTRIB_ID" = "Debian" ]]; then
+        rm -f ${TMPDIR}/tmpfile.$$;
+        cat > ${TMPDIR}/tmpfile.$$ <<-!
+# SUNRAY ADD
+auto ${INTF}
+iface ${INTF} inet ${BOOTPROTO}
+address ${IPADDR}
+netmask ${NETMASK}
+# SUNRAY ADD
+!
+        awk ' {
+          if (NF == "0") print $0;
+          else if ($1 == "allow") {print $0; param="false";}
+          else if ($1 == "mapping") {print $0; param="false";}
+          else if ($1 == "auto")
+            {if ($2 == Intf) print "# SUNRAY DEL "$0;
+             else print $0;
+             param="false";}
+          else if ($1 == "iface")
+            {if ($2 == Intf) {print "# SUNRAY DEL "$0; param="true";}
+             else {print $0; param="false";}}
+          else if (param == "true") print "# SUNRAY DEL "$0;
+          else {print $0; param="false";}
+          }' \
+          Intf=${INTF} \
+          ${IFCONFIG_SCRIPT} > ${IFCONFIG_SCRIPT}.$$
+
+        cat ${IFCONFIG_SCRIPT}.$$ ${TMPDIR}/tmpfile.$$ > ${IFCONFIG_SCRIPT}
+        rm -f ${TMPDIR}/tmpfile.$$ ${IFCONFIG_SCRIPT}.$$
+
+      else
+        rm -f ${TMPDIR}/tmpfile.$$;
+        cat > ${TMPDIR}/tmpfile.$$ <<-!
 DEVICE=${INTF} # SUNRAY ADD 
 USERCTL=no # SUNRAY ADD 
 ${IFCONFIG_BOOT} # SUNRAY ADD 
@@ -1149,17 +1195,18 @@
 NETMASK=${NETMASK} # SUNRAY ADD
 IPADDR=${IPADDR} # SUNRAY ADD
 !
-      if [[ -f ${IFCONFIG_SCRIPT}${INTF} ]] ; then
-	sed -e "/^"HWADDR"/!s/^/# SUNRAY DEL /" "${IFCONFIG_SCRIPT}${INTF}" > ${IFCONFIG_SCRIPT}${INTF}.$$
-        #
-        # change ether config so it starts on boot
-	
-	rm -f ${IFCONFIG_SCRIPT}${INTF}
-	cat ${IFCONFIG_SCRIPT}${INTF}.$$ ${TMPDIR}/tmpfile.$$ > ${IFCONFIG_SCRIPT}${INTF}
-	rm -f ${IFCONFIG_SCRIPT}${INTF}.$$ ${TMPDIR}/tmpfile.$$
-      else
-        mv -f ${TMPDIR}/tmpfile.$$ ${IFCONFIG_SCRIPT}${INTF};
-      fi
+         if [[ -f ${IFCONFIG_SCRIPT}${INTF} ]] ; then
+           sed -e "/.*/s/^/# SUNRAY DEL /" "${IFCONFIG_SCRIPT}${INTF}" > ${IFCONFIG_SCRIPT}${INTF}.$$
+           #
+           # change ether config so it starts on boot
+  	
+           rm -f ${IFCONFIG_SCRIPT}${INTF}
+ 	  cat ${IFCONFIG_SCRIPT}${INTF}.$$ ${TMPDIR}/tmpfile.$$ > ${IFCONFIG_SCRIPT}${INTF}
+ 	  rm -f ${IFCONFIG_SCRIPT}${INTF}.$$ ${TMPDIR}/tmpfile.$$
+         else
+           mv -f ${TMPDIR}/tmpfile.$$ ${IFCONFIG_SCRIPT}${INTF};
+         fi
+       fi
     fi
     print "### finished install of \"${INTF}\" interface";
     return $RC
@@ -1180,6 +1227,38 @@
       if [[ ! -s ${IFCONFIG_SCRIPT}${INTF} ]]; then
 	rm -f ${IFCONFIG_SCRIPT}${INTF}
       fi
+    elif [[ -f ${IFCONFIG_SCRIPT} ]] ; then
+      cp ${IFCONFIG_SCRIPT} ${IFCONFIG_SCRIPT}.$$
+      awk ' {
+       if (($2 == "SUNRAY" ) && ($3 == "DEL"))
+         {if (($4 == "auto") && ($5 == Intf))
+            {output="";
+             for (field=4; field<=NF; ++field) {output=output$field" ";} 
+             print output;
+             param="false";}
+          else if (($4 == "iface") && ($5 == Intf ))
+            {output=""; for (field=4; field<=NF; ++field) {output=output$field" ";}
+             print output;
+             param="true";}
+          else if (param == "true")
+            {output=""; for (field=4; field<=NF; ++field) {output=output$field" ";}
+             print output;
+             param="true";}
+          else {print $0; param="false";}
+         }
+       else if (($2 == "SUNRAY") && ($3 == "ADD"))
+         {if (comment_count == "1") {if (remove != "true") {print $0;};comment_count = "2";remove = "false";}
+          else if (comment_count == "2") {comment_count = "1";remove = "possible"}
+          else {comment_count = "1"; remove="possible";}
+         }
+       else if (remove == "possible")
+         if (($1 == "auto") && ($2 == Intf)) {remove="true";}
+         else {remove="false";print "# SUNRAY ADD"; print $0;}
+       else if (remove != "true") {print $0; param="false";}
+      }' \
+      Intf=${INTF} \
+      ${IFCONFIG_SCRIPT}.$$ > ${IFCONFIG_SCRIPT}
+      rm -f ${IFCONFIG_SCRIPT}.$$
     else
       print -u2 "Warning: unable to update ${IFCONFIG_SCRIPT}${INTF}";
     fi
@@ -1819,7 +1898,6 @@
     ${UTDHCPSERVICE} disable > /dev/null 2>&1
 }
 
-
 #
 # adds the SR network configuration for both interface and subnetwork only.
 #
@@ -3155,6 +3233,8 @@
 		lease_file=/var/lib/dhcp/dhcpd.leases
 	elif [ -f /var/lib/dhcp/db/dhcpd.leases ]; then
                 lease_file=/var/lib/dhcp/db/dhcpd.leases
+	elif [ -f /var/lib/dhcp3/dhcpd.leases ]; then
+		lease_file=/var/lib/dhcp3/dhcpd.leases
         fi
 
 	rm -f $tmp_leases
diff -ru /opt/SUNWut.orig/sbin/utconfig /opt/SUNWut/sbin/utconfig
--- /opt/SUNWut.orig/sbin/utconfig	2007-08-02 00:44:01.000000000 +0200
+++ /opt/SUNWut/sbin/utconfig	2007-09-28 21:35:27.000000000 +0200
@@ -145,7 +145,12 @@
     # Define Linux specific LDAP variables
     # Determine which LDAP client package is installed
     #
-    LCL_PACKAGE="$(rpm -qf /usr/bin/ldapadd 2>/dev/null)"
+    . /etc/lsb-release
+    if [[ "$DISTRIB_ID" = "Ubuntu" ]] || [[ "$DISTRIB_ID" = "Debian" ]]; then
+	LCL_PACKAGE="$(dpkg-query -S /usr/bin/ldapadd | awk -F: '{print $1}' 2>/dev/null)"
+    else
+        LCL_PACKAGE="$(rpm -qf /usr/bin/ldapadd 2>/dev/null)"
+    fi
 
     # Define Linux versions of LDAP client commands
     #
@@ -159,7 +164,11 @@
     # Define Linux specific filenames
     #
     ETCSERVICES="/etc/services"
-    DHCPCONFIG="/etc/dhcpd.conf"
+    if [[ -f "/etc/dhcp3/dhcpd.conf" ]]; then
+         DHCPCONFIG="/etc/dhcp3/dhcpd.conf"
+    else
+         DHCPCONFIG="/etc/dhcpd.conf"
+    fi
     ;;
 
   *)
diff -ru /opt/SUNWut.orig/sbin/utfwadm /opt/SUNWut/sbin/utfwadm
--- /opt/SUNWut.orig/sbin/utfwadm	2007-08-02 00:44:02.000000000 +0200
+++ /opt/SUNWut/sbin/utfwadm	2007-09-28 21:35:27.000000000 +0200
@@ -144,7 +144,7 @@
 function GetVersion  {
     FW_FILE_INPUT=${1}
     # extract the version string and make file names
-    FW_TYPE=$(od -t x1 $FW_FILE_INPUT | head -1 | awk '{ print sprintf("%s%s%s%s", $2,$3,$4,$5)}') 2> /dev/null
+    FW_TYPE=$(od -t x1 $FW_FILE_INPUT | head -n 1 | awk '{ print sprintf("%s%s%s%s", $2,$3,$4,$5)}') 2> /dev/null
     case $FW_TYPE in
 	4badbeef | 8badbeef)	
             $UTWHAT $FW_FILE_INPUT > ${TMPDIR}/fw_strings.$$
diff -ru /opt/SUNWut.orig/sbin/utfwload /opt/SUNWut/sbin/utfwload
--- /opt/SUNWut.orig/sbin/utfwload	2007-08-02 00:43:59.000000000 +0200
+++ /opt/SUNWut/sbin/utfwload	2007-09-28 21:35:27.000000000 +0200
@@ -164,7 +164,7 @@
 			print disp, name
 	}' $sessfiles | sort >$TMP/map2.$$
 
-join -j 1 $TMP/map1.$$ $TMP/map2.$$ | sort +1 > $TMP/map4.$$
+join -j 1 $TMP/map1.$$ $TMP/map2.$$ | sort -k 1 > $TMP/map4.$$
 
 print status | $UTNETPIPE 0.0.0.0 7010 | \
 $NAWK '
diff -ru /opt/SUNWut.orig/sbin/utreplica /opt/SUNWut/sbin/utreplica
--- /opt/SUNWut.orig/sbin/utreplica	2007-08-02 00:44:01.000000000 +0200
+++ /opt/SUNWut/sbin/utreplica	2007-09-28 21:35:27.000000000 +0200
@@ -78,7 +78,13 @@
                         ETCSERVICES=/etc/inet/services
 			LOGFILE="/var/adm/log/$PROGRAM_ID.${TIMESTAMP}.log"
                         ;;
-                Linux)  LCL_PACKAGE="$(rpm -qf /usr/bin/ldapadd 2>/dev/null)"
+                Linux)  . /etc/lsb-release
+			if [[ "$DISTRIB_ID" = "Ubuntu" ]] || [[ "$DISTRIB_ID" = "Debian" ]]; then
+				LCL_PACKAGE="$(dpkg-query -S /usr/bin/ldapadd | awk -F: '{print $1}' 2>/dev/null)"
+			else
+				LCL_PACKAGE="$(rpm -qf /usr/bin/ldapadd 2>/dev/null)"
+			fi
+ 
                         LDAPSEARCH="/usr/bin/ldapsearch -x -LLL "
 			GREP=/bin/grep
                         ETCSERVICES=/etc/services
@@ -1125,7 +1131,7 @@
 		    Fatal "$server is already configured as a primary server."
 		elif print $remote_rep | egrep "$SECONDARY_ID"\
 			>/dev/null 2>&1; then
-		    typeset -l tmp_host=`print "$remote_rep" | tail -1`
+		    typeset -l tmp_host=`print "$remote_rep" | tail -n 1`
 		    if [ "${tmp_host}" != $HOSTNAME ]; then
 		    	Fatal "$server is already configured as a secondary server\n"\
 			   "with a different primary."
@@ -1164,7 +1170,7 @@
   then
 	# only check the first line of the file.  This avoids the problem of accidentally
 	# picking up the "replica" attribute which will also have the same string match.
-  	head -1 $DSSERV_REPLOG | grep '^replica: ' >/dev/null 2>&1
+  	head -n 1 $DSSERV_REPLOG | grep '^replica: ' >/dev/null 2>&1
   	if [ $? -ne 0 ]
 	then
 		cat /dev/null > $DSSERV_REPLOG
diff -ru /opt/SUNWut.orig/sbin/utwall /opt/SUNWut/sbin/utwall
--- /opt/SUNWut.orig/sbin/utwall	2007-08-02 00:44:44.000000000 +0200
+++ /opt/SUNWut/sbin/utwall	2007-09-28 21:35:27.000000000 +0200
@@ -390,8 +390,8 @@
       ARG2="Notice"
       ARGBUTTON=" -buttons "
       ARG3="$BUTTON:0"
-      XDPY="/usr/X11R6/bin/xdpyinfo"
-      XPROC="\/usr\/X11R6\/bin\/Xnewt"
+      XDPY="/usr/bin/xdpyinfo"
+      XPROC="\/usr\/bin\/Xnewt"
       PSWW="/bin/ps -uww"
       AUDIOPLAY="play"
       MAIL="mail"
diff -ru /opt/SUNWutref.orig/amgh/utamghref_allkeys_script /opt/SUNWutref/amgh/utamghref_allkeys_script
--- /opt/SUNWutref.orig/amgh/utamghref_allkeys_script	2007-08-02 00:45:11.000000000 +0200
+++ /opt/SUNWutref/amgh/utamghref_allkeys_script	2007-09-28 21:35:27.000000000 +0200
@@ -21,7 +21,7 @@
     then
         sed -n "s/^${key}=${value}[ 	].*\(${return_key}=[^	 ]*\).*/\1/p" $DBFILE
     else
-        sed -n "s/^${key}=${value}[ 	].*\(${return_key}=[^	 ]*\).*/\1/p" $DBFILE | tail -1
+        sed -n "s/^${key}=${value}[ 	].*\(${return_key}=[^	 ]*\).*/\1/p" $DBFILE | tail -n 1
     fi
 }
 
diff -ru /opt/SUNWkio.orig/lib/gdm/kioskgreeter /opt/SUNWkio/lib/gdm/kioskgreeter
--- /opt/SUNWkio.orig/lib/gdm/kioskgreeter	2007-08-02 01:42:39.000000000 +0200
+++ /opt/SUNWkio/lib/gdm/kioskgreeter	2007-09-28 21:35:27.000000000 +0200
@@ -27,7 +27,7 @@
 #
 
 theModule=kiosk:kioskgreeter
-theDefaultGreeter=/usr/bin/gdmgreeter
+theDefaultGreeter=/usr/lib/gdm/gdmgreeter
 
 #
 ## processGDMInput acts as a fake gdm greeter. It consumes gdm requests and
