2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-31 14:17:41 +00:00

snapshot-19990324

This commit is contained in:
Wietse Venema
1999-03-24 00:00:00 -05:00
parent 75eef6a068
commit f0b8d0c08e
40 changed files with 184 additions and 55 deletions

1
postfix/.indent.pro vendored
View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -2413,6 +2413,17 @@ Apologies for any names omitted.
and would go through .forward again). Problem reported by
Roman Dolejsi, Prague University of Economics.
19990324
Bugfix: missing map name in check_xxx_access restrictions
could casue a segmentation error. Lamont Jones, Hewlett-
Packard.
Feature: forward_path configuration parameter (default:
$home/.forward$recipient_delimiter$extension,$home/.forward).
Based on initial code by Philip A. Prindeville, Mirapoint,
Inc., USA. Files: local/dotforward.c.
Future:
Planned: must be able to list the same hash table in

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -165,7 +165,7 @@ check)
-exec $WARN not owned by root: {} \;
find $daemon_directory/. $config_directory/. \
\( -perm -020 -or -perm -002 \) \
\( -perm -020 -o -perm -002 \) \
-exec $WARN group or other writable: {} \;
find $queue_directory/* $config_directory/* -name '*core' \

View File

@@ -165,7 +165,7 @@ check)
-exec $WARN not owned by root: {} \;
find $daemon_directory/. $config_directory/. \
\( -perm -020 -or -perm -002 \) \
\( -perm -020 -o -perm -002 \) \
-exec $WARN group or other writable: {} \;
find $queue_directory/* $config_directory/* -name '*core' \

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -306,7 +306,7 @@ extern char *var_fallback_transport;
* Local delivery: path to per-user forwarding file.
*/
#define VAR_FORWARD_PATH "forward_path"
#define DEF_FORWARD_PATH "$home/.forward"
#define DEF_FORWARD_PATH "$home/.forward${recipient_delimiter}${extension},$home/.forward"
extern char *var_forward_path;
#define VAR_RCPT_DELIM "recipient_delimiter"

View File

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

View File

@@ -252,11 +252,11 @@ LOCAL(8) LOCAL(8)
<b>alias</b><i>_</i><b>maps</b>
List of alias databases.
<b>local</b><i>_</i><b>command</b><i>_</i><b>shell</b>
Shell to use for external command execution (for
example, /some/where/smrsh -c). When a shell is
specified, it is invoked even when the command con-
tains no shell built-in commands or meta
<b>forward</b><i>_</i><b>path</b>
Search list for .forward files. The following
macros are recognized: <b>$home</b> (home directory),
<b>$user</b> (login name), <b>$extension</b> (address extension),
<b>$recipient</b><i>_</i><b>delimiter</b> (address extension delimiter).
@@ -269,7 +269,12 @@ LOCAL(8) LOCAL(8)
LOCAL(8) LOCAL(8)
characters.
<b>local</b><i>_</i><b>command</b><i>_</i><b>shell</b>
Shell to use for external command execution (for
example, /some/where/smrsh -c). When a shell is
specified, it is invoked even when the command con-
tains no shell built-in commands or meta charac-
ters.
<b>owner</b><i>_</i><b>request</b><i>_</i><b>special</b>
Give special treatment to <b>owner-</b><i>xxx</i> and <i>xxx</i><b>-request</b>
@@ -319,11 +324,6 @@ LOCAL(8) LOCAL(8)
Time in seconds between successive attempts to
acquire an exclusive lock.
<b>stale</b><i>_</i><b>lock</b><i>_</i><b>time</b>
Limit the time after which a stale lock is removed.
5
@@ -335,6 +335,9 @@ LOCAL(8) LOCAL(8)
LOCAL(8) LOCAL(8)
<b>stale</b><i>_</i><b>lock</b><i>_</i><b>time</b>
Limit the time after which a stale lock is removed.
<b>Resource</b> <b>controls</b>
<b>command</b><i>_</i><b>time</b><i>_</i><b>limit</b>
Limit the amount of time for delivery to external
@@ -385,9 +388,6 @@ LOCAL(8) LOCAL(8)
syslogd(8) system logging
<a href="qmgr.8.html">qmgr(8)</a> queue manager
<b>LICENSE</b>
The Secure Mailer license must be distributed with this
software.
@@ -401,6 +401,10 @@ LOCAL(8) LOCAL(8)
LOCAL(8) LOCAL(8)
<b>LICENSE</b>
The Secure Mailer license must be distributed with this
software.
<b>AUTHOR(S)</b>
Wietse Venema
IBM T.J. Watson Research
@@ -449,10 +453,6 @@ LOCAL(8) LOCAL(8)

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -152,10 +152,12 @@ dotforward.o: ../include/lstat_as.h
dotforward.o: ../include/iostuff.h
dotforward.o: ../include/stringops.h
dotforward.o: ../include/mymalloc.h
dotforward.o: ../include/mac_parse.h
dotforward.o: ../include/mypwd.h
dotforward.o: ../include/bounce.h
dotforward.o: ../include/been_here.h
dotforward.o: ../include/mail_params.h
dotforward.o: ../include/config.h
dotforward.o: local.h
dotforward.o: ../include/tok822.h
dotforward.o: ../include/resolve_clnt.h

View File

@@ -12,15 +12,11 @@
/* int *statusp;
/* DESCRIPTION
/* deliver_dotforward() delivers a message to the destinations
/* listed in a recipient's $HOME/.forward file. The result is
/* zero when no acceptable $HOME/.forward file was found, or when
/* listed in a recipient's .forward file(s) as specified through
/* the forward_path configuration parameter. The result is
/* zero when no acceptable .forward file was found, or when
/* a recipient is listed in her own .forward file.
/*
/* When mail is sent to an extended address (e.g., user+foo),
/* the address extension is appended to the .forward file name
/* (e.g., .forward+foo). When that file does not exist, .forward
/* is used instead.
/*
/* Arguments:
/* .IP state
/* Message delivery attributes (sender, recipient etc.).
@@ -71,6 +67,7 @@
#include <iostuff.h>
#include <stringops.h>
#include <mymalloc.h>
#include <mac_parse.h>
/* Global library. */
@@ -78,6 +75,7 @@
#include <bounce.h>
#include <been_here.h>
#include <mail_params.h>
#include <config.h>
/* Application-specific. */
@@ -86,6 +84,56 @@
#define NO 0
#define YES 1
/*
* A little helper structure for message-specific context.
*/
typedef struct {
int failures; /* $name not available */
struct mypasswd *pwd; /* recipient */
char *extension; /* address extension */
VSTRING *path; /* result */
} FW_CONTEXT;
/* dotforward_parse_callback - callback for mac_parse */
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;
/*
* Find out what data to substitute.
*/
if (type == MAC_PARSE_VARNAME) {
if (strcmp(vstring_str(buf), "home") == 0)
ptr = fw_context->pwd->pw_dir;
else if (strcmp(vstring_str(buf), "user") == 0)
ptr = fw_context->pwd->pw_name;
else if (strcmp(vstring_str(buf), "extension") == 0)
ptr = fw_context->extension;
else if (strcmp(vstring_str(buf), "recipient_delimiter") == 0)
ptr = var_rcpt_delim;
else
msg_fatal("unknown macro $%s in %s", vstring_str(buf),
VAR_FORWARD_PATH);
} else {
ptr = vstring_str(buf);
}
/*
* Append the data, or record that the data was not available.
*/
if (msg_verbose)
msg_info("%s: %s = %s", myname, vstring_str(buf),
ptr ? ptr : "(unavailable)");
if (ptr == 0) {
fw_context->failures++;
} else {
vstring_strcat(fw_context->path, ptr);
}
}
/* deliver_dotforward - expand contents of .forward file */
int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
@@ -100,7 +148,11 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
int forward_found = NO;
int lookup_status;
int addr_count;
char *extension;
char *saved_forward_path;
char *lhs;
char *next;
const char *forward_path;
FW_CONTEXT fw_context;
/*
* Make verbose logging easier to understand.
@@ -109,6 +161,16 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
if (msg_verbose)
MSG_LOG_STATE(myname, state);
/*
* Skip this module if per-user forwarding is disabled. XXX We need to
* extend the config_XXX() interface to request no expansion of $names in
* the given value or in the default value.
*/
if ((forward_path = config_lookup(VAR_FORWARD_PATH)) == 0)
forward_path = DEF_FORWARD_PATH;
if (*forward_path == 0)
return (NO);
/*
* DUPLICATE/LOOP ELIMINATION
*
@@ -173,36 +235,36 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
* Assume that usernames do not have file system meta characters. Open
* 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. We take no special precautions to deal with home
* directories imported via NFS, because mailbox and .forward files
* should always be local to the host running the delivery process.
* Anything else is just asking for trouble when a server goes down
* (either the mailbox server or the home directory server).
*
* With mail to user+foo, try ~/.forward+foo before ~/.forward. Ignore foo
* when it contains '/' or when forward+foo does not exist.
* permission enabled.
*/
#define STR(x) vstring_str(x)
status = 0;
path = vstring_alloc(100);
extension = state.msg_attr.extension;
if (extension && strchr(extension, '/')) {
msg_warn("%s: address with illegal extension: %s",
state.msg_attr.queue_id, state.msg_attr.recipient);
extension = 0;
}
if (extension != 0) {
vstring_sprintf(path, "%s/.forward%c%s", mypwd->pw_dir,
var_rcpt_delim[0], extension);
if ((lookup_status = lstat_as(STR(path), &st,
usr_attr.uid, usr_attr.gid)) < 0)
extension = 0;
}
if (extension == 0) {
vstring_sprintf(path, "%s/.forward", mypwd->pw_dir);
lookup_status = lstat_as(STR(path), &st, usr_attr.uid, usr_attr.gid);
saved_forward_path = mystrdup(forward_path);
next = saved_forward_path;
fw_context.pwd = mypwd;
fw_context.extension = state.msg_attr.extension;
fw_context.path = path;
lookup_status = -1;
while ((lhs = mystrtok(&next, ", \t\r\n")) != 0) {
fw_context.failures = 0;
VSTRING_RESET(path);
mac_parse(lhs, dotforward_parse_callback, (char *) &fw_context);
if (fw_context.failures == 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)
break;
}
}
if (lookup_status >= 0) {
if (S_ISREG(st.st_mode) == 0) {
msg_warn("file %s is not a regular file", STR(path));
@@ -228,6 +290,7 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp)
* Clean up.
*/
vstring_free(path);
myfree(saved_forward_path);
mypwfree(mypwd);
*statusp = status;

View File

@@ -212,6 +212,11 @@
/* .fi
/* .IP \fBalias_maps\fR
/* List of alias databases.
/* .IP \fBforward_path\fR
/* Search list for .forward files. The following macros are recognized:
/* \fB$home\fR (home directory), \fB$user\fR (login name),
/* \fB$extension\fR (address extension), \fB$recipient_delimiter\fR
/* (address extension delimiter).
/* .IP \fBlocal_command_shell\fR
/* Shell to use for external command execution (for example,
/* /some/where/smrsh -c).
@@ -370,6 +375,7 @@ int var_biff;
char *var_mail_spool_dir;
char *var_mailbox_transport;
char *var_fallback_transport;
char *var_forward_path;
int local_cmd_deliver_mask;
int local_file_deliver_mask;
@@ -535,6 +541,15 @@ int main(int argc, char **argv)
0,
};
/*
* XXX We need to extend the config_XXX() interface to request no $name
* expansion in a given value or in the default value.
*/
static CONFIG_STR_TABLE straight_str_table[] = {
VAR_FORWARD_PATH, DEF_FORWARD_PATH, &var_forward_path, 0, 0,
0,
};
single_server_main(argc, argv, local_service,
MAIL_SERVER_INT_TABLE, int_table,
MAIL_SERVER_STR_TABLE, str_table,

View File

@@ -127,6 +127,11 @@ static int deliver_switch(LOCAL_STATE state, USER_ATTR usr_attr)
if (*var_rcpt_delim)
state.msg_attr.extension =
split_addr(state.msg_attr.local, *var_rcpt_delim);
if (state.msg_attr.extension && strchr(state.msg_attr.extension, '/')) {
msg_warn("%s: address with illegal extension: %s",
state.msg_attr.queue_id, state.msg_attr.recipient);
state.msg_attr.extension = 0;
}
if (state.msg_attr.extension && deliver_alias(state, usr_attr, &status))
return (status);

View File

@@ -240,6 +240,11 @@ a configuration change.
.fi
.IP \fBalias_maps\fR
List of alias databases.
.IP \fBforward_path\fR
Search list for .forward files. The following macros are recognized:
\fB$home\fR (home directory), \fB$user\fR (login name),
\fB$extension\fR (address extension), \fB$recipient_delimiter\fR
(address extension delimiter).
.IP \fBlocal_command_shell\fR
Shell to use for external command execution (for example,
/some/where/smrsh -c).

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -1106,7 +1106,7 @@ static int is_map_command(char *name, char *command, char ***argp)
*/
if (strcasecmp(name, command) != 0) {
return (0);
} else if (*argp == 0 || strchr(*(*argp += 1), ':') == 0) {
} else if (*(*argp + 1) == 0 || strchr(*(*argp += 1), ':') == 0) {
msg_warn("restriction %s requires maptype:mapname", command);
longjmp(smtpd_check_buf, -1);
} else {

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO

View File

@@ -35,6 +35,7 @@
-TEXPAND_ATTR
-TFILE
-TFORWARD_INFO
-TFW_CONTEXT
-THEADER_OPTS
-THTABLE
-THTABLE_INFO