diff options
Diffstat (limited to 'usr.sbin/smtpd')
34 files changed, 219 insertions, 189 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index ede483d8c21..352d00b44ff 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aliases.c,v 1.38 2010/11/24 11:09:43 gilles Exp $ */ +/* $OpenBSD: aliases.c,v 1.39 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,12 +26,14 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <util.h> #include "smtpd.h" +#include "log.h" int aliases_expand_include(struct expandtree *, char *); int alias_is_filter(struct expandnode *, char *, size_t); diff --git a/usr.sbin/smtpd/authenticate.c b/usr.sbin/smtpd/authenticate.c index f439dde8b87..712c49e968f 100644 --- a/usr.sbin/smtpd/authenticate.c +++ b/usr.sbin/smtpd/authenticate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: authenticate.c,v 1.1 2009/08/07 19:02:55 gilles Exp $ */ +/* $OpenBSD: authenticate.c,v 1.2 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -25,6 +25,7 @@ #include <bsd_auth.h> #include <err.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <signal.h> #include <stdio.h> diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index f863ec3a6f8..13c5dedc97c 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.23 2010/10/09 22:11:08 gilles Exp $ */ +/* $OpenBSD: bounce.c,v 1.24 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -25,6 +25,7 @@ #include <err.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -35,6 +36,7 @@ #include "smtpd.h" #include "client.h" +#include "log.h" struct client_ctx { struct event ev; @@ -43,8 +45,6 @@ struct client_ctx { struct smtpd *env; }; -void bounce_event(int, short, void *); - int bounce_session(struct smtpd *env, int fd, struct message *messagep) { diff --git a/usr.sbin/smtpd/client.c b/usr.sbin/smtpd/client.c index a9b1586cfef..0f256d48f67 100644 --- a/usr.sbin/smtpd/client.c +++ b/usr.sbin/smtpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.32 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: client.c,v 1.33 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -37,23 +37,7 @@ #include <openssl/ssl.h> #include "client.h" - -struct client_cmd *cmd_new(int, char *, ...); -void cmd_free(struct client_cmd *); -int client_read(struct smtp_client *); -void client_get_reply(struct smtp_client *, struct client_cmd *, - int *); -int client_write(struct smtp_client *); -int client_use_extensions(struct smtp_client *); -void client_status(struct smtp_client *, char *, ...); -int client_getln(struct smtp_client *, int); -void client_putln(struct smtp_client *, char *, ...); -struct ibuf *client_content_read(FILE *, size_t); -int client_poll(struct smtp_client *); -void client_quit(struct smtp_client *); - -int client_socket_read(struct smtp_client *); -int client_socket_write(struct smtp_client *); +#include "log.h" #ifndef CLIENT_NO_SSL int client_ssl_connect(struct smtp_client *); @@ -62,13 +46,6 @@ int ssl_buf_read(SSL *, struct ibuf_read *); int ssl_buf_write(SSL *, struct msgbuf *); #endif -char *buf_getln(struct ibuf_read *); -int buf_read(int, struct ibuf_read *); - -void log_debug(const char *, ...); /* XXX */ -void fatal(const char *); /* XXX */ -void fatalx(const char *); /* XXX */ - /* * Initialize SMTP session. */ diff --git a/usr.sbin/smtpd/client.h b/usr.sbin/smtpd/client.h index 1574fbd329e..c7ab300e027 100644 --- a/usr.sbin/smtpd/client.h +++ b/usr.sbin/smtpd/client.h @@ -1,4 +1,4 @@ -/* $OpenBSD: client.h,v 1.12 2010/05/26 13:56:08 nicm Exp $ */ +/* $OpenBSD: client.h,v 1.13 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Jacek Masiulaniec <jacekm@dobremiasto.net> @@ -114,3 +114,24 @@ void client_rcpt(struct smtp_client *, void *, char *, ...); void client_printf(struct smtp_client *, char *, ...); int client_talk(struct smtp_client *, int); void client_close(struct smtp_client *); + + +struct client_cmd *cmd_new(int, char *, ...); +void cmd_free(struct client_cmd *); +int client_read(struct smtp_client *); +void client_get_reply(struct smtp_client *, struct client_cmd *, + int *); +int client_write(struct smtp_client *); +int client_use_extensions(struct smtp_client *); +void client_status(struct smtp_client *, char *, ...); +int client_getln(struct smtp_client *, int); +void client_putln(struct smtp_client *, char *, ...); +struct ibuf *client_content_read(FILE *, size_t); +int client_poll(struct smtp_client *); +void client_quit(struct smtp_client *); + +int client_socket_read(struct smtp_client *); +int client_socket_write(struct smtp_client *); + +char *buf_getln(struct ibuf_read *); +int buf_read(int, struct ibuf_read *); diff --git a/usr.sbin/smtpd/config.c b/usr.sbin/smtpd/config.c index e216e157a4f..6f40c6927ca 100644 --- a/usr.sbin/smtpd/config.c +++ b/usr.sbin/smtpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.12 2010/05/27 15:36:04 gilles Exp $ */ +/* $OpenBSD: config.c,v 1.13 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -23,11 +23,13 @@ #include <sys/socket.h> #include <event.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "smtpd.h" +#include "log.h" int is_peer(struct peer *, enum smtp_proc_type, u_int); diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 9f377ee6bf2..fe716d6b40b 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.55 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: control.c,v 1.56 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -28,6 +28,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -36,6 +37,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" #define CONTROL_BACKLOG 5 diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index 323a83b056e..3ecea9b15be 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.23 2010/09/08 13:32:13 gilles Exp $ */ +/* $OpenBSD: dns.c,v 1.24 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -27,6 +27,7 @@ #include <arpa/nameser.h> #include <event.h> +#include <imsg.h> #include <netdb.h> #include <resolv.h> #include <signal.h> @@ -35,6 +36,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" struct resdata { struct imsgev iev; diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index f9887382d87..946cd8ac79f 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.39 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: enqueue.c,v 1.40 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2005 Henning Brauer <henning@bulabula.org> @@ -28,6 +28,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <netdb.h> #include <pwd.h> #include <signal.h> diff --git a/usr.sbin/smtpd/expand.c b/usr.sbin/smtpd/expand.c index 503fb58609d..c823842d167 100644 --- a/usr.sbin/smtpd/expand.c +++ b/usr.sbin/smtpd/expand.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expand.c,v 1.9 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: expand.c,v 1.10 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -26,11 +26,13 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "smtpd.h" +#include "log.h" struct expandnode * expandtree_lookup(struct expandtree *expandtree, struct expandnode *node) diff --git a/usr.sbin/smtpd/forward.c b/usr.sbin/smtpd/forward.c index cc34ab08f14..5fee75956b0 100644 --- a/usr.sbin/smtpd/forward.c +++ b/usr.sbin/smtpd/forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: forward.c,v 1.21 2010/04/27 09:49:23 gilles Exp $ */ +/* $OpenBSD: forward.c,v 1.22 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,6 +26,7 @@ #include <ctype.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -33,6 +34,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" int forwards_get(int fd, struct expandtree *expandtree) diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index c4849e775de..1751d2e0267 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.120 2010/10/29 09:16:07 gilles Exp $ */ +/* $OpenBSD: lka.c,v 1.121 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -30,6 +30,7 @@ #include <ctype.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <netdb.h> #include <pwd.h> #include <resolv.h> @@ -40,12 +41,11 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void lka_imsg(struct smtpd *, struct imsgev *, struct imsg *); __dead void lka_shutdown(void); void lka_sig_handler(int, short, void *); -void lka_setup_events(struct smtpd *); -void lka_disable_events(struct smtpd *); void lka_expand_pickup(struct smtpd *, struct lkasession *); int lka_expand_resume(struct smtpd *, struct lkasession *); int lka_resolve_node(struct smtpd *, char *tag, struct path *, struct expandnode *); @@ -282,16 +282,6 @@ lka_shutdown(void) _exit(0); } -void -lka_setup_events(struct smtpd *env) -{ -} - -void -lka_disable_events(struct smtpd *env) -{ -} - pid_t lka(struct smtpd *env) { @@ -353,7 +343,6 @@ lka(struct smtpd *env) config_pipes(env, peers, nitems(peers)); config_peers(env, peers, nitems(peers)); - lka_setup_events(env); if (event_dispatch() < 0) fatal("event_dispatch"); lka_shutdown(); diff --git a/usr.sbin/smtpd/log.c b/usr.sbin/smtpd/log.c index df030196682..4325890cdd3 100644 --- a/usr.sbin/smtpd/log.c +++ b/usr.sbin/smtpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.9 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: log.c,v 1.10 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -32,7 +32,7 @@ #include <syslog.h> #include <time.h> -#include "smtpd.h" +#include "log.h" int debug; int verbose; diff --git a/usr.sbin/smtpd/log.h b/usr.sbin/smtpd/log.h new file mode 100644 index 00000000000..f899b58d33e --- /dev/null +++ b/usr.sbin/smtpd/log.h @@ -0,0 +1,30 @@ +/* $OpenBSD: log.h,v 1.1 2010/11/28 13:56:43 gilles Exp $ */ + +/* + * Copyright (c) 2010 Gilles Chehade <gilles@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +void log_init(int); +void log_verbose(int); +void log_warn(const char *, ...) + __attribute__ ((format (printf, 1, 2))); +void log_warnx(const char *, ...) + __attribute__ ((format (printf, 1, 2))); +void log_info(const char *, ...) + __attribute__ ((format (printf, 1, 2))); +void log_debug(const char *, ...) + __attribute__ ((format (printf, 1, 2))); +__dead void fatal(const char *); +__dead void fatalx(const char *); diff --git a/usr.sbin/smtpd/makemap.c b/usr.sbin/smtpd/makemap.c index 18677dc06cd..a04ef06fa51 100644 --- a/usr.sbin/smtpd/makemap.c +++ b/usr.sbin/smtpd/makemap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makemap.c,v 1.26 2010/04/27 09:49:23 gilles Exp $ */ +/* $OpenBSD: makemap.c,v 1.27 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -30,6 +30,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -37,6 +38,7 @@ #include <util.h> #include "smtpd.h" +#include "log.h" #define PATH_ALIASES "/etc/mail/aliases" diff --git a/usr.sbin/smtpd/map.c b/usr.sbin/smtpd/map.c index 30bc42f09a2..90efa0d10bc 100644 --- a/usr.sbin/smtpd/map.c +++ b/usr.sbin/smtpd/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.20 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: map.c,v 1.21 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -28,11 +28,13 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "smtpd.h" +#include "log.h" struct map_backend *map_backend_lookup(enum map_src); struct map_parser *map_parser_lookup(enum map_kind); diff --git a/usr.sbin/smtpd/map_backend.c b/usr.sbin/smtpd/map_backend.c index f3efd1adcbc..150a215c576 100644 --- a/usr.sbin/smtpd/map_backend.c +++ b/usr.sbin/smtpd/map_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map_backend.c,v 1.2 2010/04/27 10:17:53 gilles Exp $ */ +/* $OpenBSD: map_backend.c,v 1.3 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2010 Gilles Chehade <gilles@openbsd.org> @@ -28,12 +28,13 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "smtpd.h" - +#include "log.h" struct map_backend *map_backend_lookup(enum map_src); diff --git a/usr.sbin/smtpd/map_parser.c b/usr.sbin/smtpd/map_parser.c index 6ad702b6d0e..9c00c2fdf1c 100644 --- a/usr.sbin/smtpd/map_parser.c +++ b/usr.sbin/smtpd/map_parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map_parser.c,v 1.3 2010/04/27 09:49:23 gilles Exp $ */ +/* $OpenBSD: map_parser.c,v 1.4 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2010 Gilles Chehade <gilles@openbsd.org> @@ -28,11 +28,13 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "smtpd.h" +#include "log.h" struct map_parser *map_parser_lookup(enum map_kind); diff --git a/usr.sbin/smtpd/mda.c b/usr.sbin/smtpd/mda.c index ba9e543d46e..2823f2e9cef 100644 --- a/usr.sbin/smtpd/mda.c +++ b/usr.sbin/smtpd/mda.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mda.c,v 1.49 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: mda.c,v 1.50 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,6 +26,7 @@ #include <errno.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -36,12 +37,11 @@ #include <vis.h> #include "smtpd.h" +#include "log.h" void mda_imsg(struct smtpd *, struct imsgev *, struct imsg *); __dead void mda_shutdown(void); void mda_sig_handler(int, short, void *); -void mda_setup_events(struct smtpd *); -void mda_disable_events(struct smtpd *); void mda_store(struct mda_session *); void mda_store_event(int, short, void *); struct mda_session *mda_lookup(struct smtpd *, u_int32_t); @@ -265,16 +265,6 @@ mda_shutdown(void) _exit(0); } -void -mda_setup_events(struct smtpd *env) -{ -} - -void -mda_disable_events(struct smtpd *env) -{ -} - pid_t mda(struct smtpd *env) { @@ -330,7 +320,6 @@ mda(struct smtpd *env) config_pipes(env, peers, nitems(peers)); config_peers(env, peers, nitems(peers)); - mda_setup_events(env); if (event_dispatch() < 0) fatal("event_dispatch"); mda_shutdown(); diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c index 9daa14d7ece..8c7409b19e7 100644 --- a/usr.sbin/smtpd/mfa.c +++ b/usr.sbin/smtpd/mfa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mfa.c,v 1.52 2010/10/29 09:16:07 gilles Exp $ */ +/* $OpenBSD: mfa.c,v 1.53 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -25,6 +25,7 @@ #include <ctype.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -33,20 +34,15 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void mfa_imsg(struct smtpd *, struct imsgev *, struct imsg *); __dead void mfa_shutdown(void); void mfa_sig_handler(int, short, void *); -void mfa_setup_events(struct smtpd *); -void mfa_disable_events(struct smtpd *); - void mfa_test_mail(struct smtpd *, struct message *); void mfa_test_rcpt(struct smtpd *, struct message *); void mfa_test_rcpt_resume(struct smtpd *, struct submit_status *); - -int strip_source_route(char *, size_t); - -struct rule *ruleset_match(struct smtpd *, struct path *, struct sockaddr_storage *); +int mfa_strip_source_route(char *, size_t); void mfa_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg) @@ -109,15 +105,6 @@ mfa_shutdown(void) _exit(0); } -void -mfa_setup_events(struct smtpd *env) -{ -} - -void -mfa_disable_events(struct smtpd *env) -{ -} pid_t mfa(struct smtpd *env) @@ -174,7 +161,6 @@ mfa(struct smtpd *env) config_pipes(env, peers, nitems(peers)); config_peers(env, peers, nitems(peers)); - mfa_setup_events(env); if (event_dispatch() < 0) fatal("event_dispatch"); mfa_shutdown(); @@ -182,20 +168,6 @@ mfa(struct smtpd *env) return (0); } -int -msg_cmp(struct message *m1, struct message *m2) -{ - /* - * do not return u_int64_t's - */ - if (m1->id - m2->id > 0) - return (1); - else if (m1->id - m2->id < 0) - return (-1); - else - return (0); -} - void mfa_test_mail(struct smtpd *env, struct message *m) { @@ -205,7 +177,7 @@ mfa_test_mail(struct smtpd *env, struct message *m) ss.code = 530; ss.u.path = m->sender; - if (strip_source_route(ss.u.path.user, sizeof(ss.u.path.user))) + if (mfa_strip_source_route(ss.u.path.user, sizeof(ss.u.path.user))) goto refuse; if (! valid_localpart(ss.u.path.user) || @@ -247,7 +219,7 @@ mfa_test_rcpt(struct smtpd *env, struct message *m) ss.msg.recipient = m->session_rcpt; ss.flags = m->flags; - strip_source_route(ss.u.path.user, sizeof(ss.u.path.user)); + mfa_strip_source_route(ss.u.path.user, sizeof(ss.u.path.user)); if (! valid_localpart(ss.u.path.user) || ! valid_domainpart(ss.u.path.domain)) @@ -280,7 +252,7 @@ mfa_test_rcpt_resume(struct smtpd *env, struct submit_status *ss) { } int -strip_source_route(char *buf, size_t len) +mfa_strip_source_route(char *buf, size_t len) { char *p; diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index 58248b8a73a..43754f609c9 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.94 2010/10/29 09:16:07 gilles Exp $ */ +/* $OpenBSD: mta.c,v 1.95 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -29,6 +29,7 @@ #include <errno.h> #include <event.h> +#include <imsg.h> #include <netdb.h> #include <pwd.h> #include <signal.h> @@ -40,6 +41,7 @@ #include "smtpd.h" #include "client.h" +#include "log.h" void mta_imsg(struct smtpd *, struct imsgev *, struct imsg *); diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 38ce43c1716..4021c83f2f1 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.70 2010/10/29 09:16:08 gilles Exp $ */ +/* $OpenBSD: parse.y,v 1.71 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -37,6 +37,7 @@ #include <errno.h> #include <event.h> #include <ifaddrs.h> +#include <imsg.h> #include <limits.h> #include <paths.h> #include <pwd.h> @@ -50,6 +51,7 @@ #include <util.h> #include "smtpd.h" +#include "log.h" TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); static struct file { diff --git a/usr.sbin/smtpd/parser.c b/usr.sbin/smtpd/parser.c index 03e759d0e5f..dddc43a303d 100644 --- a/usr.sbin/smtpd/parser.c +++ b/usr.sbin/smtpd/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.16 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: parser.c,v 1.17 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -30,6 +30,7 @@ #include <err.h> #include <errno.h> +#include <imsg.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 6d774e85bd9..34058eb2102 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.91 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: queue.c,v 1.92 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,6 +26,7 @@ #include <errno.h> #include <event.h> +#include <imsg.h> #include <fcntl.h> #include <libgen.h> #include <pwd.h> @@ -36,6 +37,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void queue_imsg(struct smtpd *, struct imsgev *, struct imsg *); void queue_pass_to_runner(struct smtpd *, struct imsgev *, struct imsg *); diff --git a/usr.sbin/smtpd/queue_shared.c b/usr.sbin/smtpd/queue_shared.c index afc9e6c021d..7c600da5e07 100644 --- a/usr.sbin/smtpd/queue_shared.c +++ b/usr.sbin/smtpd/queue_shared.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_shared.c,v 1.33 2010/11/15 14:57:40 jsing Exp $ */ +/* $OpenBSD: queue_shared.c,v 1.34 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -29,6 +29,7 @@ #include <err.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <fcntl.h> #include <pwd.h> #include <stdio.h> @@ -38,6 +39,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" #define QWALK_AGAIN 0x1 #define QWALK_RECURSE 0x2 diff --git a/usr.sbin/smtpd/ruleset.c b/usr.sbin/smtpd/ruleset.c index 823aeda252b..c32b4b8e104 100644 --- a/usr.sbin/smtpd/ruleset.c +++ b/usr.sbin/smtpd/ruleset.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ruleset.c,v 1.13 2010/05/27 15:36:04 gilles Exp $ */ +/* $OpenBSD: ruleset.c,v 1.14 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org> @@ -28,12 +28,14 @@ #include <db.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "smtpd.h" +#include "log.h" struct rule *ruleset_match(struct smtpd *, char *tag, struct path *, struct sockaddr_storage *); int ruleset_check_source(struct map *, struct sockaddr_storage *); diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 4d08e7d56eb..aa6e44b0a51 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.93 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: runner.c,v 1.94 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -34,6 +34,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <libgen.h> #include <netdb.h> #include <pwd.h> @@ -45,6 +46,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void runner_imsg(struct smtpd *, struct imsgev *, struct imsg *); diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index daefbf478bc..b9503600516 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.77 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: smtp.c,v 1.78 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -30,6 +30,7 @@ #include <ctype.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <netdb.h> #include <pwd.h> #include <signal.h> @@ -40,6 +41,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void smtp_imsg(struct smtpd *, struct imsgev *, struct imsg *); __dead void smtp_shutdown(void); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 1d2ce5ef787..795892a600b 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.136 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.137 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -32,6 +32,7 @@ #include <ctype.h> #include <errno.h> #include <event.h> +#include <imsg.h> #include <pwd.h> #include <regex.h> #include <resolv.h> @@ -41,6 +42,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" int session_rfc5321_helo_handler(struct session *, char *); int session_rfc5321_ehlo_handler(struct session *, char *); diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 01a533196eb..f628542e49e 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.53 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.54 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -34,6 +34,7 @@ #include <err.h> #include <errno.h> +#include <imsg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 34d4f399d9b..835f0da64d4 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.113 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.114 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -32,6 +32,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <login_cap.h> #include <paths.h> #include <pwd.h> @@ -45,6 +46,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" void parent_imsg(struct smtpd *, struct imsgev *, struct imsg *); __dead void usage(void); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 2adc20d2ac1..60d05c998bb 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.198 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: smtpd.h,v 1.199 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -17,8 +17,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <imsg.h> - #ifndef nitems #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #endif @@ -29,6 +27,8 @@ } while (0) #define IMSG_DATA_SIZE(imsg) ((imsg)->hdr.len - IMSG_HEADER_SIZE) + + #define CONF_FILE "/etc/mail/smtpd.conf" #define MAX_LISTEN 16 #define PROC_COUNT 9 @@ -852,9 +852,10 @@ struct map_virtual { }; - extern void (*imsg_callback)(struct smtpd *, struct imsgev *, struct imsg *); + + /* aliases.c */ int aliases_exist(struct smtpd *, objid_t, char *); int aliases_get(struct smtpd *, objid_t, struct expandtree *, char *); @@ -863,36 +864,52 @@ int aliases_virtual_exist(struct smtpd *, objid_t, struct path *); int aliases_virtual_get(struct smtpd *, objid_t, struct expandtree *, struct path *); int alias_parse(struct expandnode *, char *); + /* authenticate.c */ int authenticate_user(char *, char *); + /* bounce.c */ int bounce_session(struct smtpd *, int, struct message *); int bounce_session_switch(struct smtpd *, FILE *, enum session_state *, char *, struct message *); +void bounce_event(int, short, void *); + + +/* config.c */ +#define PURGE_LISTENERS 0x01 +#define PURGE_MAPS 0x02 +#define PURGE_RULES 0x04 +#define PURGE_SSL 0x08 +#define PURGE_EVERYTHING 0xff +void purge_config(struct smtpd *, u_int8_t); +void unconfigure(struct smtpd *); +void configure(struct smtpd *); +void init_pipes(struct smtpd *); +void config_pipes(struct smtpd *, struct peer *, u_int); +void config_peers(struct smtpd *, struct peer *, u_int); -/* log.c */ -void log_init(int); -void log_verbose(int); -void log_warn(const char *, ...) - __attribute__ ((format (printf, 1, 2))); -void log_warnx(const char *, ...) - __attribute__ ((format (printf, 1, 2))); -void log_info(const char *, ...) - __attribute__ ((format (printf, 1, 2))); -void log_debug(const char *, ...) - __attribute__ ((format (printf, 1, 2))); -__dead void fatal(const char *); -__dead void fatalx(const char *); + +/* control.c */ +pid_t control(struct smtpd *); +void session_socket_blockmode(int, enum blockmodes); +void session_socket_no_linger(int); +int session_socket_error(int); /* dns.c */ void dns_query_a(struct smtpd *, char *, int, u_int64_t); void dns_query_mx(struct smtpd *, char *, int, u_int64_t); void dns_query_ptr(struct smtpd *, struct sockaddr_storage *, - u_int64_t); -void dns_async(struct smtpd *, struct imsgev *, int, - struct dns *); + u_int64_t); +void dns_async(struct smtpd *, struct imsgev *, int, struct dns *); + + +/* enqueue.c */ +int enqueue(int, char **); +int enqueue_offline(int, char **); + + /* expand.c */ int expand_cmp(struct expandnode *, struct expandnode *); void expandtree_increment_node(struct expandtree *, struct expandnode *); @@ -902,25 +919,42 @@ struct expandnode *expandtree_lookup(struct expandtree *, struct expandnode *); void expandtree_free_nodes(struct expandtree *); RB_PROTOTYPE(expandtree, expandnode, nodes, expand_cmp); + /* forward.c */ int forwards_get(int, struct expandtree *); -/* smtpd.c */ -int child_cmp(struct child *, struct child *); -SPLAY_PROTOTYPE(childtree, child, entry, child_cmp); -void imsg_event_add(struct imsgev *); -void imsg_compose_event(struct imsgev *, u_int16_t, u_int32_t, pid_t, - int, void *, u_int16_t); -void imsg_dispatch(int, short, void *); /* lka.c */ pid_t lka(struct smtpd *); int lkasession_cmp(struct lkasession *, struct lkasession *); SPLAY_PROTOTYPE(lkatree, lkasession, nodes, lkasession_cmp); + +/* map.c */ +void *map_lookup(struct smtpd *, objid_t, char *, enum map_kind); +struct map *map_find(struct smtpd *, objid_t); +struct map *map_findbyname(struct smtpd *, const char *); + + + +/* mda.c */ +pid_t mda(struct smtpd *); + + /* mfa.c */ -pid_t mfa(struct smtpd *); -int msg_cmp(struct message *, struct message *); +pid_t mfa(struct smtpd *); + + +/* mta.c */ +pid_t mta(struct smtpd *); +int mta_session_cmp(struct mta_session *, struct mta_session *); +SPLAY_PROTOTYPE(mtatree, mta_session, entry, mta_session_cmp); + + +/* parse.y */ +int parse_config(struct smtpd *, const char *, int); +int cmdline_symset(char *); + /* queue.c */ pid_t queue(struct smtpd *); @@ -933,6 +967,7 @@ int batch_cmp(struct batch *, struct batch *); struct batch *batch_by_id(struct smtpd *, u_int64_t); u_int16_t queue_hash(char *); + /* queue_shared.c */ int queue_create_layout_message(char *, char *); void queue_delete_layout_message(char *, char *); @@ -965,39 +1000,20 @@ struct qwalk *qwalk_new(char *); int qwalk(struct qwalk *, char *); void qwalk_close(struct qwalk *); void show_queue(char *, int); +u_int16_t queue_hash(char *); -u_int16_t queue_hash(char *); - -/* map.c */ -void *map_lookup(struct smtpd *, objid_t, char *, enum map_kind); - -/* mda.c */ -pid_t mda(struct smtpd *); - -/* mta.c */ -pid_t mta(struct smtpd *); -int mta_session_cmp(struct mta_session *, struct mta_session *); -SPLAY_PROTOTYPE(mtatree, mta_session, entry, mta_session_cmp); - -/* control.c */ -pid_t control(struct smtpd *); -void session_socket_blockmode(int, enum blockmodes); -void session_socket_no_linger(int); -int session_socket_error(int); - -/* enqueue.c */ -int enqueue(int, char **); -int enqueue_offline(int, char **); /* runner.c */ pid_t runner(struct smtpd *); void message_reset_flags(struct message *); SPLAY_PROTOTYPE(batchtree, batch, b_nodes, batch_cmp); + /* smtp.c */ pid_t smtp(struct smtpd *); void smtp_resume(struct smtpd *); + /* smtp_session.c */ void session_init(struct listener *, struct session *); int session_cmp(struct session *, struct session *); @@ -1009,22 +1025,15 @@ void session_bufferevent_new(struct session *); SPLAY_PROTOTYPE(sessiontree, session, s_nodes, session_cmp); -/* config.c */ -#define PURGE_LISTENERS 0x01 -#define PURGE_MAPS 0x02 -#define PURGE_RULES 0x04 -#define PURGE_SSL 0x08 -#define PURGE_EVERYTHING 0xff -void purge_config(struct smtpd *, u_int8_t); -void unconfigure(struct smtpd *); -void configure(struct smtpd *); -void init_pipes(struct smtpd *); -void config_pipes(struct smtpd *, struct peer *, u_int); -void config_peers(struct smtpd *, struct peer *, u_int); -/* parse.y */ -int parse_config(struct smtpd *, const char *, int); -int cmdline_symset(char *); +/* smtpd.c */ +int child_cmp(struct child *, struct child *); +SPLAY_PROTOTYPE(childtree, child, entry, child_cmp); +void imsg_event_add(struct imsgev *); +void imsg_compose_event(struct imsgev *, u_int16_t, u_int32_t, pid_t, + int, void *, u_int16_t); +void imsg_dispatch(int, short, void *); + /* ssl.c */ void ssl_init(void); @@ -1037,13 +1046,11 @@ void ssl_setup(struct smtpd *, struct listener *); int ssl_cmp(struct ssl *, struct ssl *); SPLAY_PROTOTYPE(ssltree, ssl, ssl_nodes, ssl_cmp); + /* ssl_privsep.c */ int ssl_ctx_use_private_key(void *, char *, off_t); int ssl_ctx_use_certificate_chain(void *, char *, off_t); -/* map.c */ -struct map *map_find(struct smtpd *, objid_t); -struct map *map_findbyname(struct smtpd *, const char *); /* util.c */ typedef struct arglist arglist; diff --git a/usr.sbin/smtpd/ssl.c b/usr.sbin/smtpd/ssl.c index b5242a99ee7..d4c05574fb9 100644 --- a/usr.sbin/smtpd/ssl.c +++ b/usr.sbin/smtpd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.30 2010/11/24 23:27:04 todd Exp $ */ +/* $OpenBSD: ssl.c,v 1.31 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -27,6 +27,7 @@ #include <ctype.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> @@ -38,6 +39,7 @@ #include <openssl/err.h> #include "smtpd.h" +#include "log.h" #define SSL_CIPHERS "HIGH" diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index e28e1d8ab6c..1021848f1b5 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.36 2010/10/09 22:05:35 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.37 2010/11/28 13:56:43 gilles Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -31,6 +31,7 @@ #include <errno.h> #include <event.h> #include <fcntl.h> +#include <imsg.h> #include <libgen.h> #include <netdb.h> #include <pwd.h> @@ -42,6 +43,7 @@ #include <unistd.h> #include "smtpd.h" +#include "log.h" int bsnprintf(char *str, size_t size, const char *format, ...) |