Bug 1350887 - Bind sacrificial goat to ephemeral port; r=whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 28 Mar 2017 16:46:54 +0100
changeset 556068 f7b7752a227dadbfe91990a79c71b1da4d9e0311
parent 556067 bc16298be5cfba70f8687b7932586945053bb3c1
child 556069 4a604a224db9e4106f6da1e898f33195c6fc82d2
push id52427
push userbmo:ato@mozilla.com
push dateWed, 05 Apr 2017 09:39:48 +0000
reviewerswhimboo
bugs1350887
milestone55.0a1
Bug 1350887 - Bind sacrificial goat to ephemeral port; r=whimboo Port 666 is in the protected port range and can not normally be bound to unless the process is running with sudo permissions. We can instead bind to port 0, which will give us a system-defined port in the epemeral range. MozReview-Commit-ID: Ld6BDMhtbck
testing/marionette/components/marionette.js
--- a/testing/marionette/components/marionette.js
+++ b/testing/marionette/components/marionette.js
@@ -282,17 +282,17 @@ MarionetteComponent.prototype.init = fun
 
   if (!prefs.forceLocal) {
     // See bug 800138.  Because the first socket that opens with
     // force-local=false fails, we open a dummy socket that will fail.
     // keepWhenOffline=true so that it still work when offline (local).
     // This allows the following attempt by Marionette to open a socket
     // to succeed.
     let insaneSacrificialGoat =
-        new ServerSocket(666, Ci.nsIServerSocket.KeepWhenOffline, 4);
+        new ServerSocket(0, Ci.nsIServerSocket.KeepWhenOffline, 4);
     insaneSacrificialGoat.asyncListen(this);
   }
 
   let s;
   try {
     Cu.import("chrome://marionette/content/server.js");
     s = new server.TCPListener(prefs.port, prefs.forceLocal);
     s.start();