plugins: Fix paths to match WSUG
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Tue, 12 Sep 2017 09:51:46 +0000 (10:51 +0100)
committerJoão Valverde <j@v6e.pt>
Sun, 17 Sep 2017 16:54:52 +0000 (16:54 +0000)
The Wireshark User Guide seems to say:

Global lua plugins are in $pkglibdir/plugins
Personal lua plugins are in XDG_CONFIG_HOME/plugins

Global binary plugins are in $pkglibdir/plugins/$version
Personal binary plugins are in XDG_CONFIG_HOME/plugins/$version

Fix code to match that. This is a backward-incompatible change
for global lua plugins and personal binary plugins.

Adds a version subfolder to the personal plugin folder for binary plugins.

This allows for safe upgrades and side-by-side installations
with different prefixes (they no longer use the same personal dir).

Change-Id: Ie0f039113628a257625a9a9fb2cb30e532f5dd47
Reviewed-on: https://code.wireshark.org/review/23516
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
CMakeLists.txt
cmakeconfig.h.in
wsutil/CMakeLists.txt
wsutil/Makefile.am
wsutil/filesystem.c
wsutil/plugins.c

index 64b2b7f29f67c418c97085009e0340c09f7a619f..29e5b3708137d3a91e2b3e68bdda1922030bd7bc 100644 (file)
@@ -1362,6 +1362,7 @@ endif()
 # Directory where plugins and Lua dissectors can be found.
 set(PLUGIN_VERSION_DIR "plugins/${CPACK_PACKAGE_VERSION}")
 set(PLUGIN_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${CPACK_PACKAGE_NAME}/${PLUGIN_VERSION_DIR}")
+# Used by the WiresharkConfig.cmake.in module
 if (WIN32)
        set(PLUGIN_INSTALL_DIR "${PLUGIN_VERSION_DIR}")
 else ()
index a8ab22fb90d4c6ec7266af77fc1df94c9292b32f..628ea2c0673f285eadb536a2abeb8f6cf2f2577c 100644 (file)
 /* Support for pcap-ng */
 #cmakedefine PCAP_NG_DEFAULT 1
 
-/* Plugin installation directory */
-#cmakedefine PLUGIN_INSTALL_DIR "${PLUGIN_INSTALL_DIR}"
-
 /* Define if we are using version of of the Portaudio library API */
 #cmakedefine PORTAUDIO_API_1 1
 
index 9bf2b6c30b6f1a21031e82abfcd9e825816d1cbc..43a574d6789dc263c26f6c8c3128fdddbfac71eb 100644 (file)
 
 include(UseABICheck)
 
+if(NOT WIN32)
+       add_definitions(-DPLUGIN_DIR=\"${CMAKE_INSTALL_FULL_LIBDIR}/wireshark/plugins\")
+endif()
+
 set(WSUTIL_PUBLIC_HEADERS
        adler32.h
        base32.h
index 9f50e9b6c9fc9134a566eb7940c3b93838127710..e6698ea4fb1084776474a228112cfe0686c442f0 100644 (file)
@@ -24,7 +24,7 @@ AM_CPPFLAGS = $(INCLUDEDIRS) $(WS_CPPFLAGS) -DWS_BUILD_DLL \
        -DTOP_SRCDIR=\"$(abs_top_srcdir)\"      \
        -DDATAFILE_DIR=\"$(pkgdatadir)\"        \
        -DEXTCAP_DIR=\"$(extcapdir)\"           \
-       -DPLUGIN_INSTALL_DIR=\"$(plugindir)\"   \
+       -DPLUGIN_DIR=\"$(pkglibdir)/plugins\"   \
        -DJSMN_STRICT                           \
        $(GLIB_CFLAGS) $(LIBGCRYPT_CFLAGS)      \
        $(LIBGNUTLS_CFLAGS)
index a4e5ff075f1c9c741e57b04bcda0be1fb6d0cc1d..4ab725377d3e113edaa299dbfd2b6f4c9f4576b7 100644 (file)
@@ -955,7 +955,7 @@ get_datafile_dir(void)
  *    otherwise, if we're running from an app bundle in macOS, we
  *    use the Contents/PlugIns/wireshark subdirectory of the app bundle;
  *
- *    otherwise, we use the PLUGIN_INSTALL_DIR value supplied by the
+ *    otherwise, we use the PLUGIN_DIR value supplied by the
  *    configure script.
  */
 static char *plugin_dir = NULL;
@@ -1028,7 +1028,7 @@ init_plugin_dir(void)
         }
 #endif
         else {
-            plugin_dir = g_strdup(PLUGIN_INSTALL_DIR);
+            plugin_dir = g_strdup(PLUGIN_DIR);
         }
     }
 #endif
index 047a6cb721437f7324e993fd104ada5d87a74e0a..f251966e31b7c79891fe57d96974826987df6dc1 100644 (file)
@@ -340,7 +340,11 @@ scan_plugins(plugin_load_failure_mode mode)
             }
         }
         else
-            plugins_scan_dir(plugin_dir, mode);
+        {
+            plugin_dir_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_plugin_dir(), VERSION);
+            plugins_scan_dir(plugin_dir_path, mode);
+            g_free(plugin_dir_path);
+        }
 
         /*
          * If the program wasn't started with special privileges,
@@ -352,7 +356,9 @@ scan_plugins(plugin_load_failure_mode mode)
          */
         if (!started_with_special_privs())
         {
-            plugins_scan_dir(get_plugins_pers_dir(), mode);
+            plugin_dir_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_plugins_pers_dir(), VERSION);
+            plugins_scan_dir(plugin_dir_path, mode);
+            g_free(plugin_dir_path);
         }
     }
 }