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

Manvendra Bhangui <[email protected]> Mon, 3 Apr 2017 19:10:54 +0530
Newsgroups gmane.mail.qmail.general
Message-ID <CAOqj+1OzPRaLahyjQZ4Mq1JsnSkQkL6CsPhuWv0y1sW99fypmA@mail.gmail.com>
On 31 March 2017 at 22:35, Manvendra Bhangui <[email protected]> wrote:
>
> 1. the entire smtpd code was written as a function smtp_init()
>     and compiled as /usr/lib/indimail/plugins/qmail_smtpd.so
> 2. the entire rblsmtpd code was written as a function rblsmtpd()
>    and compiled as /usr/lib/indimail/plugins/rblsmtpd.so
> 3. wrote a function load_shared() for tcpserver which is just
>     a 40 line function using dlopen(). To avoid messing up
>    this email link to this function is here
>    https://sourceforge.net/p/indimail/code/ci/master/tree/
> ucspi-tcp-0.88/load_shared.c
>
>
Ever since I asked this question, plenty of water has flown under the
bridge. I have understood the implications of doing what I have done. I
don't disagree with Charles. As an exercise, I will indeed carry out some
testing. 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()?

What is happening now is that the symbols of tcpserver are accessible to
the two functions that get loaded by dlopen(). However functions in lib1
are not accessible to functions in lib2 and vice versa.

Note: I am using the flags RTLD_NOW|RTLD_LOCAL|RTLD_DEEPBIND|RTLD_NODELETE
with dlopen().

If there is a way to make this happen, I can make tcpserver immune to
malicious/buggy code loaded by dlopen(). Is there a way?

This discussion has been very good. I have got some new ideas

1. Test my code on a frugal hardware like bananaPI (a Chinese clone of
raspberryPi that I have) and RaspberryPI 3. I already have my code running
on BananaPI and RaspberryPI
2. Try out an idea proposed by David Bell.