From 174a87a4df69cca2422543e6fb43c0ddb7c7a1f7 Mon Sep 17 00:00:00 2001 From: Milan Stute Date: Thu, 12 Dec 2019 16:47:44 +0100 Subject: [PATCH] Automatically look for non-standard library paths on macOS Also fixes #19 `abort` error on macOS 10.15 when trying to load default openssl library --- README.md | 16 +++++----------- opendrop/__init__.py | 8 ++++++++ opendrop/util.py | 13 ------------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 80d3f07..1b417ab 100644 --- a/README.md +++ b/README.md @@ -17,22 +17,16 @@ To achieve compatibility with Apple AirDrop, OpenDrop requires the target platfo In addition, it requires Python >=3.6 as well as several libraries. **Apple Wireless Direct Link.** -As AirDrop exclusively runs over Apple Wireless Direct Link (AWDL), OpenDrop is only supported on macOS or on Linux systems running -an open re-implementation of AWDL such as [OWL](https://github.com/seemoo-lab/owl). +As AirDrop exclusively runs over Apple Wireless Direct Link (AWDL), OpenDrop is only supported on macOS or on Linux systems running an open re-implementation of AWDL such as [OWL](https://github.com/seemoo-lab/owl). **Libraries.** OpenDrop relies on current versions of [OpenSSL](https://www.openssl.org) and [libarchive](https://www.libarchive.org). -macOS ships with rather old versions of the two, so you will need to install newer version, for example, via [Homebrew](https://brew.sh). -In any case, you will need to set the two environmental variables `LIBARCHIVE` and `LIBCRYPTO` accordingly. -For example, use `brew` to install the libraries: +macOS ships with rather old versions of the two, so you will need to install newer version, for example, via [Homebrew](https://brew.sh): ```bash -brew install libarchive openssl@1.1 -``` -Then set environmental variables: -```bash -export LIBARCHIVE=/usr/local/opt/libarchive/lib/libarchive.dylib -export LIBCRYPTO=/usr/local/opt/openssl@1.1/lib/libcrypto.dylib +brew install libarchive openssl ``` +OpenDrop automatically sets `DYLD_LIBRARY_PATH` to look for the Homebrew versions. You may need to update the variable yourself if you install the libraries differently. + Linux distributions should ship with more up-to-date versions, so this won't be necessary. diff --git a/opendrop/__init__.py b/opendrop/__init__.py index 37a2509..b9cde51 100644 --- a/opendrop/__init__.py +++ b/opendrop/__init__.py @@ -18,7 +18,15 @@ along with this program. If not, see . """ import logging +import platform +import os __version__ = '0.10.2' +if platform.system() == 'Darwin': + dyld_path = os.environ.get('DYLD_LIBRARY_PATH', '') # save old path + openssl_path = '/usr/local/opt/openssl/lib' + archive_path = '/usr/local/opt/libarchive/lib' + os.environ['DYLD_LIBRARY_PATH'] = '{}:{}:{}'.format(dyld_path, openssl_path, archive_path) + logger = logging.getLogger(__name__) diff --git a/opendrop/util.py b/opendrop/util.py index 6a2d866..dd74a7e 100644 --- a/opendrop/util.py +++ b/opendrop/util.py @@ -22,7 +22,6 @@ import datetime import io import ipaddress import os -import platform import plistlib import hashlib import ifaddr @@ -40,18 +39,6 @@ from libarchive.ffi import ( write_finish_entry, ) from libarchive.write import ArchiveWrite, new_archive_read_disk -if platform.system() == 'Darwin' and os.getenv('LIBCRYPTO') is not None: - import ctypescrypto - from ctypes import CDLL, c_uint64, c_void_p - ctypescrypto.__libname__ = os.environ['LIBCRYPTO'] - ctypescrypto.libcrypto = CDLL(ctypescrypto.__libname__) - if hasattr(ctypescrypto.libcrypto,'OPENSSL_init_crypto'): - ctypescrypto.libcrypto.OPENSSL_init_crypto.argtypes = (c_uint64,c_void_p) - ctypescrypto.libcrypto.OPENSSL_init_crypto(2+4+8+0x40,None) - strings_loaded = True - else: - ctypescrypto.libcrypto.OPENSSL_add_all_algorithms_conf() - strings_loaded = False from ctypescrypto import cms, x509, pkey, oid