Patch from Alan Curry in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=298582.
Basically, openlog was getting fd 0 for the log in some circumstances,
and safe_fork() was doing closelog after getting the desired stdin
dup'd to fd 0.  This fixes it by doing the closelog a little earlier.
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: main.c,v 1.153 2006/06/04 03:52:50 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.154 2006/12/19 07:48:19 paulus Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
        if (errfd == 0 || errfd == 1)
                errfd = dup(errfd);
 
+       closelog();
+
        /* dup the in, out, err fds to 0, 1, 2 */
        if (infd != 0)
                dup2(infd, 0);
        if (errfd != 2)
                dup2(errfd, 2);
 
-       closelog();
        if (log_to_fd > 2)
                close(log_to_fd);
        if (the_channel->close)