[wietse@porcupine.org: Re: [bug&patch] master failing on setsid() when already started as a session leader]

Jacek Konieczny jajcus at bnet.pl
Wed Jun 1 17:28:12 CEST 2005


This is about my recent patch to postfix (already in our CVS). I think
it should stay (doesn't break anythig), but maybe someone has some
objections...

----- Forwarded message from Wietse Venema <wietse at porcupine.org> -----

Subject: Re: [bug&patch] master failing on setsid() when already started as a
 session leader
In-Reply-To: <20050601132201.GB1462 at serwis2.beta> "from Jacek Konieczny at Jun
 1, 2005 03:22:01 pm"
To: Jacek Konieczny <jajcus at bnet.pl>
Date: Wed, 1 Jun 2005 11:17:10 -0400 (EDT)
Cc: Wietse Venema <wietse at porcupine.org>
X-Time-Zone:  USA EST, 6 hours behind central European time
X-Mailer: ELM [version 2.4ME+ PL82 (25)]
From: wietse at porcupine.org (Wietse Venema)
X-Virus-Scanned: by amavisd-new at bnet.pl
X-Bogosity: No, tests=bogofilter, spamicity=0.005875, version=0.16.1

Sorry, this is not a bug. You are starting the master daemon in an
unsupported manner.

	Wietse

Jacek Konieczny:
> 
> Hello,
> 
> I wanted to post this bug report with a patch to postfix-users at postfix.org, the only address 
> for bug reports I have found in the documentation (DEBUG_README), and it
> bounced because I am not subscribed to the list.
> 
> Could you, please, forward it to a right (for a bug-report/patch) address?
> 
> Greets,
> 	Jacek
> 
> -----------
> 
> I wanted to use postfix (2.2.3) with freedt (daemontools clone)
> supervision. It requires the service to start in foreground, but
> "master" daemon started this way was failing with error:
> 
> Jun  1 09:16:54 serwis2 postfix/master[17168]: fatal: unable to set session and process group ID: Operation not permitted
> 
> Here is the piece of original code that does that:
> 
>     /*
>      * Run in a separate process group, so that "postfix stop" can terminate
>      * all MTA processes cleanly. Give up if we can't separate from our
>      * parent process. We're not supposed to blow away the parent.
>      */
>     if (debug_me == 0 && setsid() == -1)
>         msg_fatal("unable to set session and process group ID: %m");
> 
> This may be reasonable not to allow master continue in a "foreign"
> process group, but setsid() also fails when the calling process is
> already a process group leader.  
> 
> Here is the patch which fixes this problem for me:
> 
> --- postfix-2.2.3.orig/src/master/master.c      2005-02-15 01:36:58.000000000 +0100
> +++ postfix-2.2.3/src/master/master.c   2005-06-01 09:55:35.000000000 +0200
> @@ -289,8 +289,8 @@
>       * all MTA processes cleanly. Give up if we can't separate from our
>       * parent process. We're not supposed to blow away the parent.
>       */
> -    if (debug_me == 0 && setsid() == -1)
> -       msg_fatal("unable to set session and process group ID: %m");
> +    if (debug_me == 0 && setsid() == -1 && getsid(0) != getpid())
> +       msg_fatal("unable to set session and process group ID: %m (pid=%d, sid=%d)", (int)getpid(), (int)getsid(0));
> 
>      /*
>       * Make some room for plumbing with file descriptors. XXX This breaks
> 
> 
> Greets,
> 	Jacek
> 


----- End forwarded message -----



More information about the pld-devel-en mailing list