2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-09-01 06:35:27 +00:00

snapshot-19990402

This commit is contained in:
Wietse Venema
1999-04-02 00:00:00 -05:00
parent 04e16ab3d5
commit c40b6e2174
3 changed files with 52 additions and 12 deletions

View File

@@ -2501,6 +2501,16 @@ Apologies for any names omitted.
sensitive when they should not. Patch by Lutz Jaenicke, sensitive when they should not. Patch by Lutz Jaenicke,
BTU Cottbus, Germany. 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: Future:
Planned: must be able to list the same hash table in Planned: must be able to list the same hash table in

View File

@@ -15,7 +15,7 @@
* Version of this program. * Version of this program.
*/ */
#define VAR_MAIL_VERSION "mail_version" #define VAR_MAIL_VERSION "mail_version"
#define DEF_MAIL_VERSION "Snapshot-19990330" #define DEF_MAIL_VERSION "Snapshot-19990402"
extern char *var_mail_version; extern char *var_mail_version;
/* LICENSE /* LICENSE

View File

@@ -88,12 +88,21 @@
* A little helper structure for message-specific context. * A little helper structure for message-specific context.
*/ */
typedef struct { typedef struct {
int failures; /* $name not available */ int flags; /* see below */
struct mypasswd *pwd; /* recipient */ struct mypasswd *pwd; /* recipient */
char *extension; /* address extension */ char *extension; /* address extension */
char *domain; /* recipient's domain */
VSTRING *path; /* result */ VSTRING *path; /* result */
} FW_CONTEXT; } 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 */ /* dotforward_parse_callback - callback for mac_parse */
static void dotforward_parse_callback(int type, VSTRING *buf, char *context) 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"; char *myname = "dotforward_parse_callback";
FW_CONTEXT *fw_context = (FW_CONTEXT *) context; FW_CONTEXT *fw_context = (FW_CONTEXT *) context;
char *ptr; char *ptr;
int flg;
if (fw_context->failures) if (fw_context->flags & FW_FLAG_FAILURE)
return; return;
/* /*
* Find out what data to substitute. * Find out what data to substitute.
*/ */
if (type == MAC_PARSE_VARNAME) { 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; 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; 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; 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; 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), msg_fatal("unknown macro $%s in %s", vstring_str(buf),
VAR_FORWARD_PATH); VAR_FORWARD_PATH);
} else { } else {
flg = FW_FLAG_OTHER;
ptr = vstring_str(buf); 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), msg_info("%s: %s = %s", myname, vstring_str(buf),
ptr ? ptr : "(unavailable)"); ptr ? ptr : "(unavailable)");
if (ptr == 0) { if (ptr == 0) {
fw_context->failures++; fw_context->flags |= FW_FLAG_FAILURE;
} else { } else {
fw_context->flags |= flg;
vstring_strcat(fw_context->path, ptr); 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 *saved_forward_path;
char *lhs; char *lhs;
char *next; char *next;
char *domain;
const char *forward_path; const char *forward_path;
FW_CONTEXT fw_context; 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, * 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 * files that are owned by the wrong user, or files that have world write
* permission enabled. * 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) #define STR(x) vstring_str(x)
@@ -247,26 +270,33 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
saved_forward_path = mystrdup(forward_path); saved_forward_path = mystrdup(forward_path);
next = saved_forward_path; next = saved_forward_path;
if ((domain = strrchr(state.msg_attr.recipient, '@')) != 0)
domain++;
fw_context.pwd = mypwd; fw_context.pwd = mypwd;
fw_context.extension = state.msg_attr.extension; fw_context.extension = state.msg_attr.extension;
fw_context.path = path; fw_context.path = path;
fw_context.domain = domain;
lookup_status = -1; lookup_status = -1;
while ((lhs = mystrtok(&next, ", \t\r\n")) != 0) { while ((lhs = mystrtok(&next, ", \t\r\n")) != 0) {
fw_context.failures = 0; fw_context.flags = 0;
VSTRING_RESET(path); VSTRING_RESET(path);
mac_parse(lhs, dotforward_parse_callback, (char *) &fw_context); mac_parse(lhs, dotforward_parse_callback, (char *) &fw_context);
if (fw_context.failures == 0) { if ((fw_context.flags & FW_FLAG_FAILURE) == 0) {
lookup_status = lookup_status =
lstat_as(STR(path), &st, usr_attr.uid, usr_attr.gid); lstat_as(STR(path), &st, usr_attr.uid, usr_attr.gid);
if (msg_verbose) if (msg_verbose)
msg_info("%s: path %s status %d", myname, msg_info("%s: path %s status %d", myname,
STR(path), lookup_status); 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; break;
} }
} }
}
if (lookup_status >= 0) { if (lookup_status >= 0) {
if (S_ISREG(st.st_mode) == 0) { if (S_ISREG(st.st_mode) == 0) {