diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2012-09-26 19:52:21 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2012-09-26 19:52:21 +0000 |
commit | 06581330965bd9f1e6f774a3d405d9671c644f26 (patch) | |
tree | bec019aa6ec2a8d731e3ab6a5b5c59db610e3637 /usr.sbin | |
parent | 1c96254e998950d7451302540f7410cde768f6bb (diff) |
Stop using the delivery_data union (field "to") in delivery_mda.
It's confusing and not necessary as it's only used for "buffer".
Instead, just add a "buffer" member in the structure and rename
"as_user" to "user".
The delivery_data union becomes an anonymous union in expandnode,
which is the only other place where it's used.
ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/envelope.c | 14 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_session.c | 57 | ||||
-rw-r--r-- | usr.sbin/smtpd/mda.c | 16 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 18 | ||||
-rw-r--r-- | usr.sbin/smtpd/util.c | 4 |
5 files changed, 54 insertions, 55 deletions
diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c index e09bc56225b..3bdccfea86c 100644 --- a/usr.sbin/smtpd/envelope.c +++ b/usr.sbin/smtpd/envelope.c @@ -1,4 +1,4 @@ -/* $OpenBSD: envelope.c,v 1.13 2012/09/19 18:20:36 eric Exp $ */ +/* $OpenBSD: envelope.c,v 1.14 2012/09/26 19:52:20 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -341,11 +341,11 @@ envelope_ascii_load(enum envelope_field field, struct envelope *ep, char *buf) case EVP_MDA_METHOD: return ascii_load_mda_method(&ep->agent.mda.method, buf); case EVP_MDA_BUFFER: - return ascii_load_string(ep->agent.mda.to.buffer, buf, - sizeof ep->agent.mda.to.buffer); + return ascii_load_string(ep->agent.mda.buffer, buf, + sizeof ep->agent.mda.buffer); case EVP_MDA_USER: - return ascii_load_string(ep->agent.mda.as_user, buf, - sizeof ep->agent.mda.as_user); + return ascii_load_string(ep->agent.mda.user, buf, + sizeof ep->agent.mda.user); case EVP_MTA_RELAY_HOST: return ascii_load_string(ep->agent.mta.relay.hostname, buf, sizeof ep->agent.mta.relay.hostname); @@ -408,9 +408,9 @@ envelope_ascii_dump(enum envelope_field field, struct envelope *ep, case EVP_MDA_METHOD: return ascii_dump_mda_method(ep->agent.mda.method, buf, len); case EVP_MDA_BUFFER: - return ascii_dump_string(ep->agent.mda.to.buffer, buf, len); + return ascii_dump_string(ep->agent.mda.buffer, buf, len); case EVP_MDA_USER: - return ascii_dump_string(ep->agent.mda.as_user, buf, len); + return ascii_dump_string(ep->agent.mda.user, buf, len); case EVP_MTA_RELAY_HOST: return ascii_dump_string(ep->agent.mta.relay.hostname, buf, len); diff --git a/usr.sbin/smtpd/lka_session.c b/usr.sbin/smtpd/lka_session.c index d86b7a57363..2b5cf095a82 100644 --- a/usr.sbin/smtpd/lka_session.c +++ b/usr.sbin/smtpd/lka_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_session.c,v 1.34 2012/09/24 08:56:12 eric Exp $ */ +/* $OpenBSD: lka_session.c,v 1.35 2012/09/26 19:52:20 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -108,10 +108,10 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep) switch (ep->rule.r_condition.c_type) { case C_ALL: case C_DOM: - if (ep->agent.mda.to.user[0] == '\0') + if (ep->agent.mda.user[0] == '\0') user = ep->dest.user; else - user = ep->agent.mda.to.user; + user = ep->agent.mda.user; xlowercase(username, user, sizeof(username)); /* gilles+hackers@ -> gilles@ */ @@ -131,30 +131,30 @@ lka_session_envelope_expand(struct lka_session *lks, struct envelope *ep) if (! ub->getbyname(&u, username)) return 0; - (void)strlcpy(ep->agent.mda.as_user, u.username, - sizeof (ep->agent.mda.as_user)); + (void)strlcpy(ep->agent.mda.user, u.username, + sizeof (ep->agent.mda.user)); ep->type = D_MDA; switch (ep->rule.r_action) { case A_MBOX: ep->agent.mda.method = A_MBOX; - (void)strlcpy(ep->agent.mda.to.user, + (void)strlcpy(ep->agent.mda.user, u.username, - sizeof (ep->agent.mda.to.user)); + sizeof (ep->agent.mda.user)); break; case A_MAILDIR: case A_FILENAME: case A_MDA: ep->agent.mda.method = ep->rule.r_action; - (void)strlcpy(ep->agent.mda.to.buffer, + (void)strlcpy(ep->agent.mda.buffer, ep->rule.r_value.buffer, - sizeof (ep->agent.mda.to.buffer)); + sizeof (ep->agent.mda.buffer)); if (tag && *tag) { - (void)strlcat(ep->agent.mda.to.buffer, "/.", - sizeof (ep->agent.mda.to.buffer)); - (void)strlcat(ep->agent.mda.to.buffer, tag, - sizeof (ep->agent.mda.to.buffer)); + (void)strlcat(ep->agent.mda.buffer, "/.", + sizeof (ep->agent.mda.buffer)); + (void)strlcat(ep->agent.mda.buffer, tag, + sizeof (ep->agent.mda.buffer)); } break; default: @@ -353,8 +353,8 @@ lka_session_deliver(struct lka_session *lks, struct envelope *ep) case A_FILENAME: case A_MDA: if (! lka_session_expand_format( - new_ep->agent.mda.to.buffer, - sizeof(new_ep->agent.mda.to.buffer), new_ep)) + new_ep->agent.mda.buffer, + sizeof(new_ep->agent.mda.buffer), new_ep)) lks->flags |= F_ERROR; default: break; @@ -410,7 +410,8 @@ lka_session_resolve_node(struct envelope *ep, struct expandnode *xn) log_debug("lka_resolve_node: node is local username: %s", xn->u.user); ep->type = D_MDA; - ep->agent.mda.to = xn->u; + strlcpy(ep->agent.mda.user, xn->u.user, + sizeof ep->agent.mda.user); /* overwrite the initial condition before we expand the * envelope again. if we came from a C_VDOM, not doing @@ -429,30 +430,30 @@ lka_session_resolve_node(struct envelope *ep, struct expandnode *xn) } /* otherwise rewrite delivery user with expansion result */ - (void)strlcpy(ep->agent.mda.to.user, xn->u.user, - sizeof (ep->agent.mda.to.user)); - (void)strlcpy(ep->agent.mda.as_user, xn->u.user, - sizeof (ep->agent.mda.as_user)); + (void)strlcpy(ep->agent.mda.user, xn->u.user, + sizeof (ep->agent.mda.user)); return 0; case EXPAND_FILENAME: log_debug("lka_resolve_node: node is filename: %s", xn->u.buffer); ep->type = D_MDA; - ep->agent.mda.to = xn->u; ep->agent.mda.method = A_FILENAME; - (void)strlcpy(ep->agent.mda.as_user, xn->as_user, - sizeof (ep->agent.mda.as_user)); + (void)strlcpy(ep->agent.mda.buffer, xn->u.buffer, + sizeof (ep->agent.mda.buffer)); + (void)strlcpy(ep->agent.mda.user, xn->as_user, + sizeof (ep->agent.mda.user)); break; case EXPAND_FILTER: log_debug("lka_resolve_node: node is filter: %s", xn->u.buffer); ep->type = D_MDA; - ep->agent.mda.to = xn->u; ep->agent.mda.method = A_MDA; - (void)strlcpy(ep->agent.mda.as_user, xn->as_user, - sizeof (ep->agent.mda.as_user)); + (void)strlcpy(ep->agent.mda.buffer, xn->u.buffer, + sizeof (ep->agent.mda.buffer)); + (void)strlcpy(ep->agent.mda.user, xn->as_user, + sizeof (ep->agent.mda.user)); break; } @@ -480,7 +481,7 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep) bzero(&u, sizeof (u)); ub = user_backend_lookup(USER_PWD); - if (! ub->getbyname(&u, ep->agent.mda.as_user)) + if (! ub->getbyname(&u, ep->agent.mda.user)) return 0; lret = strlcat(pbuf, u.directory, len); @@ -531,7 +532,7 @@ lka_session_expand_format(char *buf, size_t len, struct envelope *ep) string = ep->sender.domain; break; case 'u': - string = ep->agent.mda.as_user; + string = ep->agent.mda.user; break; case 'a': string = ep->dest.user; diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index b949a54c2ec..ce6628feb3b 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.75 2012/09/21 12:33:32 eric Exp $ */ +/* $OpenBSD: mda.c,v 1.76 2012/09/26 19:52:20 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -97,9 +97,9 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg) switch (d_mda->method) { case A_MDA: deliver.mode = A_MDA; - strlcpy(deliver.user, d_mda->as_user, + strlcpy(deliver.user, d_mda->user, sizeof (deliver.user)); - strlcpy(deliver.to, d_mda->to.buffer, + strlcpy(deliver.to, d_mda->buffer, sizeof deliver.to); break; @@ -107,7 +107,7 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg) deliver.mode = A_MBOX; strlcpy(deliver.user, "root", sizeof (deliver.user)); - strlcpy(deliver.to, d_mda->to.user, + strlcpy(deliver.to, d_mda->user, sizeof (deliver.to)); snprintf(deliver.from, sizeof(deliver.from), "%s@%s", ep->sender.user, @@ -116,17 +116,17 @@ mda_imsg(struct imsgev *iev, struct imsg *imsg) case A_MAILDIR: deliver.mode = A_MAILDIR; - strlcpy(deliver.user, d_mda->as_user, + strlcpy(deliver.user, d_mda->user, sizeof deliver.user); - strlcpy(deliver.to, d_mda->to.buffer, + strlcpy(deliver.to, d_mda->buffer, sizeof deliver.to); break; case A_FILENAME: deliver.mode = A_FILENAME; - strlcpy(deliver.user, d_mda->as_user, + strlcpy(deliver.user, d_mda->user, sizeof deliver.user); - strlcpy(deliver.to, d_mda->to.buffer, + strlcpy(deliver.to, d_mda->buffer, sizeof deliver.to); break; diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 96e99cba981..390bf7b88c5 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.367 2012/09/25 17:38:55 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.368 2012/09/26 19:52:20 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -343,16 +343,10 @@ enum delivery_flags { DF_INTERNAL = 0x8 /* internal expansion forward */ }; -union delivery_data { - char user[MAXLOGNAME]; - char buffer[MAX_RULEBUFFER_LEN]; - struct mailaddr mailaddr; -}; - struct delivery_mda { enum action_type method; - union delivery_data to; - char as_user[MAXLOGNAME]; + char user[MAXLOGNAME]; + char buffer[MAX_RULEBUFFER_LEN]; }; struct delivery_mta { @@ -373,7 +367,11 @@ struct expandnode { int done; enum expand_type type; char as_user[MAXLOGNAME]; - union delivery_data u; + union { + char user[MAXLOGNAME]; + char buffer[MAX_RULEBUFFER_LEN]; + struct mailaddr mailaddr; + } u; }; struct expand { diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index ced5b0d80df..a7f8c08c083 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.83 2012/09/26 09:43:42 eric Exp $ */ +/* $OpenBSD: util.c,v 1.84 2012/09/26 19:52:20 eric Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -1057,7 +1057,7 @@ log_envelope(const struct envelope *evp, const char *extra, const char *status) else fatalx("log_envelope: bad method"); snprintf(tmp, sizeof tmp, "user=%s, method=%s, ", - evp->agent.mda.as_user, method); + evp->agent.mda.user, method); } if (extra == NULL) |