From 8619eace4c44f113d592afa401de8820a4f22600 Mon Sep 17 00:00:00 2001 From: Gilles Chehade Date: Sun, 19 May 2019 14:25:18 +0200 Subject: sync with OpenBSD 6.5 --- smtpd/lka_filter.c | 17 ++++++++++++----- smtpd/smtp_client.c | 8 ++++---- smtpd/smtp_session.c | 4 ++-- smtpd/smtpc.c | 11 +++++++++-- smtpd/smtpd.c | 9 ++++++--- smtpd/smtpd.h | 24 ++---------------------- 6 files changed, 35 insertions(+), 38 deletions(-) diff --git a/smtpd/lka_filter.c b/smtpd/lka_filter.c index a10d9cbe..94945955 100644 --- a/smtpd/lka_filter.c +++ b/smtpd/lka_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_filter.c,v 1.34 2019/01/15 04:49:50 sunil Exp $ */ +/* $OpenBSD: lka_filter.c,v 1.36 2019/05/02 11:39:45 martijn Exp $ */ /* * Copyright (c) 2018 Gilles Chehade @@ -421,6 +421,7 @@ lka_filter_process_response(const char *name, const char *line) /*char *phase = NULL;*/ char *response = NULL; char *parameter = NULL; + struct filter_session *fs; (void)strlcpy(buffer, line, sizeof buffer); if ((ep = strchr(buffer, '|')) == NULL) @@ -458,15 +459,21 @@ lka_filter_process_response(const char *name, const char *line) return 0; response = ep+1; - if ((ep = strchr(response, '|'))) { - parameter = ep + 1; - *ep = 0; - } + fs = tree_xget(&sessions, reqid); if (strcmp(kind, "filter-dataline") == 0) { + if (fs->phase != FILTER_DATA_LINE) + fatalx("misbehaving filter"); filter_data_next(token, reqid, response); return 1; } + if (fs->phase == FILTER_DATA_LINE) + fatalx("misbehaving filter"); + + if ((ep = strchr(response, '|'))) { + parameter = ep + 1; + *ep = 0; + } if (strcmp(response, "proceed") != 0 && strcmp(response, "reject") != 0 && diff --git a/smtpd/smtp_client.c b/smtpd/smtp_client.c index f2113af2..a6e70de5 100644 --- a/smtpd/smtp_client.c +++ b/smtpd/smtp_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_client.c,v 1.8 2018/09/20 11:42:28 eric Exp $ */ +/* $OpenBSD: smtp_client.c,v 1.9 2019/05/14 12:08:54 eric Exp $ */ /* * Copyright (c) 2018 Eric Faurot @@ -188,7 +188,7 @@ void smtp_quit(struct smtp_client *proto) { if (proto->state != STATE_READY) - fatalx("protoection is not ready"); + fatalx("connection is not ready"); smtp_client_state(proto, STATE_QUIT); } @@ -197,7 +197,7 @@ void smtp_sendmail(struct smtp_client *proto, struct smtp_mail *mail) { if (proto->state != STATE_READY) - fatalx("protoection is not ready"); + fatalx("connection is not ready"); proto->mail = mail; smtp_client_state(proto, STATE_MAIL); @@ -636,7 +636,7 @@ smtp_client_io(struct io *io, int evt, void *arg) case IO_TIMEOUT: errno = ETIMEDOUT; - smtp_client_abort(proto, FAIL_CONN, "protoection timeout"); + smtp_client_abort(proto, FAIL_CONN, "Connection timeout"); break; case IO_ERROR: diff --git a/smtpd/smtp_session.c b/smtpd/smtp_session.c index 1fc67d77..db86abdb 100644 --- a/smtpd/smtp_session.c +++ b/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.389 2019/02/20 11:56:27 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.390 2019/05/15 11:56:19 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -2685,7 +2685,7 @@ smtp_tx_filtered_dataline(struct smtp_tx *tx, const char *line) if (tx->error) return 0; } - io_printf(tx->filter, "%s\r\n", line ? line : "."); + io_printf(tx->filter, "%s\n", line ? line : "."); return line ? 0 : 1; } diff --git a/smtpd/smtpc.c b/smtpd/smtpc.c index d6bb2c83..2373aa76 100644 --- a/smtpd/smtpc.c +++ b/smtpd/smtpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpc.c,v 1.4 2018/09/20 11:42:28 eric Exp $ */ +/* $OpenBSD: smtpc.c,v 1.5 2019/05/15 05:02:43 eric Exp $ */ /* * Copyright (c) 2018 Eric Faurot @@ -283,8 +283,15 @@ parse_message(FILE *ifp) break; fatal("getline"); } + + if (len >= 2 && line[len - 2] == '\r' && line[len - 1] == '\n') + line[--len - 1] = '\n'; + if (fwrite(line, 1, len, mail.fp) != len) - fatal("frwite"); + fatal("fwrite"); + + if (line[len - 1] != '\n' && fputc('\n', mail.fp) == EOF) + fatal("fputc"); } fclose(ifp); diff --git a/smtpd/smtpd.c b/smtpd/smtpd.c index 66022264..acf0f657 100644 --- a/smtpd/smtpd.c +++ b/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.317 2019/01/30 21:31:48 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.318 2019/03/31 03:36:18 yasuoka Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -827,8 +827,11 @@ start_child(int save_argc, char **save_argv, char *rexec) return p; } - if (dup2(sp[0], 3) == -1) - fatal("%s: dup2", rexec); + if (sp[0] != 3) { + if (dup2(sp[0], 3) == -1) + fatal("%s: dup2", rexec); + } else if (fcntl(sp[0], F_SETFD, 0) == -1) + fatal("%s: fcntl", rexec); if (closefrom(4) == -1) fatal("%s: closefrom", rexec); diff --git a/smtpd/smtpd.h b/smtpd/smtpd.h index 10420526..46a4e6af 100644 --- a/smtpd/smtpd.h +++ b/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.619 2019/01/30 21:31:48 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.621 2019/04/08 08:22:32 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -51,7 +51,7 @@ #define SMTPD_QUEUE_EXPIRY (4 * 24 * 60 * 60) #define SMTPD_SOCKET "/var/run/smtpd.sock" #define SMTPD_NAME "OpenSMTPD" -#define SMTPD_VERSION "6.4.0" +#define SMTPD_VERSION "6.5.0" #define SMTPD_SESSION_TIMEOUT 300 #define SMTPD_BACKLOG 5 @@ -996,16 +996,6 @@ extern struct mproc *p_ca; extern struct smtpd *env; extern void (*imsg_callback)(struct mproc *, struct imsg *); -struct imsgproc { - pid_t pid; - struct event ev; - struct imsgbuf *ibuf; - char *path; - char *name; - void (*cb)(struct imsg *, void *); - void *cb_arg; -}; - /* inter-process structures */ struct bounce_req_msg { @@ -1313,16 +1303,6 @@ RB_PROTOTYPE(expandtree, expandnode, nodes, expand_cmp); int forwards_get(int, struct expand *); -/* imsgproc.c */ -void imsgproc_init(void); -struct imsgproc *imsgproc_fork(const char *, const char *, - void (*)(struct imsg *, void *), void *); -void imsgproc_set_read(struct imsgproc *); -void imsgproc_set_write(struct imsgproc *); -void imsgproc_set_read_write(struct imsgproc *); -void imsgproc_reset_callback(struct imsgproc *, void (*)(struct imsg *, void *), void *); - - /* limit.c */ void limit_mta_set_defaults(struct mta_limits *); int limit_mta_set(struct mta_limits *, const char*, int64_t); -- cgit v1.2.3-59-g8ed1b