Use i- as prefix for the IPC path on macOS

With Qt 5.12, standarddir.runtime() gives us a path in /private/var/folders/...
instead of /var/folders/... like before. Due to that change, the path length is
105 chars, which is too long for a named socket (104 seems to be okay).

The complete name is just slightly too long, so using i- instead of ipc- fixes
things...

Fixes #4471
See #888
This commit is contained in:
Florian Bruhin 2019-02-22 10:22:09 +01:00
parent 81889dd7bd
commit 99c8b80a46
3 changed files with 14 additions and 14 deletions

View File

@ -62,6 +62,9 @@ Changed
`org.qutebrowser.qutebrowser.appdata.xml`.
- The `qute-pass` userscript now understands domains in gpg filenames
in addition to directory names.
- macOS: The IPC socket path used to communicate with existing instances
changed due to changes in Qt 5.12. Please make sure to quit qutebrowser
before upgrading.
Fixed
~~~~~

View File

@ -65,11 +65,9 @@ def _get_socketname(basedir):
data_to_hash = '-'.join(parts_to_hash).encode('utf-8')
md5 = hashlib.md5(data_to_hash).hexdigest()
target_dir = standarddir.runtime()
parts = ['ipc']
parts.append(md5)
return os.path.join(target_dir, '-'.join(parts))
prefix = 'i-' if utils.is_mac else 'ipc-'
filename = '{}{}'.format(prefix, md5)
return os.path.join(standarddir.runtime(), filename)
class Error(Exception):

View File

@ -177,11 +177,6 @@ def md5(inp):
class TestSocketName:
POSIX_TESTS = [
(None, 'ipc-{}'.format(md5('testusername'))),
('/x', 'ipc-{}'.format(md5('testusername-/x'))),
]
WINDOWS_TESTS = [
(None, 'qutebrowser-testusername'),
('/x', 'qutebrowser-testusername-{}'.format(md5('/x'))),
@ -203,7 +198,10 @@ class TestSocketName:
assert socketname == expected
@pytest.mark.mac
@pytest.mark.parametrize('basedir, expected', POSIX_TESTS)
@pytest.mark.parametrize('basedir, expected', [
(None, 'i-{}'.format(md5('testusername'))),
('/x', 'i-{}'.format(md5('testusername-/x'))),
])
def test_mac(self, basedir, expected):
socketname = ipc._get_socketname(basedir)
parts = socketname.split(os.sep)
@ -211,7 +209,10 @@ class TestSocketName:
assert parts[-1] == expected
@pytest.mark.linux
@pytest.mark.parametrize('basedir, expected', POSIX_TESTS)
@pytest.mark.parametrize('basedir, expected', [
(None, 'ipc-{}'.format(md5('testusername'))),
('/x', 'ipc-{}'.format(md5('testusername-/x'))),
])
def test_linux(self, basedir, fake_runtime_dir, expected):
socketname = ipc._get_socketname(basedir)
expected_path = str(fake_runtime_dir / 'qutebrowser' / expected)
@ -630,8 +631,6 @@ class TestSendOrListen:
assert ret_client is None
@pytest.mark.posix(reason="Unneeded on Windows")
@pytest.mark.xfail(qtutils.version_check('5.12', compiled=False) and
utils.is_mac, reason="Broken, see #4471")
def test_correct_socket_name(self, args):
server = ipc.send_or_listen(args)
expected_dir = ipc._get_socketname(args.basedir)