Argument to turn login screen off (--host=0.0.0.0 --unsecure --login=False)

This commit is contained in:
Adam Strauch
2014-04-13 14:19:08 +02:00
parent cd6b7aadff
commit 6a0bdf2147
2 changed files with 9 additions and 3 deletions

View File

@@ -37,6 +37,8 @@ tornado.options.define("port", default=57575, type=int, help="Server port")
tornado.options.define("shell", help="Shell to execute at login")
tornado.options.define("unsecure", default=False,
help="Don't use ssl not recommended")
tornado.options.define("login", default=True,
help="Use login screen at start")
tornado.options.define("generate_certs", default=False,
help="Generate butterfly certificates")

View File

@@ -108,12 +108,16 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
self.communicate()
def shell(self):
if self.callee is None and tornado.options.options.unsecure:
if self.callee is None and (tornado.options.options.unsecure and tornado.options.options.login):
# If callee is now known and we have unsecure connection
user = input('login: ')
try:
self.callee = utils.User(name=user)
except:
self.callee = utils.User(name='nobody')
else:
# if login is not required, we will use the same user as butterfly is executed
self.callee = utils.User()
assert self.callee is not None
@@ -140,8 +144,8 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
if not tornado.options.options.unsecure or (
self.socket.local and
self.caller == self.callee and
server == self.callee):
# User has been auth with ssl or is the same user as server
server == self.callee) or not tornado.options.options.login:
# User has been auth with ssl or is the same user as server or login is explicitly turned off
try:
os.setuid(self.callee.uid)
except PermissionError: