[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC] Load frontends with RTLD_NOW | RTLD_GLOBAL in cdebconf



Hi!

Here's the first patch of a series with the work I have done while
offline.  Git was definitely helpful in this regard. :)

When does frontend switching currently happens in d-i?  I did not
experience any crash while running a dialog based installation with this
patch. (Using loop-aes encryption to be sure to get the entropy plugin.)

Here's the patch:

This will allow plugins to access frontend API without requiring calls to
dlsym().  Kudos to Steve Langasek for the help to figure this out!

---
 packages/cdebconf/debian/changelog |    5 +++++
 packages/cdebconf/src/frontend.c   |    4 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/packages/cdebconf/debian/changelog b/packages/cdebconf/debian/changelog
index 958c79a..2344d31 100644
--- a/packages/cdebconf/debian/changelog
+++ b/packages/cdebconf/debian/changelog
@@ -17,6 +17,11 @@ cdebconf (0.120) UNRELEASED; urgency=low
   [ Joey Hess ]
   * Call dh_md5sums.
 
+  [ Jérémy Bobbio ]
+  * Load frontend with RTLD_NOW | RTLD_GLOBAL to allow plugins to access
+    frontend API without requiring calls to dlsym().  Kudos to Steve Langasek
+    for the help to figure this out!
+
  -- Joey Hess <joeyh@debian.org>  Fri, 17 Aug 2007 13:54:30 -0400
 
 cdebconf (0.119) unstable; urgency=low
diff --git a/packages/cdebconf/src/frontend.c b/packages/cdebconf/src/frontend.c
index 7dba994..9ab94d3 100644
--- a/packages/cdebconf/src/frontend.c
+++ b/packages/cdebconf/src/frontend.c
@@ -170,9 +170,7 @@ struct frontend *frontend_new(struct configuration *cfg, struct template_db *tdb
 	    question_setvalue(q, modname);
         question_deref(q);
         snprintf(tmp, sizeof(tmp), "%s/%s.so", modpath, modname);
-        //Frontend switching works when dlopening with RTLD_LAZY
-        //The real reason why it segfaultes with RTLD_NOW has yet to be found
-	if ((dlh = dlopen(tmp, RTLD_LAZY)) == NULL)
+	if ((dlh = dlopen(tmp, RTLD_NOW | RTLD_GLOBAL)) == NULL)
 		DIE("Cannot load frontend module %s: %s", tmp, dlerror());
 
 	if ((mod = (struct frontend_module *)dlsym(dlh, "debconf_frontend_module")) == NULL)

-- 
Jérémy Bobbio                        .''`. 
lunar@debian.org                    : :Ⓐ  :  # apt-get install anarchism
                                    `. `'` 
                                      `-   

Attachment: signature.asc
Description: Digital signature


Reply to: