Paul,

Reading from imapd.c, through server.c, and to pool.c, it looks like the
process path is like this:

imapd.c: parent process (root)
  imapd.c: child process (nobody)
    server.c, pool.c: manage more children (more nobodies)

When you send a HUP to the parent, it does this:

imapd.c: parent process - Receive the HUP, tell child to restart
  imapd.c: child process - Told to restart, kill the children
    server.c, pool.c: told to stop, children are killed.

Then this happens:

imapd.c: parent process (root)
  imapd.c: child process (nobody) -- tries to get a new socket, can't!

Is that first fork needed to establish the dropped privs before forking
each of the children in the pool?

It would make sense to have the first child simply terminate when it
gets a signal, and then the top level parent restarts everything...

This fixes it for me:

--- ../dbmail/imapd.c   2006-02-28 04:15:22.556837664 -0800
+++ imapd.c     2006-02-28 10:16:50.398784536 -0800
  case 0:
          /* child process */
          drop_privileges(config.serverUser, config.serverGroup);
          result = StartServer(&config);
          trace(TRACE_INFO, "%s,%s: server done, restart = [%d]",
                          __FILE__, __func__, result);
-
+         exit(result);
          break;


Aaron

On Tue, 2006-02-28 at 04:58 -0800, Aaron Stone wrote:
> Adding some trace calls to the failed bind:
> 
> server.c,dm_bind_and_listen: My pid is: 24964 parent is 24963
> server.c,dm_bind_and_listen: My uid is: 65534 effective 65534
> server.c,dm_bind_and_listen: Permission denied
> 
> 65534 is nobody on my machine. The process 24963 is still root; 24964 is
> the first child process, but it's the one trying to perform the restart.
> 
> Aaron
> 
> On Tue, 2006-02-28 at 04:44 -0800, Aaron Stone wrote:
> > Here's another one. I'm getting "permission denied" errors when the
> > parent process tries to grab the socket again after SIGHUP. Before
> > giving the HUP, the parent process is still running with root privs.
> > 
> > 
> > Feb 28 04:41:11 [dbmail/imap4d] server.c,StartServer: starting main
> > service loop
> > Feb 28 04:41:22 [dbmail/imap4d] MainSigHandler(): got signal [1]
> > Feb 28 04:41:22 [dbmail/imap4d] pool.c,manage_stop_children: General
> > stop requested. Killing children..
> > Feb 28 04:41:22 [dbmail/imap4d] serverchild.c,PerformChildTask: accept
> > failed
> > Feb 28 04:41:22 [dbmail/imap4d] serverchild.c,PerformChildTask: stop
> > requested
> > Feb 28 04:41:22 [dbmail/imap4d] pool.c,child_reg_disconnected: [15908]
> > Feb 28 04:41:22 [dbmail/imap4d] serverchild.c,PerformChildTask: accept
> > failed
> > Feb 28 04:41:22 [dbmail/imap4d] serverchild.c,PerformChildTask: stop
> > requested
> > Feb 28 04:41:22 [dbmail/imap4d] pool.c,child_reg_disconnected: [15910]
> > Feb 28 04:41:24 [dbmail/imap4d] imapd.c,main: server done, restart = [1]
> > Feb 28 04:41:24 [dbmail/imap4d] imapd.c,get_config: reading config
> > [set config items]
> > Feb 28 04:41:24 [dbmail/imap4d] server.c,dm_socket: done
> > Feb 28 04:41:24 [dbmail/imap4d] server.c,dm_bind_and_listen: Permission
> > denied
> > Feb 28 04:41:26 [dbmail/imap4d] imapd.c,main: server has exited, exit
> > status [75]
> > Feb 28 04:41:26 [dbmail/imap4d] imapd.c,main: exit
> > 
> > 
> > On Tue, 2006-02-28 at 12:51 +0100, Paul J Stevens wrote:
> > > Found it. db_check_connection called from StartServer was being called
> > > before db_connect which load the module.
> > > 
> > > Oleg Lapshin wrote:
> > > >>I've just checked in some changes in the server code. SIGHUPs are now
> > > >>handled correctly. Oleg and Aaron, please test and confirm if you don't
> > > >>mind. If this works out, 2.1.4 can be released later this week.
> > > > 
> > > > 
> > > > No.
> > > > The 1st connect from client to dbmail-imapd works fine,
> > > > but the 2nd - don't at all ;(
> > > > 
> > > > (in my environment of course)
> > > > 
> > > 
> > 
> > _______________________________________________
> > Dbmail-dev mailing list
> > Dbmail-dev@dbmail.org
> > http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> 
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://twister.fastxs.net/mailman/listinfo/dbmail-dev

Reply via email to