OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Subject: PATCH: Possible problem in cleanup
From: Wietse Venema (wietseporcupine.org)
Date: Wed Oct 25 2000 - 19:15:48 CDT


Wietse Venema:
> Given:
>
> > > alias -> user1,user2
> > > user1 -> user1,user1remotehost.com
> > > user2 -> user2,user2remotehost.com
>
> > initial: alias
>
> Successive passes would give:
>
> > pass 1: user1, user2
> > pass 2: user1, user1remotehost.com, user2, user2remotehost.com
>
> In order to achieve that:
>
> > pass 3: user1, user1remotehost.com, user2, user2remotehost.com
>
> One would have to remember what names have been expanded already.

Try the patch below & let me know if it does what you want.

        Wietse

*** ./cleanup_map1n.c- Sat Jan 29 19:23:30 2000
--- ./cleanup_map1n.c Wed Oct 25 20:10:29 2000
***************
*** 54,59 ****
--- 54,60 ----
  #include <mail_addr_map.h>
  #include <cleanup_user.h>
  #include <quote_822_local.h>
+ #include <been_here.h>
  
  /* Application-specific. */
  
***************
*** 69,76 ****
      int count;
      int i;
      int arg;
- int expand_to_self;
      char *saved_lhs;
  
      /*
       * Initialize.
--- 70,77 ----
      int count;
      int i;
      int arg;
      char *saved_lhs;
+ BH_TABLE *been_here;
  
      /*
       * Initialize.
***************
*** 78,83 ****
--- 79,85 ----
      argv = argv_alloc(1);
      argv_add(argv, addr, ARGV_END);
      argv_terminate(argv);
+ been_here = been_here_init(0, BH_FLAG_FOLD);
  
      /*
       * Rewrite the address vector in place. With each map lookup result,
***************
*** 91,103 ****
  #define MAX_EXPANSION 1000
  #define STR vstring_str
  
! for (expand_to_self = 0, arg = 0; arg < argv->argc; arg++) {
          if (argv->argc > MAX_EXPANSION) {
              msg_warn("%s: unreasonable %s map expansion size for %s",
                       state->queue_id, maps->title, addr);
              break;
          }
          for (count = 0; /* void */ ; count++) {
              if (count >= MAX_RECURSION) {
                  msg_warn("%s: unreasonable %s map nesting for %s",
                           state->queue_id, maps->title, addr);
--- 93,107 ----
  #define MAX_EXPANSION 1000
  #define STR vstring_str
  
! for (arg = 0; arg < argv->argc; arg++) {
          if (argv->argc > MAX_EXPANSION) {
              msg_warn("%s: unreasonable %s map expansion size for %s",
                       state->queue_id, maps->title, addr);
              break;
          }
          for (count = 0; /* void */ ; count++) {
+ if (been_here_fixed(been_here, argv->argv[arg]) != 0)
+ break;
              if (count >= MAX_RECURSION) {
                  msg_warn("%s: unreasonable %s map nesting for %s",
                           state->queue_id, maps->title, addr);
***************
*** 107,114 ****
                  saved_lhs = mystrdup(argv->argv[arg]);
                  for (i = 0; i < lookup->argc; i++) {
                      unquote_822_local(state->temp1, lookup->argv[i]);
- if (strcasecmp(saved_lhs, STR(state->temp1)) == 0)
- expand_to_self = 1;
                      if (i == 0) {
                          UPDATE(argv->argv[arg], STR(state->temp1));
                      } else {
--- 111,116 ----
***************
*** 118,134 ****
                  }
                  myfree(saved_lhs);
                  argv_free(lookup);
- if (expand_to_self)
- return (argv);
              } else if (dict_errno != 0) {
                  msg_warn("%s: %s map lookup problem for %s",
                           state->queue_id, maps->title, addr);
                  state->errs |= CLEANUP_STAT_WRITE;
                  return (argv);
              } else {
                  break;
              }
          }
      }
      return (argv);
  }
--- 120,136 ----
                  }
                  myfree(saved_lhs);
                  argv_free(lookup);
              } else if (dict_errno != 0) {
                  msg_warn("%s: %s map lookup problem for %s",
                           state->queue_id, maps->title, addr);
                  state->errs |= CLEANUP_STAT_WRITE;
+ been_here_free(been_here);
                  return (argv);
              } else {
                  break;
              }
          }
      }
+ been_here_free(been_here);
      return (argv);
  }