]> gitweb.fluxo.info Git - termplex.git/commitdiff
Setting random monitoring port for autossh
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 27 Dec 2016 12:02:36 +0000 (10:02 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 27 Dec 2016 12:02:36 +0000 (10:02 -0200)
shell

diff --git a/shell b/shell
index 36aa30d49200d16f13883cfb445017b785a98292..f07f8540dfb939e404fc27da2271dae577bb1cba 100755 (executable)
--- a/shell
+++ b/shell
@@ -1,13 +1,19 @@
 #!/bin/bash
 #
-# Simple autossh and screen wrapper.
+# Simple $AUTOSSH and screen wrapper.
 #
 
 # Parameters
+#
+# We're enforcing a random monitoring por for autossh
+# as some systems might deny reading /proc/net/tcp like
+# kernels with grsecurity patch.
 BASENAME="`basename $0`"
 DEST="$1"
 COMMAND="$2"
 MULTIPLEXER="wscreen"
+MONITORING="-M $(($RANDOM + 1024))"
+AUTOSSH="autossh $MONITORING"
 
 # Set window title
 # http://stackoverflow.com/questions/899609/gnu-screen-run-script-that-sends-commands-to-the-screen-session-it-is-being-run
@@ -31,11 +37,11 @@ window_title $DEST
 
 # Dispatcher
 if [ "$BASENAME" == "shells" ]; then
-  # Remote screen shell using autossh
+  # Remote screen shell using $AUTOSSH
   if [ "$COMMAND" == "root" ]; then
-    autossh $DEST -t -- sudo screen -x
+    $AUTOSSH $DEST -t -- sudo screen -x
   else
-    autossh $DEST -t -- screen -x $COMMAND
+    $AUTOSSH $DEST -t -- screen -x $COMMAND
   fi
 else
   if [ -z "$COMMAND" ] && screen -ls $DEST | grep -q "There is a screen on"; then
@@ -54,8 +60,8 @@ else
     window_title $COMMAND
     $MULTIPLEXER $COMMAND
   else
-    # Remote shell using autossh
-    autossh $DEST -t -- $COMMAND
+    # Remote shell using $AUTOSSH
+    $AUTOSSH $DEST -t -- $COMMAND
   fi
 fi