2 a440fac0 2018-09-06 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 a440fac0 2018-09-06 stsp * Permission to use, copy, modify, and distribute this software for any
5 a440fac0 2018-09-06 stsp * purpose with or without fee is hereby granted, provided that the above
6 a440fac0 2018-09-06 stsp * copyright notice and this permission notice appear in all copies.
8 a440fac0 2018-09-06 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 a440fac0 2018-09-06 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 a440fac0 2018-09-06 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 a440fac0 2018-09-06 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 a440fac0 2018-09-06 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 a440fac0 2018-09-06 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 a440fac0 2018-09-06 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 a440fac0 2018-09-06 stsp #include <sys/types.h>
18 a440fac0 2018-09-06 stsp #include <sys/stat.h>
19 a440fac0 2018-09-06 stsp #include <sys/queue.h>
20 a440fac0 2018-09-06 stsp #include <sys/uio.h>
21 a440fac0 2018-09-06 stsp #include <sys/socket.h>
22 876c234b 2018-09-10 stsp #include <sys/syslimits.h>
23 a440fac0 2018-09-06 stsp #include <sys/wait.h>
25 a440fac0 2018-09-06 stsp #include <errno.h>
26 a440fac0 2018-09-06 stsp #include <stdio.h>
27 a440fac0 2018-09-06 stsp #include <stdlib.h>
28 a440fac0 2018-09-06 stsp #include <string.h>
29 a440fac0 2018-09-06 stsp #include <stdint.h>
30 a440fac0 2018-09-06 stsp #include <sha1.h>
31 a440fac0 2018-09-06 stsp #include <zlib.h>
32 a440fac0 2018-09-06 stsp #include <ctype.h>
33 a440fac0 2018-09-06 stsp #include <limits.h>
34 a440fac0 2018-09-06 stsp #include <imsg.h>
35 a440fac0 2018-09-06 stsp #include <time.h>
36 ad242220 2018-09-08 stsp #include <unistd.h>
38 a440fac0 2018-09-06 stsp #include "got_error.h"
39 a440fac0 2018-09-06 stsp #include "got_object.h"
40 a440fac0 2018-09-06 stsp #include "got_repository.h"
41 a440fac0 2018-09-06 stsp #include "got_opentemp.h"
43 a440fac0 2018-09-06 stsp #include "got_lib_sha1.h"
44 a440fac0 2018-09-06 stsp #include "got_lib_delta.h"
45 ad242220 2018-09-08 stsp #include "got_lib_privsep.h"
46 a440fac0 2018-09-06 stsp #include "got_lib_pack.h"
47 a440fac0 2018-09-06 stsp #include "got_lib_inflate.h"
48 a440fac0 2018-09-06 stsp #include "got_lib_object.h"
49 ad242220 2018-09-08 stsp #include "got_lib_repository.h"
51 a440fac0 2018-09-06 stsp #ifndef nitems
52 a440fac0 2018-09-06 stsp #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
55 a440fac0 2018-09-06 stsp #define GOT_OBJ_TAG_COMMIT "commit"
56 a440fac0 2018-09-06 stsp #define GOT_OBJ_TAG_TREE "tree"
57 a440fac0 2018-09-06 stsp #define GOT_OBJ_TAG_BLOB "blob"
59 a440fac0 2018-09-06 stsp #define GOT_COMMIT_TAG_TREE "tree "
60 a440fac0 2018-09-06 stsp #define GOT_COMMIT_TAG_PARENT "parent "
61 a440fac0 2018-09-06 stsp #define GOT_COMMIT_TAG_AUTHOR "author "
62 a440fac0 2018-09-06 stsp #define GOT_COMMIT_TAG_COMMITTER "committer "
65 03fa71c8 2018-09-06 stsp got_object_close(struct got_object *obj)
67 03fa71c8 2018-09-06 stsp if (obj->refcnt > 0) {
68 03fa71c8 2018-09-06 stsp obj->refcnt--;
69 03fa71c8 2018-09-06 stsp if (obj->refcnt > 0)
73 03fa71c8 2018-09-06 stsp if (obj->flags & GOT_OBJ_FLAG_DELTIFIED) {
74 03fa71c8 2018-09-06 stsp struct got_delta *delta;
75 03fa71c8 2018-09-06 stsp while (!SIMPLEQ_EMPTY(&obj->deltas.entries)) {
76 03fa71c8 2018-09-06 stsp delta = SIMPLEQ_FIRST(&obj->deltas.entries);
77 03fa71c8 2018-09-06 stsp SIMPLEQ_REMOVE_HEAD(&obj->deltas.entries, entry);
78 03fa71c8 2018-09-06 stsp got_delta_close(delta);
81 03fa71c8 2018-09-06 stsp if (obj->flags & GOT_OBJ_FLAG_PACKED)
82 03fa71c8 2018-09-06 stsp free(obj->path_packfile);
87 03fa71c8 2018-09-06 stsp got_object_qid_free(struct got_object_qid *qid)
89 03fa71c8 2018-09-06 stsp free(qid->id);
93 a440fac0 2018-09-06 stsp static const struct got_error *
94 ad242220 2018-09-08 stsp request_object(struct got_object **obj, struct got_repository *repo, int fd)
96 ad242220 2018-09-08 stsp const struct got_error *err = NULL;
97 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
99 3516b818 2018-09-08 stsp ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].ibuf;
101 3516b818 2018-09-08 stsp err = got_privsep_send_obj_req(ibuf, fd, NULL);
103 3516b818 2018-09-08 stsp return err;
105 3516b818 2018-09-08 stsp return got_privsep_recv_obj(obj, ibuf);
108 a440fac0 2018-09-06 stsp static void
109 3cab8b4d 2018-09-08 stsp exec_privsep_child(int imsg_fds[2], const char *path, const char *repo_path)
111 a440fac0 2018-09-06 stsp close(imsg_fds[0]);
113 ad242220 2018-09-08 stsp if (dup2(imsg_fds[1], GOT_IMSG_FD_CHILD) == -1) {
114 ad242220 2018-09-08 stsp fprintf(stderr, "%s: %s\n", getprogname(),
115 ad242220 2018-09-08 stsp strerror(errno));
118 ad242220 2018-09-08 stsp if (closefrom(GOT_IMSG_FD_CHILD + 1) == -1) {
119 ad242220 2018-09-08 stsp fprintf(stderr, "%s: %s\n", getprogname(),
120 ad242220 2018-09-08 stsp strerror(errno));
124 3cab8b4d 2018-09-08 stsp if (execl(path, path, repo_path, (char *)NULL) == -1) {
125 ad242220 2018-09-08 stsp fprintf(stderr, "%s: %s: %s\n", getprogname(), path,
126 ad242220 2018-09-08 stsp strerror(errno));
131 a440fac0 2018-09-06 stsp const struct got_error *
132 ad242220 2018-09-08 stsp got_object_read_header_privsep(struct got_object **obj,
133 ad242220 2018-09-08 stsp struct got_repository *repo, int obj_fd)
135 a440fac0 2018-09-06 stsp int imsg_fds[2];
137 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
139 ad242220 2018-09-08 stsp if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd != -1)
140 ad242220 2018-09-08 stsp return request_object(obj, repo, obj_fd);
142 3516b818 2018-09-08 stsp ibuf = calloc(1, sizeof(*ibuf));
143 3516b818 2018-09-08 stsp if (ibuf == NULL)
144 3516b818 2018-09-08 stsp return got_error_from_errno();
146 a440fac0 2018-09-06 stsp if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
147 a440fac0 2018-09-06 stsp return got_error_from_errno();
149 a440fac0 2018-09-06 stsp pid = fork();
150 a440fac0 2018-09-06 stsp if (pid == -1)
151 a440fac0 2018-09-06 stsp return got_error_from_errno();
152 a440fac0 2018-09-06 stsp else if (pid == 0) {
153 3cab8b4d 2018-09-08 stsp exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_OBJECT,
154 3cab8b4d 2018-09-08 stsp repo->path);
155 a440fac0 2018-09-06 stsp /* not reached */
158 a440fac0 2018-09-06 stsp close(imsg_fds[1]);
159 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].imsg_fd =
160 ad242220 2018-09-08 stsp imsg_fds[0];
161 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].pid = pid;
162 3516b818 2018-09-08 stsp imsg_init(ibuf, imsg_fds[0]);
163 3516b818 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_OBJECT].ibuf = ibuf;
165 ad242220 2018-09-08 stsp return request_object(obj, repo, obj_fd);
168 876c234b 2018-09-10 stsp static const struct got_error *
169 876c234b 2018-09-10 stsp request_packed_object(struct got_object **obj, struct got_pack *pack, int idx,
170 876c234b 2018-09-10 stsp struct got_object_id *id)
172 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
173 876c234b 2018-09-10 stsp struct imsgbuf *ibuf = pack->privsep_child->ibuf;
175 876c234b 2018-09-10 stsp err = got_privsep_send_packed_obj_req(ibuf, idx);
177 876c234b 2018-09-10 stsp return err;
179 876c234b 2018-09-10 stsp err = got_privsep_recv_obj(obj, ibuf);
181 876c234b 2018-09-10 stsp return err;
183 876c234b 2018-09-10 stsp (*obj)->path_packfile = strdup(pack->path_packfile);
184 876c234b 2018-09-10 stsp if ((*obj)->path_packfile == NULL) {
185 876c234b 2018-09-10 stsp err = got_error_from_errno();
186 876c234b 2018-09-10 stsp return err;
188 876c234b 2018-09-10 stsp memcpy(&(*obj)->id, id, sizeof((*obj)->id));
190 876c234b 2018-09-10 stsp return NULL;
193 876c234b 2018-09-10 stsp const struct got_error *
194 876c234b 2018-09-10 stsp got_object_packed_read_privsep(struct got_object **obj,
195 876c234b 2018-09-10 stsp struct got_repository *repo, struct got_pack *pack,
196 876c234b 2018-09-10 stsp struct got_packidx *packidx, int idx, struct got_object_id *id)
198 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
199 876c234b 2018-09-10 stsp int imsg_fds[2];
201 876c234b 2018-09-10 stsp struct imsgbuf *ibuf;
203 876c234b 2018-09-10 stsp if (pack->privsep_child)
204 876c234b 2018-09-10 stsp return request_packed_object(obj, pack, idx, id);
206 876c234b 2018-09-10 stsp ibuf = calloc(1, sizeof(*ibuf));
207 876c234b 2018-09-10 stsp if (ibuf == NULL)
208 876c234b 2018-09-10 stsp return got_error_from_errno();
210 876c234b 2018-09-10 stsp pack->privsep_child = calloc(1, sizeof(*pack->privsep_child));
211 876c234b 2018-09-10 stsp if (pack->privsep_child == NULL) {
212 876c234b 2018-09-10 stsp err = got_error_from_errno();
213 876c234b 2018-09-10 stsp free(ibuf);
214 876c234b 2018-09-10 stsp return err;
217 876c234b 2018-09-10 stsp if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
218 876c234b 2018-09-10 stsp err = got_error_from_errno();
222 876c234b 2018-09-10 stsp pid = fork();
223 876c234b 2018-09-10 stsp if (pid == -1) {
224 876c234b 2018-09-10 stsp err = got_error_from_errno();
226 876c234b 2018-09-10 stsp } else if (pid == 0) {
227 876c234b 2018-09-10 stsp exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_PACK,
228 876c234b 2018-09-10 stsp pack->path_packfile);
229 876c234b 2018-09-10 stsp /* not reached */
232 876c234b 2018-09-10 stsp close(imsg_fds[1]);
233 876c234b 2018-09-10 stsp pack->privsep_child->imsg_fd = imsg_fds[0];
234 876c234b 2018-09-10 stsp pack->privsep_child->pid = pid;
235 876c234b 2018-09-10 stsp imsg_init(ibuf, imsg_fds[0]);
236 876c234b 2018-09-10 stsp pack->privsep_child->ibuf = ibuf;
238 876c234b 2018-09-10 stsp err = got_privsep_init_pack_child(ibuf, pack, packidx);
240 876c234b 2018-09-10 stsp const struct got_error *child_err;
241 876c234b 2018-09-10 stsp err = got_privsep_send_stop(pack->privsep_child->imsg_fd);
242 876c234b 2018-09-10 stsp child_err = got_privsep_wait_for_child(
243 876c234b 2018-09-10 stsp pack->privsep_child->pid);
244 876c234b 2018-09-10 stsp if (child_err && err == NULL)
245 876c234b 2018-09-10 stsp err = child_err;
246 876c234b 2018-09-10 stsp free(ibuf);
247 876c234b 2018-09-10 stsp free(pack->privsep_child);
248 876c234b 2018-09-10 stsp pack->privsep_child = NULL;
249 876c234b 2018-09-10 stsp return err;
254 876c234b 2018-09-10 stsp free(ibuf);
255 876c234b 2018-09-10 stsp free(pack->privsep_child);
256 876c234b 2018-09-10 stsp pack->privsep_child = NULL;
258 876c234b 2018-09-10 stsp err = request_packed_object(obj, pack, idx, id);
259 876c234b 2018-09-10 stsp return err;
262 a440fac0 2018-09-06 stsp struct got_commit_object *
263 a440fac0 2018-09-06 stsp got_object_commit_alloc_partial(void)
265 a440fac0 2018-09-06 stsp struct got_commit_object *commit;
267 a440fac0 2018-09-06 stsp commit = calloc(1, sizeof(*commit));
268 a440fac0 2018-09-06 stsp if (commit == NULL)
269 a440fac0 2018-09-06 stsp return NULL;
270 a440fac0 2018-09-06 stsp commit->tree_id = calloc(1, sizeof(*commit->tree_id));
271 a440fac0 2018-09-06 stsp if (commit->tree_id == NULL) {
272 a440fac0 2018-09-06 stsp free(commit);
273 a440fac0 2018-09-06 stsp return NULL;
276 a440fac0 2018-09-06 stsp SIMPLEQ_INIT(&commit->parent_ids);
278 a440fac0 2018-09-06 stsp return commit;
281 a440fac0 2018-09-06 stsp const struct got_error *
282 a440fac0 2018-09-06 stsp got_object_commit_add_parent(struct got_commit_object *commit,
283 a440fac0 2018-09-06 stsp const char *id_str)
285 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
286 a440fac0 2018-09-06 stsp struct got_object_qid *qid;
288 a440fac0 2018-09-06 stsp qid = malloc(sizeof(*qid));
289 a440fac0 2018-09-06 stsp if (qid == NULL)
290 a440fac0 2018-09-06 stsp return got_error_from_errno();
292 a440fac0 2018-09-06 stsp qid->id = malloc(sizeof(*qid->id));
293 a440fac0 2018-09-06 stsp if (qid->id == NULL) {
294 a440fac0 2018-09-06 stsp err = got_error_from_errno();
295 a440fac0 2018-09-06 stsp got_object_qid_free(qid);
296 a440fac0 2018-09-06 stsp return err;
299 a440fac0 2018-09-06 stsp if (!got_parse_sha1_digest(qid->id->sha1, id_str)) {
300 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
301 a440fac0 2018-09-06 stsp free(qid->id);
303 a440fac0 2018-09-06 stsp return err;
306 a440fac0 2018-09-06 stsp SIMPLEQ_INSERT_TAIL(&commit->parent_ids, qid, entry);
307 a440fac0 2018-09-06 stsp commit->nparents++;
309 a440fac0 2018-09-06 stsp return NULL;
312 a440fac0 2018-09-06 stsp static const struct got_error *
313 a440fac0 2018-09-06 stsp parse_gmtoff(time_t *gmtoff, const char *tzstr)
315 a440fac0 2018-09-06 stsp int sign = 1;
316 a440fac0 2018-09-06 stsp const char *p = tzstr;
317 a440fac0 2018-09-06 stsp time_t h, m;
319 a440fac0 2018-09-06 stsp *gmtoff = 0;
321 a440fac0 2018-09-06 stsp if (*p == '-')
323 a440fac0 2018-09-06 stsp else if (*p != '+')
324 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
326 a440fac0 2018-09-06 stsp if (!isdigit(*p) && !isdigit(*(p + 1)))
327 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
328 a440fac0 2018-09-06 stsp h = (((*p - '0') * 10) + (*(p + 1) - '0'));
331 a440fac0 2018-09-06 stsp if (!isdigit(*p) && !isdigit(*(p + 1)))
332 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
333 a440fac0 2018-09-06 stsp m = ((*p - '0') * 10) + (*(p + 1) - '0');
335 a440fac0 2018-09-06 stsp *gmtoff = (h * 60 * 60 + m * 60) * sign;
336 a440fac0 2018-09-06 stsp return NULL;
339 a440fac0 2018-09-06 stsp static const struct got_error *
340 a440fac0 2018-09-06 stsp parse_commit_time(struct tm *tm, char *committer)
342 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
343 a440fac0 2018-09-06 stsp const char *errstr;
344 a440fac0 2018-09-06 stsp char *space, *tzstr;
345 a440fac0 2018-09-06 stsp time_t gmtoff;
346 a440fac0 2018-09-06 stsp time_t time;
348 a440fac0 2018-09-06 stsp /* Parse and strip off trailing timezone indicator string. */
349 a440fac0 2018-09-06 stsp space = strrchr(committer, ' ');
350 a440fac0 2018-09-06 stsp if (space == NULL)
351 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
352 a440fac0 2018-09-06 stsp tzstr = strdup(space + 1);
353 a440fac0 2018-09-06 stsp if (tzstr == NULL)
354 a440fac0 2018-09-06 stsp return got_error_from_errno();
355 a440fac0 2018-09-06 stsp err = parse_gmtoff(&gmtoff, tzstr);
356 a440fac0 2018-09-06 stsp free(tzstr);
358 a440fac0 2018-09-06 stsp return err;
359 a440fac0 2018-09-06 stsp *space = '\0';
361 a440fac0 2018-09-06 stsp /* Timestamp is separated from committer name + email by space. */
362 a440fac0 2018-09-06 stsp space = strrchr(committer, ' ');
363 a440fac0 2018-09-06 stsp if (space == NULL)
364 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
366 a440fac0 2018-09-06 stsp /* Timestamp parsed here is expressed in comitter's local time. */
367 a440fac0 2018-09-06 stsp time = strtonum(space + 1, 0, INT64_MAX, &errstr);
368 a440fac0 2018-09-06 stsp if (errstr)
369 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
371 a440fac0 2018-09-06 stsp /* Express the time stamp in UTC. */
372 a440fac0 2018-09-06 stsp memset(tm, 0, sizeof(*tm));
373 a440fac0 2018-09-06 stsp time -= gmtoff;
374 a440fac0 2018-09-06 stsp if (localtime_r(&time, tm) == NULL)
375 a440fac0 2018-09-06 stsp return got_error_from_errno();
376 a440fac0 2018-09-06 stsp tm->tm_gmtoff = gmtoff;
378 a440fac0 2018-09-06 stsp /* Strip off parsed time information, leaving just author and email. */
379 a440fac0 2018-09-06 stsp *space = '\0';
381 a440fac0 2018-09-06 stsp return NULL;
385 03fa71c8 2018-09-06 stsp got_object_commit_close(struct got_commit_object *commit)
387 03fa71c8 2018-09-06 stsp struct got_object_qid *qid;
389 03fa71c8 2018-09-06 stsp if (commit->refcnt > 0) {
390 03fa71c8 2018-09-06 stsp commit->refcnt--;
391 03fa71c8 2018-09-06 stsp if (commit->refcnt > 0)
395 03fa71c8 2018-09-06 stsp while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
396 03fa71c8 2018-09-06 stsp qid = SIMPLEQ_FIRST(&commit->parent_ids);
397 03fa71c8 2018-09-06 stsp SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
398 03fa71c8 2018-09-06 stsp got_object_qid_free(qid);
401 03fa71c8 2018-09-06 stsp free(commit->tree_id);
402 03fa71c8 2018-09-06 stsp free(commit->author);
403 03fa71c8 2018-09-06 stsp free(commit->committer);
404 03fa71c8 2018-09-06 stsp free(commit->logmsg);
405 03fa71c8 2018-09-06 stsp free(commit);
408 a440fac0 2018-09-06 stsp const struct got_error *
409 a440fac0 2018-09-06 stsp got_object_parse_commit(struct got_commit_object **commit, char *buf, size_t len)
411 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
412 a440fac0 2018-09-06 stsp char *s = buf;
413 a440fac0 2018-09-06 stsp size_t tlen;
414 a440fac0 2018-09-06 stsp ssize_t remain = (ssize_t)len;
416 a440fac0 2018-09-06 stsp *commit = got_object_commit_alloc_partial();
417 a440fac0 2018-09-06 stsp if (*commit == NULL)
418 a440fac0 2018-09-06 stsp return got_error_from_errno();
420 a440fac0 2018-09-06 stsp tlen = strlen(GOT_COMMIT_TAG_TREE);
421 a440fac0 2018-09-06 stsp if (strncmp(s, GOT_COMMIT_TAG_TREE, tlen) == 0) {
422 a440fac0 2018-09-06 stsp remain -= tlen;
423 a440fac0 2018-09-06 stsp if (remain < SHA1_DIGEST_STRING_LENGTH) {
424 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
428 a440fac0 2018-09-06 stsp if (!got_parse_sha1_digest((*commit)->tree_id->sha1, s)) {
429 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
432 a440fac0 2018-09-06 stsp remain -= SHA1_DIGEST_STRING_LENGTH;
433 a440fac0 2018-09-06 stsp s += SHA1_DIGEST_STRING_LENGTH;
435 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
439 a440fac0 2018-09-06 stsp tlen = strlen(GOT_COMMIT_TAG_PARENT);
440 a440fac0 2018-09-06 stsp while (strncmp(s, GOT_COMMIT_TAG_PARENT, tlen) == 0) {
441 a440fac0 2018-09-06 stsp remain -= tlen;
442 a440fac0 2018-09-06 stsp if (remain < SHA1_DIGEST_STRING_LENGTH) {
443 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
447 a440fac0 2018-09-06 stsp err = got_object_commit_add_parent(*commit, s);
451 a440fac0 2018-09-06 stsp remain -= SHA1_DIGEST_STRING_LENGTH;
452 a440fac0 2018-09-06 stsp s += SHA1_DIGEST_STRING_LENGTH;
455 a440fac0 2018-09-06 stsp tlen = strlen(GOT_COMMIT_TAG_AUTHOR);
456 a440fac0 2018-09-06 stsp if (strncmp(s, GOT_COMMIT_TAG_AUTHOR, tlen) == 0) {
458 a440fac0 2018-09-06 stsp size_t slen;
460 a440fac0 2018-09-06 stsp remain -= tlen;
461 a440fac0 2018-09-06 stsp if (remain <= 0) {
462 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
466 a440fac0 2018-09-06 stsp p = strchr(s, '\n');
467 a440fac0 2018-09-06 stsp if (p == NULL) {
468 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
472 a440fac0 2018-09-06 stsp slen = strlen(s);
473 a440fac0 2018-09-06 stsp err = parse_commit_time(&(*commit)->tm_author, s);
476 a440fac0 2018-09-06 stsp (*commit)->author = strdup(s);
477 a440fac0 2018-09-06 stsp if ((*commit)->author == NULL) {
478 a440fac0 2018-09-06 stsp err = got_error_from_errno();
481 a440fac0 2018-09-06 stsp s += slen + 1;
482 a440fac0 2018-09-06 stsp remain -= slen + 1;
485 a440fac0 2018-09-06 stsp tlen = strlen(GOT_COMMIT_TAG_COMMITTER);
486 a440fac0 2018-09-06 stsp if (strncmp(s, GOT_COMMIT_TAG_COMMITTER, tlen) == 0) {
488 a440fac0 2018-09-06 stsp size_t slen;
490 a440fac0 2018-09-06 stsp remain -= tlen;
491 a440fac0 2018-09-06 stsp if (remain <= 0) {
492 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
496 a440fac0 2018-09-06 stsp p = strchr(s, '\n');
497 a440fac0 2018-09-06 stsp if (p == NULL) {
498 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
502 a440fac0 2018-09-06 stsp slen = strlen(s);
503 a440fac0 2018-09-06 stsp err = parse_commit_time(&(*commit)->tm_committer, s);
506 a440fac0 2018-09-06 stsp (*commit)->committer = strdup(s);
507 a440fac0 2018-09-06 stsp if ((*commit)->committer == NULL) {
508 a440fac0 2018-09-06 stsp err = got_error_from_errno();
511 a440fac0 2018-09-06 stsp s += slen + 1;
512 a440fac0 2018-09-06 stsp remain -= slen + 1;
515 a440fac0 2018-09-06 stsp (*commit)->logmsg = strndup(s, remain);
516 a440fac0 2018-09-06 stsp if ((*commit)->logmsg == NULL) {
517 a440fac0 2018-09-06 stsp err = got_error_from_errno();
522 a440fac0 2018-09-06 stsp got_object_commit_close(*commit);
523 a440fac0 2018-09-06 stsp *commit = NULL;
525 a440fac0 2018-09-06 stsp return err;
529 ad242220 2018-09-08 stsp got_object_tree_entry_close(struct got_tree_entry *te)
531 a440fac0 2018-09-06 stsp free(te->id);
532 a440fac0 2018-09-06 stsp free(te->name);
537 03fa71c8 2018-09-06 stsp got_object_tree_close(struct got_tree_object *tree)
539 03fa71c8 2018-09-06 stsp struct got_tree_entry *te;
541 03fa71c8 2018-09-06 stsp if (tree->refcnt > 0) {
542 03fa71c8 2018-09-06 stsp tree->refcnt--;
543 03fa71c8 2018-09-06 stsp if (tree->refcnt > 0)
547 03fa71c8 2018-09-06 stsp while (!SIMPLEQ_EMPTY(&tree->entries.head)) {
548 03fa71c8 2018-09-06 stsp te = SIMPLEQ_FIRST(&tree->entries.head);
549 03fa71c8 2018-09-06 stsp SIMPLEQ_REMOVE_HEAD(&tree->entries.head, entry);
550 ad242220 2018-09-08 stsp got_object_tree_entry_close(te);
553 03fa71c8 2018-09-06 stsp free(tree);
556 a440fac0 2018-09-06 stsp struct got_tree_entry *
557 a440fac0 2018-09-06 stsp got_alloc_tree_entry_partial(void)
559 a440fac0 2018-09-06 stsp struct got_tree_entry *te;
561 a440fac0 2018-09-06 stsp te = calloc(1, sizeof(*te));
562 a440fac0 2018-09-06 stsp if (te == NULL)
563 a440fac0 2018-09-06 stsp return NULL;
565 a440fac0 2018-09-06 stsp te->id = calloc(1, sizeof(*te->id));
566 a440fac0 2018-09-06 stsp if (te->id == NULL) {
573 a440fac0 2018-09-06 stsp static const struct got_error *
574 a440fac0 2018-09-06 stsp parse_tree_entry(struct got_tree_entry **te, size_t *elen, char *buf,
575 a440fac0 2018-09-06 stsp size_t maxlen)
577 a440fac0 2018-09-06 stsp char *p = buf, *space;
578 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
580 a440fac0 2018-09-06 stsp *te = got_alloc_tree_entry_partial();
581 a440fac0 2018-09-06 stsp if (*te == NULL)
582 a440fac0 2018-09-06 stsp return got_error_from_errno();
584 a440fac0 2018-09-06 stsp *elen = strlen(buf) + 1;
585 a440fac0 2018-09-06 stsp if (*elen > maxlen) {
587 a440fac0 2018-09-06 stsp *te = NULL;
588 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
591 a440fac0 2018-09-06 stsp space = strchr(buf, ' ');
592 a440fac0 2018-09-06 stsp if (space == NULL) {
593 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
595 a440fac0 2018-09-06 stsp *te = NULL;
596 a440fac0 2018-09-06 stsp return err;
598 a440fac0 2018-09-06 stsp while (*p != ' ') {
599 a440fac0 2018-09-06 stsp if (*p < '0' && *p > '7') {
600 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
603 a440fac0 2018-09-06 stsp (*te)->mode <<= 3;
604 a440fac0 2018-09-06 stsp (*te)->mode |= *p - '0';
608 a440fac0 2018-09-06 stsp (*te)->name = strdup(space + 1);
609 a440fac0 2018-09-06 stsp if (*elen > maxlen || maxlen - *elen < SHA1_DIGEST_LENGTH) {
610 a440fac0 2018-09-06 stsp err = got_error(GOT_ERR_BAD_OBJ_DATA);
613 a440fac0 2018-09-06 stsp buf += strlen(buf) + 1;
614 a440fac0 2018-09-06 stsp memcpy((*te)->id->sha1, buf, SHA1_DIGEST_LENGTH);
615 a440fac0 2018-09-06 stsp *elen += SHA1_DIGEST_LENGTH;
618 ad242220 2018-09-08 stsp got_object_tree_entry_close(*te);
619 a440fac0 2018-09-06 stsp *te = NULL;
621 a440fac0 2018-09-06 stsp return err;
624 a440fac0 2018-09-06 stsp const struct got_error *
625 a440fac0 2018-09-06 stsp got_object_parse_tree(struct got_tree_object **tree, uint8_t *buf, size_t len)
627 a440fac0 2018-09-06 stsp const struct got_error *err;
628 a440fac0 2018-09-06 stsp size_t remain = len;
630 a440fac0 2018-09-06 stsp *tree = calloc(1, sizeof(**tree));
631 a440fac0 2018-09-06 stsp if (*tree == NULL)
632 a440fac0 2018-09-06 stsp return got_error_from_errno();
634 a440fac0 2018-09-06 stsp SIMPLEQ_INIT(&(*tree)->entries.head);
636 a440fac0 2018-09-06 stsp while (remain > 0) {
637 a440fac0 2018-09-06 stsp struct got_tree_entry *te;
638 a440fac0 2018-09-06 stsp size_t elen;
640 a440fac0 2018-09-06 stsp err = parse_tree_entry(&te, &elen, buf, remain);
642 a440fac0 2018-09-06 stsp return err;
643 a440fac0 2018-09-06 stsp (*tree)->entries.nentries++;
644 a440fac0 2018-09-06 stsp SIMPLEQ_INSERT_TAIL(&(*tree)->entries.head, te, entry);
645 a440fac0 2018-09-06 stsp buf += elen;
646 a440fac0 2018-09-06 stsp remain -= elen;
649 a440fac0 2018-09-06 stsp if (remain != 0) {
650 a440fac0 2018-09-06 stsp got_object_tree_close(*tree);
651 a440fac0 2018-09-06 stsp return got_error(GOT_ERR_BAD_OBJ_DATA);
654 a440fac0 2018-09-06 stsp return NULL;
657 ad242220 2018-09-08 stsp const struct got_error *
658 ad242220 2018-09-08 stsp got_read_file_to_mem(uint8_t **outbuf, size_t *outlen, FILE *f)
660 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
661 a440fac0 2018-09-06 stsp static const size_t blocksize = 512;
662 a440fac0 2018-09-06 stsp size_t n, total, remain;
663 a440fac0 2018-09-06 stsp uint8_t *buf;
665 a440fac0 2018-09-06 stsp *outbuf = NULL;
666 a440fac0 2018-09-06 stsp *outlen = 0;
668 a440fac0 2018-09-06 stsp buf = malloc(blocksize);
669 a440fac0 2018-09-06 stsp if (buf == NULL)
670 a440fac0 2018-09-06 stsp return got_error_from_errno();
672 a440fac0 2018-09-06 stsp remain = blocksize;
674 a440fac0 2018-09-06 stsp while (1) {
675 a440fac0 2018-09-06 stsp if (remain == 0) {
676 a440fac0 2018-09-06 stsp uint8_t *newbuf;
677 a440fac0 2018-09-06 stsp newbuf = reallocarray(buf, 1, total + blocksize);
678 a440fac0 2018-09-06 stsp if (newbuf == NULL) {
679 a440fac0 2018-09-06 stsp err = got_error_from_errno();
682 a440fac0 2018-09-06 stsp buf = newbuf;
683 a440fac0 2018-09-06 stsp remain += blocksize;
685 a440fac0 2018-09-06 stsp n = fread(buf + total, 1, remain, f);
686 a440fac0 2018-09-06 stsp if (n == 0) {
687 a440fac0 2018-09-06 stsp if (ferror(f)) {
688 a440fac0 2018-09-06 stsp err = got_ferror(f, GOT_ERR_IO);
691 a440fac0 2018-09-06 stsp break; /* EOF */
693 a440fac0 2018-09-06 stsp remain -= n;
694 a440fac0 2018-09-06 stsp total += n;
698 a440fac0 2018-09-06 stsp if (err == NULL) {
699 a440fac0 2018-09-06 stsp *outbuf = buf;
700 a440fac0 2018-09-06 stsp *outlen = total;
703 a440fac0 2018-09-06 stsp return err;
706 a440fac0 2018-09-06 stsp static const struct got_error *
707 ad242220 2018-09-08 stsp request_commit(struct got_commit_object **commit, struct got_repository *repo,
708 ad242220 2018-09-08 stsp struct got_object *obj, int fd)
710 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
711 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
713 3516b818 2018-09-08 stsp ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].ibuf;
715 cfd633c2 2018-09-10 stsp err = got_privsep_send_obj_req(ibuf, fd, obj);
717 3516b818 2018-09-08 stsp return err;
719 3516b818 2018-09-08 stsp return got_privsep_recv_commit(commit, ibuf);
722 a440fac0 2018-09-06 stsp const struct got_error *
723 cfd633c2 2018-09-10 stsp got_object_read_packed_commit_privsep(struct got_commit_object **commit,
724 cfd633c2 2018-09-10 stsp struct got_object *obj, struct got_pack *pack)
726 cfd633c2 2018-09-10 stsp const struct got_error *err = NULL;
728 cfd633c2 2018-09-10 stsp err = got_privsep_send_obj_req(pack->privsep_child->ibuf, -1, obj);
730 cfd633c2 2018-09-10 stsp return err;
732 cfd633c2 2018-09-10 stsp return got_privsep_recv_commit(commit, pack->privsep_child->ibuf);
735 cfd633c2 2018-09-10 stsp const struct got_error *
736 a440fac0 2018-09-06 stsp got_object_read_commit_privsep(struct got_commit_object **commit,
737 ad242220 2018-09-08 stsp struct got_object *obj, int obj_fd, struct got_repository *repo)
739 a440fac0 2018-09-06 stsp int imsg_fds[2];
741 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
743 ad242220 2018-09-08 stsp if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd != -1)
744 ad242220 2018-09-08 stsp return request_commit(commit, repo, obj, obj_fd);
746 3516b818 2018-09-08 stsp ibuf = calloc(1, sizeof(*ibuf));
747 3516b818 2018-09-08 stsp if (ibuf == NULL)
748 3516b818 2018-09-08 stsp return got_error_from_errno();
750 a440fac0 2018-09-06 stsp if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
751 a440fac0 2018-09-06 stsp return got_error_from_errno();
753 a440fac0 2018-09-06 stsp pid = fork();
754 a440fac0 2018-09-06 stsp if (pid == -1)
755 a440fac0 2018-09-06 stsp return got_error_from_errno();
756 a440fac0 2018-09-06 stsp else if (pid == 0) {
757 3cab8b4d 2018-09-08 stsp exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_COMMIT,
758 3cab8b4d 2018-09-08 stsp repo->path);
759 a440fac0 2018-09-06 stsp /* not reached */
762 a440fac0 2018-09-06 stsp close(imsg_fds[1]);
763 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd =
764 ad242220 2018-09-08 stsp imsg_fds[0];
765 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].pid = pid;
766 3516b818 2018-09-08 stsp imsg_init(ibuf, imsg_fds[0]);
767 3516b818 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].ibuf = ibuf;
769 ad242220 2018-09-08 stsp return request_commit(commit, repo, obj, obj_fd);
772 a440fac0 2018-09-06 stsp static const struct got_error *
773 ad242220 2018-09-08 stsp request_tree(struct got_tree_object **tree, struct got_repository *repo,
774 ad242220 2018-09-08 stsp struct got_object *obj, int fd)
776 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
777 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
779 3516b818 2018-09-08 stsp ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].ibuf;
781 cfd633c2 2018-09-10 stsp err = got_privsep_send_obj_req(ibuf, fd, obj);
783 3516b818 2018-09-08 stsp return err;
785 3516b818 2018-09-08 stsp return got_privsep_recv_tree(tree, ibuf);
788 a440fac0 2018-09-06 stsp const struct got_error *
789 a440fac0 2018-09-06 stsp got_object_read_tree_privsep(struct got_tree_object **tree,
790 ad242220 2018-09-08 stsp struct got_object *obj, int obj_fd, struct got_repository *repo)
792 a440fac0 2018-09-06 stsp int imsg_fds[2];
794 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
796 ad242220 2018-09-08 stsp if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].imsg_fd != -1)
797 ad242220 2018-09-08 stsp return request_tree(tree, repo, obj, obj_fd);
799 3516b818 2018-09-08 stsp ibuf = calloc(1, sizeof(*ibuf));
800 3516b818 2018-09-08 stsp if (ibuf == NULL)
801 3516b818 2018-09-08 stsp return got_error_from_errno();
803 a440fac0 2018-09-06 stsp if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
804 a440fac0 2018-09-06 stsp return got_error_from_errno();
806 a440fac0 2018-09-06 stsp pid = fork();
807 a440fac0 2018-09-06 stsp if (pid == -1)
808 a440fac0 2018-09-06 stsp return got_error_from_errno();
809 a440fac0 2018-09-06 stsp else if (pid == 0) {
810 3cab8b4d 2018-09-08 stsp exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_TREE,
811 3cab8b4d 2018-09-08 stsp repo->path);
812 a440fac0 2018-09-06 stsp /* not reached */
815 a440fac0 2018-09-06 stsp close(imsg_fds[1]);
817 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].imsg_fd =
818 ad242220 2018-09-08 stsp imsg_fds[0];
819 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].pid = pid;
820 3516b818 2018-09-08 stsp imsg_init(ibuf, imsg_fds[0]);
821 3516b818 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_TREE].ibuf = ibuf;
824 ad242220 2018-09-08 stsp return request_tree(tree, repo, obj, obj_fd);
827 e7885405 2018-09-10 stsp const struct got_error *
828 e7885405 2018-09-10 stsp got_object_read_packed_tree_privsep(struct got_tree_object **tree,
829 e7885405 2018-09-10 stsp struct got_object *obj, struct got_pack *pack)
831 e7885405 2018-09-10 stsp const struct got_error *err = NULL;
833 e7885405 2018-09-10 stsp err = got_privsep_send_obj_req(pack->privsep_child->ibuf, -1, obj);
835 e7885405 2018-09-10 stsp return err;
837 e7885405 2018-09-10 stsp return got_privsep_recv_tree(tree, pack->privsep_child->ibuf);
840 55da3778 2018-09-10 stsp const struct got_error *
841 55da3778 2018-09-10 stsp got_object_read_packed_blob_privsep(size_t *size, int outfd,
842 55da3778 2018-09-10 stsp struct got_object *obj, struct got_pack *pack)
844 a440fac0 2018-09-06 stsp const struct got_error *err = NULL;
845 ad242220 2018-09-08 stsp int outfd_child;
847 ad242220 2018-09-08 stsp outfd_child = dup(outfd);
848 ad242220 2018-09-08 stsp if (outfd_child == -1)
849 ad242220 2018-09-08 stsp return got_error_from_errno();
851 55da3778 2018-09-10 stsp err = got_privsep_send_obj_req(pack->privsep_child->ibuf, -1, obj);
853 55da3778 2018-09-10 stsp return err;
855 55da3778 2018-09-10 stsp err = got_privsep_send_blob_outfd(pack->privsep_child->ibuf,
856 55da3778 2018-09-10 stsp outfd_child);
858 55da3778 2018-09-10 stsp close(outfd_child);
859 55da3778 2018-09-10 stsp return err;
862 55da3778 2018-09-10 stsp err = got_privsep_recv_blob(size, pack->privsep_child->ibuf);
864 3516b818 2018-09-08 stsp return err;
866 55da3778 2018-09-10 stsp if (lseek(outfd, SEEK_SET, 0) == -1)
867 55da3778 2018-09-10 stsp err = got_error_from_errno();
869 55da3778 2018-09-10 stsp return err;
872 55da3778 2018-09-10 stsp static const struct got_error *
873 55da3778 2018-09-10 stsp request_blob(size_t *size, int outfd, int infd, struct imsgbuf *ibuf)
875 55da3778 2018-09-10 stsp const struct got_error *err = NULL;
876 55da3778 2018-09-10 stsp int outfd_child;
878 55da3778 2018-09-10 stsp outfd_child = dup(outfd);
879 55da3778 2018-09-10 stsp if (outfd_child == -1)
880 55da3778 2018-09-10 stsp return got_error_from_errno();
882 55da3778 2018-09-10 stsp err = got_privsep_send_blob_req(ibuf, infd);
884 55da3778 2018-09-10 stsp return err;
886 55da3778 2018-09-10 stsp err = got_privsep_send_blob_outfd(ibuf, outfd_child);
888 55da3778 2018-09-10 stsp close(outfd_child);
889 55da3778 2018-09-10 stsp return err;
892 3516b818 2018-09-08 stsp err = got_privsep_recv_blob(size, ibuf);
894 3516b818 2018-09-08 stsp return err;
896 ad242220 2018-09-08 stsp if (lseek(outfd, SEEK_SET, 0) == -1)
897 3516b818 2018-09-08 stsp return got_error_from_errno();
899 ad242220 2018-09-08 stsp return err;
902 a440fac0 2018-09-06 stsp const struct got_error *
903 ad242220 2018-09-08 stsp got_object_read_blob_privsep(size_t *size, int outfd, int infd,
904 ad242220 2018-09-08 stsp struct got_repository *repo)
906 a440fac0 2018-09-06 stsp int imsg_fds[2];
908 3516b818 2018-09-08 stsp struct imsgbuf *ibuf;
910 55da3778 2018-09-10 stsp if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].imsg_fd != -1) {
911 55da3778 2018-09-10 stsp ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].ibuf;
912 55da3778 2018-09-10 stsp return request_blob(size, outfd, infd, ibuf);
915 3516b818 2018-09-08 stsp ibuf = calloc(1, sizeof(*ibuf));
916 3516b818 2018-09-08 stsp if (ibuf == NULL)
917 3516b818 2018-09-08 stsp return got_error_from_errno();
919 a440fac0 2018-09-06 stsp if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
920 a440fac0 2018-09-06 stsp return got_error_from_errno();
922 a440fac0 2018-09-06 stsp pid = fork();
923 a440fac0 2018-09-06 stsp if (pid == -1)
924 a440fac0 2018-09-06 stsp return got_error_from_errno();
925 a440fac0 2018-09-06 stsp else if (pid == 0) {
926 3cab8b4d 2018-09-08 stsp exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_BLOB,
927 3cab8b4d 2018-09-08 stsp repo->path);
928 a440fac0 2018-09-06 stsp /* not reached */
931 a440fac0 2018-09-06 stsp close(imsg_fds[1]);
932 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].imsg_fd =
933 ad242220 2018-09-08 stsp imsg_fds[0];
934 ad242220 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].pid = pid;
935 3516b818 2018-09-08 stsp imsg_init(ibuf, imsg_fds[0]);
936 3516b818 2018-09-08 stsp repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_BLOB].ibuf = ibuf;
938 55da3778 2018-09-10 stsp return request_blob(size, outfd, infd, ibuf);