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

Manvendra Bhangui <[email protected]> Sun, 2 Apr 2017 13:33:00 +0530
Newsgroups gmane.mail.qmail.general
Message-ID <CAOqj+1OX94qVZJf4B+jESEujitQhxa_ceGDiDbq5nHX_zs+w5g@mail.gmail.com>
On 2 April 2017 at 03:32, Erwin Hoffmann <[email protected]> wrote:
> actually, Charles spoke out what is common believe: Fork/Exec is an operation to lightweight to invest a lot of efforts to improve it. In particular considering the benefits of an uncompromised and clean environment (unlike a thread). HW multithreading (lots of CPUs) will again be in favor of this decision.
>

Just to be clear, The design I spoke about, tcpserver still does a
fork() and only then executes the function loaded in an earlier call
to dlopen(). However, if it does invoke an initialization function, if
in case PLUGIN_n_init is defined. In the case of qmail_smtpd.so, I do
invoke smtp_init(). smtp_init() is a simple function which loads only
the control files. This function can be written carefully so as not to
compromise the environment of the parent. I think that's what you
meant about "uncompromised and clean environment"

I am attaching a simple textual representation of the dlopen() design
for tcpserver. If you see, the only way the environment can be
compromised is by a bad load_control_files() function
tcpserver_design.txt (text/plain, 2.2 KB)
Current qmail/netqmail Design
=============================
                 tcpserver
                     |
                     |
        -----------------------------
        |                           |
        |                           |
      fork()                      fork()
        |                           |
        |                           |
  exec("qmail-smtpd",..)      exec("qmail-smtpd",..)
        |                           |
        |                           |
     setup()                      setup()      ----> load all control files.
        |                           |                every child loads this
        |                           |                same set of control
     commands()                  commands()          files
        |                           |
        |                           |
  smtp_tranaction()         smtp_tranaction()
        |                           |
        |                           |
  smtp_tranaction()         smtp_tranaction()
        |                           |
        |                           |
      exit                         exit



Design in indimail-mta/indimail 
using dlopen()
===============================

                 tcpserver
                     |
                     |
              load_control_files()         ------> All control files loaded
                     |                             only once. all control
                     |                             files loaded into
        -----------------------------              stralloc/constmap vars
        |                           |              avlbl to child
        |                           |
      fork()                      fork()
        |                           |
        |                           |
   qmail_smtpd()              qmail_smtpd()
        |                           |
        |                           |
     commands()                commands()
        |                           |
  smtp_tranaction()         smtp_tranaction()
        |                           |
        |                           |
  smtp_tranaction()         smtp_tranaction()
        |                           |
        |                           |
      exit                         exit