diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-09-08 13:46:19 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-09-08 13:46:19 +0000 |
commit | 1d264ec471038b319a8ce96e1a14dbfa6353698d (patch) | |
tree | bb663fb025a86e9cf1135b2d4dcf4b0e993c726f /usr.sbin/smtpd/lka.c | |
parent | a5a022bf8743a142c6ffa311255c3c8ccc09782e (diff) |
add support for sender expansion in smtpd.conf:
%U for sender localpart
%D for sender domainpart
diff sent to tech@ by Gregory Edigarov <greg@bestnet.kharkov.ua>, timeout
by jacekm@, ok by me
Diffstat (limited to 'usr.sbin/smtpd/lka.c')
-rw-r--r-- | usr.sbin/smtpd/lka.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 5e1334133ae..e896d45b79c 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.115 2010/06/04 11:15:25 jacekm Exp $ */ +/* $OpenBSD: lka.c,v 1.116 2010/09/08 13:46:18 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -57,7 +57,7 @@ void lka_request_forwardfile(struct smtpd *, struct lkasession *, struct path * void lka_clear_expandtree(struct expandtree *); void lka_clear_deliverylist(struct deliverylist *); char *lka_encode_secret(struct map_secret *); -size_t lka_expand(char *, size_t, struct path *); +size_t lka_expand(char *, size_t, struct path *,struct path *); void lka_rcpt_action(struct smtpd *, char *, struct path *); void lka_session_destroy(struct smtpd *, struct lkasession *); void lka_expansion_done(struct smtpd *, struct lkasession *); @@ -372,7 +372,7 @@ lka_verify_mail(struct smtpd *env, struct path *path) } size_t -lka_expand(char *buf, size_t len, struct path *path) +lka_expand(char *buf, size_t len, struct path *path, struct path *sender) { char *p, *pbuf; struct rule r; @@ -424,6 +424,22 @@ lka_expand(char *buf, size_t len, struct path *path) continue; } } + if (strncmp(p, "%U", 2) == 0) { + ret += strlcat(pbuf, sender->user, len); + if (ret >= len) + return ret; + pbuf += strlen (sender->user); + ++p; + continue; + } + if (strncmp(p,"%D",2) == 0) { + ret += strlcat(pbuf, sender->domain, len); + if (ret >= len) + return ret; + pbuf += strlen(sender->domain); + ++p; + continue; + } if (strncmp(p, "%a", 2) == 0) { ret += strlcat(pbuf, path->user, len); if (ret >= len) @@ -682,7 +698,7 @@ lka_queue_append(struct smtpd *env, struct lkasession *s, int status) /* send next item to queue */ message = s->message; - lka_expand(path->rule.r_value.path, sizeof(path->rule.r_value.path), path); + lka_expand(path->rule.r_value.path, sizeof(path->rule.r_value.path), path, &message.sender); message.recipient = *path; sep = strchr(message.session_hostname, '@'); if (sep) { |