Commit Diff


commit - 678ade17323ba52d28ca9b2b58dfe8a232958363
commit + e70bf110de343a3c1fc422b6682f56853686772f
blob - dcfb30c7f3aef64701b8fae8369a9a04ded29115
blob + b6668b257a2454bd0f92457ae8cd5ccb9069e2a9
--- lib/got_lib_privsep.h
+++ lib/got_lib_privsep.h
@@ -383,6 +383,7 @@ struct got_pathlist_head;
 
 const struct got_error *got_send_ack(pid_t);
 const struct got_error *got_privsep_wait_for_child(pid_t);
+const struct got_error *got_privsep_flush_imsg(struct imsgbuf *);
 const struct got_error *got_privsep_send_stop(int);
 const struct got_error *got_privsep_recv_imsg(struct imsg *, struct imsgbuf *,
     size_t);
@@ -406,28 +407,15 @@ const struct got_error *got_privsep_send_index_pack_re
     uint8_t *, int);
 const struct got_error *got_privsep_send_index_pack_outfd(struct imsgbuf *,
     int);
-const struct got_error *got_privsep_send_index_pack_progress(struct imsgbuf *,
-    int, int, int, int);
-const struct got_error *got_privsep_send_index_pack_done(struct imsgbuf *);
 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 *, int, struct got_pathlist_head *,
     struct got_pathlist_head *, int, int);
 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 *,
-    struct got_object_id *, const char *);
-const struct got_error *got_privsep_send_fetch_server_progress(struct imsgbuf *,
-    const char *, size_t);
-const struct got_error *got_privsep_send_fetch_download_progress(struct imsgbuf *,
-    off_t);
 const struct got_error *got_privsep_recv_fetch_progress(int *,
     struct got_object_id **, char **, struct got_pathlist_head *,
     char **, off_t *, struct imsgbuf *);
-const struct got_error *got_privsep_send_fetch_done(struct imsgbuf *,
-    struct got_object_id);
 const struct got_error *got_privsep_get_imsg_obj(struct got_object **,
     struct imsg *, struct imsgbuf *);
 const struct got_error *got_privsep_recv_obj(struct got_object **,
@@ -465,14 +453,9 @@ const struct got_error *got_privsep_send_gitconfig_aut
 const struct got_error *got_privsep_send_gitconfig_remotes_req(
     struct imsgbuf *);
 const struct got_error *got_privsep_send_gitconfig_owner_req(struct imsgbuf *);
-const struct got_error *got_privsep_send_gitconfig_str(struct imsgbuf *,
-    const char *);
 const struct got_error *got_privsep_recv_gitconfig_str(char **,
     struct imsgbuf *);
-const struct got_error *got_privsep_send_gitconfig_int(struct imsgbuf *, int);
 const struct got_error *got_privsep_recv_gitconfig_int(int *, struct imsgbuf *);
-const struct got_error *got_privsep_send_gitconfig_remotes(struct imsgbuf *,
-    struct got_remote_repo *, int);
 const struct got_error *got_privsep_recv_gitconfig_remotes(
     struct got_remote_repo **, int *, struct imsgbuf *);
 
@@ -481,9 +464,5 @@ const struct got_error *got_privsep_send_commit_traver
 const struct got_error *got_privsep_recv_traversed_commits(
     struct got_commit_object **, struct got_object_id **,
     struct got_object_id_queue *, struct imsgbuf *);
-const struct got_error *got_privsep_send_traversed_commits(
-    struct got_object_id *, size_t, struct imsgbuf *);
-const struct got_error *got_privsep_send_commit_traversal_done(
-    struct imsgbuf *);
 
 void got_privsep_exec_child(int[2], const char *, const char *);
blob - 3e7631e45cb6f10d8c034f2706fc258bd7aeea54
blob + 8fcc4cad0241a7f7715f2d045fcb4a7b0cf2bb7d
--- lib/privsep.c
+++ lib/privsep.c
@@ -216,6 +216,12 @@ flush_imsg(struct imsgbuf *ibuf)
 }
 
 const struct got_error *
+got_privsep_flush_imsg(struct imsgbuf *ibuf)
+{
+	return flush_imsg(ibuf);
+}
+
+const struct got_error *
 got_privsep_send_stop(int fd)
 {
 	const struct got_error *err = NULL;
@@ -557,147 +563,9 @@ 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)
-{
-	const struct got_error *err = NULL;
-	struct ibuf *wbuf;
-	size_t len, nsymrefs = 0;
-	struct got_pathlist_entry *pe;
-
-	len = sizeof(struct got_imsg_fetch_symrefs);
-	TAILQ_FOREACH(pe, symrefs, entry) {
-		const char *target = pe->data;
-		len += sizeof(struct got_imsg_fetch_symref) +
-		    pe->path_len + strlen(target);
-		nsymrefs++;
-	}
-
-	if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
-		return got_error(GOT_ERR_NO_SPACE);
-
-	wbuf = imsg_create(ibuf, GOT_IMSG_FETCH_SYMREFS, 0, 0, len);
-	if (wbuf == NULL)
-		return got_error_from_errno("imsg_create FETCH_SYMREFS");
-
-	/* Keep in sync with struct got_imsg_fetch_symrefs definition! */
-	if (imsg_add(wbuf, &nsymrefs, sizeof(nsymrefs)) == -1) {
-		err = got_error_from_errno("imsg_add FETCH_SYMREFS");
-		ibuf_free(wbuf);
-		return err;
-	}
-
-	TAILQ_FOREACH(pe, symrefs, entry) {
-		const char *name = pe->path;
-		size_t name_len = pe->path_len;
-		const char *target = pe->data;
-		size_t target_len = strlen(target);
-
-		/* Keep in sync with struct got_imsg_fetch_symref definition! */
-		if (imsg_add(wbuf, &name_len, sizeof(name_len)) == -1) {
-			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
-			ibuf_free(wbuf);
-			return err;
-		}
-		if (imsg_add(wbuf, &target_len, sizeof(target_len)) == -1) {
-			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
-			ibuf_free(wbuf);
-			return err;
-		}
-		if (imsg_add(wbuf, name, name_len) == -1) {
-			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
-			ibuf_free(wbuf);
-			return err;
-		}
-		if (imsg_add(wbuf, target, target_len) == -1) {
-			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
-			ibuf_free(wbuf);
-			return err;
-		}
-	}
-
-	wbuf->fd = -1;
-	imsg_close(ibuf, wbuf);
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_send_fetch_ref(struct imsgbuf *ibuf,
-    struct got_object_id *refid, const char *refname)
-{
-	const struct got_error *err = NULL;
-	struct ibuf *wbuf;
-	size_t len, reflen = strlen(refname);
-
-	len = sizeof(struct got_imsg_fetch_ref) + reflen;
-	if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
-		return got_error(GOT_ERR_NO_SPACE);
-
-	wbuf = imsg_create(ibuf, GOT_IMSG_FETCH_REF, 0, 0, len);
-	if (wbuf == NULL)
-		return got_error_from_errno("imsg_create FETCH_REF");
-
-	/* Keep in sync with struct got_imsg_fetch_ref definition! */
-	if (imsg_add(wbuf, refid->sha1, SHA1_DIGEST_LENGTH) == -1) {
-		err = got_error_from_errno("imsg_add FETCH_REF");
-		ibuf_free(wbuf);
-		return err;
-	}
-	if (imsg_add(wbuf, refname, reflen) == -1) {
-		err = got_error_from_errno("imsg_add FETCH_REF");
-		ibuf_free(wbuf);
-		return err;
-	}
-
-	wbuf->fd = -1;
-	imsg_close(ibuf, wbuf);
-	return flush_imsg(ibuf);
 }
 
 const struct got_error *
-got_privsep_send_fetch_server_progress(struct imsgbuf *ibuf, const char *msg,
-    size_t msglen)
-{
-	if (msglen > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
-		return got_error(GOT_ERR_NO_SPACE);
-
-	if (msglen == 0)
-		return NULL;
-
-	if (imsg_compose(ibuf, GOT_IMSG_FETCH_SERVER_PROGRESS, 0, 0, -1,
-	    msg, msglen) == -1)
-		return got_error_from_errno(
-		    "imsg_compose FETCH_SERVER_PROGRESS");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_send_fetch_download_progress(struct imsgbuf *ibuf, off_t bytes)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_FETCH_DOWNLOAD_PROGRESS, 0, 0, -1,
-	    &bytes, sizeof(bytes)) == -1)
-		return got_error_from_errno(
-		    "imsg_compose FETCH_DOWNLOAD_PROGRESS");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_send_fetch_done(struct imsgbuf *ibuf, struct got_object_id hash)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_FETCH_DONE, 0, 0, -1,
-	    hash.sha1, SHA1_DIGEST_LENGTH) == -1)
-		return got_error_from_errno("imsg_compose FETCH");
-	return flush_imsg(ibuf);
-}
-
-
-const struct got_error *
 got_privsep_recv_fetch_progress(int *done, struct got_object_id **id,
     char **refname, struct got_pathlist_head *symrefs, char **server_progress,
     off_t *packfile_size, struct imsgbuf *ibuf)
@@ -879,32 +747,6 @@ got_privsep_send_index_pack_outfd(struct imsgbuf *ibuf
 }
 
 const struct got_error *
-got_privsep_send_index_pack_progress(struct imsgbuf *ibuf, int nobj_total,
-    int nobj_indexed, int nobj_loose, int nobj_resolved)
-{
-	struct got_imsg_index_pack_progress iprogress;
-
-	iprogress.nobj_total = nobj_total;
-	iprogress.nobj_indexed = nobj_indexed;
-	iprogress.nobj_loose = nobj_loose;
-	iprogress.nobj_resolved = nobj_resolved;
-
-	if (imsg_compose(ibuf, GOT_IMSG_IDXPACK_PROGRESS, 0, 0, -1,
-	    &iprogress, sizeof(iprogress)) == -1)
-		return got_error_from_errno("imsg_compose IDXPACK_PROGRESS");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_send_index_pack_done(struct imsgbuf *ibuf)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_IDXPACK_DONE, 0, 0, -1, NULL, 0) == -1)
-		return got_error_from_errno("imsg_compose FETCH");
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
 got_privsep_recv_index_progress(int *done, int *nobj_total,
     int *nobj_indexed, int *nobj_loose, int *nobj_resolved,
     struct imsgbuf *ibuf)
@@ -1872,18 +1714,6 @@ got_privsep_send_gitconfig_owner_req(struct imsgbuf *i
 }
 
 const struct got_error *
-got_privsep_send_gitconfig_str(struct imsgbuf *ibuf, const char *value)
-{
-	size_t len = value ? strlen(value) + 1 : 0;
-
-	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_STR_VAL, 0, 0, -1,
-	    value, len) == -1)
-		return got_error_from_errno("imsg_compose GITCONFIG_STR_VAL");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
 got_privsep_recv_gitconfig_str(char **str, struct imsgbuf *ibuf)
 {
 	const struct got_error *err = NULL;
@@ -1920,16 +1750,6 @@ got_privsep_recv_gitconfig_str(char **str, struct imsg
 }
 
 const struct got_error *
-got_privsep_send_gitconfig_int(struct imsgbuf *ibuf, int value)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_INT_VAL, 0, 0, -1,
-	    &value, sizeof(value)) == -1)
-		return got_error_from_errno("imsg_compose GITCONFIG_INT_VAL");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
 got_privsep_recv_gitconfig_int(int *val, struct imsgbuf *ibuf)
 {
 	const struct got_error *err = NULL;
@@ -1960,70 +1780,6 @@ got_privsep_recv_gitconfig_int(int *val, struct imsgbu
 
 	imsg_free(&imsg);
 	return err;
-}
-
-const struct got_error *
-got_privsep_send_gitconfig_remotes(struct imsgbuf *ibuf,
-    struct got_remote_repo *remotes, int nremotes)
-{
-	const struct got_error *err = NULL;
-	struct got_imsg_remotes iremotes;
-	int i;
-
-	iremotes.nremotes = nremotes;
-	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_REMOTES, 0, 0, -1,
-	    &iremotes, sizeof(iremotes)) == -1)
-		return got_error_from_errno("imsg_compose GITCONFIG_REMOTES");
-
-	err = flush_imsg(ibuf);
-	imsg_clear(ibuf);
-	if (err)
-		return err;
-
-	for (i = 0; i < nremotes; i++) {
-		struct got_imsg_remote iremote;
-		size_t len = sizeof(iremote);
-		struct ibuf *wbuf;
-
-		iremote.mirror_references = remotes[i].mirror_references;
-		iremote.name_len = strlen(remotes[i].name);
-		len += iremote.name_len;
-		iremote.url_len = strlen(remotes[i].url);
-		len += iremote.url_len;
-
-		wbuf = imsg_create(ibuf, GOT_IMSG_GITCONFIG_REMOTE, 0, 0, len);
-		if (wbuf == NULL)
-			return got_error_from_errno(
-			    "imsg_create GITCONFIG_REMOTE");
-
-		if (imsg_add(wbuf, &iremote, sizeof(iremote)) == -1) {
-			err = got_error_from_errno(
-			    "imsg_add GITCONFIG_REMOTE");
-			ibuf_free(wbuf);
-			return err;
-		}
-
-		if (imsg_add(wbuf, remotes[i].name, iremote.name_len) == -1) {
-			err = got_error_from_errno(
-			    "imsg_add GITCONFIG_REMOTE");
-			ibuf_free(wbuf);
-			return err;
-		}
-		if (imsg_add(wbuf, remotes[i].url, iremote.url_len) == -1) {
-			err = got_error_from_errno(
-			    "imsg_add GITCONFIG_REMOTE");
-			ibuf_free(wbuf);
-			return err;
-		}
-
-		wbuf->fd = -1;
-		imsg_close(ibuf, wbuf);
-		err = flush_imsg(ibuf);
-		if (err)
-			return err;
-	}
-
-	return NULL;
 }
 
 const struct got_error *
@@ -2154,44 +1910,9 @@ got_privsep_send_commit_traversal_request(struct imsgb
 	}
 	if (imsg_add(wbuf, path, path_len) == -1) {
 		err = got_error_from_errno("imsg_add COMMIT_TRAVERSAL_REQUEST");
-		ibuf_free(wbuf);
-		return err;
-	}
-
-	wbuf->fd = -1;
-	imsg_close(ibuf, wbuf);
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
-got_privsep_send_traversed_commits(struct got_object_id *commit_ids, 
-    size_t ncommits, struct imsgbuf *ibuf)
-{
-	const struct got_error *err;
-	struct ibuf *wbuf;
-	int i;
-
-	wbuf = imsg_create(ibuf, GOT_IMSG_TRAVERSED_COMMITS, 0, 0,
-	    sizeof(struct got_imsg_traversed_commits) +
-	    ncommits * SHA1_DIGEST_LENGTH);
-	if (wbuf == NULL)
-		return got_error_from_errno("imsg_create TRAVERSED_COMMITS");
-
-	if (imsg_add(wbuf, &ncommits, sizeof(ncommits)) == -1) {
-		err = got_error_from_errno("imsg_add TRAVERSED_COMMITS");
 		ibuf_free(wbuf);
 		return err;
 	}
-	for (i = 0; i < ncommits; i++) {
-		struct got_object_id *id = &commit_ids[i];
-		if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
-			err = got_error_from_errno(
-			    "imsg_add TRAVERSED_COMMITS");
-			ibuf_free(wbuf);
-			return err;
-		}
-	}
 
 	wbuf->fd = -1;
 	imsg_close(ibuf, wbuf);
@@ -2276,16 +1997,6 @@ got_privsep_recv_traversed_commits(struct got_commit_o
 }
 
 const struct got_error *
-got_privsep_send_commit_traversal_done(struct imsgbuf *ibuf)
-{
-	if (imsg_compose(ibuf, GOT_IMSG_COMMIT_TRAVERSAL_DONE, 0, 0, -1,
-	    NULL, 0) == -1)
-		return got_error_from_errno("imsg_compose TRAVERSAL_DONE");
-
-	return flush_imsg(ibuf);
-}
-
-const struct got_error *
 got_privsep_unveil_exec_helpers(void)
 {
 	const char *helpers[] = {
blob - 8bedceae325de82abd4bbef6715118687872c598
blob + fe49bfbdb846dbdf93b1ea61211e91911f5ee571
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
@@ -467,9 +467,48 @@ match_capabilities(char **my_capabilities, struct got_
 			err = got_error_from_errno("strdup");
 	}
 	return err;
+}
+
+static const struct got_error *
+send_fetch_server_progress(struct imsgbuf *ibuf, const char *msg, size_t msglen)
+{
+	if (msglen > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
+		return got_error(GOT_ERR_NO_SPACE);
+
+	if (msglen == 0)
+		return NULL;
+
+	if (imsg_compose(ibuf, GOT_IMSG_FETCH_SERVER_PROGRESS, 0, 0, -1,
+	    msg, msglen) == -1)
+		return got_error_from_errno(
+		    "imsg_compose FETCH_SERVER_PROGRESS");
+
+	return got_privsep_flush_imsg(ibuf);
 }
 
 static const struct got_error *
+send_fetch_download_progress(struct imsgbuf *ibuf, off_t bytes)
+{
+	if (imsg_compose(ibuf, GOT_IMSG_FETCH_DOWNLOAD_PROGRESS, 0, 0, -1,
+	    &bytes, sizeof(bytes)) == -1)
+		return got_error_from_errno(
+		    "imsg_compose FETCH_DOWNLOAD_PROGRESS");
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
+send_fetch_done(struct imsgbuf *ibuf, struct got_object_id hash)
+{
+	if (imsg_compose(ibuf, GOT_IMSG_FETCH_DONE, 0, 0, -1,
+	    hash.sha1, SHA1_DIGEST_LENGTH) == -1)
+		return got_error_from_errno("imsg_compose FETCH");
+	return got_privsep_flush_imsg(ibuf);
+}
+
+
+
+static const struct got_error *
 fetch_progress(struct imsgbuf *ibuf, const char *buf, size_t len)
 {
 	int i;
@@ -493,7 +532,7 @@ fetch_progress(struct imsgbuf *ibuf, const char *buf, 
 		    "non-printable progress message received from server");
 	}
 
-	return got_privsep_send_fetch_server_progress(ibuf, buf, len);
+	return send_fetch_server_progress(ibuf, buf, len);
 }
 
 static const struct got_error *
@@ -513,6 +552,104 @@ fetch_error(const char *buf, size_t len)
 }
 
 static const struct got_error *
+send_fetch_symrefs(struct imsgbuf *ibuf, struct got_pathlist_head *symrefs)
+{
+	const struct got_error *err = NULL;
+	struct ibuf *wbuf;
+	size_t len, nsymrefs = 0;
+	struct got_pathlist_entry *pe;
+
+	len = sizeof(struct got_imsg_fetch_symrefs);
+	TAILQ_FOREACH(pe, symrefs, entry) {
+		const char *target = pe->data;
+		len += sizeof(struct got_imsg_fetch_symref) +
+		    pe->path_len + strlen(target);
+		nsymrefs++;
+	}
+
+	if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
+		return got_error(GOT_ERR_NO_SPACE);
+
+	wbuf = imsg_create(ibuf, GOT_IMSG_FETCH_SYMREFS, 0, 0, len);
+	if (wbuf == NULL)
+		return got_error_from_errno("imsg_create FETCH_SYMREFS");
+
+	/* Keep in sync with struct got_imsg_fetch_symrefs definition! */
+	if (imsg_add(wbuf, &nsymrefs, sizeof(nsymrefs)) == -1) {
+		err = got_error_from_errno("imsg_add FETCH_SYMREFS");
+		ibuf_free(wbuf);
+		return err;
+	}
+
+	TAILQ_FOREACH(pe, symrefs, entry) {
+		const char *name = pe->path;
+		size_t name_len = pe->path_len;
+		const char *target = pe->data;
+		size_t target_len = strlen(target);
+
+		/* Keep in sync with struct got_imsg_fetch_symref definition! */
+		if (imsg_add(wbuf, &name_len, sizeof(name_len)) == -1) {
+			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
+			ibuf_free(wbuf);
+			return err;
+		}
+		if (imsg_add(wbuf, &target_len, sizeof(target_len)) == -1) {
+			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
+			ibuf_free(wbuf);
+			return err;
+		}
+		if (imsg_add(wbuf, name, name_len) == -1) {
+			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
+			ibuf_free(wbuf);
+			return err;
+		}
+		if (imsg_add(wbuf, target, target_len) == -1) {
+			err = got_error_from_errno("imsg_add FETCH_SYMREFS");
+			ibuf_free(wbuf);
+			return err;
+		}
+	}
+
+	wbuf->fd = -1;
+	imsg_close(ibuf, wbuf);
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
+send_fetch_ref(struct imsgbuf *ibuf, struct got_object_id *refid,
+    const char *refname)
+{
+	const struct got_error *err = NULL;
+	struct ibuf *wbuf;
+	size_t len, reflen = strlen(refname);
+
+	len = sizeof(struct got_imsg_fetch_ref) + reflen;
+	if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
+		return got_error(GOT_ERR_NO_SPACE);
+
+	wbuf = imsg_create(ibuf, GOT_IMSG_FETCH_REF, 0, 0, len);
+	if (wbuf == NULL)
+		return got_error_from_errno("imsg_create FETCH_REF");
+
+	/* Keep in sync with struct got_imsg_fetch_ref definition! */
+	if (imsg_add(wbuf, refid->sha1, SHA1_DIGEST_LENGTH) == -1) {
+		err = got_error_from_errno("imsg_add FETCH_REF");
+		ibuf_free(wbuf);
+		return err;
+	}
+	if (imsg_add(wbuf, refname, reflen) == -1) {
+		err = got_error_from_errno("imsg_add FETCH_REF");
+		ibuf_free(wbuf);
+		return err;
+	}
+
+	wbuf->fd = -1;
+	imsg_close(ibuf, wbuf);
+	return got_privsep_flush_imsg(ibuf);
+}
+
+
+static const struct got_error *
 fetch_pack(int fd, int packfd, struct got_object_id *packid,
     struct got_pathlist_head *have_refs, int fetch_all_branches,
     struct got_pathlist_head *wanted_branches,
@@ -569,7 +706,7 @@ fetch_pack(int fd, int packfd, struct got_object_id *p
 			if (chattygot)
 				fprintf(stderr, "%s: my capabilities:%s\n",
 				    getprogname(), my_capabilities);
-			err = got_privsep_send_fetch_symrefs(ibuf, &symrefs);
+			err = send_fetch_symrefs(ibuf, &symrefs);
 			if (err)
 				goto done;
 			is_firstpkt = 0;
@@ -663,8 +800,7 @@ fetch_pack(int fd, int packfd, struct got_object_id *p
 			goto done;
 		}
 		match_remote_ref(have_refs, &have[nref], refname);
-		err = got_privsep_send_fetch_ref(ibuf, &want[nref],
-		    refname);
+		err = send_fetch_ref(ibuf, &want[nref], refname);
 		if (err)
 			goto done;
 
@@ -878,14 +1014,13 @@ fetch_pack(int fd, int packfd, struct got_object_id *p
 
 		/* Don't send too many progress privsep messages. */
 		if (packsz > last_reported_packsz + 1024) {
-			err = got_privsep_send_fetch_download_progress(ibuf,
-			    packsz);
+			err = send_fetch_download_progress(ibuf, packsz);
 			if (err)
 				goto done;
 			last_reported_packsz = packsz;
 		}
 	}
-	err = got_privsep_send_fetch_download_progress(ibuf, packsz);
+	err = send_fetch_download_progress(ibuf, packsz);
 	if (err)
 		goto done;
 done:
@@ -1130,7 +1265,7 @@ done:
 	if (err != NULL)
 		got_privsep_send_error(&ibuf, err);
 	else
-		err = got_privsep_send_fetch_done(&ibuf, packid);
+		err = send_fetch_done(&ibuf, packid);
 	if (err != NULL) {
 		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
 		got_privsep_send_error(&ibuf, err);
blob - e2ac91ea26b2772a6a81c2d5fb5b7c950157677d
blob + bfc9107d2db18c2536c48ab9fad45c73b2153910
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
@@ -569,8 +569,35 @@ update_packidx(struct got_packidx *packidx, int nobj,
 	    sizeof(uint32_t) * (nindexed - idx));
 
 	add_indexed_object(packidx, idx, obj);
+}
+
+static const struct got_error *
+send_index_pack_progress(struct imsgbuf *ibuf, int nobj_total,
+    int nobj_indexed, int nobj_loose, int nobj_resolved)
+{
+	struct got_imsg_index_pack_progress iprogress;
+
+	iprogress.nobj_total = nobj_total;
+	iprogress.nobj_indexed = nobj_indexed;
+	iprogress.nobj_loose = nobj_loose;
+	iprogress.nobj_resolved = nobj_resolved;
+
+	if (imsg_compose(ibuf, GOT_IMSG_IDXPACK_PROGRESS, 0, 0, -1,
+	    &iprogress, sizeof(iprogress)) == -1)
+		return got_error_from_errno("imsg_compose IDXPACK_PROGRESS");
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
+send_index_pack_done(struct imsgbuf *ibuf)
+{
+	if (imsg_compose(ibuf, GOT_IMSG_IDXPACK_DONE, 0, 0, -1, NULL, 0) == -1)
+		return got_error_from_errno("imsg_compose FETCH");
+	return got_privsep_flush_imsg(ibuf);
 }
 
+
 static const struct got_error *
 index_pack(struct got_pack *pack, int idxfd, FILE *tmpfile,
     FILE *delta_base_file, FILE *delta_accum_file, uint8_t *pack_hash,
@@ -684,8 +711,8 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp
 		/* Don't send too many progress privsep messages. */
 		p_indexed = ((i + 1) * 100) / nobj;
 		if (p_indexed != last_p_indexed) {
-			err = got_privsep_send_index_pack_progress(ibuf,
-			    nobj, i + 1, nloose, 0);
+			err = send_index_pack_progress(ibuf, nobj, i + 1,
+			    nloose, 0);
 			if (err)
 				goto done;
 			last_p_indexed = p_indexed;
@@ -791,8 +818,8 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp
 			/* Don't send too many progress privsep messages. */
 			p_resolved = ((nresolved + n) * 100) / nobj;
 			if (p_resolved != last_p_resolved) {
-				err = got_privsep_send_index_pack_progress(ibuf,
-				    nobj, nobj, nloose, nresolved + n);
+				err = send_index_pack_progress(ibuf, nobj,
+				    nobj, nloose, nresolved + n);
 				if (err)
 					goto done;
 				last_p_resolved = p_resolved;
@@ -819,8 +846,7 @@ index_pack(struct got_pack *pack, int idxfd, FILE *tmp
 		goto done;
 	}
 
-	err = got_privsep_send_index_pack_progress(ibuf, nobj, nobj,
-	    nloose, nresolved);
+	err = send_index_pack_progress(ibuf, nobj, nobj, nloose, nresolved);
 	if (err)
 		goto done;
 
@@ -1012,7 +1038,7 @@ done:
 	}
 
 	if (err == NULL)
-		err = got_privsep_send_index_pack_done(&ibuf);
+		err = send_index_pack_done(&ibuf);
 	if (err) {
 		got_privsep_send_error(&ibuf, err);
 		fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
blob - 6f203d17788fd8772211527b029238c7be2d3e99
blob + 4685960f41cf29909f661344f0aa7dd6f83457c8
--- libexec/got-read-gitconfig/got-read-gitconfig.c
+++ libexec/got-read-gitconfig/got-read-gitconfig.c
@@ -48,6 +48,16 @@ catch_sigint(int signo)
 }
 
 static const struct got_error *
+send_gitconfig_int(struct imsgbuf *ibuf, int value)
+{
+	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_INT_VAL, 0, 0, -1,
+	    &value, sizeof(value)) == -1)
+		return got_error_from_errno("imsg_compose GITCONFIG_INT_VAL");
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
 gitconfig_num_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig,
     char *section, char *tag, int def)
 {
@@ -57,10 +67,22 @@ gitconfig_num_request(struct imsgbuf *ibuf, struct got
 		return got_error(GOT_ERR_PRIVSEP_MSG);
 
 	value = got_gitconfig_get_num(gitconfig, section, tag, def);
-	return got_privsep_send_gitconfig_int(ibuf, value);
+	return send_gitconfig_int(ibuf, value);
 }
 
 static const struct got_error *
+send_gitconfig_str(struct imsgbuf *ibuf, const char *value)
+{
+	size_t len = value ? strlen(value) + 1 : 0;
+
+	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_STR_VAL, 0, 0, -1,
+	    value, len) == -1)
+		return got_error_from_errno("imsg_compose GITCONFIG_STR_VAL");
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
 gitconfig_str_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig,
     char *section, char *tag)
 {
@@ -70,10 +92,75 @@ gitconfig_str_request(struct imsgbuf *ibuf, struct got
 		return got_error(GOT_ERR_PRIVSEP_MSG);
 
 	value = got_gitconfig_get_str(gitconfig, section, tag);
-	return got_privsep_send_gitconfig_str(ibuf, value);
+	return send_gitconfig_str(ibuf, value);
 }
 
 static const struct got_error *
+send_gitconfig_remotes(struct imsgbuf *ibuf, struct got_remote_repo *remotes,
+    int nremotes)
+{
+	const struct got_error *err = NULL;
+	struct got_imsg_remotes iremotes;
+	int i;
+
+	iremotes.nremotes = nremotes;
+	if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_REMOTES, 0, 0, -1,
+	    &iremotes, sizeof(iremotes)) == -1)
+		return got_error_from_errno("imsg_compose GITCONFIG_REMOTES");
+
+	err = got_privsep_flush_imsg(ibuf);
+	imsg_clear(ibuf);
+	if (err)
+		return err;
+
+	for (i = 0; i < nremotes; i++) {
+		struct got_imsg_remote iremote;
+		size_t len = sizeof(iremote);
+		struct ibuf *wbuf;
+
+		iremote.mirror_references = remotes[i].mirror_references;
+		iremote.name_len = strlen(remotes[i].name);
+		len += iremote.name_len;
+		iremote.url_len = strlen(remotes[i].url);
+		len += iremote.url_len;
+
+		wbuf = imsg_create(ibuf, GOT_IMSG_GITCONFIG_REMOTE, 0, 0, len);
+		if (wbuf == NULL)
+			return got_error_from_errno(
+			    "imsg_create GITCONFIG_REMOTE");
+
+		if (imsg_add(wbuf, &iremote, sizeof(iremote)) == -1) {
+			err = got_error_from_errno(
+			    "imsg_add GITCONFIG_REMOTE");
+			ibuf_free(wbuf);
+			return err;
+		}
+
+		if (imsg_add(wbuf, remotes[i].name, iremote.name_len) == -1) {
+			err = got_error_from_errno(
+			    "imsg_add GITCONFIG_REMOTE");
+			ibuf_free(wbuf);
+			return err;
+		}
+		if (imsg_add(wbuf, remotes[i].url, iremote.url_len) == -1) {
+			err = got_error_from_errno(
+			    "imsg_add GITCONFIG_REMOTE");
+			ibuf_free(wbuf);
+			return err;
+		}
+
+		wbuf->fd = -1;
+		imsg_close(ibuf, wbuf);
+		err = got_privsep_flush_imsg(ibuf);
+		if (err)
+			return err;
+	}
+
+	return NULL;
+}
+
+
+static const struct got_error *
 gitconfig_remotes_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig)
 {
 	const struct got_error *err = NULL;
@@ -96,7 +183,7 @@ gitconfig_remotes_request(struct imsgbuf *ibuf, struct
 	}
 
 	if (nremotes == 0) {
-		err = got_privsep_send_gitconfig_remotes(ibuf, NULL, 0);
+		err = send_gitconfig_remotes(ibuf, NULL, 0);
 		goto done;
 	}
 
@@ -143,7 +230,7 @@ gitconfig_remotes_request(struct imsgbuf *ibuf, struct
 		i++;
 	}
 
-	err = got_privsep_send_gitconfig_remotes(ibuf, remotes, nremotes);
+	err = send_gitconfig_remotes(ibuf, remotes, nremotes);
 done:
 	for (i = 0; i < nremotes; i++)
 		free(remotes[i].name);
@@ -162,9 +249,9 @@ gitconfig_owner_request(struct imsgbuf *ibuf, struct g
 
 	value = got_gitconfig_get_str(gitconfig, "gotweb", "owner");
 	if (value)
-		return got_privsep_send_gitconfig_str(ibuf, value);
+		return send_gitconfig_str(ibuf, value);
 	value = got_gitconfig_get_str(gitconfig, "gitweb", "owner");
-	return got_privsep_send_gitconfig_str(ibuf, value);
+	return send_gitconfig_str(ibuf, value);
 }
 
 int
blob - d690ffc7275d9e4d25db624b27397f29249f6361
blob + b66f6065e2c02dedef1895df6032263be70e7738
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -537,6 +537,52 @@ tree_path_changed(int *changed, uint8_t **buf1, uint8_
 }
 
 static const struct got_error *
+send_traversed_commits(struct got_object_id *commit_ids, size_t ncommits,
+    struct imsgbuf *ibuf)
+{
+	const struct got_error *err;
+	struct ibuf *wbuf;
+	int i;
+
+	wbuf = imsg_create(ibuf, GOT_IMSG_TRAVERSED_COMMITS, 0, 0,
+	    sizeof(struct got_imsg_traversed_commits) +
+	    ncommits * SHA1_DIGEST_LENGTH);
+	if (wbuf == NULL)
+		return got_error_from_errno("imsg_create TRAVERSED_COMMITS");
+
+	if (imsg_add(wbuf, &ncommits, sizeof(ncommits)) == -1) {
+		err = got_error_from_errno("imsg_add TRAVERSED_COMMITS");
+		ibuf_free(wbuf);
+		return err;
+	}
+	for (i = 0; i < ncommits; i++) {
+		struct got_object_id *id = &commit_ids[i];
+		if (imsg_add(wbuf, id->sha1, SHA1_DIGEST_LENGTH) == -1) {
+			err = got_error_from_errno(
+			    "imsg_add TRAVERSED_COMMITS");
+			ibuf_free(wbuf);
+			return err;
+		}
+	}
+
+	wbuf->fd = -1;
+	imsg_close(ibuf, wbuf);
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+static const struct got_error *
+send_commit_traversal_done(struct imsgbuf *ibuf)
+{
+	if (imsg_compose(ibuf, GOT_IMSG_COMMIT_TRAVERSAL_DONE, 0, 0, -1,
+	    NULL, 0) == -1)
+		return got_error_from_errno("imsg_compose TRAVERSAL_DONE");
+
+	return got_privsep_flush_imsg(ibuf);
+}
+
+
+static const struct got_error *
 commit_traversal_request(struct imsg *imsg, struct imsgbuf *ibuf,
     struct got_pack *pack, struct got_packidx *packidx,
     struct got_object_cache *objcache)
@@ -602,8 +648,8 @@ commit_traversal_request(struct imsg *imsg, struct ims
 
 		if (sizeof(struct got_imsg_traversed_commits) +
 		    ncommits * SHA1_DIGEST_LENGTH >= max_datalen) {
-			err = got_privsep_send_traversed_commits(commit_ids,
-			    ncommits, ibuf);
+			err = send_traversed_commits(commit_ids, ncommits,
+			    ibuf);
 			if (err)
 				goto done;
 			ncommits = 0;
@@ -697,8 +743,7 @@ commit_traversal_request(struct imsg *imsg, struct ims
 	} while (!changed);
 
 	if (ncommits > 0) {
-		err = got_privsep_send_traversed_commits(commit_ids,
-		    ncommits, ibuf);
+		err = send_traversed_commits(commit_ids, ncommits, ibuf);
 		if (err)
 			goto done;
 
@@ -708,7 +753,7 @@ commit_traversal_request(struct imsg *imsg, struct ims
 				goto done;
 		}
 	}
-	err = got_privsep_send_commit_traversal_done(ibuf);
+	err = send_commit_traversal_done(ibuf);
 done:
 	free(commit_ids);
 	if (commit)