Fix for tornado 4.0

This commit is contained in:
Florian Mounier
2014-07-16 15:46:18 +02:00
parent 3b6578658b
commit 2db77cc250
3 changed files with 12 additions and 5 deletions

View File

@@ -222,7 +222,8 @@ else:
from butterfly import application
http_server = tornado_systemd.SystemdHTTPServer(application, ssl_options=ssl_opts)
http_server = tornado_systemd.SystemdHTTPServer(
application, ssl_options=ssl_opts)
http_server.listen(port, address=host)
url = "http%s://%s:%d/*" % (
"s" if not tornado.options.options.unsecure else "", host, port)

View File

@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '1.5.3'
__version__ = '1.5.4'
import os

View File

@@ -176,7 +176,11 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
# or login is explicitly turned off
if (
not tornado.options.options.unsecure and
tornado.options.options.login):
tornado.options.options.login and not (
self.socket.local and
self.caller == self.callee and
server == self.callee
)):
# User is authed by ssl, setting groups
try:
os.initgroups(self.callee.name, self.callee.gid)
@@ -241,6 +245,7 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
self.fd, self.shell_handler, ioloop.READ | ioloop.ERROR)
def open(self, user, path):
self.fd = None
if self.request.headers['Origin'] not in (
'http://%s' % self.request.headers['Host'],
'https://%s' % self.request.headers['Host']):
@@ -275,7 +280,7 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
if not self.callee and not self.user and self.socket.local:
self.callee = self.caller
else:
user = utils.parse_cert(self.request.get_ssl_certificate())
user = utils.parse_cert(self.stream.socket.getpeercert())
assert user, 'No user in certificate'
self.user = user
try:
@@ -323,7 +328,8 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
self.close()
def on_close(self):
self.log.info('Closing fd %d' % self.fd)
if self.fd is not None:
self.log.info('Closing fd %d' % self.fd)
if getattr(self, 'pid', 0) == 0:
self.log.info('pid is 0')