From 58afc7858cffe180bafbae306db6be66d313b74b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 17 Apr 2021 15:56:56 +0200 Subject: Remove hardcoded run paths from libraries. --- configure.ac | 68 +++++++++++++++++++---- plugins/Makefile.am | 14 ++--- plugins/arm/Makefile.am | 21 +++++-- plugins/bhash/Makefile.am | 31 ++++++++--- plugins/bootimg/Makefile.am | 21 +++++-- plugins/dalvik/Makefile.am | 25 +++++++-- plugins/devdbg/Makefile.am | 11 +++- plugins/dex/Makefile.am | 21 +++++-- plugins/dexbnf/Makefile.am | 24 +++++--- plugins/dwarf/Makefile.am | 13 ++++- plugins/elf/Makefile.am | 25 ++++++--- plugins/fmtp/Makefile.am | 11 +++- plugins/itanium/Makefile.am | 21 +++++-- plugins/javadesc/Makefile.am | 21 +++++-- plugins/libcsem/Makefile.am | 16 +++++- plugins/lnxsyscalls/Makefile.am | 14 ++++- plugins/mobicore/Makefile.am | 11 +++- plugins/pe/Makefile.am | 25 ++++++--- plugins/pychrysalide/Makefile.am | 13 ++++- plugins/pychrysalide/core.c | 30 ++++++++++ plugins/readdex/Makefile.am | 15 ++++- plugins/readelf/Makefile.am | 15 ++++- plugins/readmc/Makefile.am | 15 ++++- plugins/ropgadgets/Makefile.am | 15 ++++- plugins/winordinals/Makefile.am | 29 +++++++--- plugins/yaml/Makefile.am | 24 +++++--- src/Makefile.am | 6 +- src/core/logs.h | 12 ++++ src/core/paths.c | 117 +++++++++++++++++++++++++++++++++++++++ src/core/paths.h | 10 ++++ src/plugins/pglist.c | 9 +-- 31 files changed, 589 insertions(+), 114 deletions(-) diff --git a/configure.ac b/configure.ac index 291acca..5c383a7 100644 --- a/configure.ac +++ b/configure.ac @@ -210,27 +210,50 @@ AC_DEFINE_UNQUOTED(LOCALE_DIR, "${basedir}/share/locale") # Compilation options ############################################################ -AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [compile with debugging support [default=no]]), +AC_ARG_ENABLE([debug], + AS_HELP_STRING([--enable-debug], [compile with debugging support [default=no]]), [], [enable_debug=no]) -AC_ARG_WITH(gobject-leak-tracker, +AC_ARG_ENABLE([python-bindings], + AS_HELP_STRING([--disable-python-bindings], [disable Python bindings [default=no]]), + [], [enable_python_bindings=yes]) + +AC_ARG_ENABLE([python-package], + AS_HELP_STRING([--enable-python-package], [configure the compilation for building a Python binary distribution [default=no]]), + [build_python_package=$enableval], [build_python_package=no]) + +AC_ARG_WITH([gobject-leak-tracker], AS_HELP_STRING([--with-gobject-leak-tracker], [track remaining GObject instances at exit (imply --enable-debug and GLib support) [default=no]]), [], [with_gobject_leak_tracker=no]) -AC_ARG_WITH(desktop-dir, +AC_ARG_WITH([desktop-dir], AS_HELP_STRING([--with-desktop-dir=PATH], [specify to destination of desktop files (default=PREFIX/share)])) -AC_ARG_WITH(local-resources, +AC_ARG_WITH([local-resources], AS_HELP_STRING([--with-local-resources], [define if built components located in the sources are used at runtime [default=no]]), [with_local_resources=yes], [with_local_resources=no]) + +AM_CONDITIONAL([BUILD_PYTHON_PACKAGE], [test "x$build_python_package" = "xyes"]) + +AM_CONDITIONAL([BUILD_DISCARD_LOCAL], [test "x$with_local_resources" = "xno"]) + + +#-- Delete all kinds of runtime library paths? + +if test "x$enable_rpath" = "xno"; then + hardcode_into_libs=no +fi + + #--- Small enumerations CFLAGS="$CFLAGS -fshort-enums -D_LARGEFILE64_SOURCE" + #--- Is debug mode needed ? if test "x$with_gobject_leak_tracker" = "xyes"; then @@ -252,20 +275,25 @@ if test "x$with_gobject_leak_tracker" = "xyes"; then [Define to 1 to enable code for dumping remaining GObject instances at exit.]) fi + #--- Discard local sources when looking for resources ? -if test "x$enable_rpath" = "xno"; then - hardcode_libdir_flag_spec= +if test "x$build_python_package" = "xyes"; then + CFLAGS="$CFLAGS -DPYTHON_PACKAGE" fi +AC_SUBST(CFLAGS) + + +#--- Discard local sources when looking for resources ? + if test "x$with_local_resources" = "xno"; then CFLAGS="$CFLAGS -DDISCARD_LOCAL" fi -AM_CONDITIONAL([BUILD_DISCARD_LOCAL], [test "x$with_local_resources" = "xno"]) - AC_SUBST(CFLAGS) + #--- Custom destination for desktop resources ? if test "x$with_desktop_dir" != x; then @@ -369,10 +397,6 @@ AC_SUBST(LIBSSL_LIBS) #--- Checks for Python -AC_ARG_ENABLE([python-bindings], - AS_HELP_STRING([--disable-python-bindings], [disable Python bindings [default=no]]), - [], [enable_python_bindings=yes]) - if test "x$enable_debug" = "xyes"; then AC_CHECK_PROG(python3_cfg_binary, [python3-dbg-config] , yes) else @@ -613,9 +637,29 @@ echo echo Found lexical analyzer generator............. : $LEX_INST echo Found general-purpose parser generator....... : $YACC_INST +if test "x$enable_python_bindings" = "xyes"; then + disable_python_bindings="no" +else + disable_python_bindings="yes" +fi + echo echo Print debugging messages..................... : $enable_debug echo Consider local resources..................... : $with_local_resources +echo Disable Python bindings...................... : $disable_python_bindings +echo Build a Python binary distribution........... : $build_python_package + +if test "$disable_python_bindings" = "yes" -a "x$build_python_package" = "xyes"; then + + echo + + m4_define([python_target_warning],[m4_joinall([m4_newline([])], + [Lack of consistency detected as a proper Python package can not get built without Python bindings.], + [Please fix the arguments provided to the configure script.])]) + + AC_MSG_WARN([python_target_warning]) + +fi if test -z "$LEX_INST" -o -z "$YACC_INST"; then diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 608c927..8d39c37 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -9,24 +9,24 @@ endif SUBDIRS = \ $(PYTHON3_SUBDIRS) \ arm \ - bhash \ bootimg \ - dex \ - dalvik \ devdbg \ + dex \ dexbnf \ dwarf \ elf \ fmtp \ itanium \ javadesc \ - libcsem \ - lnxsyscalls \ mobicore \ pe \ + yaml \ + bhash \ + dalvik \ + libcsem \ + lnxsyscalls \ readdex \ readelf \ readmc \ ropgadgets \ - winordinals \ - yaml + winordinals diff --git a/plugins/arm/Makefile.am b/plugins/arm/Makefile.am index 66cff6f..a37cbbd 100644 --- a/plugins/arm/Makefile.am +++ b/plugins/arm/Makefile.am @@ -4,22 +4,32 @@ lib_LTLIBRARIES = libarm.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libarmpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -43,8 +53,9 @@ libarm_la_LIBADD = \ v7/libarmv7.la libarm_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/bhash/Makefile.am b/plugins/bhash/Makefile.am index 44d1c21..45c5ee0 100644 --- a/plugins/bhash/Makefile.am +++ b/plugins/bhash/Makefile.am @@ -4,23 +4,36 @@ lib_LTLIBRARIES = libbhash.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + if BUILD_PYTHON3_BINDINGS -PYTHON3_LIBADD = \ - python/libbhashpython.la +PYTHON3_LIBADD = python/libbhashpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -35,9 +48,11 @@ libbhash_la_SOURCES = \ libbhash_la_LIBADD = \ $(PYTHON3_LIBADD) -libbhash_la_LDFLAGS = \ +libbhash_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + -L$(top_srcdir)/plugins/pe/.libs -lpe \ + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/bootimg/Makefile.am b/plugins/bootimg/Makefile.am index 3f8efb7..ada1e4e 100644 --- a/plugins/bootimg/Makefile.am +++ b/plugins/bootimg/Makefile.am @@ -4,22 +4,32 @@ lib_LTLIBRARIES = libbootimg.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libbootimgpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -35,8 +45,9 @@ libbootimg_la_LIBADD = \ $(PYTHON3_LIBADD) libbootimg_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/dalvik/Makefile.am b/plugins/dalvik/Makefile.am index 0183cfb..644c38a 100644 --- a/plugins/dalvik/Makefile.am +++ b/plugins/dalvik/Makefile.am @@ -4,22 +4,36 @@ lib_LTLIBRARIES = libdalvik.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libdalvikpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -46,9 +60,10 @@ libdalvik_la_LIBADD = \ v35/libdalvik35.la libdalvik_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ -L$(top_srcdir)/plugins/dex/.libs -ldex \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/devdbg/Makefile.am b/plugins/devdbg/Makefile.am index e2dc7b8..a92744d 100644 --- a/plugins/devdbg/Makefile.am +++ b/plugins/devdbg/Makefile.am @@ -4,11 +4,20 @@ lib_LTLIBRARIES = libspeed.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + + libspeed_la_SOURCES = \ speed.h speed.c libspeed_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/dex/Makefile.am b/plugins/dex/Makefile.am index 45003f6..8eb7bde 100644 --- a/plugins/dex/Makefile.am +++ b/plugins/dex/Makefile.am @@ -4,22 +4,32 @@ lib_LTLIBRARIES = libdex.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libdexpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -41,8 +51,9 @@ libdex_la_LIBADD = \ $(PYTHON3_LIBADD) libdex_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/dexbnf/Makefile.am b/plugins/dexbnf/Makefile.am index 3340bc2..51598ce 100644 --- a/plugins/dexbnf/Makefile.am +++ b/plugins/dexbnf/Makefile.am @@ -4,22 +4,31 @@ lib_LTLIBRARIES = libdexbnf.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libdexbnfpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so PYTHON3_SUBDIRS = python endif @@ -36,9 +45,10 @@ libdexbnf_la_SOURCES = \ libdexbnf_la_LIBADD = \ $(PYTHON3_LIBADD) -libdexbnf_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) +libdexbnf_la_LDFLAGS = \ + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/dwarf/Makefile.am b/plugins/dwarf/Makefile.am index 47387db..5a8c9c9 100644 --- a/plugins/dwarf/Makefile.am +++ b/plugins/dwarf/Makefile.am @@ -4,6 +4,13 @@ lib_LTLIBRARIES = libdwarf.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + + libdwarf_la_SOURCES = \ abbrev.h abbrev.c \ checks.h checks.c \ @@ -31,8 +38,10 @@ libdwarf_la_LIBADD = \ v3/libdwarfv3.la \ v4/libdwarfv4.la -libdwarf_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore +libdwarf_la_LDFLAGS = \ + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/elf/Makefile.am b/plugins/elf/Makefile.am index 8a8ce5b..880ae78 100644 --- a/plugins/elf/Makefile.am +++ b/plugins/elf/Makefile.am @@ -6,22 +6,32 @@ lib_LTLIBRARIES = libelf.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libelfpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -44,9 +54,10 @@ libelf_la_SOURCES = \ libelf_la_LIBADD = \ $(PYTHON3_LIBADD) -libelf_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) +libelf_la_LDFLAGS = \ + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/fmtp/Makefile.am b/plugins/fmtp/Makefile.am index 0180111..f365c03 100644 --- a/plugins/fmtp/Makefile.am +++ b/plugins/fmtp/Makefile.am @@ -4,12 +4,21 @@ lib_LTLIBRARIES = libfmtp.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + + libfmtp_la_SOURCES = \ def.h \ parser.h parser.c libfmtp_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/itanium/Makefile.am b/plugins/itanium/Makefile.am index ec2e93b..e1b2d9e 100644 --- a/plugins/itanium/Makefile.am +++ b/plugins/itanium/Makefile.am @@ -4,22 +4,32 @@ lib_LTLIBRARIES = libitanium.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libitaniumpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -37,8 +47,9 @@ libitanium_la_LIBADD = \ $(PYTHON3_LIBADD) libitanium_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/javadesc/Makefile.am b/plugins/javadesc/Makefile.am index e4da266..7a79b99 100644 --- a/plugins/javadesc/Makefile.am +++ b/plugins/javadesc/Makefile.am @@ -4,22 +4,32 @@ lib_LTLIBRARIES = libjavadesc.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libjavadescpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -36,8 +46,9 @@ libjavadesc_la_LIBADD = \ $(PYTHON3_LIBADD) libjavadesc_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/libcsem/Makefile.am b/plugins/libcsem/Makefile.am index e4d4cca..c55a2f8 100644 --- a/plugins/libcsem/Makefile.am +++ b/plugins/libcsem/Makefile.am @@ -4,12 +4,26 @@ lib_LTLIBRARIES = liblibcsem.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + + liblibcsem_la_SOURCES = \ exit.h exit.c \ semantic.h semantic.c liblibcsem_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + -L$(top_srcdir)/plugins/elf/.libs -lelf \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/lnxsyscalls/Makefile.am b/plugins/lnxsyscalls/Makefile.am index c12537c..9c5158f 100644 --- a/plugins/lnxsyscalls/Makefile.am +++ b/plugins/lnxsyscalls/Makefile.am @@ -4,6 +4,16 @@ lib_LTLIBRARIES = liblnxsyscalls.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + liblnxsyscalls_la_SOURCES = \ collect.h collect.c \ core.h core.c \ @@ -17,8 +27,10 @@ liblnxsyscalls_la_SOURCES = \ liblnxsyscalls_la_LIBADD = liblnxsyscalls_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - -L$(top_srcdir)/plugins/arm/.libs -larm + -L$(top_srcdir)/plugins/arm/.libs -larm \ + $(RUN_PATH) EXTRA_DIST = linux-syscalls.db diff --git a/plugins/mobicore/Makefile.am b/plugins/mobicore/Makefile.am index a1a3b08..761108e 100644 --- a/plugins/mobicore/Makefile.am +++ b/plugins/mobicore/Makefile.am @@ -4,6 +4,13 @@ lib_LTLIBRARIES = libmobicore.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + + libmobicore_la_SOURCES = \ core.h core.c \ mclf-def.h \ @@ -12,7 +19,9 @@ libmobicore_la_SOURCES = \ symbols.h symbols.c libmobicore_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/pe/Makefile.am b/plugins/pe/Makefile.am index 8e9bca6..038b8c5 100644 --- a/plugins/pe/Makefile.am +++ b/plugins/pe/Makefile.am @@ -6,22 +6,32 @@ lib_LTLIBRARIES = libpe.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS PYTHON3_LIBADD = python/libpepython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -40,9 +50,10 @@ libpe_la_SOURCES = \ libpe_la_LIBADD = \ $(PYTHON3_LIBADD) -libpe_la_LDFLAGS = \ - -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) +libpe_la_LDFLAGS = \ + -avoid-version \ + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/pychrysalide/Makefile.am b/plugins/pychrysalide/Makefile.am index b4b20ad..fb3986c 100644 --- a/plugins/pychrysalide/Makefile.am +++ b/plugins/pychrysalide/Makefile.am @@ -6,6 +6,13 @@ lib_LTLIBRARIES = pychrysalide.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/chrysalide-libs' + +endif + + pychrysalide_la_SOURCES = \ access.h access.c \ core.h core.c \ @@ -28,10 +35,12 @@ pychrysalide_la_LIBADD = \ mangling/libpychrysamangling.la \ plugins/libpychrysaplugins.la +# -ldl: dladdr(), dlerror() pychrysalide_la_LDFLAGS = \ - -module -avoid-version \ + -module -avoid-version -ldl \ $(LIBPYTHON_LIBS) $(LIBPYGOBJECT_LIBS) \ - -L$(top_srcdir)/src/.libs -lchrysacore + -L$(top_srcdir)/src/.libs -lchrysacore \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c index 38e3c7c..98f94b6 100644 --- a/plugins/pychrysalide/core.c +++ b/plugins/pychrysalide/core.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -399,6 +400,9 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) PyObject *result; /* Module Python à retourner */ bool status; /* Bilan des inclusions */ int ret; /* Bilan de préparatifs */ +#ifdef PYTHON_PACKAGE + Dl_info info; /* Informations dynamiques */ +#endif GPluginModule *self; /* Représentation interne */ PluginStatusFlags self_flags; /* Fanions à mettre à jour */ @@ -529,6 +533,32 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) set_batch_mode(); + /** + * Si cette extension pour Python est chargée depuis un dépôt Python, + * elle ne se trouve pas dans le répertoire classique des extensions et + * n'est donc pas chargée et enregistrée comme attendu. + * + * Cet enregistrement est donc forcé ici. + */ + +#ifdef PYTHON_PACKAGE + + ret = dladdr(__FUNCTION__, &info); + if (ret == 0) + { + LOG_ERROR_DL_N("dladdr"); + Py_DECREF(result); + result = NULL; + goto exit; + } + + self = g_plugin_module_new(info.dli_fname); + assert(self != NULL); + + register_plugin(self); + +#endif + init_all_plugins(false); lock_plugin_list_for_reading(); diff --git a/plugins/readdex/Makefile.am b/plugins/readdex/Makefile.am index e4d961a..b21f855 100644 --- a/plugins/readdex/Makefile.am +++ b/plugins/readdex/Makefile.am @@ -4,6 +4,17 @@ lib_LTLIBRARIES = libreaddex.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + + libreaddex_la_SOURCES = \ class.h class.c \ code.h code.c \ @@ -12,9 +23,11 @@ libreaddex_la_SOURCES = \ reader.h reader.c libreaddex_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ -L$(top_srcdir)/plugins/dex/.libs -ldex \ - -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp + -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/readelf/Makefile.am b/plugins/readelf/Makefile.am index 35c185d..0ca002b 100644 --- a/plugins/readelf/Makefile.am +++ b/plugins/readelf/Makefile.am @@ -4,6 +4,17 @@ lib_LTLIBRARIES = libreadelf.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + + libreadelf_la_SOURCES = \ header.h header.c \ program.h program.c \ @@ -12,9 +23,11 @@ libreadelf_la_SOURCES = \ strtab.h strtab.c libreadelf_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ -L$(top_srcdir)/plugins/elf/.libs -lelf \ - -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp + -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/readmc/Makefile.am b/plugins/readmc/Makefile.am index 1c63ccd..fa13fb2 100644 --- a/plugins/readmc/Makefile.am +++ b/plugins/readmc/Makefile.am @@ -4,6 +4,17 @@ lib_LTLIBRARIES = libreadmc.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + + libreadmc_la_SOURCES = \ header.h header.c \ reader.h reader.c \ @@ -13,9 +24,11 @@ libreadmc_la_SOURCES = \ v24.h v24.c libreadmc_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ -L$(top_srcdir)/plugins/mobicore/.libs -lmobicore \ - -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp + -L$(top_srcdir)/plugins/fmtp/.libs -lfmtp \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/ropgadgets/Makefile.am b/plugins/ropgadgets/Makefile.am index 3cb5e9a..f23e054 100644 --- a/plugins/ropgadgets/Makefile.am +++ b/plugins/ropgadgets/Makefile.am @@ -4,6 +4,17 @@ lib_LTLIBRARIES = libropgadgets.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + + libropgadgets_la_SOURCES = \ finder.h finder.c \ helper.h helper.c \ @@ -12,8 +23,10 @@ libropgadgets_la_SOURCES = \ select.h select.c libropgadgets_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - -L$(top_srcdir)/plugins/arm/.libs -larm + -L$(top_srcdir)/plugins/arm/.libs -larm \ + $(RUN_PATH) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/winordinals/Makefile.am b/plugins/winordinals/Makefile.am index 91607f3..f9ff14f 100644 --- a/plugins/winordinals/Makefile.am +++ b/plugins/winordinals/Makefile.am @@ -4,23 +4,36 @@ lib_LTLIBRARIES = libwinordinals.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs:$$ORIGIN' + +else + +RUN_PATH = -Wl,-rpath,'$$ORIGIN' + +endif + if BUILD_PYTHON3_BINDINGS -PYTHON3_LIBADD = \ - python/libwinordinalspython.la +PYTHON3_LIBADD = python/libwinordinalspython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -38,8 +51,10 @@ libwinordinals_la_LIBADD = \ $(PYTHON3_LIBADD) libwinordinals_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + -L$(top_srcdir)/plugins/pe/.libs -lpe \ + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/plugins/yaml/Makefile.am b/plugins/yaml/Makefile.am index 13596e1..9eee4ab 100644 --- a/plugins/yaml/Makefile.am +++ b/plugins/yaml/Makefile.am @@ -4,23 +4,32 @@ lib_LTLIBRARIES = libyaml.la libdir = $(pluginslibdir) +if BUILD_PYTHON_PACKAGE + +RUN_PATH = -Wl,-rpath,'$$ORIGIN/../chrysalide-libs' + +endif + if BUILD_PYTHON3_BINDINGS -PYTHON3_LIBADD = \ - python/libyamlpython.la +PYTHON3_LIBADD = python/libyamlpython.la if BUILD_DISCARD_LOCAL -PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +if BUILD_PYTHON_PACKAGE +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN/..' +else +PYTHON3_RUN_PATH = -Wl,-rpath,'$$ORIGIN' +endif else -PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ - -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so +PYTHON3_RUN_PATH = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs endif +PYTHON3_LDFLAGS = $(PYTHON3_RUN_PATH) -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + PYTHON3_SUBDIRS = python endif @@ -41,8 +50,9 @@ libyaml_la_LIBADD = \ $(PYTHON3_LIBADD) libyaml_la_LDFLAGS = \ + -avoid-version \ -L$(top_srcdir)/src/.libs -lchrysacore \ - $(PYTHON3_LDFLAGS) + $(RUN_PATH) $(PYTHON3_LDFLAGS) devdir = $(includedir)/chrysalide/$(subdir) diff --git a/src/Makefile.am b/src/Makefile.am index 30a043e..d239a0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,11 @@ endif libchrysacore_la_SOURCES = \ $(GOBJECT_LEAKS_SOURCES) -libchrysacore_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS) $(LIBSQLITE_LIBS) $(LIBARCHIVE_LIBS) +# -ldl: dladdr(), dlerror() +libchrysacore_la_LDFLAGS = \ + -avoid-version -ldl \ + $(LIBGTK_LIBS) $(LIBXML_LIBS) \ + $(LIBSQLITE_LIBS) $(LIBARCHIVE_LIBS) libchrysacore_la_LIBADD = \ analysis/libanalysis.la \ diff --git a/src/core/logs.h b/src/core/logs.h index d3a81b6..a58a5a8 100644 --- a/src/core/logs.h +++ b/src/core/logs.h @@ -25,6 +25,7 @@ #define _CORE_LOGS_H +#include #include #include #include @@ -105,6 +106,17 @@ void log_variadic_message(LogMessageType, const char *, ...); } \ while (0) +#define LOG_ERROR_DL_N(func) \ + do \ + { \ + const char *__msg_ptr; \ + __msg_ptr = dlerror(); \ + if (__msg_ptr == NULL) \ + __msg_ptr = "???"; \ + log_variadic_message(LMT_EXT_ERROR, "[%s:%u] %s: %s", __FUNCTION__, __LINE__, func, __msg_ptr); \ + } \ + while (0) + #define LOG_ERROR_GAI_N(func, errcode) \ do \ { \ diff --git a/src/core/paths.c b/src/core/paths.c index 7f4765e..0bb59e7 100644 --- a/src/core/paths.c +++ b/src/core/paths.c @@ -24,7 +24,10 @@ #include "paths.h" +#include +#include #include +#include #include #include #include @@ -34,6 +37,7 @@ #include +#include "logs.h" #include "../common/extstr.h" @@ -108,6 +112,119 @@ char *get_effective_directory(const char *template) /****************************************************************************** * * +* Paramètres : type = type de répertoire de travail visé. * +* * +* Description : Fournit le répertoire réel correspondant à une cible. * +* * +* Retour : Répertoire de travail effectif. * +* * +* Remarques : - * +* * +******************************************************************************/ + +char *get_effective_directory_new(TargetDirectoryType type) +{ + char *result; /* Répertoire à retourner */ +#ifdef DISCARD_LOCAL + Dl_info info; /* Informations dynamiques */ + int ret; /* Bilan d'une récupération */ + char *dyn_path_tmp; /* Chemin d'accès modifiable */ + const char *dyn_path; /* Chemin d'accès courant */ +# ifdef PYTHON_PACKAGE + size_t len; /* Taille de comparaison */ + size_t pos; /* Position dans une chaîne */ +# endif +#endif + + /** + * Toutes les définitions traitées dans cette fonction doivent rester synchronisées + * avec celles du fichier configure.ac. + * + * Quand les ressources issues du code source ne sont pas utilisées, deux cas de + * figure sont pris en compte : + * + * - .../lib + * - .../lib/chrysalide-plugins + * + * - .../lib/python3.7/site-packages/chrysalide-libs + * - .../lib/python3.7/site-packages + * + * Le chemin courant pointe sur le premier élément et doit permettre de retrouver + * les autres sur demandes. + */ + + result = NULL; + +#ifdef DISCARD_LOCAL + + ret = dladdr(__FUNCTION__, &info); + if (ret == 0) + { + LOG_ERROR_DL_N("dladdr"); + goto exit; + } + + dyn_path_tmp = strdup(info.dli_fname); + dyn_path = dirname(dyn_path_tmp); + +#endif + + switch (type) + { + case TDT_PLUGINS_LIB: + +#ifndef DISCARD_LOCAL + result = strdup(PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "plugins"); +#else +# ifdef PYTHON_PACKAGE + + len = strlen("chrysalide-libs"); + pos = strlen(dyn_path); + + if (pos <= len) + goto bad_sync; + + pos -= len; + + if (strcmp(&dyn_path[pos], "chrysalide-libs") != 0) + goto bad_sync; + + result = strdup(dyn_path); + result[pos] = '\0'; + result = stradd(result, "chrysalide-plugins"); + +# else + result = strdup(dyn_path); + result = stradd(result, G_DIR_SEPARATOR_S "chrysalide-plugins"); +# endif +#endif + break; + + default: + result = NULL; + break; + + } + + bad_sync: + +#ifdef DISCARD_LOCAL + + free(dyn_path_tmp); + +#endif + + exit: + + assert(result != NULL); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : dirname = répertoire de travail à fouiller. * * filename = nom de fichier seul comme indice. * * * diff --git a/src/core/paths.h b/src/core/paths.h index e6ce61f..f56beb0 100644 --- a/src/core/paths.h +++ b/src/core/paths.h @@ -32,6 +32,16 @@ void register_new_prefix(const char *); /* Fournit le répertoire réel correspondant à une cible. */ char *get_effective_directory(const char *); +/* Listes de répertoires d'installation */ +typedef enum _TargetDirectoryType +{ + TDT_PLUGINS_LIB, /* Répertoire des extensions */ + +} TargetDirectoryType; + +/* Fournit le répertoire réel correspondant à une cible. */ +char *get_effective_directory_new(TargetDirectoryType); + /* Trouve le chemin d'accès complet à un fichier d'image. */ char *find_pixmap_file(const char *); diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index dd4e127..e7ca037 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -32,7 +32,6 @@ #include -#include #include @@ -75,22 +74,16 @@ static void on_plugin_ref_toggle(gpointer, GPluginModule *, gboolean); bool init_all_plugins(bool load) { -#ifdef DISCARD_LOCAL char *edir; /* Répertoire de base effectif */ -#endif char *env; /* Contenu environnemental */ char *saveptr; /* Sauvegarde pour parcours */ char *udir; /* Répertoire supplémentaire ? */ g_rw_lock_init(&_pg_lock); -#ifndef DISCARD_LOCAL - browse_directory_for_plugins(PACKAGE_SOURCE_DIR "/plugins"); -#else - edir = get_effective_directory(PLUGINS_LIB_DIR); + edir = get_effective_directory_new(TDT_PLUGINS_LIB); browse_directory_for_plugins(edir); free(edir); -#endif env = getenv("CHRYSALIDE_PLUGINS_PATH"); -- cgit v0.11.2-87-g4458