Re: Advice Required - for avoiding conflict betwen qmail-smtpd, rblsmtpd loaded as shared objects in tcpserver

Manvendra Bhangui <[email protected]> Mon, 3 Apr 2017 20:09:35 +0530
Newsgroups gmane.mail.qmail.general
Message-ID <CAOqj+1N7tmmHxEcj4ooDFePhbDaMrESvx=nNi7dMVPrV1=FVSg@mail.gmail.com>
On 3 April 2017 at 19:10, Manvendra Bhangui <[email protected]> wrote:
>
>  But I am still looking for an answer about dlopen() to improve by own understanding and get some knowledge.  I think I can again put the question in a different way.
>
> If I call dlopen() in tcpserver, how do I make the symbols of tcpserver not accessible to any function(s) that get loaded by calling dlopen()?


Eureka!!!. Found it.  The answer is in using dlmopen() instead of
dlopen(). What was happening was dlopen() was using the same namespace
as the calling program (in this case tcpserver). I need to use
LM_ID_NEWLM to create a new namespace and load the shared libraries in
the new namespace. Not sure why I missed it out even after reading the
man page for dlopen() n number of times. I just need to test it and
confirm that it works the way man page says it.

The dlmopen() function differs from dlopen() primarily in that it
accepts an additional argument,  lmid,  that  specifies the  link-map
list  (also  referred  to  as  a  namespace) in which the shared
object should be loaded.  (By comparison, dlopen() adds the
dynamically loaded shared object to the same namespace as the shared
object  from  which  the  dlopen() call is made.)  The Lmid_t type is
an opaque handle that refers to a namespace.

The  lmid  argument  is  either  the  ID of an existing namespace
(which can be obtained using the dlinfo(3) RTLD_DI_LMID request) or
one of the following special values:

LM_ID_BASE
   Load the shared object in the initial namespace (i.e., the
application's namespace).

LM_ID_NEWLM
   Create a new namespace and load the shared object in that
namespace.  The object must have been  correctly  linked to reference
all of the other shared objects that it requires, since the new
namespace is initially empty.

Thank you all.

-- 
Regards Manvendra - http://www.indimail.org
GPG Pub Key
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xC7CBC760014D250C