run-dev: Fix regression ignoring --interface argument.

When we migrated run-dev.py from Twisted to Tornado a few weeks ago,
the --interface argument wasn't properly ported and thus was ignored.

This restores the original functionality of defaulting to only
listening on localhost.

Ideally, we'd replace the vagrant/zulipdev user check with something
that just checks whether a special file that is created by the
Vagrant/remote-dev-vm creation process exists; that would be more
robust.
This commit is contained in:
Tim Abbott 2016-11-20 13:30:28 -08:00
parent 4e5c4c5ffb
commit 92d1b6d6da
1 changed files with 8 additions and 4 deletions

View File

@ -73,14 +73,18 @@ if not options.force:
if options.interface is None:
user_id = os.getuid()
user_name = pwd.getpwuid(user_id).pw_name
if user_name == "vagrant":
if user_name in ["vagrant", "zulipdev"]:
# In the Vagrant development environment, we need to listen on
# all ports, and it's safe to do so, because Vagrant is only
# exposing certain guest ports (by default just 9991) to the host.
options.interface = ""
# exposing certain guest ports (by default just 9991) to the
# host. The same argument applies to the remote development
# servers using username "zulipdev".
options.interface = None
else:
# Otherwise, only listen to requests on localhost for security.
options.interface = "127.0.0.1"
elif options.interface == "":
options.interface = None
base_port = 9991
if options.test:
@ -360,7 +364,7 @@ print("".join((WARNING,
try:
app = Application()
app.listen(proxy_port)
app.listen(proxy_port, address=options.interface)
ioloop = IOLoop.instance()
for s in (signal.SIGINT, signal.SIGTERM):
signal.signal(s, shutdown_handler)