-/* $OpenBSD: control.c,v 1.130 2023/05/31 16:51:46 op Exp $ */
+/* $OpenBSD: control.c,v 1.131 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@poolp.org>
c = tree_get(&ctl_conns, imsg->hdr.peerid);
if (c == NULL)
return;
- m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg->fd, NULL, 0);
+ m_compose(&c->mproc, IMSG_CTL_OK, 0, 0, imsg_get_fd(imsg),
+ NULL, 0);
return;
case IMSG_STAT_INCREMENT:
-/* $OpenBSD: enqueue.c,v 1.121 2023/05/31 16:51:46 op Exp $ */
+/* $OpenBSD: enqueue.c,v 1.122 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2005 Henning Brauer <henning@bulabula.org>
errx(1, "unexpected imsg reply type");
}
- fd = imsg.fd;
+ fd = imsg_get_fd(&imsg);
imsg_free(&imsg);
break;
-/* $OpenBSD: lka.c,v 1.247 2021/06/14 17:58:15 eric Exp $ */
+/* $OpenBSD: lka.c,v 1.248 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
lka_imsg(struct mproc *p, struct imsg *imsg)
{
struct table *table;
- int ret;
+ int ret, fd;
struct sockaddr_storage ss;
struct userinfo userinfo;
struct addrname addrname;
return;
case IMSG_LKA_OPEN_FORWARD:
- lka_session_forward_reply(imsg->data, imsg->fd);
+ lka_session_forward_reply(imsg->data, imsg_get_fd(imsg));
return;
case IMSG_LKA_AUTHENTICATE:
m_add_string(p, procname);
m_close(p);
- lka_proc_forked(procname, subsystems, imsg->fd);
+ lka_proc_forked(procname, subsystems, imsg_get_fd(imsg));
return;
case IMSG_LKA_PROCESSOR_ERRFD:
m_get_string(&m, &procname);
m_end(&m);
- lka_proc_errfd(procname, imsg->fd);
- shutdown(imsg->fd, SHUT_WR);
+ fd = imsg_get_fd(imsg);
+ lka_proc_errfd(procname, fd);
+ shutdown(fd, SHUT_WR);
return;
case IMSG_REPORT_SMTP_LINK_CONNECT:
-/* $OpenBSD: mda.c,v 1.146 2023/05/31 16:51:46 op Exp $ */
+/* $OpenBSD: mda.c,v 1.147 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
uint64_t reqid;
size_t sz;
char out[256], buf[LINE_MAX];
- int n;
+ int n, fd;
enum lka_resp_status status;
enum mda_resp_status mda_status;
int mda_sysexit;
s = tree_xget(&sessions, reqid);
e = s->evp;
- if (imsg->fd == -1) {
+ fd = imsg_get_fd(imsg);
+ if (fd == -1) {
log_debug("debug: mda: cannot get message fd");
mda_queue_tempfail(e->id,
"Cannot get message fd",
log_debug("debug: mda: got message fd %d "
"for session %016"PRIx64 " evpid %016"PRIx64,
- imsg->fd, s->id, e->id);
+ fd, s->id, e->id);
- if ((s->datafp = fdopen(imsg->fd, "r")) == NULL) {
+ if ((s->datafp = fdopen(fd, "r")) == NULL) {
log_warn("warn: mda: fdopen");
- close(imsg->fd);
+ close(fd);
mda_queue_tempfail(e->id, "fdopen failed",
ESC_OTHER_MAIL_SYSTEM_STATUS);
mda_log(e, "TempFail", "fdopen failed");
s = tree_xget(&sessions, reqid);
e = s->evp;
- if (imsg->fd == -1) {
+ fd = imsg_get_fd(imsg);
+ if (fd == -1) {
log_warn("warn: mda: fail to retrieve mda fd");
mda_queue_tempfail(e->id, "Cannot get mda fd",
ESC_OTHER_MAIL_SYSTEM_STATUS);
log_debug("debug: mda: got mda fd %d "
"for session %016"PRIx64 " evpid %016"PRIx64,
- imsg->fd, s->id, s->evp->id);
+ fd, s->id, s->evp->id);
- io_set_nonblocking(imsg->fd);
- io_set_fd(s->io, imsg->fd);
+ io_set_nonblocking(fd);
+ io_set_fd(s->io, fd);
io_set_write(s->io);
return;
* Grab last line of mda stdout/stderr if available.
*/
out[0] = '\0';
- if (imsg->fd != -1)
- mda_getlastline(imsg->fd, out, sizeof(out));
+ fd = imsg_get_fd(imsg);
+ if (fd != -1)
+ mda_getlastline(fd, out, sizeof(out));
/*
* Choose between parent's description of error and
-/* $OpenBSD: mproc.c,v 1.39 2021/06/14 17:58:15 eric Exp $ */
+/* $OpenBSD: mproc.c,v 1.40 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@faurot.net>
m_forward(struct mproc *p, struct imsg *imsg)
{
imsg_compose(&p->imsgbuf, imsg->hdr.type, imsg->hdr.peerid,
- imsg->hdr.pid, imsg->fd, imsg->data,
+ imsg->hdr.pid, imsg_get_fd(imsg), imsg->data,
imsg->hdr.len - sizeof(imsg->hdr));
if (imsg->hdr.type != IMSG_STAT_DECREMENT &&
-/* $OpenBSD: mta_session.c,v 1.150 2024/01/03 08:11:15 op Exp $ */
+/* $OpenBSD: mta_session.c,v 1.151 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
struct msg m;
uint64_t reqid;
const char *name;
- int status;
+ int status, fd;
struct stat sb;
switch (imsg->hdr.type) {
m_get_id(&m, &reqid);
m_end(&m);
+ fd = imsg_get_fd(imsg);
s = mta_tree_pop(&wait_fd, reqid);
if (s == NULL) {
- if (imsg->fd != -1)
- close(imsg->fd);
+ if (fd != -1)
+ close(fd);
return;
}
- if (imsg->fd == -1) {
+ if (fd == -1) {
log_debug("debug: mta: failed to obtain msg fd");
mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL,
"Could not get message fd", 0, 0);
}
if ((s->ext & MTA_EXT_SIZE) && s->ext_size != 0) {
- if (fstat(imsg->fd, &sb) == -1) {
+ if (fstat(fd, &sb) == -1) {
log_debug("debug: mta: failed to stat msg fd");
mta_flush_task(s, IMSG_MTA_DELIVERY_TEMPFAIL,
"Could not stat message fd", 0, 0);
mta_enter_state(s, MTA_READY);
- close(imsg->fd);
+ close(fd);
return;
}
if (sb.st_size > (off_t)s->ext_size) {
mta_flush_task(s, IMSG_MTA_DELIVERY_PERMFAIL,
"message too large for peer", 0, 0);
mta_enter_state(s, MTA_READY);
- close(imsg->fd);
+ close(fd);
return;
}
}
- s->datafp = fdopen(imsg->fd, "r");
+ s->datafp = fdopen(fd, "r");
if (s->datafp == NULL)
fatal("mta: fdopen");
-/* $OpenBSD: queue.c,v 1.195 2023/05/31 16:51:46 op Exp $ */
+/* $OpenBSD: queue.c,v 1.196 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
return;
case IMSG_QUEUE_SMTP_SESSION:
- bounce_fd(imsg->fd);
+ bounce_fd(imsg_get_fd(imsg));
return;
case IMSG_LKA_ENVELOPE_SUBMIT:
-/* $OpenBSD: queue_proc.c,v 1.9 2021/06/14 17:58:16 eric Exp $ */
+/* $OpenBSD: queue_proc.c,v 1.10 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
queue_proc_call();
queue_proc_end();
- return (imsg.fd);
+ return (imsg_get_fd(&imsg));
}
static int
-/* $OpenBSD: smtp_session.c,v 1.439 2024/01/03 08:11:15 op Exp $ */
+/* $OpenBSD: smtp_session.c,v 1.440 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
const char *line, *helo;
uint64_t reqid, evpid;
uint32_t msgid;
- int status, success;
+ int status, success, fd;
int filter_response;
const char *filter_param;
uint8_t i;
m_get_int(&m, &success);
m_end(&m);
+ fd = imsg_get_fd(imsg);
s = tree_xpop(&wait_queue_fd, reqid);
- if (!success || imsg->fd == -1) {
- if (imsg->fd != -1)
- close(imsg->fd);
+ if (!success || fd == -1) {
+ if (fd != -1)
+ close(fd);
smtp_reply(s, "421 %s Temporary Error",
esc_code(ESC_STATUS_TEMPFAIL, ESC_OTHER_MAIL_SYSTEM_STATUS));
smtp_enter_state(s, STATE_QUIT);
return;
}
- log_debug("smtp: %p: fd %d from queue", s, imsg->fd);
+ log_debug("smtp: %p: fd %d from queue", s, fd);
- if (smtp_message_fd(s->tx, imsg->fd)) {
+ if (smtp_message_fd(s->tx, fd)) {
if (!SESSION_DATA_FILTERED(s))
smtp_message_begin(s->tx);
else
m_get_int(&m, &success);
m_end(&m);
+ fd = imsg_get_fd(imsg);
s = tree_xpop(&wait_filter_fd, reqid);
- if (!success || imsg->fd == -1) {
- if (imsg->fd != -1)
- close(imsg->fd);
+ if (!success || fd == -1) {
+ if (fd != -1)
+ close(fd);
smtp_reply(s, "421 %s Temporary Error",
esc_code(ESC_STATUS_TEMPFAIL, ESC_OTHER_MAIL_SYSTEM_STATUS));
smtp_enter_state(s, STATE_QUIT);
return;
}
- log_debug("smtp: %p: fd %d from lka", s, imsg->fd);
+ log_debug("smtp: %p: fd %d from lka", s, fd);
- smtp_filter_fd(s->tx, imsg->fd);
+ smtp_filter_fd(s->tx, fd);
smtp_message_begin(s->tx);
return;
-/* $OpenBSD: smtpd.c,v 1.346 2023/06/18 17:28:42 op Exp $ */
+/* $OpenBSD: smtpd.c,v 1.347 2024/01/20 09:01:03 claudio Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
env->sc_queue_key = strdup(imsg.data);
break;
case IMSG_SETUP_PEER:
- setup_peer(imsg.hdr.peerid, imsg.hdr.pid, imsg.fd);
+ setup_peer(imsg.hdr.peerid, imsg.hdr.pid,
+ imsg_get_fd(&imsg));
break;
case IMSG_SETUP_DONE:
setup = 0;
if (to == PROC_CONTROL && imsg->hdr.type == IMSG_STAT_SET)
return;
- if (imsg->fd != -1)
- log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu, fd=%d)",
- proc_name(to),
- proc_name(from),
- imsg_to_str(imsg->hdr.type),
- imsg->hdr.len - IMSG_HEADER_SIZE,
- imsg->fd);
- else
- log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu)",
- proc_name(to),
- proc_name(from),
- imsg_to_str(imsg->hdr.type),
- imsg->hdr.len - IMSG_HEADER_SIZE);
+ log_trace(TRACE_IMSG, "imsg: %s <- %s: %s (len=%zu)",
+ proc_name(to),
+ proc_name(from),
+ imsg_to_str(imsg->hdr.type),
+ imsg->hdr.len - IMSG_HEADER_SIZE);
}
const char *