summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-01-17 08:22:41 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-01-17 08:22:41 +0000
commit8d2a45bcfdc45825ab5c23377b32873c9142426c (patch)
treea5355189d8d3210deab4b76db3bff183c5a05a6a
parent7e70dbd2dce1bea7e381fb50d5c01c465c27a635 (diff)
Convert to use imsg_get_fd() since proc_forward_imsg() never forwards a
file descriptor just use -1 there. OK tb@
-rw-r--r--usr.sbin/httpd/config.c17
-rw-r--r--usr.sbin/httpd/logger.c6
-rw-r--r--usr.sbin/httpd/proc.c6
3 files changed, 16 insertions, 13 deletions
diff --git a/usr.sbin/httpd/config.c b/usr.sbin/httpd/config.c
index e8c5cd5b6be..b4a8e734d61 100644
--- a/usr.sbin/httpd/config.c
+++ b/usr.sbin/httpd/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.64 2024/01/17 08:20:58 claudio Exp $ */
+/* $OpenBSD: config.c,v 1.65 2024/01/17 08:22:40 claudio Exp $ */
/*
* Copyright (c) 2011 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -626,6 +626,7 @@ config_getserver(struct httpd *env, struct imsg *imsg)
struct server_config srv_conf;
uint8_t *p = imsg->data;
size_t s;
+ int fd;
IMSG_SIZE_CHECK(imsg, &srv_conf);
memcpy(&srv_conf, p, sizeof(srv_conf));
@@ -634,6 +635,8 @@ config_getserver(struct httpd *env, struct imsg *imsg)
/* Reset these variables to avoid free'ing invalid pointers */
serverconfig_reset(&srv_conf);
+ fd = imsg_get_fd(imsg);
+
if ((IMSG_DATA_SIZE(imsg) - s) < (size_t)srv_conf.return_uri_len) {
log_debug("%s: invalid message length", __func__);
goto fail;
@@ -643,11 +646,11 @@ config_getserver(struct httpd *env, struct imsg *imsg)
if ((srv = server_byaddr((struct sockaddr *)
&srv_conf.ss, srv_conf.port)) != NULL) {
/* Add "host" to existing listening server */
- if (imsg->fd != -1) {
+ if (fd != -1) {
if (srv->srv_s == -1)
- srv->srv_s = imsg->fd;
+ srv->srv_s = fd;
else
- close(imsg->fd);
+ close(fd);
}
return (config_getserver_config(env, srv, imsg));
}
@@ -660,7 +663,7 @@ config_getserver(struct httpd *env, struct imsg *imsg)
goto fail;
memcpy(&srv->srv_conf, &srv_conf, sizeof(srv->srv_conf));
- srv->srv_s = imsg->fd;
+ srv->srv_s = fd;
if (config_getserver_auth(env, &srv->srv_conf) != 0)
goto fail;
@@ -688,8 +691,8 @@ config_getserver(struct httpd *env, struct imsg *imsg)
return (0);
fail:
- if (imsg->fd != -1)
- close(imsg->fd);
+ if (fd != -1)
+ close(fd);
if (srv != NULL)
serverconfig_free(&srv->srv_conf);
free(srv);
diff --git a/usr.sbin/httpd/logger.c b/usr.sbin/httpd/logger.c
index 9c62485e022..31f441011ab 100644
--- a/usr.sbin/httpd/logger.c
+++ b/usr.sbin/httpd/logger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logger.c,v 1.24 2021/01/27 07:21:53 deraadt Exp $ */
+/* $OpenBSD: logger.c,v 1.25 2024/01/17 08:22:40 claudio Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -144,9 +144,9 @@ logger_open_fd(struct imsg *imsg)
TAILQ_FOREACH(log, &log_files, log_entry) {
if (log->log_id == id) {
+ log->log_fd = imsg_get_fd(imsg);
DPRINTF("%s: received log fd %d, file %s",
- __func__, imsg->fd, log->log_name);
- log->log_fd = imsg->fd;
+ __func__, log->log_fd, log->log_name);
return (0);
}
}
diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c
index 71bb3c287db..e8b08dd2317 100644
--- a/usr.sbin/httpd/proc.c
+++ b/usr.sbin/httpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.42 2023/02/15 20:44:01 tobhe Exp $ */
+/* $OpenBSD: proc.c,v 1.43 2024/01/17 08:22:40 claudio Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -668,7 +668,7 @@ proc_dispatch(int fd, short event, void *arg)
case IMSG_CTL_PROCFD:
IMSG_SIZE_CHECK(&imsg, &pf);
memcpy(&pf, imsg.data, sizeof(pf));
- proc_accept(ps, imsg.fd, pf.pf_procid,
+ proc_accept(ps, imsg_get_fd(&imsg), pf.pf_procid,
pf.pf_instance);
break;
default:
@@ -799,7 +799,7 @@ proc_forward_imsg(struct privsep *ps, struct imsg *imsg,
enum privsep_procid id, int n)
{
return (proc_compose_imsg(ps, id, n, imsg->hdr.type,
- imsg->hdr.peerid, imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg)));
+ imsg->hdr.peerid, -1, imsg->data, IMSG_DATA_SIZE(imsg)));
}
struct imsgbuf *