changeset 1196:1cdd44f2bac2

If some clever sysadmin claimed 1024-65535 for local ports, punt.
author Rob Landley <rob@landley.net>
date Thu, 05 Aug 2010 13:10:07 -0500
parents 41fdac77a907
children 8b1017be9de8
files sources/toys/unique-port.sh
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sources/toys/unique-port.sh	Thu Aug 05 12:31:01 2010 -0500
+++ b/sources/toys/unique-port.sh	Thu Aug 05 13:10:07 2010 -0500
@@ -4,10 +4,15 @@
 
   START=8192
   RANGE=$[$(awk '{print $1}' /proc/sys/net/ipv4/ip_local_port_range)-$START]
-  if [ $RANGE -lt 1 ]
+  if [ $RANGE -lt 8 ]
   then
     START=$[$(awk '{print $2}' /proc/sys/net/ipv4/ip_local_port_range)]
     RANGE=$[65535-$START]
+    if [ $RANGE -lt 8 ]
+    then
+      START=16384
+      RANGE=32768
+    fi
   fi
   echo $[($$%$RANGE)+$START]
 }