]> git.ipfire.org Git - thirdparty/postfix.git/commitdiff
snapshot-19990402
authorWietse Venema <wietse@porcupine.org>
Fri, 2 Apr 1999 05:00:00 +0000 (00:00 -0500)
committerWietse Venema <wietse@porcupine.org>
Thu, 17 Jan 2013 03:34:04 +0000 (22:34 -0500)
postfix/HISTORY
postfix/global/mail_version.h
postfix/local/dotforward.c

index ccc96896be6b9a14875fcd3061b01c4c790f5d91..cfdaaa5065f4f2ab4d5845d70b74629bfeb6a470 100644 (file)
@@ -2501,6 +2501,16 @@ Apologies for any names omitted.
        sensitive when they should not. Patch by Lutz Jaenicke,
        BTU Cottbus, Germany.
 
+19990402
+
+       Feature: $domain macro support in forward_path.  Philip A.
+       Prindeville, Mirapoint, Inc., USA.  File:  local/dotforward.c.
+
+       Feature: if an address extension (+foo) is explicitly
+       matched by the .forward+foo file name, do not propagate
+       the extension to recipient addresses. This is more consistent
+       with the way aliases are expanded. File:  local/dotforward.c.
+
 Future:
 
        Planned: must be able to list the same hash table in
index 4ddf7132a7d0b5b98d8877bc648c7c8074bd3059..5f5e5a96a0a560ea42e1ce4025046b0dd10eae2d 100644 (file)
@@ -15,7 +15,7 @@
   * Version of this program.
   */
 #define VAR_MAIL_VERSION       "mail_version"
-#define DEF_MAIL_VERSION       "Snapshot-19990330"
+#define DEF_MAIL_VERSION       "Snapshot-19990402"
 extern char *var_mail_version;
 
 /* LICENSE
index 9eea11caf2f7045e09cc383e2ebdb4466c0ec9ff..d3e5b614c999163731389b6e40074f309d102e87 100644 (file)
   * A little helper structure for message-specific context.
   */
 typedef struct {
-    int     failures;                  /* $name not available */
+    int     flags;                     /* see below */
     struct mypasswd *pwd;              /* recipient */
     char   *extension;                 /* address extension */
+    char   *domain;                    /* recipient's domain */
     VSTRING *path;                     /* result */
 } FW_CONTEXT;
 
+#define FW_FLAG_FAILURE                (1<<0)  /* $name not available */
+#define FW_FLAG_HOME           (1<<1)  /* expanded $home */
+#define FW_FLAG_USER           (1<<2)  /* expanded $user */
+#define FW_FLAG_EXTENSION      (1<<3)  /* expanded $extension */
+#define FW_FLAG_DELIMITER      (1<<4)  /* expanded $recipient_delimiter */
+#define FW_FLAG_DOMAIN         (1<<5)  /* expanded $domain */
+#define FW_FLAG_OTHER          (1<<5)  /* expanded text */
+
 /* dotforward_parse_callback - callback for mac_parse */
 
 static void dotforward_parse_callback(int type, VSTRING *buf, char *context)
@@ -101,26 +110,35 @@ static void dotforward_parse_callback(int type, VSTRING *buf, char *context)
     char   *myname = "dotforward_parse_callback";
     FW_CONTEXT *fw_context = (FW_CONTEXT *) context;
     char   *ptr;
+    int     flg;
 
-    if (fw_context->failures)
+    if (fw_context->flags & FW_FLAG_FAILURE)
        return;
 
     /*
      * Find out what data to substitute.
      */
     if (type == MAC_PARSE_VARNAME) {
-       if (strcmp(vstring_str(buf), "home") == 0)
+       if (strcmp(vstring_str(buf), "home") == 0) {
+           flg = FW_FLAG_HOME;
            ptr = fw_context->pwd->pw_dir;
-       else if (strcmp(vstring_str(buf), "user") == 0)
+       } else if (strcmp(vstring_str(buf), "user") == 0) {
+           flg = FW_FLAG_USER;
            ptr = fw_context->pwd->pw_name;
-       else if (strcmp(vstring_str(buf), "extension") == 0)
+       } else if (strcmp(vstring_str(buf), "extension") == 0) {
+           flg = FW_FLAG_EXTENSION;
            ptr = fw_context->extension;
-       else if (strcmp(vstring_str(buf), "recipient_delimiter") == 0)
+       } else if (strcmp(vstring_str(buf), "recipient_delimiter") == 0) {
+           flg = FW_FLAG_DELIMITER;
            ptr = var_rcpt_delim;
-       else
+       } else if (strcmp(vstring_str(buf), "domain") == 0) {
+           flg = FW_FLAG_DOMAIN;
+           ptr = fw_context->domain;
+       } else
            msg_fatal("unknown macro $%s in %s", vstring_str(buf),
                      VAR_FORWARD_PATH);
     } else {
+       flg = FW_FLAG_OTHER;
        ptr = vstring_str(buf);
     }
 
@@ -131,8 +149,9 @@ static void dotforward_parse_callback(int type, VSTRING *buf, char *context)
        msg_info("%s: %s = %s", myname, vstring_str(buf),
                 ptr ? ptr : "(unavailable)");
     if (ptr == 0) {
-       fw_context->failures++;
+       fw_context->flags |= FW_FLAG_FAILURE;
     } else {
+       fw_context->flags |= flg;
        vstring_strcat(fw_context->path, ptr);
     }
 }
@@ -154,6 +173,7 @@ int     deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
     char   *saved_forward_path;
     char   *lhs;
     char   *next;
+    char   *domain;
     const char *forward_path;
     FW_CONTEXT fw_context;
 
@@ -239,6 +259,9 @@ int     deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
      * the .forward file as the user. Ignore files that aren't regular files,
      * files that are owned by the wrong user, or files that have world write
      * permission enabled.
+     * 
+     * If a forward file name includes the address extension, don't propagate
+     * the extension to the recipient addresses.
      */
 #define STR(x) vstring_str(x)
 
@@ -247,24 +270,31 @@ int     deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
     saved_forward_path = mystrdup(forward_path);
     next = saved_forward_path;
 
+    if ((domain = strrchr(state.msg_attr.recipient, '@')) != 0)
+       domain++;
+
     fw_context.pwd = mypwd;
     fw_context.extension = state.msg_attr.extension;
     fw_context.path = path;
+    fw_context.domain = domain;
 
     lookup_status = -1;
 
     while ((lhs = mystrtok(&next, ", \t\r\n")) != 0) {
-       fw_context.failures = 0;
+       fw_context.flags = 0;
        VSTRING_RESET(path);
        mac_parse(lhs, dotforward_parse_callback, (char *) &fw_context);
-       if (fw_context.failures == 0) {
+       if ((fw_context.flags & FW_FLAG_FAILURE) == 0) {
            lookup_status =
                lstat_as(STR(path), &st, usr_attr.uid, usr_attr.gid);
            if (msg_verbose)
                msg_info("%s: path %s status %d", myname,
                         STR(path), lookup_status);
-           if (lookup_status >= 0)
+           if (lookup_status >= 0) {
+               if (fw_context.flags & FW_FLAG_EXTENSION)
+                   state.msg_attr.extension = 0;
                break;
+           }
        }
     }