Commit f826addf6c9cb9f000276eda59137f01fe9a037e

Stefan Sperling 2020-03-18T16:13:45

use a dedicated imsg for sending the pack fetch output file descriptor

diff --git a/lib/fetch.c b/lib/fetch.c
index 0a0cc26..db72516 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -419,7 +419,7 @@ got_fetch_pack(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
 	if (err != NULL)
 		goto done;
 	nfetchfd = -1;
-	err = got_privsep_send_tmpfd(&fetchibuf, npackfd);
+	err = got_privsep_send_fetch_outfd(&fetchibuf, npackfd);
 	if (err != NULL)
 		goto done;
 	npackfd = dup(packfd);
diff --git a/lib/got_lib_privsep.h b/lib/got_lib_privsep.h
index 0e76d54..060d60c 100644
--- a/lib/got_lib_privsep.h
+++ b/lib/got_lib_privsep.h
@@ -110,6 +110,7 @@ enum got_imsg_type {
 
 	/* Messages related to networking. */
 	GOT_IMSG_FETCH_REQUEST,
+	GOT_IMSG_FETCH_OUTFD,
 	GOT_IMSG_FETCH_SYMREFS,
 	GOT_IMSG_FETCH_REF,
 	GOT_IMSG_FETCH_SERVER_PROGRESS,
@@ -387,6 +388,7 @@ const struct got_error *got_privsep_recv_index_progress(int *, int *, int *,
     int *, int *, struct imsgbuf *ibuf);
 const struct got_error *got_privsep_send_fetch_req(struct imsgbuf *, int,
     struct got_pathlist_head *);
+const struct got_error *got_privsep_send_fetch_outfd(struct imsgbuf *, int);
 const struct got_error *got_privsep_send_fetch_symrefs(struct imsgbuf *,
     struct got_pathlist_head *);
 const struct got_error *got_privsep_send_fetch_ref(struct imsgbuf *,
diff --git a/lib/privsep.c b/lib/privsep.c
index 938c697..d271eda 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -477,6 +477,13 @@ got_privsep_send_fetch_req(struct imsgbuf *ibuf, int fd,
 }
 
 const struct got_error *
+got_privsep_send_fetch_outfd(struct imsgbuf *ibuf, int fd)
+{
+	return send_fd(ibuf, GOT_IMSG_FETCH_OUTFD, fd);
+}
+
+
+const struct got_error *
 got_privsep_send_fetch_symrefs(struct imsgbuf *ibuf,
     struct got_pathlist_head *symrefs)
 {
diff --git a/libexec/got-fetch-pack/got-fetch-pack.c b/libexec/got-fetch-pack/got-fetch-pack.c
index 913393e..d86b89f 100644
--- a/libexec/got-fetch-pack/got-fetch-pack.c
+++ b/libexec/got-fetch-pack/got-fetch-pack.c
@@ -793,7 +793,7 @@ main(int argc, char **argv)
 	}
 	if (imsg.hdr.type == GOT_IMSG_STOP)
 		goto done;
-	if (imsg.hdr.type != GOT_IMSG_TMPFD) {
+	if (imsg.hdr.type != GOT_IMSG_FETCH_OUTFD) {
 		err = got_error(GOT_ERR_PRIVSEP_MSG);
 		goto done;
 	}