diff --git a/anaconda_lib/unix_socket.py b/anaconda_lib/unix_socket.py index 93c3fb54..7f2d336e 100644 --- a/anaconda_lib/unix_socket.py +++ b/anaconda_lib/unix_socket.py @@ -47,3 +47,10 @@ def socket(self): ) return socket_path + + +def get_current_umask(): + 'Return the current umask without changing it.' + current_umask = os.umask(0) + os.umask(current_umask) + return current_umask diff --git a/anaconda_server/jsonserver.py b/anaconda_server/jsonserver.py old mode 100644 new mode 100755 index a1ece079..1c3e4482 --- a/anaconda_server/jsonserver.py +++ b/anaconda_server/jsonserver.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: utf8 -*- # Copyright (C) 2013 - Oscar Campos @@ -16,20 +17,23 @@ import subprocess from logging import handlers from optparse import OptionParser +from os import chmod +from os.path import dirname, join, abspath +from operator import xor -# we use ujson if it's available on the target intrepreter +# we use ujson if it's available on the target interpreter try: import ujson as json except ImportError: import json -sys.path.insert(0, os.path.join( - os.path.split(os.path.split(__file__)[0])[0], 'anaconda_lib')) +PROJECT_ROOT = dirname(dirname(abspath(__file__))) +sys.path.insert(0, join(PROJECT_ROOT, 'anaconda_lib')) from lib.path import log_directory from jedi import set_debug_function from lib.contexts import json_decode -from unix_socket import UnixSocketPath +from unix_socket import UnixSocketPath, get_current_umask from handlers import ANACONDA_HANDLERS from jedi import settings as jedi_settings from lib.anaconda_handler import AnacondaHandler @@ -154,9 +158,10 @@ def __init__(self, address, handler=JSONHandler): self.last_call = time.time() self.bind(self.address) - if platform.system().lower() != 'linux': + if hasattr(socket, 'AF_UNIX') and \ + self.address_family == socket.AF_UNIX: # WSL 1903 fix - os.chmod(self.address, 0o600) + chmod(self.address, xor(0o777, get_current_umask())) logging.debug('bind: address=%s' % (address,)) self.listen(self.request_queue_size) logging.debug('listen: backlog=%d' % (self.request_queue_size,)) @@ -266,7 +271,7 @@ def get_logger(path): log = logging.getLogger('') log.setLevel(logging.DEBUG) hdlr = handlers.RotatingFileHandler( - filename=os.path.join(path, 'anaconda_jsonserver.log'), + filename=join(path, 'anaconda_jsonserver.log'), maxBytes=10000000, backupCount=5, encoding='utf-8' @@ -318,10 +323,10 @@ def log_traceback(): PID = args[0] if options.project is not None: - jedi_settings.cache_directory = os.path.join( + jedi_settings.cache_directory = join( jedi_settings.cache_directory, options.project ) - log_directory = os.path.join(log_directory, options.project) + log_directory = join(log_directory, options.project) if not os.path.exists(jedi_settings.cache_directory): os.makedirs(jedi_settings.cache_directory) @@ -338,8 +343,8 @@ def log_traceback(): server = JSONServer(('localhost', port)) else: unix_socket_path = UnixSocketPath(options.project) - if not os.path.exists(os.path.dirname(unix_socket_path.socket)): - os.makedirs(os.path.dirname(unix_socket_path.socket)) + if not os.path.exists(dirname(unix_socket_path.socket)): + os.makedirs(dirname(unix_socket_path.socket)) if os.path.exists(unix_socket_path.socket): os.unlink(unix_socket_path.socket) server = JSONServer(unix_socket_path.socket) diff --git a/messages.json b/messages.json index a29af55b..aa6444ba 100644 --- a/messages.json +++ b/messages.json @@ -82,5 +82,6 @@ "2.1.29": "messages/2.1.29.txt", "2.1.30": "messages/2.1.30.txt", "2.1.31": "messages/2.1.31.txt", - "2.1.32": "messages/2.1.32.txt" + "2.1.32": "messages/2.1.32.txt", + "2.1.33": "messages/2.1.33.txt" } diff --git a/messages/2.1.32.txt b/messages/2.1.32.txt index 191967a1..a53d8dc3 100644 --- a/messages/2.1.32.txt +++ b/messages/2.1.32.txt @@ -6,10 +6,10 @@ The Sublime Text 3 Python IDE -Anaconda v2.1.31 +Anaconda v2.1.32 ================ -Welcome to new anaconda v2.1.31, what can do you find in this minor release? +Welcome to new anaconda v2.1.32, what can do you find in this minor release? ## Fixes - Fixing a nasty socket problem occurring in WSL 1903 diff --git a/messages/2.1.33.txt b/messages/2.1.33.txt new file mode 100644 index 00000000..4d081fdc --- /dev/null +++ b/messages/2.1.33.txt @@ -0,0 +1,15 @@ + + | + _` | __ \ _` | __| _ \ __ \ _` | _` | + ( | | | ( | ( ( | | | ( | ( | + \__,_| _| _| \__,_| \___| \___/ _| _| \__,_| \__,_| + The Sublime Text 3 Python IDE + + +Anaconda v2.1.33 +================ + +Welcome to new anaconda v2.1.33, what can do you find in this minor release? + +## Fixes + - Further fixing a bug introduced due to Windows WSL 1903 release