-cat $root/etc/aliases.legacy > $root/etc/aliases.tmp
-cat $root/etc/aliases.new >> $root/etc/aliases.tmp
-cat $root/etc/aliases.local >> $root/etc/aliases.tmp
-mv $root/etc/aliases.tmp $root/etc/aliases.new
+# Play it safe and be sure we have reasonable data
+olines=`wc -l $root/etc/aliases | awk '{print $1}'`
+nlines=`wc -l $root/etc/aliases.new | awk '{print $1}'`
+diff=`expr $nlines - $olines`
+thresh=`expr $olines / 10`
+
+# Catch the zero case
+if [ $nlines -eq 0 ]; then
+ logger -p mail.error -t mailhub.sh "Recieved empty aliases file, aborting."
+ exit $MR_MISSINGFILE
+fi
+
+# If its a greater than 10% shift bomb out to be safe
+if [ $diff -gt $thresh ]; then
+ logger -p mail.error -t mailhub.sh "Alias changes threshold exceeded, aborting."
+ exit $MR_NOCRED
+fi