View Single Post
Old 07-12-2022, 12:00 AM   #74
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 41,785
Karma: 18984052
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I looked briefly into the issues caused by the dedrm plugin on macOS. As best as I can tell the problem is it tries to load the system libcrypto instead of loading the one bundled with calibre. Apple doesnt allow loading of system libcrypto. Easily verified by doing:

Code:
calibre-debug -c "import ctypes; from ctypes.util import find_library; l = find_library('crypto'); print(l); ctypes.CDLL(l)"
/usr/lib/libcrypto.dylib
WARNING: /Applications/calibre.app/Contents/MacOS/calibre-debug is loading libcrypto in an unsafe way
zsh: abort      /Applications/calibre.app/Contents/MacOS/calibre-debug -c
Instead the correct way to load libcrypto on macOS is demonstrated by this snippet:

Code:
calibre-debug -c "import ctypes, sys, glob, os; l = glob.glob(os.path.join(sys.frameworks_dir, 'libcrypto*.dylib'))[0]; ctypes.CDLL(l)"
So the plugin should be changed to do something like this:

Code:
if hasattr(sys, 'frameworks_dir'):
  lib = glob.glob(os.path.join(sys.frameworks_dir, 'libcrypto*.dylib'))[0]
else:
  lib = find_library('crypto')
Pass this along to the developer of the plugin and hopefully they can release a fix.
kovidgoyal is offline