[SCM] Debian Qt/KDE packaging tools branch, master, updated. debian/0.13.1-12-gef732bc
Modestas Vainius
modax at alioth.debian.org
Wed May 25 12:11:31 UTC 2011
The following commit has been merged in the master branch:
commit 164fde2750f513f3e66265386dc65b5780bf38b4
Author: Modestas Vainius <modax at debian.org>
Date: Wed May 25 12:18:29 2011 +0300
DLRestrictions: improve library compatibility checking APIs.
Also export more public APIs and document them.
---
debian/changelog | 2 +
dlrestrictions/dlrestrictions.c | 59 +++++++++++++++++++++------------------
dlrestrictions/dlrestrictions.h | 30 +++++++++++++++++++-
3 files changed, 63 insertions(+), 28 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8aced16..10b7ef5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ pkg-kde-tools (0.14.0~pre1) UNRELEASED; urgency=low
* pkgkde-symbolshelper: expand qreal subst to float on sh4. (Closes: #627486)
* DLRestrictions: hide dlr_are_symbol_objects_compatible() symbol.
* DLRestrictions: rework and cleanup error functions. Export new APIs.
+ * DLRestrictions: improve library compatibility checking APIs and export more
+ functions.
-- Modestas Vainius <modax at debian.org> Tue, 24 May 2011 21:47:52 +0300
diff --git a/dlrestrictions/dlrestrictions.c b/dlrestrictions/dlrestrictions.c
index a46978b..16841bf 100644
--- a/dlrestrictions/dlrestrictions.c
+++ b/dlrestrictions/dlrestrictions.c
@@ -493,8 +493,7 @@ static int dlr_are_symbol_objects_compatible(void *h_base, void *h_against)
return status;
}
-/* An extended wrapper around dlopen() with runtime restriction checking */
-void* dlr_dlopen_extended(const char *file, int mode, int print_error, int fail_on_error)
+int dlr_check_file_compatibility(const char *file)
{
void *h_global, *h_file;
int status;
@@ -505,44 +504,50 @@ void* dlr_dlopen_extended(const char *file, int mode, int print_error, int fail_
h_file = dlmopen(LM_ID_NEWLM, file, RTLD_LAZY | RTLD_LOCAL);
if (h_file == NULL) {
- return NULL;
+ return -ENOENT;
}
h_global = dlopen(0, RTLD_LAZY | RTLD_LOCAL);
if (h_global == NULL) {
dlr_set_error("unable to dlopen() global symbol object");
+ dlclose(h_file);
+ return -ENOTDIR;
+ }
+
+ status = dlr_are_symbol_objects_compatible(h_global, h_file);
+ if (status < 0) {
+ status = -EPROTO;
+ }
+
+ dlclose(h_global);
+ dlclose(h_file);
+
+ return status;
+}
+
+void* dlr_dlopen_extended(const char *file, int mode, int print_error, int fail_on_error)
+{
+ int status;
+
+ status = dlr_check_file_compatibility(file);
+ if (status == -ENOENT) { /* file cannot be loaded (does not exist) */
+ return NULL;
+ } else if (status < 0) { /* other error while checking compatibility */
if (print_error) {
dlr_print_pretty_error(file);
}
if (fail_on_error) {
- dlclose(h_file);
return NULL;
}
- }
-
- if (h_global != NULL) {
- status = dlr_are_symbol_objects_compatible(h_global, h_file);
- if (status < 0 && print_error) {
+ } else if (status == 0) { /* library is not compatible */
+ if (print_error) {
dlr_print_pretty_error(file);
}
- /* Check for failure */
- if (status == 0 || (status < 0 && fail_on_error)) {
- if (status == 0 && print_error) {
- dlr_print_pretty_error(file);
- }
- dlclose(h_file);
- h_file = NULL;
- }
- }
-
- if (h_global != NULL)
- dlclose(h_global);
-
- if (h_file != NULL) {
- /* Reopen the file with base link map */
- dlclose(h_file);
- h_file = dlopen(file, mode);
+ return NULL;
}
- return h_file;
+ /* Else either library is compatible or fail_on_error is disabled
+ Just dlopen() the library.
+ */
+ return dlopen(file, mode);
}
diff --git a/dlrestrictions/dlrestrictions.h b/dlrestrictions/dlrestrictions.h
index 10c2af0..7fe4a9b 100644
--- a/dlrestrictions/dlrestrictions.h
+++ b/dlrestrictions/dlrestrictions.h
@@ -58,7 +58,35 @@ const char* dlr_error(void);
int dlr_snprintf_pretty_error(char *str, size_t n, const char *context);
void dlr_print_pretty_error(const char *context);
-/* Library verification functions and dlopen() wrappers */
+/* Library compatibility checking functions */
+
+/*
+ Public function for verification of the given library file against global
+ symbol object.
+
+ * file - same as to dlopen();
+ * Return value:
+ < 0 - error occured while checking compatibility:
+ * -ENOENT - unable to open file;
+ * -ENOTDIR - unable to dlopen() global symbol object;
+ * -EPROTO - syntax or other fatal error while checking compatibility;
+ == 0 - library and its dependencies are NOT compatible with global object;
+ > 0 - library and its dependencies are compatible with global object;
+*/
+int dlr_check_file_compatibility(const char *file);
+
+/*
+ An extended wrapper around dlopen() with integrated file compatibility checking.
+
+ * file - same as to dlopen();
+ * mode - same as to dlopen();
+ * printerror - if enabled, a pretty DLRestrctions error will be printed to stderr
+ when one occurs or if the file is NOT compatible.
+ * fail_on_error - if enabled, NULL will be returned if DLRestrictions specific
+ error occurs. Please note that successful compatibility checking regardless
+ of the outcome is NOT an error.
+ * Return value - a valid dlopen() handle if successful, NULL otherwise.
+*/
void* dlr_dlopen_extended(const char *file, int mode, int print_error, int fail_on_error);
#endif
--
Debian Qt/KDE packaging tools
More information about the pkg-kde-commits
mailing list