Skip to content

Commit

Permalink
Fixes #793, fixes #527, fixes #820 again
Browse files Browse the repository at this point in the history
  • Loading branch information
karolyi committed Jun 11, 2019
1 parent 694e9b8 commit 31f602e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
7 changes: 7 additions & 0 deletions anaconda_lib/unix_socket.py
Expand Up @@ -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
27 changes: 16 additions & 11 deletions anaconda_server/jsonserver.py 100644 → 100755
@@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-

# Copyright (C) 2013 - Oscar Campos <oscar.campos@member.fsf.org>
Expand All @@ -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
Expand Down Expand Up @@ -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,))
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Expand Up @@ -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"
}
4 changes: 2 additions & 2 deletions messages/2.1.32.txt
Expand Up @@ -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
15 changes: 15 additions & 0 deletions 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

0 comments on commit 31f602e

Please sign in to comment.