about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-11-01 20:02:47 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-01 20:05:19 +0000
commitd5870ccc714a4bb442a46aedd4c68c547e8e56f4 (patch)
tree7575e2aacb8816bc911b454c8662e6dd6162bd79
parent7e9e4c740aba24096f768f578779dc1053cb8b70 (diff)
downloadunicorn-d5870ccc714a4bb442a46aedd4c68c547e8e56f4.tar.gz
Users may confuse '-p' with the (to-be-deprecated) '-P/--pid'
option, leading to surprising behavior if a pathname is passed as a
port, because String#to_i would convert it to zero, causing:

    TCPServer.new(host, port = 0)

to bind to a random, unused port.
-rwxr-xr-xbin/unicorn6
-rwxr-xr-xbin/unicorn_rails6
2 files changed, 6 insertions, 6 deletions
diff --git a/bin/unicorn b/bin/unicorn
index 01984f8..c272e43 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -47,9 +47,9 @@ op = OptionParser.new("", 24, '  ') do |opts|
     rackup_opts[:set_listener] = true
   end
 
-  opts.on("-p", "--port PORT",
-          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |p|
-    rackup_opts[:port] = p.to_i
+  opts.on("-p", "--port PORT", Integer,
+          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |port|
+    rackup_opts[:port] = port
     rackup_opts[:set_listener] = true
   end
 
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index 4bd599f..b080846 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -48,9 +48,9 @@ op = OptionParser.new("", 24, '  ') do |opts|
     rackup_opts[:set_listener] = true
   end
 
-  opts.on("-p", "--port PORT",
-          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |p|
-    rackup_opts[:port] = p.to_i
+  opts.on("-p", "--port PORT", Integer,
+          "use PORT (default: #{Unicorn::Const::DEFAULT_PORT})") do |port|
+    rackup_opts[:port] = port
     rackup_opts[:set_listener] = true
   end