2 b61ceafc 2022-10-13 thomas * Copyright (c) 2018, 2019, 2022 Stefan Sperling <stsp@openbsd.org>
4 b61ceafc 2022-10-13 thomas * Permission to use, copy, modify, and distribute this software for any
5 b61ceafc 2022-10-13 thomas * purpose with or without fee is hereby granted, provided that the above
6 b61ceafc 2022-10-13 thomas * copyright notice and this permission notice appear in all copies.
8 b61ceafc 2022-10-13 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 b61ceafc 2022-10-13 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 b61ceafc 2022-10-13 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 b61ceafc 2022-10-13 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 b61ceafc 2022-10-13 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 b61ceafc 2022-10-13 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 b61ceafc 2022-10-13 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 b61ceafc 2022-10-13 thomas #include <sys/mman.h>
18 b61ceafc 2022-10-13 thomas #include <sys/queue.h>
19 b61ceafc 2022-10-13 thomas #include <sys/types.h>
20 b61ceafc 2022-10-13 thomas #include <sys/stat.h>
21 b61ceafc 2022-10-13 thomas #include <sys/socket.h>
22 b61ceafc 2022-10-13 thomas #include <sys/uio.h>
24 b61ceafc 2022-10-13 thomas #include <errno.h>
25 b61ceafc 2022-10-13 thomas #include <imsg.h>
26 b61ceafc 2022-10-13 thomas #include <stdio.h>
27 b61ceafc 2022-10-13 thomas #include <stdint.h>
28 b61ceafc 2022-10-13 thomas #include <stdlib.h>
29 b61ceafc 2022-10-13 thomas #include <string.h>
30 b61ceafc 2022-10-13 thomas #include <limits.h>
31 b61ceafc 2022-10-13 thomas #include <unistd.h>
33 b61ceafc 2022-10-13 thomas #include "got_error.h"
34 b61ceafc 2022-10-13 thomas #include "got_object.h"
35 b61ceafc 2022-10-13 thomas #include "got_repository.h"
36 b61ceafc 2022-10-13 thomas #include "got_opentemp.h"
37 b61ceafc 2022-10-13 thomas #include "got_path.h"
39 b61ceafc 2022-10-13 thomas #include "got_lib_delta.h"
40 b61ceafc 2022-10-13 thomas #include "got_lib_object.h"
41 b61ceafc 2022-10-13 thomas #include "got_lib_privsep.h"
42 b61ceafc 2022-10-13 thomas #include "got_lib_object_cache.h"
43 b61ceafc 2022-10-13 thomas #include "got_lib_pack.h"
44 b61ceafc 2022-10-13 thomas #include "got_lib_repository.h"
46 b61ceafc 2022-10-13 thomas static const struct got_error *
47 b61ceafc 2022-10-13 thomas request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
48 b61ceafc 2022-10-13 thomas struct got_object_id *id)
50 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
51 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf = pack->privsep_child->ibuf;
53 b61ceafc 2022-10-13 thomas err = got_privsep_send_packed_obj_req(ibuf, idx, id);
55 b61ceafc 2022-10-13 thomas return err;
57 b61ceafc 2022-10-13 thomas err = got_privsep_recv_obj(obj, ibuf);
59 b61ceafc 2022-10-13 thomas return err;
61 b61ceafc 2022-10-13 thomas memcpy(&(*obj)->id, id, sizeof((*obj)->id));
63 b61ceafc 2022-10-13 thomas return NULL;
66 b61ceafc 2022-10-13 thomas /* Create temporary files used during delta application. */
67 b61ceafc 2022-10-13 thomas static const struct got_error *
68 b61ceafc 2022-10-13 thomas pack_child_send_tempfiles(struct imsgbuf *ibuf, struct got_pack *pack)
70 b61ceafc 2022-10-13 thomas const struct got_error *err;
71 b61ceafc 2022-10-13 thomas int basefd = -1, accumfd = -1;
74 b61ceafc 2022-10-13 thomas * For performance reasons, the child will keep reusing the
75 b61ceafc 2022-10-13 thomas * same temporary files during every object request.
76 b61ceafc 2022-10-13 thomas * Opening and closing new files for every object request is
77 b61ceafc 2022-10-13 thomas * too expensive during operations such as 'gotadmin pack'.
79 b61ceafc 2022-10-13 thomas if (pack->child_has_tempfiles)
80 b61ceafc 2022-10-13 thomas return NULL;
82 b61ceafc 2022-10-13 thomas basefd = dup(pack->basefd);
83 b61ceafc 2022-10-13 thomas if (basefd == -1)
84 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
86 b61ceafc 2022-10-13 thomas accumfd = dup(pack->accumfd);
87 b61ceafc 2022-10-13 thomas if (accumfd == -1) {
88 b61ceafc 2022-10-13 thomas err = got_error_from_errno("dup");
89 b61ceafc 2022-10-13 thomas goto done;
92 b61ceafc 2022-10-13 thomas err = got_privsep_send_tmpfd(ibuf, basefd);
94 b61ceafc 2022-10-13 thomas goto done;
96 b61ceafc 2022-10-13 thomas err = got_privsep_send_tmpfd(ibuf, accumfd);
98 b61ceafc 2022-10-13 thomas if (err) {
99 b61ceafc 2022-10-13 thomas if (basefd != -1)
100 b61ceafc 2022-10-13 thomas close(basefd);
101 b61ceafc 2022-10-13 thomas if (accumfd != -1)
102 b61ceafc 2022-10-13 thomas close(accumfd);
104 b61ceafc 2022-10-13 thomas pack->child_has_tempfiles = 1;
105 b61ceafc 2022-10-13 thomas return NULL;
108 b61ceafc 2022-10-13 thomas static const struct got_error *
109 b61ceafc 2022-10-13 thomas request_packed_object_raw(uint8_t **outbuf, off_t *size, size_t *hdrlen,
110 b61ceafc 2022-10-13 thomas int outfd, struct got_pack *pack, int idx, struct got_object_id *id)
112 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
113 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf = pack->privsep_child->ibuf;
114 b61ceafc 2022-10-13 thomas int outfd_child;
116 b61ceafc 2022-10-13 thomas err = pack_child_send_tempfiles(ibuf, pack);
118 b61ceafc 2022-10-13 thomas return err;
120 b61ceafc 2022-10-13 thomas outfd_child = dup(outfd);
121 b61ceafc 2022-10-13 thomas if (outfd_child == -1)
122 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
124 b61ceafc 2022-10-13 thomas err = got_privsep_send_packed_raw_obj_req(ibuf, idx, id);
125 b61ceafc 2022-10-13 thomas if (err) {
126 b61ceafc 2022-10-13 thomas close(outfd_child);
127 b61ceafc 2022-10-13 thomas return err;
130 b61ceafc 2022-10-13 thomas err = got_privsep_send_raw_obj_outfd(ibuf, outfd_child);
132 b61ceafc 2022-10-13 thomas return err;
134 b61ceafc 2022-10-13 thomas err = got_privsep_recv_raw_obj(outbuf, size, hdrlen, ibuf);
136 b61ceafc 2022-10-13 thomas return err;
138 b61ceafc 2022-10-13 thomas return NULL;
141 b61ceafc 2022-10-13 thomas static const struct got_error *
142 b61ceafc 2022-10-13 thomas read_packed_object_privsep(struct got_object **obj,
143 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_pack *pack,
144 b61ceafc 2022-10-13 thomas struct got_packidx *packidx, int idx, struct got_object_id *id)
146 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
148 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
149 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
151 b61ceafc 2022-10-13 thomas return err;
154 b61ceafc 2022-10-13 thomas return request_packed_object(obj, pack, idx, id);
157 b61ceafc 2022-10-13 thomas static const struct got_error *
158 b61ceafc 2022-10-13 thomas read_packed_object_raw_privsep(uint8_t **outbuf, off_t *size, size_t *hdrlen,
159 b61ceafc 2022-10-13 thomas int outfd, struct got_pack *pack, struct got_packidx *packidx, int idx,
160 b61ceafc 2022-10-13 thomas struct got_object_id *id)
162 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
164 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
165 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
167 b61ceafc 2022-10-13 thomas return err;
170 b61ceafc 2022-10-13 thomas return request_packed_object_raw(outbuf, size, hdrlen, outfd, pack,
171 b61ceafc 2022-10-13 thomas idx, id);
174 b61ceafc 2022-10-13 thomas const struct got_error *
175 b61ceafc 2022-10-13 thomas got_object_open_packed(struct got_object **obj, struct got_object_id *id,
176 b61ceafc 2022-10-13 thomas struct got_repository *repo)
178 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
179 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
180 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
182 b61ceafc 2022-10-13 thomas char *path_packfile;
184 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
186 b61ceafc 2022-10-13 thomas return err;
188 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
189 b61ceafc 2022-10-13 thomas packidx->path_packidx);
191 b61ceafc 2022-10-13 thomas return err;
193 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
194 b61ceafc 2022-10-13 thomas if (pack == NULL) {
195 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile, packidx);
197 b61ceafc 2022-10-13 thomas goto done;
200 b61ceafc 2022-10-13 thomas err = read_packed_object_privsep(obj, repo, pack, packidx, idx, id);
202 b61ceafc 2022-10-13 thomas goto done;
204 b61ceafc 2022-10-13 thomas free(path_packfile);
205 b61ceafc 2022-10-13 thomas return err;
208 b61ceafc 2022-10-13 thomas const struct got_error *
209 b61ceafc 2022-10-13 thomas got_object_open_from_packfile(struct got_object **obj, struct got_object_id *id,
210 b61ceafc 2022-10-13 thomas struct got_pack *pack, struct got_packidx *packidx, int obj_idx,
211 b61ceafc 2022-10-13 thomas struct got_repository *repo)
213 b61ceafc 2022-10-13 thomas return read_packed_object_privsep(obj, repo, pack, packidx,
214 b61ceafc 2022-10-13 thomas obj_idx, id);
217 b61ceafc 2022-10-13 thomas const struct got_error *
218 b61ceafc 2022-10-13 thomas got_object_read_raw_delta(uint64_t *base_size, uint64_t *result_size,
219 b61ceafc 2022-10-13 thomas off_t *delta_size, off_t *delta_compressed_size, off_t *delta_offset,
220 b61ceafc 2022-10-13 thomas off_t *delta_out_offset, struct got_object_id **base_id, int delta_cache_fd,
221 b61ceafc 2022-10-13 thomas struct got_packidx *packidx, int obj_idx, struct got_object_id *id,
222 b61ceafc 2022-10-13 thomas struct got_repository *repo)
224 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
225 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
226 b61ceafc 2022-10-13 thomas char *path_packfile;
228 b61ceafc 2022-10-13 thomas *base_size = 0;
229 b61ceafc 2022-10-13 thomas *result_size = 0;
230 b61ceafc 2022-10-13 thomas *delta_size = 0;
231 b61ceafc 2022-10-13 thomas *delta_compressed_size = 0;
232 b61ceafc 2022-10-13 thomas *delta_offset = 0;
233 b61ceafc 2022-10-13 thomas *delta_out_offset = 0;
235 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
236 b61ceafc 2022-10-13 thomas packidx->path_packidx);
238 b61ceafc 2022-10-13 thomas return err;
240 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
241 b61ceafc 2022-10-13 thomas if (pack == NULL) {
242 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile, packidx);
244 b61ceafc 2022-10-13 thomas return err;
247 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
248 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
250 b61ceafc 2022-10-13 thomas return err;
253 b61ceafc 2022-10-13 thomas if (!pack->child_has_delta_outfd) {
254 b61ceafc 2022-10-13 thomas int outfd_child;
255 b61ceafc 2022-10-13 thomas outfd_child = dup(delta_cache_fd);
256 b61ceafc 2022-10-13 thomas if (outfd_child == -1)
257 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
258 b61ceafc 2022-10-13 thomas err = got_privsep_send_raw_delta_outfd(
259 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf, outfd_child);
261 b61ceafc 2022-10-13 thomas return err;
262 b61ceafc 2022-10-13 thomas pack->child_has_delta_outfd = 1;
265 b61ceafc 2022-10-13 thomas err = got_privsep_send_raw_delta_req(pack->privsep_child->ibuf,
266 b61ceafc 2022-10-13 thomas obj_idx, id);
268 b61ceafc 2022-10-13 thomas return err;
270 b61ceafc 2022-10-13 thomas return got_privsep_recv_raw_delta(base_size, result_size, delta_size,
271 b61ceafc 2022-10-13 thomas delta_compressed_size, delta_offset, delta_out_offset, base_id,
272 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf);
275 b61ceafc 2022-10-13 thomas static const struct got_error *
276 b61ceafc 2022-10-13 thomas request_object(struct got_object **obj, struct got_object_id *id,
277 b61ceafc 2022-10-13 thomas struct got_repository *repo, int fd)
279 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
280 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
282 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].ibuf;
284 b61ceafc 2022-10-13 thomas err = got_privsep_send_obj_req(ibuf, fd, id);
286 b61ceafc 2022-10-13 thomas return err;
288 b61ceafc 2022-10-13 thomas return got_privsep_recv_obj(obj, ibuf);
291 b61ceafc 2022-10-13 thomas static const struct got_error *
292 b61ceafc 2022-10-13 thomas request_raw_object(uint8_t **outbuf, off_t *size, size_t *hdrlen, int outfd,
293 b61ceafc 2022-10-13 thomas struct got_object_id *id, struct got_repository *repo, int infd)
295 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
296 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
297 b61ceafc 2022-10-13 thomas int outfd_child;
299 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].ibuf;
301 b61ceafc 2022-10-13 thomas outfd_child = dup(outfd);
302 b61ceafc 2022-10-13 thomas if (outfd_child == -1)
303 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
305 b61ceafc 2022-10-13 thomas err = got_privsep_send_raw_obj_req(ibuf, infd, id);
307 b61ceafc 2022-10-13 thomas return err;
309 b61ceafc 2022-10-13 thomas err = got_privsep_send_raw_obj_outfd(ibuf, outfd_child);
311 b61ceafc 2022-10-13 thomas return err;
313 b61ceafc 2022-10-13 thomas return got_privsep_recv_raw_obj(outbuf, size, hdrlen, ibuf);
316 b61ceafc 2022-10-13 thomas static const struct got_error *
317 54c22772 2022-10-13 thomas start_child(struct got_repository *repo, int type)
319 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
320 b61ceafc 2022-10-13 thomas int imsg_fds[2];
321 b61ceafc 2022-10-13 thomas pid_t pid;
322 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
323 54c22772 2022-10-13 thomas const char *prog_path;
325 54c22772 2022-10-13 thomas switch (type) {
326 54c22772 2022-10-13 thomas case GOT_REPO_PRIVSEP_CHILD_OBJECT:
327 54c22772 2022-10-13 thomas prog_path = GOT_PATH_PROG_READ_OBJECT;
329 54c22772 2022-10-13 thomas case GOT_REPO_PRIVSEP_CHILD_TREE:
330 54c22772 2022-10-13 thomas prog_path = GOT_PATH_PROG_READ_TREE;
332 54c22772 2022-10-13 thomas case GOT_REPO_PRIVSEP_CHILD_COMMIT:
333 54c22772 2022-10-13 thomas prog_path = GOT_PATH_PROG_READ_COMMIT;
335 54c22772 2022-10-13 thomas case GOT_REPO_PRIVSEP_CHILD_BLOB:
336 54c22772 2022-10-13 thomas prog_path = GOT_PATH_PROG_READ_BLOB;
338 54c22772 2022-10-13 thomas case GOT_REPO_PRIVSEP_CHILD_TAG:
339 54c22772 2022-10-13 thomas prog_path = GOT_PATH_PROG_READ_TAG;
342 54c22772 2022-10-13 thomas return got_error(GOT_ERR_OBJ_TYPE);
345 b61ceafc 2022-10-13 thomas ibuf = calloc(1, sizeof(*ibuf));
346 b61ceafc 2022-10-13 thomas if (ibuf == NULL)
347 b61ceafc 2022-10-13 thomas return got_error_from_errno("calloc");
349 b61ceafc 2022-10-13 thomas if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
350 b61ceafc 2022-10-13 thomas err = got_error_from_errno("socketpair");
351 b61ceafc 2022-10-13 thomas free(ibuf);
352 b61ceafc 2022-10-13 thomas return err;
355 b61ceafc 2022-10-13 thomas pid = fork();
356 b61ceafc 2022-10-13 thomas if (pid == -1) {
357 b61ceafc 2022-10-13 thomas err = got_error_from_errno("fork");
358 b61ceafc 2022-10-13 thomas free(ibuf);
359 b61ceafc 2022-10-13 thomas return err;
361 b61ceafc 2022-10-13 thomas else if (pid == 0) {
362 54c22772 2022-10-13 thomas got_privsep_exec_child(imsg_fds, prog_path, repo->path);
363 b61ceafc 2022-10-13 thomas /* not reached */
366 b61ceafc 2022-10-13 thomas if (close(imsg_fds[1]) == -1) {
367 b61ceafc 2022-10-13 thomas err = got_error_from_errno("close");
368 b61ceafc 2022-10-13 thomas free(ibuf);
369 b61ceafc 2022-10-13 thomas return err;
372 54c22772 2022-10-13 thomas repo->privsep_children[type].imsg_fd = imsg_fds[0];
373 54c22772 2022-10-13 thomas repo->privsep_children[type].pid = pid;
374 b61ceafc 2022-10-13 thomas imsg_init(ibuf, imsg_fds[0]);
375 54c22772 2022-10-13 thomas repo->privsep_children[type].ibuf = ibuf;
377 b61ceafc 2022-10-13 thomas return NULL;
380 b61ceafc 2022-10-13 thomas const struct got_error *
381 b61ceafc 2022-10-13 thomas got_object_read_header_privsep(struct got_object **obj,
382 b61ceafc 2022-10-13 thomas struct got_object_id *id, struct got_repository *repo, int obj_fd)
384 b61ceafc 2022-10-13 thomas const struct got_error *err;
386 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd != -1)
387 b61ceafc 2022-10-13 thomas return request_object(obj, id, repo, obj_fd);
389 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_OBJECT);
391 b61ceafc 2022-10-13 thomas return err;
393 b61ceafc 2022-10-13 thomas return request_object(obj, id, repo, obj_fd);
396 b61ceafc 2022-10-13 thomas static const struct got_error *
397 b61ceafc 2022-10-13 thomas read_object_raw_privsep(uint8_t **outbuf, off_t *size, size_t *hdrlen,
398 b61ceafc 2022-10-13 thomas int outfd, struct got_object_id *id, struct got_repository *repo,
399 b61ceafc 2022-10-13 thomas int obj_fd)
401 b61ceafc 2022-10-13 thomas const struct got_error *err;
403 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd != -1)
404 b61ceafc 2022-10-13 thomas return request_raw_object(outbuf, size, hdrlen, outfd, id,
405 b61ceafc 2022-10-13 thomas repo, obj_fd);
407 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_OBJECT);
409 b61ceafc 2022-10-13 thomas return err;
411 b61ceafc 2022-10-13 thomas return request_raw_object(outbuf, size, hdrlen, outfd, id, repo,
415 b61ceafc 2022-10-13 thomas const struct got_error *
416 b61ceafc 2022-10-13 thomas got_object_open(struct got_object **obj, struct got_repository *repo,
417 b61ceafc 2022-10-13 thomas struct got_object_id *id)
419 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
422 b61ceafc 2022-10-13 thomas *obj = got_repo_get_cached_object(repo, id);
423 b61ceafc 2022-10-13 thomas if (*obj != NULL) {
424 b61ceafc 2022-10-13 thomas (*obj)->refcnt++;
425 b61ceafc 2022-10-13 thomas return NULL;
428 b61ceafc 2022-10-13 thomas err = got_object_open_packed(obj, id, repo);
429 b61ceafc 2022-10-13 thomas if (err && err->code != GOT_ERR_NO_OBJ)
430 b61ceafc 2022-10-13 thomas return err;
431 b61ceafc 2022-10-13 thomas if (*obj) {
432 b61ceafc 2022-10-13 thomas (*obj)->refcnt++;
433 b61ceafc 2022-10-13 thomas return got_repo_cache_object(repo, id, *obj);
436 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
437 b61ceafc 2022-10-13 thomas if (err) {
438 b61ceafc 2022-10-13 thomas if (err->code == GOT_ERR_ERRNO && errno == ENOENT)
439 b61ceafc 2022-10-13 thomas err = got_error_no_obj(id);
440 b61ceafc 2022-10-13 thomas return err;
443 b61ceafc 2022-10-13 thomas err = got_object_read_header_privsep(obj, id, repo, fd);
445 b61ceafc 2022-10-13 thomas return err;
447 b61ceafc 2022-10-13 thomas memcpy((*obj)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
449 b61ceafc 2022-10-13 thomas (*obj)->refcnt++;
450 b61ceafc 2022-10-13 thomas return got_repo_cache_object(repo, id, *obj);
453 b61ceafc 2022-10-13 thomas /* *outfd must be initialized to -1 by caller */
454 b61ceafc 2022-10-13 thomas const struct got_error *
455 b61ceafc 2022-10-13 thomas got_object_raw_open(struct got_raw_object **obj, int *outfd,
456 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id)
458 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
459 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
461 b61ceafc 2022-10-13 thomas uint8_t *outbuf = NULL;
462 b61ceafc 2022-10-13 thomas off_t size = 0;
463 b61ceafc 2022-10-13 thomas size_t hdrlen = 0;
464 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
466 b61ceafc 2022-10-13 thomas *obj = got_repo_get_cached_raw_object(repo, id);
467 b61ceafc 2022-10-13 thomas if (*obj != NULL) {
468 b61ceafc 2022-10-13 thomas (*obj)->refcnt++;
469 b61ceafc 2022-10-13 thomas return NULL;
472 b61ceafc 2022-10-13 thomas if (*outfd == -1) {
473 b61ceafc 2022-10-13 thomas *outfd = got_opentempfd();
474 b61ceafc 2022-10-13 thomas if (*outfd == -1)
475 b61ceafc 2022-10-13 thomas return got_error_from_errno("got_opentempfd");
478 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
479 b61ceafc 2022-10-13 thomas if (err == NULL) {
480 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
482 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
483 b61ceafc 2022-10-13 thomas packidx->path_packidx);
485 b61ceafc 2022-10-13 thomas goto done;
487 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
488 b61ceafc 2022-10-13 thomas if (pack == NULL) {
489 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile,
490 b61ceafc 2022-10-13 thomas packidx);
492 b61ceafc 2022-10-13 thomas goto done;
494 b61ceafc 2022-10-13 thomas err = read_packed_object_raw_privsep(&outbuf, &size, &hdrlen,
495 b61ceafc 2022-10-13 thomas *outfd, pack, packidx, idx, id);
497 b61ceafc 2022-10-13 thomas goto done;
498 b61ceafc 2022-10-13 thomas } else if (err->code == GOT_ERR_NO_OBJ) {
501 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
503 b61ceafc 2022-10-13 thomas goto done;
504 b61ceafc 2022-10-13 thomas err = read_object_raw_privsep(&outbuf, &size, &hdrlen, *outfd,
505 b61ceafc 2022-10-13 thomas id, repo, fd);
507 b61ceafc 2022-10-13 thomas goto done;
510 ebe6ec92 2023-01-09 thomas err = got_object_raw_alloc(obj, outbuf, outfd,
511 ebe6ec92 2023-01-09 thomas GOT_DELTA_RESULT_SIZE_CACHED_MAX, hdrlen, size);
513 b61ceafc 2022-10-13 thomas goto done;
515 b61ceafc 2022-10-13 thomas err = got_repo_cache_raw_object(repo, id, *obj);
517 b61ceafc 2022-10-13 thomas free(path_packfile);
518 b61ceafc 2022-10-13 thomas if (err) {
519 b61ceafc 2022-10-13 thomas if (*obj) {
520 b61ceafc 2022-10-13 thomas got_object_raw_close(*obj);
521 b61ceafc 2022-10-13 thomas *obj = NULL;
523 b61ceafc 2022-10-13 thomas free(outbuf);
525 b61ceafc 2022-10-13 thomas return err;
528 b61ceafc 2022-10-13 thomas static const struct got_error *
529 b61ceafc 2022-10-13 thomas request_packed_commit(struct got_commit_object **commit, struct got_pack *pack,
530 b61ceafc 2022-10-13 thomas int pack_idx, struct got_object_id *id)
532 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
534 b61ceafc 2022-10-13 thomas err = got_privsep_send_commit_req(pack->privsep_child->ibuf, -1, id,
535 b61ceafc 2022-10-13 thomas pack_idx);
537 b61ceafc 2022-10-13 thomas return err;
539 b61ceafc 2022-10-13 thomas err = got_privsep_recv_commit(commit, pack->privsep_child->ibuf);
541 b61ceafc 2022-10-13 thomas return err;
543 b61ceafc 2022-10-13 thomas (*commit)->flags |= GOT_COMMIT_FLAG_PACKED;
544 b61ceafc 2022-10-13 thomas return NULL;
547 b61ceafc 2022-10-13 thomas static const struct got_error *
548 b61ceafc 2022-10-13 thomas read_packed_commit_privsep(struct got_commit_object **commit,
549 b61ceafc 2022-10-13 thomas struct got_pack *pack, struct got_packidx *packidx, int idx,
550 b61ceafc 2022-10-13 thomas struct got_object_id *id)
552 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
554 b61ceafc 2022-10-13 thomas if (pack->privsep_child)
555 b61ceafc 2022-10-13 thomas return request_packed_commit(commit, pack, idx, id);
557 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
559 b61ceafc 2022-10-13 thomas return err;
561 b61ceafc 2022-10-13 thomas return request_packed_commit(commit, pack, idx, id);
564 b61ceafc 2022-10-13 thomas static const struct got_error *
565 b61ceafc 2022-10-13 thomas request_commit(struct got_commit_object **commit, struct got_repository *repo,
566 b61ceafc 2022-10-13 thomas int fd, struct got_object_id *id)
568 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
569 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
571 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].ibuf;
573 b61ceafc 2022-10-13 thomas err = got_privsep_send_commit_req(ibuf, fd, id, -1);
575 b61ceafc 2022-10-13 thomas return err;
577 b61ceafc 2022-10-13 thomas return got_privsep_recv_commit(commit, ibuf);
580 b61ceafc 2022-10-13 thomas static const struct got_error *
581 b61ceafc 2022-10-13 thomas read_commit_privsep(struct got_commit_object **commit, int obj_fd,
582 b61ceafc 2022-10-13 thomas struct got_object_id *id, struct got_repository *repo)
584 b61ceafc 2022-10-13 thomas const struct got_error *err;
586 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd != -1)
587 b61ceafc 2022-10-13 thomas return request_commit(commit, repo, obj_fd, id);
589 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_COMMIT);
591 b61ceafc 2022-10-13 thomas return err;
593 b61ceafc 2022-10-13 thomas return request_commit(commit, repo, obj_fd, id);
596 b61ceafc 2022-10-13 thomas static const struct got_error *
597 b61ceafc 2022-10-13 thomas open_commit(struct got_commit_object **commit,
598 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id, int check_cache)
600 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
601 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
603 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
605 b61ceafc 2022-10-13 thomas if (check_cache) {
606 b61ceafc 2022-10-13 thomas *commit = got_repo_get_cached_commit(repo, id);
607 b61ceafc 2022-10-13 thomas if (*commit != NULL) {
608 b61ceafc 2022-10-13 thomas (*commit)->refcnt++;
609 b61ceafc 2022-10-13 thomas return NULL;
612 b61ceafc 2022-10-13 thomas *commit = NULL;
614 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
615 b61ceafc 2022-10-13 thomas if (err == NULL) {
616 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
618 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
619 b61ceafc 2022-10-13 thomas packidx->path_packidx);
621 b61ceafc 2022-10-13 thomas return err;
623 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
624 b61ceafc 2022-10-13 thomas if (pack == NULL) {
625 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile,
626 b61ceafc 2022-10-13 thomas packidx);
628 b61ceafc 2022-10-13 thomas goto done;
630 b61ceafc 2022-10-13 thomas err = read_packed_commit_privsep(commit, pack,
631 b61ceafc 2022-10-13 thomas packidx, idx, id);
632 b61ceafc 2022-10-13 thomas } else if (err->code == GOT_ERR_NO_OBJ) {
635 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
637 b61ceafc 2022-10-13 thomas return err;
638 b61ceafc 2022-10-13 thomas err = read_commit_privsep(commit, fd, id, repo);
641 b61ceafc 2022-10-13 thomas if (err == NULL) {
642 b61ceafc 2022-10-13 thomas (*commit)->refcnt++;
643 b61ceafc 2022-10-13 thomas err = got_repo_cache_commit(repo, id, *commit);
646 b61ceafc 2022-10-13 thomas free(path_packfile);
647 b61ceafc 2022-10-13 thomas return err;
650 b61ceafc 2022-10-13 thomas const struct got_error *
651 b61ceafc 2022-10-13 thomas got_object_open_as_commit(struct got_commit_object **commit,
652 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id)
654 b61ceafc 2022-10-13 thomas *commit = got_repo_get_cached_commit(repo, id);
655 b61ceafc 2022-10-13 thomas if (*commit != NULL) {
656 b61ceafc 2022-10-13 thomas (*commit)->refcnt++;
657 b61ceafc 2022-10-13 thomas return NULL;
660 b61ceafc 2022-10-13 thomas return open_commit(commit, repo, id, 0);
663 b61ceafc 2022-10-13 thomas const struct got_error *
664 b61ceafc 2022-10-13 thomas got_object_commit_open(struct got_commit_object **commit,
665 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object *obj)
667 b61ceafc 2022-10-13 thomas return open_commit(commit, repo, got_object_get_id(obj), 1);
670 b61ceafc 2022-10-13 thomas static const struct got_error *
671 b61ceafc 2022-10-13 thomas request_packed_tree(struct got_tree_object **tree, struct got_pack *pack,
672 b61ceafc 2022-10-13 thomas int pack_idx, struct got_object_id *id)
674 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
676 b61ceafc 2022-10-13 thomas err = got_privsep_send_tree_req(pack->privsep_child->ibuf, -1, id,
677 b61ceafc 2022-10-13 thomas pack_idx);
679 b61ceafc 2022-10-13 thomas return err;
681 b61ceafc 2022-10-13 thomas return got_privsep_recv_tree(tree, pack->privsep_child->ibuf);
684 b61ceafc 2022-10-13 thomas static const struct got_error *
685 b61ceafc 2022-10-13 thomas read_packed_tree_privsep(struct got_tree_object **tree,
686 b61ceafc 2022-10-13 thomas struct got_pack *pack, struct got_packidx *packidx, int idx,
687 b61ceafc 2022-10-13 thomas struct got_object_id *id)
689 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
691 b61ceafc 2022-10-13 thomas if (pack->privsep_child)
692 b61ceafc 2022-10-13 thomas return request_packed_tree(tree, pack, idx, id);
694 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
696 b61ceafc 2022-10-13 thomas return err;
698 b61ceafc 2022-10-13 thomas return request_packed_tree(tree, pack, idx, id);
701 b61ceafc 2022-10-13 thomas static const struct got_error *
702 b61ceafc 2022-10-13 thomas request_tree(struct got_tree_object **tree, struct got_repository *repo,
703 b61ceafc 2022-10-13 thomas int fd, struct got_object_id *id)
705 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
706 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
708 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].ibuf;
710 b61ceafc 2022-10-13 thomas err = got_privsep_send_tree_req(ibuf, fd, id, -1);
712 b61ceafc 2022-10-13 thomas return err;
714 b61ceafc 2022-10-13 thomas return got_privsep_recv_tree(tree, ibuf);
717 b61ceafc 2022-10-13 thomas static const struct got_error *
718 b61ceafc 2022-10-13 thomas read_tree_privsep(struct got_tree_object **tree, int obj_fd,
719 b61ceafc 2022-10-13 thomas struct got_object_id *id, struct got_repository *repo)
721 b61ceafc 2022-10-13 thomas const struct got_error *err;
723 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].imsg_fd != -1)
724 b61ceafc 2022-10-13 thomas return request_tree(tree, repo, obj_fd, id);
726 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_TREE);
728 b61ceafc 2022-10-13 thomas return err;
730 b61ceafc 2022-10-13 thomas return request_tree(tree, repo, obj_fd, id);
733 b61ceafc 2022-10-13 thomas static const struct got_error *
734 b61ceafc 2022-10-13 thomas open_tree(struct got_tree_object **tree, struct got_repository *repo,
735 b61ceafc 2022-10-13 thomas struct got_object_id *id, int check_cache)
737 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
738 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
740 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
742 b61ceafc 2022-10-13 thomas if (check_cache) {
743 b61ceafc 2022-10-13 thomas *tree = got_repo_get_cached_tree(repo, id);
744 b61ceafc 2022-10-13 thomas if (*tree != NULL) {
745 b61ceafc 2022-10-13 thomas (*tree)->refcnt++;
746 b61ceafc 2022-10-13 thomas return NULL;
749 b61ceafc 2022-10-13 thomas *tree = NULL;
751 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
752 b61ceafc 2022-10-13 thomas if (err == NULL) {
753 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
755 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
756 b61ceafc 2022-10-13 thomas packidx->path_packidx);
758 b61ceafc 2022-10-13 thomas return err;
760 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
761 b61ceafc 2022-10-13 thomas if (pack == NULL) {
762 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile,
763 b61ceafc 2022-10-13 thomas packidx);
765 b61ceafc 2022-10-13 thomas goto done;
767 b61ceafc 2022-10-13 thomas err = read_packed_tree_privsep(tree, pack,
768 b61ceafc 2022-10-13 thomas packidx, idx, id);
769 b61ceafc 2022-10-13 thomas } else if (err->code == GOT_ERR_NO_OBJ) {
772 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
774 b61ceafc 2022-10-13 thomas return err;
775 b61ceafc 2022-10-13 thomas err = read_tree_privsep(tree, fd, id, repo);
778 b61ceafc 2022-10-13 thomas if (err == NULL) {
779 b61ceafc 2022-10-13 thomas (*tree)->refcnt++;
780 b61ceafc 2022-10-13 thomas err = got_repo_cache_tree(repo, id, *tree);
783 b61ceafc 2022-10-13 thomas free(path_packfile);
784 b61ceafc 2022-10-13 thomas return err;
787 b61ceafc 2022-10-13 thomas const struct got_error *
788 b61ceafc 2022-10-13 thomas got_object_open_as_tree(struct got_tree_object **tree,
789 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id)
791 b61ceafc 2022-10-13 thomas *tree = got_repo_get_cached_tree(repo, id);
792 b61ceafc 2022-10-13 thomas if (*tree != NULL) {
793 b61ceafc 2022-10-13 thomas (*tree)->refcnt++;
794 b61ceafc 2022-10-13 thomas return NULL;
797 b61ceafc 2022-10-13 thomas return open_tree(tree, repo, id, 0);
800 b61ceafc 2022-10-13 thomas const struct got_error *
801 b61ceafc 2022-10-13 thomas got_object_tree_open(struct got_tree_object **tree,
802 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object *obj)
804 b61ceafc 2022-10-13 thomas return open_tree(tree, repo, got_object_get_id(obj), 1);
807 b61ceafc 2022-10-13 thomas static const struct got_error *
808 b61ceafc 2022-10-13 thomas request_packed_blob(uint8_t **outbuf, size_t *size, size_t *hdrlen, int outfd,
809 b61ceafc 2022-10-13 thomas struct got_pack *pack, struct got_packidx *packidx, int idx,
810 b61ceafc 2022-10-13 thomas struct got_object_id *id)
812 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
813 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf = pack->privsep_child->ibuf;
814 b61ceafc 2022-10-13 thomas int outfd_child;
816 b61ceafc 2022-10-13 thomas err = pack_child_send_tempfiles(ibuf, pack);
818 b61ceafc 2022-10-13 thomas return err;
820 b61ceafc 2022-10-13 thomas outfd_child = dup(outfd);
821 b61ceafc 2022-10-13 thomas if (outfd_child == -1)
822 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
824 b61ceafc 2022-10-13 thomas err = got_privsep_send_blob_req(pack->privsep_child->ibuf, -1, id, idx);
826 b61ceafc 2022-10-13 thomas return err;
828 b61ceafc 2022-10-13 thomas err = got_privsep_send_blob_outfd(pack->privsep_child->ibuf,
829 b61ceafc 2022-10-13 thomas outfd_child);
830 b61ceafc 2022-10-13 thomas if (err) {
831 b61ceafc 2022-10-13 thomas return err;
834 b61ceafc 2022-10-13 thomas err = got_privsep_recv_blob(outbuf, size, hdrlen,
835 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf);
837 b61ceafc 2022-10-13 thomas return err;
839 b61ceafc 2022-10-13 thomas if (lseek(outfd, SEEK_SET, 0) == -1)
840 b61ceafc 2022-10-13 thomas err = got_error_from_errno("lseek");
842 b61ceafc 2022-10-13 thomas return err;
845 b61ceafc 2022-10-13 thomas static const struct got_error *
846 b61ceafc 2022-10-13 thomas read_packed_blob_privsep(uint8_t **outbuf, size_t *size, size_t *hdrlen,
847 b61ceafc 2022-10-13 thomas int outfd, struct got_pack *pack, struct got_packidx *packidx, int idx,
848 b61ceafc 2022-10-13 thomas struct got_object_id *id)
850 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
852 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
853 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
855 b61ceafc 2022-10-13 thomas return err;
858 b61ceafc 2022-10-13 thomas return request_packed_blob(outbuf, size, hdrlen, outfd, pack, packidx,
859 b61ceafc 2022-10-13 thomas idx, id);
862 b61ceafc 2022-10-13 thomas static const struct got_error *
863 b61ceafc 2022-10-13 thomas request_blob(uint8_t **outbuf, size_t *size, size_t *hdrlen, int outfd,
864 b61ceafc 2022-10-13 thomas int infd, struct got_object_id *id, struct imsgbuf *ibuf)
866 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
867 b61ceafc 2022-10-13 thomas int outfd_child;
869 b61ceafc 2022-10-13 thomas outfd_child = dup(outfd);
870 b61ceafc 2022-10-13 thomas if (outfd_child == -1)
871 b61ceafc 2022-10-13 thomas return got_error_from_errno("dup");
873 b61ceafc 2022-10-13 thomas err = got_privsep_send_blob_req(ibuf, infd, id, -1);
875 b61ceafc 2022-10-13 thomas return err;
877 b61ceafc 2022-10-13 thomas err = got_privsep_send_blob_outfd(ibuf, outfd_child);
879 b61ceafc 2022-10-13 thomas return err;
881 b61ceafc 2022-10-13 thomas err = got_privsep_recv_blob(outbuf, size, hdrlen, ibuf);
883 b61ceafc 2022-10-13 thomas return err;
885 b61ceafc 2022-10-13 thomas if (lseek(outfd, SEEK_SET, 0) == -1)
886 b61ceafc 2022-10-13 thomas return got_error_from_errno("lseek");
888 b61ceafc 2022-10-13 thomas return err;
891 b61ceafc 2022-10-13 thomas static const struct got_error *
892 b61ceafc 2022-10-13 thomas read_blob_privsep(uint8_t **outbuf, size_t *size, size_t *hdrlen,
893 b61ceafc 2022-10-13 thomas int outfd, int infd, struct got_object_id *id, struct got_repository *repo)
895 b61ceafc 2022-10-13 thomas const struct got_error *err;
896 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
898 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].imsg_fd != -1) {
899 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].ibuf;
900 b61ceafc 2022-10-13 thomas return request_blob(outbuf, size, hdrlen, outfd, infd, id,
904 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_BLOB);
906 b61ceafc 2022-10-13 thomas return err;
908 54c22772 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].ibuf;
909 b61ceafc 2022-10-13 thomas return request_blob(outbuf, size, hdrlen, outfd, infd, id, ibuf);
912 b61ceafc 2022-10-13 thomas static const struct got_error *
913 b61ceafc 2022-10-13 thomas open_blob(struct got_blob_object **blob, struct got_repository *repo,
914 b61ceafc 2022-10-13 thomas struct got_object_id *id, size_t blocksize, int outfd)
916 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
917 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
918 b61ceafc 2022-10-13 thomas int idx, dfd = -1;
919 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
920 b61ceafc 2022-10-13 thomas uint8_t *outbuf;
921 b61ceafc 2022-10-13 thomas size_t size, hdrlen;
922 b61ceafc 2022-10-13 thomas struct stat sb;
924 b61ceafc 2022-10-13 thomas *blob = calloc(1, sizeof(**blob));
925 b61ceafc 2022-10-13 thomas if (*blob == NULL)
926 b61ceafc 2022-10-13 thomas return got_error_from_errno("calloc");
928 b61ceafc 2022-10-13 thomas (*blob)->read_buf = malloc(blocksize);
929 b61ceafc 2022-10-13 thomas if ((*blob)->read_buf == NULL) {
930 b61ceafc 2022-10-13 thomas err = got_error_from_errno("malloc");
931 b61ceafc 2022-10-13 thomas goto done;
934 b61ceafc 2022-10-13 thomas if (ftruncate(outfd, 0L) == -1) {
935 b61ceafc 2022-10-13 thomas err = got_error_from_errno("ftruncate");
936 b61ceafc 2022-10-13 thomas goto done;
938 b61ceafc 2022-10-13 thomas if (lseek(outfd, SEEK_SET, 0) == -1) {
939 b61ceafc 2022-10-13 thomas err = got_error_from_errno("lseek");
940 b61ceafc 2022-10-13 thomas goto done;
943 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
944 b61ceafc 2022-10-13 thomas if (err == NULL) {
945 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
947 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
948 b61ceafc 2022-10-13 thomas packidx->path_packidx);
950 b61ceafc 2022-10-13 thomas goto done;
952 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
953 b61ceafc 2022-10-13 thomas if (pack == NULL) {
954 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile,
955 b61ceafc 2022-10-13 thomas packidx);
957 b61ceafc 2022-10-13 thomas goto done;
959 b61ceafc 2022-10-13 thomas err = read_packed_blob_privsep(&outbuf, &size, &hdrlen, outfd,
960 b61ceafc 2022-10-13 thomas pack, packidx, idx, id);
961 b61ceafc 2022-10-13 thomas } else if (err->code == GOT_ERR_NO_OBJ) {
962 b61ceafc 2022-10-13 thomas int infd;
964 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&infd, id, repo);
966 b61ceafc 2022-10-13 thomas goto done;
967 b61ceafc 2022-10-13 thomas err = read_blob_privsep(&outbuf, &size, &hdrlen, outfd, infd,
968 b61ceafc 2022-10-13 thomas id, repo);
971 b61ceafc 2022-10-13 thomas goto done;
973 b61ceafc 2022-10-13 thomas if (hdrlen > size) {
974 b61ceafc 2022-10-13 thomas err = got_error(GOT_ERR_BAD_OBJ_HDR);
975 b61ceafc 2022-10-13 thomas goto done;
978 b61ceafc 2022-10-13 thomas if (outbuf) {
979 b61ceafc 2022-10-13 thomas (*blob)->f = fmemopen(outbuf, size, "rb");
980 b61ceafc 2022-10-13 thomas if ((*blob)->f == NULL) {
981 b61ceafc 2022-10-13 thomas err = got_error_from_errno("fmemopen");
982 b61ceafc 2022-10-13 thomas free(outbuf);
983 b61ceafc 2022-10-13 thomas goto done;
985 b61ceafc 2022-10-13 thomas (*blob)->data = outbuf;
987 b61ceafc 2022-10-13 thomas if (fstat(outfd, &sb) == -1) {
988 b61ceafc 2022-10-13 thomas err = got_error_from_errno("fstat");
989 b61ceafc 2022-10-13 thomas goto done;
992 b61ceafc 2022-10-13 thomas if (sb.st_size != size) {
993 b61ceafc 2022-10-13 thomas err = got_error(GOT_ERR_PRIVSEP_LEN);
994 b61ceafc 2022-10-13 thomas goto done;
997 b61ceafc 2022-10-13 thomas dfd = dup(outfd);
998 b61ceafc 2022-10-13 thomas if (dfd == -1) {
999 b61ceafc 2022-10-13 thomas err = got_error_from_errno("dup");
1000 b61ceafc 2022-10-13 thomas goto done;
1003 b61ceafc 2022-10-13 thomas (*blob)->f = fdopen(dfd, "rb");
1004 b61ceafc 2022-10-13 thomas if ((*blob)->f == NULL) {
1005 b61ceafc 2022-10-13 thomas err = got_error_from_errno("fdopen");
1006 b61ceafc 2022-10-13 thomas close(dfd);
1007 b61ceafc 2022-10-13 thomas dfd = -1;
1008 b61ceafc 2022-10-13 thomas goto done;
1012 b61ceafc 2022-10-13 thomas (*blob)->hdrlen = hdrlen;
1013 b61ceafc 2022-10-13 thomas (*blob)->blocksize = blocksize;
1014 b61ceafc 2022-10-13 thomas memcpy(&(*blob)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
1017 b61ceafc 2022-10-13 thomas free(path_packfile);
1018 b61ceafc 2022-10-13 thomas if (err) {
1019 b61ceafc 2022-10-13 thomas if (*blob) {
1020 b61ceafc 2022-10-13 thomas got_object_blob_close(*blob);
1021 b61ceafc 2022-10-13 thomas *blob = NULL;
1024 b61ceafc 2022-10-13 thomas return err;
1027 b61ceafc 2022-10-13 thomas const struct got_error *
1028 b61ceafc 2022-10-13 thomas got_object_open_as_blob(struct got_blob_object **blob,
1029 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id, size_t blocksize,
1030 b61ceafc 2022-10-13 thomas int outfd)
1032 b61ceafc 2022-10-13 thomas return open_blob(blob, repo, id, blocksize, outfd);
1035 b61ceafc 2022-10-13 thomas const struct got_error *
1036 b61ceafc 2022-10-13 thomas got_object_blob_open(struct got_blob_object **blob,
1037 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object *obj, size_t blocksize,
1038 b61ceafc 2022-10-13 thomas int outfd)
1040 b61ceafc 2022-10-13 thomas return open_blob(blob, repo, got_object_get_id(obj), blocksize, outfd);
1043 b61ceafc 2022-10-13 thomas static const struct got_error *
1044 b61ceafc 2022-10-13 thomas request_packed_tag(struct got_tag_object **tag, struct got_pack *pack,
1045 b61ceafc 2022-10-13 thomas int pack_idx, struct got_object_id *id)
1047 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1049 b61ceafc 2022-10-13 thomas err = got_privsep_send_tag_req(pack->privsep_child->ibuf, -1, id,
1050 b61ceafc 2022-10-13 thomas pack_idx);
1051 b61ceafc 2022-10-13 thomas if (err)
1052 b61ceafc 2022-10-13 thomas return err;
1054 b61ceafc 2022-10-13 thomas return got_privsep_recv_tag(tag, pack->privsep_child->ibuf);
1057 b61ceafc 2022-10-13 thomas static const struct got_error *
1058 b61ceafc 2022-10-13 thomas read_packed_tag_privsep(struct got_tag_object **tag,
1059 b61ceafc 2022-10-13 thomas struct got_pack *pack, struct got_packidx *packidx, int idx,
1060 b61ceafc 2022-10-13 thomas struct got_object_id *id)
1062 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1064 b61ceafc 2022-10-13 thomas if (pack->privsep_child)
1065 b61ceafc 2022-10-13 thomas return request_packed_tag(tag, pack, idx, id);
1067 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
1068 b61ceafc 2022-10-13 thomas if (err)
1069 b61ceafc 2022-10-13 thomas return err;
1071 b61ceafc 2022-10-13 thomas return request_packed_tag(tag, pack, idx, id);
1074 b61ceafc 2022-10-13 thomas static const struct got_error *
1075 b61ceafc 2022-10-13 thomas request_tag(struct got_tag_object **tag, struct got_repository *repo,
1076 b61ceafc 2022-10-13 thomas int fd, struct got_object_id *id)
1078 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1079 b61ceafc 2022-10-13 thomas struct imsgbuf *ibuf;
1081 b61ceafc 2022-10-13 thomas ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].ibuf;
1083 b61ceafc 2022-10-13 thomas err = got_privsep_send_tag_req(ibuf, fd, id, -1);
1084 b61ceafc 2022-10-13 thomas if (err)
1085 b61ceafc 2022-10-13 thomas return err;
1087 b61ceafc 2022-10-13 thomas return got_privsep_recv_tag(tag, ibuf);
1090 b61ceafc 2022-10-13 thomas static const struct got_error *
1091 b61ceafc 2022-10-13 thomas read_tag_privsep(struct got_tag_object **tag, int obj_fd,
1092 b61ceafc 2022-10-13 thomas struct got_object_id *id, struct got_repository *repo)
1094 b61ceafc 2022-10-13 thomas const struct got_error *err;
1096 b61ceafc 2022-10-13 thomas if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TAG].imsg_fd != -1)
1097 b61ceafc 2022-10-13 thomas return request_tag(tag, repo, obj_fd, id);
1099 54c22772 2022-10-13 thomas err = start_child(repo, GOT_REPO_PRIVSEP_CHILD_TAG);
1100 54c22772 2022-10-13 thomas if (err)
1101 b61ceafc 2022-10-13 thomas return err;
1103 b61ceafc 2022-10-13 thomas return request_tag(tag, repo, obj_fd, id);
1106 b61ceafc 2022-10-13 thomas static const struct got_error *
1107 b61ceafc 2022-10-13 thomas open_tag(struct got_tag_object **tag, struct got_repository *repo,
1108 b61ceafc 2022-10-13 thomas struct got_object_id *id, int check_cache)
1110 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1111 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
1112 b61ceafc 2022-10-13 thomas int idx;
1113 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
1114 b61ceafc 2022-10-13 thomas struct got_object *obj = NULL;
1115 b61ceafc 2022-10-13 thomas int obj_type = GOT_OBJ_TYPE_ANY;
1117 b61ceafc 2022-10-13 thomas if (check_cache) {
1118 b61ceafc 2022-10-13 thomas *tag = got_repo_get_cached_tag(repo, id);
1119 b61ceafc 2022-10-13 thomas if (*tag != NULL) {
1120 b61ceafc 2022-10-13 thomas (*tag)->refcnt++;
1121 b61ceafc 2022-10-13 thomas return NULL;
1124 b61ceafc 2022-10-13 thomas *tag = NULL;
1126 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, id);
1127 b61ceafc 2022-10-13 thomas if (err == NULL) {
1128 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
1130 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
1131 b61ceafc 2022-10-13 thomas packidx->path_packidx);
1132 b61ceafc 2022-10-13 thomas if (err)
1133 b61ceafc 2022-10-13 thomas return err;
1135 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
1136 b61ceafc 2022-10-13 thomas if (pack == NULL) {
1137 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile,
1138 b61ceafc 2022-10-13 thomas packidx);
1139 b61ceafc 2022-10-13 thomas if (err)
1140 b61ceafc 2022-10-13 thomas goto done;
1143 b61ceafc 2022-10-13 thomas /* Beware of "lightweight" tags: Check object type first. */
1144 b61ceafc 2022-10-13 thomas err = read_packed_object_privsep(&obj, repo, pack, packidx,
1145 b61ceafc 2022-10-13 thomas idx, id);
1146 b61ceafc 2022-10-13 thomas if (err)
1147 b61ceafc 2022-10-13 thomas goto done;
1148 b61ceafc 2022-10-13 thomas obj_type = obj->type;
1149 b61ceafc 2022-10-13 thomas got_object_close(obj);
1150 b61ceafc 2022-10-13 thomas if (obj_type != GOT_OBJ_TYPE_TAG) {
1151 b61ceafc 2022-10-13 thomas err = got_error(GOT_ERR_OBJ_TYPE);
1152 b61ceafc 2022-10-13 thomas goto done;
1154 b61ceafc 2022-10-13 thomas err = read_packed_tag_privsep(tag, pack, packidx, idx, id);
1155 b61ceafc 2022-10-13 thomas } else if (err->code == GOT_ERR_NO_OBJ) {
1158 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
1159 b61ceafc 2022-10-13 thomas if (err)
1160 b61ceafc 2022-10-13 thomas return err;
1161 b61ceafc 2022-10-13 thomas err = got_object_read_header_privsep(&obj, id, repo, fd);
1162 b61ceafc 2022-10-13 thomas if (err)
1163 b61ceafc 2022-10-13 thomas return err;
1164 b61ceafc 2022-10-13 thomas obj_type = obj->type;
1165 b61ceafc 2022-10-13 thomas got_object_close(obj);
1166 b61ceafc 2022-10-13 thomas if (obj_type != GOT_OBJ_TYPE_TAG)
1167 b61ceafc 2022-10-13 thomas return got_error(GOT_ERR_OBJ_TYPE);
1169 b61ceafc 2022-10-13 thomas err = got_object_open_loose_fd(&fd, id, repo);
1170 b61ceafc 2022-10-13 thomas if (err)
1171 b61ceafc 2022-10-13 thomas return err;
1172 b61ceafc 2022-10-13 thomas err = read_tag_privsep(tag, fd, id, repo);
1175 b61ceafc 2022-10-13 thomas if (err == NULL) {
1176 b61ceafc 2022-10-13 thomas (*tag)->refcnt++;
1177 b61ceafc 2022-10-13 thomas err = got_repo_cache_tag(repo, id, *tag);
1180 b61ceafc 2022-10-13 thomas free(path_packfile);
1181 b61ceafc 2022-10-13 thomas return err;
1184 b61ceafc 2022-10-13 thomas const struct got_error *
1185 b61ceafc 2022-10-13 thomas got_object_open_as_tag(struct got_tag_object **tag,
1186 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object_id *id)
1188 b61ceafc 2022-10-13 thomas *tag = got_repo_get_cached_tag(repo, id);
1189 b61ceafc 2022-10-13 thomas if (*tag != NULL) {
1190 b61ceafc 2022-10-13 thomas (*tag)->refcnt++;
1191 b61ceafc 2022-10-13 thomas return NULL;
1194 b61ceafc 2022-10-13 thomas return open_tag(tag, repo, id, 0);
1197 b61ceafc 2022-10-13 thomas const struct got_error *
1198 b61ceafc 2022-10-13 thomas got_object_tag_open(struct got_tag_object **tag,
1199 b61ceafc 2022-10-13 thomas struct got_repository *repo, struct got_object *obj)
1201 b61ceafc 2022-10-13 thomas return open_tag(tag, repo, got_object_get_id(obj), 1);
1204 b61ceafc 2022-10-13 thomas const struct got_error *
1205 b61ceafc 2022-10-13 thomas got_traverse_packed_commits(struct got_object_id_queue *traversed_commits,
1206 b61ceafc 2022-10-13 thomas struct got_object_id *commit_id, const char *path,
1207 b61ceafc 2022-10-13 thomas struct got_repository *repo)
1209 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1210 b61ceafc 2022-10-13 thomas struct got_pack *pack = NULL;
1211 b61ceafc 2022-10-13 thomas struct got_packidx *packidx = NULL;
1212 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
1213 b61ceafc 2022-10-13 thomas struct got_commit_object *changed_commit = NULL;
1214 b61ceafc 2022-10-13 thomas struct got_object_id *changed_commit_id = NULL;
1215 b61ceafc 2022-10-13 thomas int idx;
1217 b61ceafc 2022-10-13 thomas err = got_repo_search_packidx(&packidx, &idx, repo, commit_id);
1218 b61ceafc 2022-10-13 thomas if (err) {
1219 b61ceafc 2022-10-13 thomas if (err->code != GOT_ERR_NO_OBJ)
1220 b61ceafc 2022-10-13 thomas return err;
1221 b61ceafc 2022-10-13 thomas return NULL;
1224 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
1225 b61ceafc 2022-10-13 thomas packidx->path_packidx);
1226 b61ceafc 2022-10-13 thomas if (err)
1227 b61ceafc 2022-10-13 thomas return err;
1229 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
1230 b61ceafc 2022-10-13 thomas if (pack == NULL) {
1231 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile, packidx);
1232 b61ceafc 2022-10-13 thomas if (err)
1233 b61ceafc 2022-10-13 thomas goto done;
1236 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
1237 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
1238 b61ceafc 2022-10-13 thomas if (err)
1239 b61ceafc 2022-10-13 thomas goto done;
1242 b61ceafc 2022-10-13 thomas err = got_privsep_send_commit_traversal_request(
1243 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf, commit_id, idx, path);
1244 b61ceafc 2022-10-13 thomas if (err)
1245 b61ceafc 2022-10-13 thomas goto done;
1247 b61ceafc 2022-10-13 thomas err = got_privsep_recv_traversed_commits(&changed_commit,
1248 b61ceafc 2022-10-13 thomas &changed_commit_id, traversed_commits, pack->privsep_child->ibuf);
1249 b61ceafc 2022-10-13 thomas if (err)
1250 b61ceafc 2022-10-13 thomas goto done;
1252 b61ceafc 2022-10-13 thomas if (changed_commit) {
1254 b61ceafc 2022-10-13 thomas * Cache the commit in which the path was changed.
1255 b61ceafc 2022-10-13 thomas * This commit might be opened again soon.
1257 b61ceafc 2022-10-13 thomas changed_commit->refcnt++;
1258 b61ceafc 2022-10-13 thomas err = got_repo_cache_commit(repo, changed_commit_id,
1259 b61ceafc 2022-10-13 thomas changed_commit);
1260 b61ceafc 2022-10-13 thomas got_object_commit_close(changed_commit);
1263 b61ceafc 2022-10-13 thomas free(path_packfile);
1264 b61ceafc 2022-10-13 thomas free(changed_commit_id);
1265 b61ceafc 2022-10-13 thomas return err;
1268 b61ceafc 2022-10-13 thomas const struct got_error *
1269 b61ceafc 2022-10-13 thomas got_object_enumerate(int *found_all_objects,
1270 b61ceafc 2022-10-13 thomas got_object_enumerate_commit_cb cb_commit,
1271 b61ceafc 2022-10-13 thomas got_object_enumerate_tree_cb cb_tree, void *cb_arg,
1272 b61ceafc 2022-10-13 thomas struct got_object_id **ours, int nours,
1273 b61ceafc 2022-10-13 thomas struct got_object_id **theirs, int ntheirs,
1274 b61ceafc 2022-10-13 thomas struct got_packidx *packidx, struct got_repository *repo)
1276 b61ceafc 2022-10-13 thomas const struct got_error *err = NULL;
1277 b61ceafc 2022-10-13 thomas struct got_pack *pack;
1278 b61ceafc 2022-10-13 thomas char *path_packfile = NULL;
1280 b61ceafc 2022-10-13 thomas err = got_packidx_get_packfile_path(&path_packfile,
1281 b61ceafc 2022-10-13 thomas packidx->path_packidx);
1282 b61ceafc 2022-10-13 thomas if (err)
1283 b61ceafc 2022-10-13 thomas return err;
1285 b61ceafc 2022-10-13 thomas pack = got_repo_get_cached_pack(repo, path_packfile);
1286 b61ceafc 2022-10-13 thomas if (pack == NULL) {
1287 b61ceafc 2022-10-13 thomas err = got_repo_cache_pack(&pack, repo, path_packfile, packidx);
1288 b61ceafc 2022-10-13 thomas if (err)
1289 b61ceafc 2022-10-13 thomas goto done;
1292 b61ceafc 2022-10-13 thomas if (pack->privsep_child == NULL) {
1293 b61ceafc 2022-10-13 thomas err = got_pack_start_privsep_child(pack, packidx);
1294 b61ceafc 2022-10-13 thomas if (err)
1295 b61ceafc 2022-10-13 thomas goto done;
1298 b61ceafc 2022-10-13 thomas err = got_privsep_send_object_enumeration_request(
1299 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf);
1300 b61ceafc 2022-10-13 thomas if (err)
1301 b61ceafc 2022-10-13 thomas goto done;
1303 b61ceafc 2022-10-13 thomas err = got_privsep_send_object_idlist(pack->privsep_child->ibuf,
1304 b61ceafc 2022-10-13 thomas ours, nours);
1305 b61ceafc 2022-10-13 thomas if (err)
1306 b61ceafc 2022-10-13 thomas goto done;
1307 b61ceafc 2022-10-13 thomas err = got_privsep_send_object_idlist_done(pack->privsep_child->ibuf);
1308 b61ceafc 2022-10-13 thomas if (err)
1309 b61ceafc 2022-10-13 thomas goto done;
1311 b61ceafc 2022-10-13 thomas err = got_privsep_send_object_idlist(pack->privsep_child->ibuf,
1312 b61ceafc 2022-10-13 thomas theirs, ntheirs);
1313 b61ceafc 2022-10-13 thomas if (err)
1314 b61ceafc 2022-10-13 thomas goto done;
1315 b61ceafc 2022-10-13 thomas err = got_privsep_send_object_idlist_done(pack->privsep_child->ibuf);
1316 b61ceafc 2022-10-13 thomas if (err)
1317 b61ceafc 2022-10-13 thomas goto done;
1319 b61ceafc 2022-10-13 thomas err = got_privsep_recv_enumerated_objects(found_all_objects,
1320 b61ceafc 2022-10-13 thomas pack->privsep_child->ibuf, cb_commit, cb_tree, cb_arg, repo);
1322 b61ceafc 2022-10-13 thomas free(path_packfile);
1323 b61ceafc 2022-10-13 thomas return err;