Added -dd for daemon debugging.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 10 Nov 2004 10:29:56 +0000 (10:29 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Wed, 10 Nov 2004 10:29:56 +0000 (10:29 +0000)
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
doc/doc-txt/OptionLists.txt
src/ACKNOWLEDGMENTS
src/src/daemon.c
src/src/exim.c
src/src/globals.c
src/src/globals.h

index f946cd0881d2894873731e245306ae2bf0ab98a6..59f1019c6b56b3c887c27b0faf7ff52c182bb0c8 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.18 2004/11/05 16:53:28 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.19 2004/11/10 10:29:56 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -68,6 +68,8 @@ Exim version 4.44
 18. New variables $sender_verify_failure and $recipient_verify_failure contain
     information about exactly what failed.
 
 18. New variables $sender_verify_failure and $recipient_verify_failure contain
     information about exactly what failed.
 
+19. Added -dd to debug only the daemon process.
+
 
 Exim version 4.43
 -----------------
 
 Exim version 4.43
 -----------------
index 5ed1661930bb0f0fdc405386db1fa1bca88e91a6..19150e85f555f67c79942418b1b91941003aeb7e 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.7 2004/11/05 16:53:28 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.8 2004/11/10 10:29:56 ph10 Exp $
 
 New Features in Exim
 --------------------
 
 New Features in Exim
 --------------------
@@ -61,6 +61,12 @@ Version 4.44
     The main use of these variables is expected to be to distinguish between
     rejections of MAIL and rejections of RCPT.
 
     The main use of these variables is expected to be to distinguish between
     rejections of MAIL and rejections of RCPT.
 
+ 8. The command line option -dd behaves exactly like -d except when used on a
+    command that starts a daemon process. In that case, debugging is turned off
+    for the subprocesses that the daemon creates. Thus, it is useful for
+    monitoring the behaviour of the daemon without creating as much output as
+    full debugging.
+
 
 
 Version 4.43
 
 
 Version 4.43
index 42d1d267fcfb3267aae74dd48580a0135bbd3b24..ae04feb59609ef5a01e127ee161bc94e9c9668bc 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.3 2004/11/04 10:42:11 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.4 2004/11/10 10:29:56 ph10 Exp $
 
 LISTS OF EXIM OPTIONS
 ---------------------
 
 LISTS OF EXIM OPTIONS
 ---------------------
@@ -589,7 +589,8 @@ provide compatibility with Sendmail.
 -bvs             Test sender address verification
 -C             + Use alternate configuration file
 -D             + Define macro for configuration file
 -bvs             Test sender address verification
 -C             + Use alternate configuration file
 -D             + Define macro for configuration file
--d               Turn on debugging output
+-d             + Turn on debugging output
+-dd            + Ditto, but if a daemon, not for subprocesses
 -dropcr          Remove CR character in input: became a no-op in 4.21
 -E               Internal use only
 -ex            * Synonym for -oex (for several different x)
 -dropcr          Remove CR character in input: became a no-op in 4.21
 -E               Internal use only
 -ex            * Synonym for -oex (for several different x)
index 53b9a80251e9868c8105f2980b7ef2b4ea0a6e6e..b20e5e2453c31d23e76dd0005879f9fadb35856e 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.2 2004/10/19 11:40:52 ph10 Exp $
+$Cambridge: exim/src/ACKNOWLEDGMENTS,v 1.3 2004/11/10 10:29:56 ph10 Exp $
 
 EXIM ACKNOWLEDGEMENTS
 
 
 EXIM ACKNOWLEDGEMENTS
 
@@ -20,7 +20,7 @@ relatively small patches.
 Philip Hazel
 
 Lists created: 20 November 2002
 Philip Hazel
 
 Lists created: 20 November 2002
-Last updated:  19 October 2004
+Last updated:  10 November 2004
 
 
 THE OLD LIST
 
 
 THE OLD LIST
@@ -119,6 +119,7 @@ Tony Finch                Expansion extensions
                             A number of useful code criticisms
                             Timezone patch for exiwhat
                             Patch for more daemon exiwhat information
                             A number of useful code criticisms
                             Timezone patch for exiwhat
                             Patch for more daemon exiwhat information
+                            Patch for -dd 
 Giuliano Gavazzi          Patches for OSX compilation
 Dominic Germain           Patch for exiqgrep MacOS X bug
 Oliver Gorwits            $load_average patch
 Giuliano Gavazzi          Patches for OSX compilation
 Dominic Germain           Patch for exiqgrep MacOS X bug
 Oliver Gorwits            $load_average patch
index d9375eabf2df79b7c1f6e4b82dedff24973b651a..19a8cea352e173a638a038cd555835c7650cd78c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/daemon.c,v 1.1 2004/10/07 10:39:01 ph10 Exp $ */
+/* $Cambridge: exim/src/src/daemon.c,v 1.2 2004/11/10 10:29:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -362,6 +362,7 @@ if (pid == 0)
   int i;
   int queue_only_reason = 0;
   int old_pool = store_pool;
   int i;
   int queue_only_reason = 0;
   int old_pool = store_pool;
+  int save_debug_selector = debug_selector; 
   BOOL local_queue_only;
   #ifdef SA_NOCLDWAIT
   struct sigaction act;
   BOOL local_queue_only;
   #ifdef SA_NOCLDWAIT
   struct sigaction act;
@@ -432,15 +433,26 @@ if (pid == 0)
   /* Attempt to get an id from the sending machine via the RFC 1413
   protocol. We do this in the sub-process in order not to hold up the
   main process if there is any delay. Then set up the fullhost information
   /* Attempt to get an id from the sending machine via the RFC 1413
   protocol. We do this in the sub-process in order not to hold up the
   main process if there is any delay. Then set up the fullhost information
-  in case there is no HELO/EHLO. */
-
+  in case there is no HELO/EHLO. 
+  
+  If debugging is enabled only for the daemon, we must turn if off while 
+  finding the id, but turn it on again afterwards so that information about the 
+  incoming connection is output. */
+  
+  if (debug_daemon) debug_selector = 0;
   verify_get_ident(IDENT_PORT);
   host_build_sender_fullhost();
   verify_get_ident(IDENT_PORT);
   host_build_sender_fullhost();
+  debug_selector = save_debug_selector; 
 
   DEBUG(D_any)
     debug_printf("Process %d is handling incoming connection from %s\n",
       (int)getpid(), sender_fullhost);
 
 
   DEBUG(D_any)
     debug_printf("Process %d is handling incoming connection from %s\n",
       (int)getpid(), sender_fullhost);
 
+  /* Now disable debugging permanently if it's required only for the daemon
+  process. */
+
+  if (debug_daemon) debug_selector = 0;
+
   /* If there are too many child processes for immediate delivery,
   set the local_queue_only flag, which is initialized from the
   configured value and may therefore already be TRUE. Leave logging
   /* If there are too many child processes for immediate delivery,
   set the local_queue_only flag, which is initialized from the
   configured value and may therefore already be TRUE. Leave logging
@@ -1511,9 +1523,16 @@ for (;;)
       if ((pid = fork()) == 0)
         {
         int sk;
       if ((pid = fork()) == 0)
         {
         int sk;
+        
         DEBUG(D_any) debug_printf("Starting queue-runner: pid %d\n",
           (int)getpid());
 
         DEBUG(D_any) debug_printf("Starting queue-runner: pid %d\n",
           (int)getpid());
 
+        /* Disable debugging if it's required only for the daemon process. We
+        leave the above message, because it ties up with the "child ended" 
+        debugging messages. */
+
+        if (debug_daemon) debug_selector = 0;
         /* Close any open listening sockets in the child */
 
         for (sk = 0; sk < listen_socket_count; sk++) close(listen_sockets[sk]);
         /* Close any open listening sockets in the child */
 
         for (sk = 0; sk < listen_socket_count; sk++) close(listen_sockets[sk]);
index e22fd23089f4f2be908244f6bd156a7a03a69980..6664ea2146216f3c23ab798aa3731dd24faa8cfc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/exim.c,v 1.7 2004/11/04 12:19:48 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.8 2004/11/10 10:29:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1863,7 +1863,8 @@ for (i = 1; i < argc; i++)
     break;
 
     /* -d: Set debug level (see also -v below) or set the drop_cr option.
     break;
 
     /* -d: Set debug level (see also -v below) or set the drop_cr option.
-    The latter is now a no-opt, retained for compatibility only. */
+    The latter is now a no-op, retained for compatibility only. If -dd is used, 
+    debugging subprocesses of the daemon is disabled. */
 
     case 'd':
     if (Ustrcmp(argrest, "ropcr") == 0)
 
     case 'd':
     if (Ustrcmp(argrest, "ropcr") == 0)
@@ -1879,6 +1880,11 @@ for (i = 1; i < argc; i++)
       unsigned int selector = D_default;
       debug_selector = 0;
       debug_file = NULL;
       unsigned int selector = D_default;
       debug_selector = 0;
       debug_file = NULL;
+      if (*argrest == 'd')
+        {
+        debug_daemon = TRUE;
+        argrest++;
+        }
       if (*argrest != 0)
         decode_bits(&selector, NULL, argrest, debug_options,
           debug_options_count, US"debug");
       if (*argrest != 0)
         decode_bits(&selector, NULL, argrest, debug_options,
           debug_options_count, US"debug");
index 0794e03f93354851debaad175d1240af9dc87db1..3ea8d7d209089d2cca8b9850b19d25582d107a00 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.c,v 1.5 2004/11/05 16:53:28 ph10 Exp $ */
+/* $Cambridge: exim/src/src/globals.c,v 1.6 2004/11/10 10:29:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -363,6 +363,7 @@ uschar *continue_transport     = NULL;
 
 BOOL    daemon_listen          = FALSE;
 uschar *daemon_smtp_port       = US"smtp";
 
 BOOL    daemon_listen          = FALSE;
 uschar *daemon_smtp_port       = US"smtp";
+BOOL    debug_daemon           = FALSE;
 int     debug_fd               = -1;
 FILE   *debug_file             = NULL;
 bit_table debug_options[]      = {
 int     debug_fd               = -1;
 FILE   *debug_file             = NULL;
 bit_table debug_options[]      = {
index eaf192e66eeceaf1bc25d5c8191aef6bb44ac7d3..59154403e7460841dafd29e5f3a5319da6108b94 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/globals.h,v 1.5 2004/11/05 16:53:28 ph10 Exp $ */
+/* $Cambridge: exim/src/src/globals.h,v 1.6 2004/11/10 10:29:56 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -194,6 +194,7 @@ extern uschar *continue_transport;     /* Transport for continued delivery */
 
 extern BOOL    daemon_listen;          /* True if listening required */
 extern uschar *daemon_smtp_port;       /* Can be a list of ports */
 
 extern BOOL    daemon_listen;          /* True if listening required */
 extern uschar *daemon_smtp_port;       /* Can be a list of ports */
+extern BOOL    debug_daemon;           /* Debug the daemon process only */
 extern int     debug_fd;               /* The fd for debug_file */
 extern FILE   *debug_file;             /* Where to write debugging info */
 extern bit_table debug_options[];      /* Table of debug options */
 extern int     debug_fd;               /* The fd for debug_file */
 extern FILE   *debug_file;             /* Where to write debugging info */
 extern bit_table debug_options[];      /* Table of debug options */