1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
From: Modestas Vainius <modax@debian.org>
Subject: Add DLRestrictions support
Forwarded: not-needed
Origin: vendor
Last-Update: 2013-09-04
The patch adds DLRestrictions compatibility checks to the KPluginLoader::load()
function. Moreover, a new helper CMake macro is introduced to ease addition of
the special DLRestrictions symbol to the KDE 4 shared objects (shared library
and module targets) defined in the project with kde4_add_library() macro.
In order to define DLRestrictions expressions for the shared objects in your
project, you may add something like this to the bottom of the main
CMakeLists.txt:
find_package(DLRestrictions REQUIRED)
kde4deb_dlrestrictions_process_libraries()
Please that either DEFAULT_DLRESTRICTIONS variable or DLRESTRICITIONS target
property must have set beforehand. Otherwise, this snippet will have no effect
on all (or some) the targets.
Index: kde4libs/cmake/modules/KDE4Macros.cmake
===================================================================
--- kde4libs.orig/cmake/modules/KDE4Macros.cmake 2015-09-19 02:00:46.024140148 +0200
+++ kde4libs/cmake/modules/KDE4Macros.cmake 2015-09-19 02:00:46.008140794 +0200
@@ -1061,10 +1061,14 @@
if (${_lib_TYPE} STREQUAL "SHARED")
set(_first_SRC)
set(_add_lib_param SHARED)
+ # Keep a list of SO targets in the global property
+ set_property(GLOBAL PROPERTY KDE4DEB_SO_TARGETS ${_target_NAME} APPEND)
endif (${_lib_TYPE} STREQUAL "SHARED")
if (${_lib_TYPE} STREQUAL "MODULE")
set(_first_SRC)
set(_add_lib_param MODULE)
+ # Keep a list of SO targets in the global property
+ set_property(GLOBAL PROPERTY KDE4DEB_SO_TARGETS ${_target_NAME} APPEND)
endif (${_lib_TYPE} STREQUAL "MODULE")
set(_SRCS ${_first_SRC} ${ARGN})
@@ -1376,6 +1380,13 @@
endfunction(KDE4_INSTALL_AUTH_ACTIONS)
+macro(KDE4DEB_DLRESTRICTIONS_PROCESS_LIBRARIES)
+ if (NOT DLRESTRICTIONS_FOUND)
+ MESSAGE(SEND_ERROR "Install and find_package() DLRestrictions before using it")
+ endif (NOT DLRESTRICTIONS_FOUND)
+ get_property(_all_kde4_so_targets GLOBAL PROPERTY KDE4DEB_SO_TARGETS)
+ dlrestrictions_process_targets(${_all_kde4_so_targets})
+endmacro(KDE4DEB_DLRESTRICTIONS_PROCESS_LIBRARIES)
macro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES _append_or_write _filename)
message(FATAL_ERROR "_KDE4_EXPORT_LIBRARY_DEPENDENCIES() was an internal macro and has been removed again. Just remove the code which calls it, there is no substitute.")
Index: kde4libs/kdecore/CMakeLists.txt
===================================================================
--- kde4libs.orig/kdecore/CMakeLists.txt 2015-09-19 02:00:46.024140148 +0200
+++ kde4libs/kdecore/CMakeLists.txt 2015-09-19 02:00:46.020140310 +0200
@@ -412,6 +412,14 @@
target_link_libraries(kdecore LINK_PRIVATE ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${ZLIB_LIBRARY} ${kdecore_OPTIONAL_LIBS})
+# Enable DLRestrictions library checking for Debian only
+if (CMAKE_BUILD_TYPE STREQUAL "Debian")
+ find_package(DLRestrictions REQUIRED)
+ macro_log_feature(DLRESTRICTIONS_FOUND "DLRestrictions" "Needed for kdecore plugin loader (Debian specific)" "http://packages.debian.org/search?keywords=libdlrestrictions-dev" TRUE "" "")
+ set_property(TARGET kdecore PROPERTY COMPILE_DEFINITIONS HAVE_DLRESTRICTIONS)
+ target_link_libraries(kdecore dlrestrictions)
+endif (CMAKE_BUILD_TYPE STREQUAL "Debian")
+
if(WINCE)
target_link_libraries(kdecore LINK_PRIVATE ${WCECOMPAT_LIBRARIES} Ceshell.lib)
endif(WINCE)
Index: kde4libs/kdecore/util/kpluginloader.cpp
===================================================================
--- kde4libs.orig/kdecore/util/kpluginloader.cpp 2015-09-19 02:00:46.024140148 +0200
+++ kde4libs/kdecore/util/kpluginloader.cpp 2015-09-19 02:00:46.020140310 +0200
@@ -31,6 +31,14 @@
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
+#ifdef HAVE_DLRESTRICTIONS
+extern "C" {
+#include <dlrestrictions.h>
+}
+#include <errno.h>
+#include <QtCore/QFile>
+#endif
+
extern int kLibraryDebugArea();
class KPluginLoaderPrivate
@@ -259,6 +267,30 @@
else
d->pluginVersion = ~0U;
+#ifdef HAVE_DLRESTRICTIONS
+ QByteArray enLibFileName = QFile::encodeName(lib.fileName());
+ int dlr_plugstatus = dlr_check_file_compatibility(enLibFileName.data(), NULL);
+ if (dlr_plugstatus == -ENOENT) {
+ // Something was wrong with the given filename
+ kWarning(kLibraryDebugArea()) << "DLRestrictions was unable to load plugin" <<
+ d->name << "(filename: " << lib.fileName() << ") for compatibility checking. "
+ "Error was" << QString::fromLocal8Bit(dlr_error()) << ". Accepting anyway.";
+ } else if (dlr_plugstatus < 0) {
+ /* Do not fail if DLRestrictions specific error occurs */
+ char dlr_buf[4096];
+ dlr_buf[0] = 0;
+ dlr_snprintf_pretty_error(dlr_buf, sizeof(dlr_buf), d->name.toLocal8Bit().data());
+ kWarning(kLibraryDebugArea()) << dlr_buf << ". Accepting" << d->name << "plugin anyway.";
+ } else if (dlr_plugstatus == 0) {
+ /* Plugin or its shared library dependencies are not compatible */
+ d->errorString = i18n("The plugin '%1' or its library dependencies are not "
+ "compatible with currently loaded libraries: %2", d->name,
+ QString::fromLocal8Bit(dlr_error()));
+ unload();
+ return false;
+ } /* Else plugin passed DLRestrictions checks. Fine */
+#endif
+
return true;
}
|