2 876c234b 2018-09-10 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
4 876c234b 2018-09-10 stsp * Permission to use, copy, modify, and distribute this software for any
5 876c234b 2018-09-10 stsp * purpose with or without fee is hereby granted, provided that the above
6 876c234b 2018-09-10 stsp * copyright notice and this permission notice appear in all copies.
8 876c234b 2018-09-10 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 876c234b 2018-09-10 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 876c234b 2018-09-10 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 876c234b 2018-09-10 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 876c234b 2018-09-10 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 876c234b 2018-09-10 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 876c234b 2018-09-10 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 876c234b 2018-09-10 stsp #include <sys/types.h>
18 876c234b 2018-09-10 stsp #include <sys/queue.h>
19 876c234b 2018-09-10 stsp #include <sys/uio.h>
20 876c234b 2018-09-10 stsp #include <sys/time.h>
21 876c234b 2018-09-10 stsp #include <sys/limits.h>
22 876c234b 2018-09-10 stsp #include <sys/syslimits.h>
23 876c234b 2018-09-10 stsp #include <sys/mman.h>
25 876c234b 2018-09-10 stsp #include <limits.h>
26 876c234b 2018-09-10 stsp #include <stdint.h>
27 876c234b 2018-09-10 stsp #include <imsg.h>
28 876c234b 2018-09-10 stsp #include <stdio.h>
29 876c234b 2018-09-10 stsp #include <stdlib.h>
30 876c234b 2018-09-10 stsp #include <string.h>
31 876c234b 2018-09-10 stsp #include <sha1.h>
32 876c234b 2018-09-10 stsp #include <zlib.h>
34 876c234b 2018-09-10 stsp #include "got_error.h"
35 876c234b 2018-09-10 stsp #include "got_object.h"
37 876c234b 2018-09-10 stsp #include "got_lib_delta.h"
38 876c234b 2018-09-10 stsp #include "got_lib_inflate.h"
39 876c234b 2018-09-10 stsp #include "got_lib_object.h"
40 c59b3346 2018-09-11 stsp #include "got_lib_object_cache.h"
41 876c234b 2018-09-10 stsp #include "got_lib_object_parse.h"
42 876c234b 2018-09-10 stsp #include "got_lib_privsep.h"
43 876c234b 2018-09-10 stsp #include "got_lib_pack.h"
45 876c234b 2018-09-10 stsp static const struct got_error *
46 876c234b 2018-09-10 stsp object_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
47 c59b3346 2018-09-11 stsp struct got_packidx *packidx, struct got_object_cache *objcache)
49 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
50 876c234b 2018-09-10 stsp struct got_imsg_packed_object iobj;
51 876c234b 2018-09-10 stsp struct got_object *obj;
52 876c234b 2018-09-10 stsp size_t datalen;
54 876c234b 2018-09-10 stsp datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
55 876c234b 2018-09-10 stsp if (datalen != sizeof(iobj))
56 876c234b 2018-09-10 stsp return got_error(GOT_ERR_PRIVSEP_LEN);
57 876c234b 2018-09-10 stsp memcpy(&iobj, imsg->data, sizeof(iobj));
59 876c234b 2018-09-10 stsp err = got_packfile_open_object(&obj, pack, packidx, iobj.idx, NULL);
62 c59b3346 2018-09-11 stsp obj->refcnt++;
64 c59b3346 2018-09-11 stsp err = got_object_cache_add(objcache, &obj->id, obj);
67 c59b3346 2018-09-11 stsp obj->refcnt++;
69 876c234b 2018-09-10 stsp err = got_privsep_send_obj(ibuf, obj);
71 876c234b 2018-09-10 stsp got_object_close(obj);
75 876c234b 2018-09-10 stsp static const struct got_error *
76 c59b3346 2018-09-11 stsp get_object(struct got_object **obj, struct imsg *imsg, struct imsgbuf *ibuf,
77 c59b3346 2018-09-11 stsp struct got_pack *pack, struct got_packidx *packidx,
78 c59b3346 2018-09-11 stsp struct got_object_cache *objcache, int type)
80 c59b3346 2018-09-11 stsp const struct got_error *err = NULL;
81 c59b3346 2018-09-11 stsp struct got_object *iobj;
83 c59b3346 2018-09-11 stsp err = got_privsep_get_imsg_obj(&iobj, imsg, ibuf);
87 c59b3346 2018-09-11 stsp if (iobj->type != type) {
88 c59b3346 2018-09-11 stsp err = got_error(GOT_ERR_OBJ_TYPE);
92 c59b3346 2018-09-11 stsp if ((iobj->flags & GOT_OBJ_FLAG_PACKED) == 0)
93 c59b3346 2018-09-11 stsp return got_error(GOT_ERR_OBJ_NOT_PACKED);
95 c59b3346 2018-09-11 stsp *obj = got_object_cache_get(objcache, &iobj->id);
96 c59b3346 2018-09-11 stsp if (*obj == NULL) {
97 c59b3346 2018-09-11 stsp err = got_packfile_open_object(obj, pack, packidx,
98 c59b3346 2018-09-11 stsp iobj->pack_idx, &iobj->id);
102 c59b3346 2018-09-11 stsp (*obj)->refcnt++;
104 c59b3346 2018-09-11 stsp got_object_close(iobj);
105 c59b3346 2018-09-11 stsp return err;
108 c59b3346 2018-09-11 stsp static const struct got_error *
109 876c234b 2018-09-10 stsp commit_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
110 c59b3346 2018-09-11 stsp struct got_packidx *packidx, struct got_object_cache *objcache)
112 cfd633c2 2018-09-10 stsp const struct got_error *err = NULL;
113 cfd633c2 2018-09-10 stsp struct got_object *obj = NULL;
114 cfd633c2 2018-09-10 stsp struct got_commit_object *commit = NULL;
115 cfd633c2 2018-09-10 stsp uint8_t *buf;
116 cfd633c2 2018-09-10 stsp size_t len;
118 c59b3346 2018-09-11 stsp err = get_object(&obj, imsg, ibuf, pack, packidx, objcache,
119 c59b3346 2018-09-11 stsp GOT_OBJ_TYPE_COMMIT);
121 cfd633c2 2018-09-10 stsp return err;
123 cfd633c2 2018-09-10 stsp err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
125 cfd633c2 2018-09-10 stsp return err;
127 cfd633c2 2018-09-10 stsp obj->size = len;
128 cfd633c2 2018-09-10 stsp err = got_object_parse_commit(&commit, buf, len);
131 cfd633c2 2018-09-10 stsp err = got_privsep_send_commit(ibuf, commit);
133 cfd633c2 2018-09-10 stsp got_object_close(obj);
134 cfd633c2 2018-09-10 stsp got_object_commit_close(commit);
136 cfd633c2 2018-09-10 stsp if (err->code == GOT_ERR_PRIVSEP_PIPE)
137 cfd633c2 2018-09-10 stsp err = NULL;
139 cfd633c2 2018-09-10 stsp got_privsep_send_error(ibuf, err);
142 cfd633c2 2018-09-10 stsp return err;
145 876c234b 2018-09-10 stsp static const struct got_error *
146 876c234b 2018-09-10 stsp tree_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
147 c59b3346 2018-09-11 stsp struct got_packidx *packidx, struct got_object_cache *objcache)
149 e7885405 2018-09-10 stsp const struct got_error *err = NULL;
150 e7885405 2018-09-10 stsp struct got_object *obj = NULL;
151 e7885405 2018-09-10 stsp struct got_tree_object *tree = NULL;
152 e7885405 2018-09-10 stsp uint8_t *buf;
153 e7885405 2018-09-10 stsp size_t len;
155 c59b3346 2018-09-11 stsp err = get_object(&obj, imsg, ibuf, pack, packidx, objcache,
156 c59b3346 2018-09-11 stsp GOT_OBJ_TYPE_TREE);
158 e7885405 2018-09-10 stsp return err;
160 e7885405 2018-09-10 stsp err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
162 e7885405 2018-09-10 stsp return err;
164 e7885405 2018-09-10 stsp obj->size = len;
165 e7885405 2018-09-10 stsp err = got_object_parse_tree(&tree, buf, len);
168 e7885405 2018-09-10 stsp err = got_privsep_send_tree(ibuf, tree);
170 e7885405 2018-09-10 stsp got_object_close(obj);
171 e7885405 2018-09-10 stsp got_object_tree_close(tree);
173 e7885405 2018-09-10 stsp if (err->code == GOT_ERR_PRIVSEP_PIPE)
174 e7885405 2018-09-10 stsp err = NULL;
176 e7885405 2018-09-10 stsp got_privsep_send_error(ibuf, err);
179 e7885405 2018-09-10 stsp return err;
182 876c234b 2018-09-10 stsp static const struct got_error *
183 3840f4c9 2018-09-12 stsp receive_file(FILE **f, struct imsgbuf *ibuf, int imsg_code)
185 3840f4c9 2018-09-12 stsp const struct got_error *err;
186 3840f4c9 2018-09-12 stsp struct imsg imsg;
187 55da3778 2018-09-10 stsp size_t datalen;
189 3840f4c9 2018-09-12 stsp err = got_privsep_recv_imsg(&imsg, ibuf, 0);
191 55da3778 2018-09-10 stsp return err;
193 3840f4c9 2018-09-12 stsp if (imsg.hdr.type != imsg_code) {
194 55da3778 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_MSG);
198 3840f4c9 2018-09-12 stsp datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
199 55da3778 2018-09-10 stsp if (datalen != 0) {
200 55da3778 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_LEN);
203 3840f4c9 2018-09-12 stsp if (imsg.fd == -1) {
204 55da3778 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_NO_FD);
208 3840f4c9 2018-09-12 stsp *f = fdopen(imsg.fd, "w+");
209 3840f4c9 2018-09-12 stsp if (*f == NULL) {
210 3840f4c9 2018-09-12 stsp close(imsg.fd);
211 55da3778 2018-09-10 stsp err = got_error_from_errno();
215 3840f4c9 2018-09-12 stsp imsg_free(&imsg);
216 3840f4c9 2018-09-12 stsp return err;
219 3840f4c9 2018-09-12 stsp static const struct got_error *
220 3840f4c9 2018-09-12 stsp blob_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
221 3840f4c9 2018-09-12 stsp struct got_packidx *packidx, struct got_object_cache *objcache)
223 3840f4c9 2018-09-12 stsp const struct got_error *err = NULL;
224 3840f4c9 2018-09-12 stsp struct got_object *obj = NULL;
225 3840f4c9 2018-09-12 stsp FILE *outfile = NULL, *basefile = NULL, *accumfile = NULL;
227 3840f4c9 2018-09-12 stsp err = get_object(&obj, imsg, ibuf, pack, packidx, objcache,
228 3840f4c9 2018-09-12 stsp GOT_OBJ_TYPE_BLOB);
230 3840f4c9 2018-09-12 stsp return err;
232 3840f4c9 2018-09-12 stsp err = receive_file(&outfile, ibuf, GOT_IMSG_BLOB_OUTFD);
234 3840f4c9 2018-09-12 stsp return err;
235 3840f4c9 2018-09-12 stsp err = receive_file(&basefile, ibuf, GOT_IMSG_TMPFD);
237 3840f4c9 2018-09-12 stsp return err;
238 3840f4c9 2018-09-12 stsp err = receive_file(&accumfile, ibuf, GOT_IMSG_TMPFD);
240 3840f4c9 2018-09-12 stsp return err;
242 3840f4c9 2018-09-12 stsp err = got_packfile_extract_object(pack, obj, outfile, basefile,
243 3840f4c9 2018-09-12 stsp accumfile);
247 55da3778 2018-09-10 stsp err = got_privsep_send_blob(ibuf, obj->size);
249 3840f4c9 2018-09-12 stsp if (outfile)
250 3840f4c9 2018-09-12 stsp fclose(outfile);
251 3840f4c9 2018-09-12 stsp if (basefile)
252 3840f4c9 2018-09-12 stsp fclose(basefile);
253 3840f4c9 2018-09-12 stsp if (accumfile)
254 3840f4c9 2018-09-12 stsp fclose(accumfile);
256 c59b3346 2018-09-11 stsp got_object_close(obj);
257 3840f4c9 2018-09-12 stsp if (err && err->code != GOT_ERR_PRIVSEP_PIPE)
258 3840f4c9 2018-09-12 stsp got_privsep_send_error(ibuf, err);
260 55da3778 2018-09-10 stsp return err;
263 876c234b 2018-09-10 stsp static const struct got_error *
264 876c234b 2018-09-10 stsp receive_packidx(struct got_packidx **packidx, struct imsgbuf *ibuf)
266 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
267 876c234b 2018-09-10 stsp struct imsg imsg;
268 876c234b 2018-09-10 stsp struct got_imsg_packidx ipackidx;
269 876c234b 2018-09-10 stsp size_t datalen;
270 876c234b 2018-09-10 stsp struct got_packidx *p;
272 876c234b 2018-09-10 stsp *packidx = NULL;
274 876c234b 2018-09-10 stsp err = got_privsep_recv_imsg(&imsg, ibuf, 0);
276 876c234b 2018-09-10 stsp return err;
278 876c234b 2018-09-10 stsp p = calloc(1, sizeof(*p));
279 876c234b 2018-09-10 stsp if (p == NULL) {
280 876c234b 2018-09-10 stsp err = got_error_from_errno();
284 876c234b 2018-09-10 stsp if (imsg.hdr.type != GOT_IMSG_PACKIDX) {
285 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_MSG);
289 876c234b 2018-09-10 stsp if (imsg.fd == -1) {
290 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_NO_FD);
294 876c234b 2018-09-10 stsp datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
295 876c234b 2018-09-10 stsp if (datalen != sizeof(ipackidx)) {
296 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_LEN);
299 876c234b 2018-09-10 stsp memcpy(&ipackidx, imsg.data, sizeof(ipackidx));
301 876c234b 2018-09-10 stsp p->len = ipackidx.len;
302 876c234b 2018-09-10 stsp p->fd = dup(imsg.fd);
303 876c234b 2018-09-10 stsp if (p->fd == -1) {
304 56bef47a 2018-09-15 stsp err = got_error_from_errno();
307 56bef47a 2018-09-15 stsp if (lseek(p->fd, 0, SEEK_SET) == -1) {
308 876c234b 2018-09-10 stsp err = got_error_from_errno();
312 876c234b 2018-09-10 stsp #ifndef GOT_PACK_NO_MMAP
313 876c234b 2018-09-10 stsp p->map = mmap(NULL, p->len, PROT_READ, MAP_PRIVATE, p->fd, 0);
314 876c234b 2018-09-10 stsp if (p->map == MAP_FAILED)
315 876c234b 2018-09-10 stsp p->map = NULL; /* fall back to read(2) */
317 876c234b 2018-09-10 stsp err = got_packidx_init_hdr(p, 1);
320 876c234b 2018-09-10 stsp if (imsg.fd != -1)
321 876c234b 2018-09-10 stsp close(imsg.fd);
322 876c234b 2018-09-10 stsp got_packidx_close(p);
324 876c234b 2018-09-10 stsp *packidx = p;
325 876c234b 2018-09-10 stsp imsg_free(&imsg);
326 876c234b 2018-09-10 stsp return err;
329 876c234b 2018-09-10 stsp static const struct got_error *
330 876c234b 2018-09-10 stsp receive_pack(struct got_pack **packp, struct imsgbuf *ibuf)
332 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
333 876c234b 2018-09-10 stsp struct imsg imsg;
334 876c234b 2018-09-10 stsp struct got_imsg_pack ipack;
335 876c234b 2018-09-10 stsp size_t datalen;
336 876c234b 2018-09-10 stsp struct got_pack *pack;
338 876c234b 2018-09-10 stsp *packp = NULL;
340 876c234b 2018-09-10 stsp err = got_privsep_recv_imsg(&imsg, ibuf, 0);
342 876c234b 2018-09-10 stsp return err;
344 876c234b 2018-09-10 stsp pack = calloc(1, sizeof(*pack));
345 876c234b 2018-09-10 stsp if (pack == NULL) {
346 876c234b 2018-09-10 stsp err = got_error_from_errno();
350 876c234b 2018-09-10 stsp if (imsg.hdr.type != GOT_IMSG_PACK) {
351 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_MSG);
355 876c234b 2018-09-10 stsp if (imsg.fd == -1) {
356 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_NO_FD);
360 876c234b 2018-09-10 stsp datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
361 876c234b 2018-09-10 stsp if (datalen != sizeof(ipack)) {
362 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_LEN);
365 876c234b 2018-09-10 stsp memcpy(&ipack, imsg.data, sizeof(ipack));
367 876c234b 2018-09-10 stsp pack->filesize = ipack.filesize;
368 876c234b 2018-09-10 stsp pack->fd = dup(imsg.fd);
369 876c234b 2018-09-10 stsp if (pack->fd == -1) {
370 876c234b 2018-09-10 stsp err = got_error_from_errno();
373 56bef47a 2018-09-15 stsp if (lseek(pack->fd, 0, SEEK_SET) == -1) {
374 56bef47a 2018-09-15 stsp err = got_error_from_errno();
377 876c234b 2018-09-10 stsp pack->path_packfile = strdup(ipack.path_packfile);
378 876c234b 2018-09-10 stsp if (pack->path_packfile == NULL) {
379 876c234b 2018-09-10 stsp err = got_error_from_errno();
383 876c234b 2018-09-10 stsp #ifndef GOT_PACK_NO_MMAP
384 876c234b 2018-09-10 stsp pack->map = mmap(NULL, pack->filesize, PROT_READ, MAP_PRIVATE,
385 876c234b 2018-09-10 stsp pack->fd, 0);
386 876c234b 2018-09-10 stsp if (pack->map == MAP_FAILED)
387 876c234b 2018-09-10 stsp pack->map = NULL; /* fall back to read(2) */
391 876c234b 2018-09-10 stsp if (imsg.fd != -1)
392 876c234b 2018-09-10 stsp close(imsg.fd);
393 876c234b 2018-09-10 stsp free(pack);
395 876c234b 2018-09-10 stsp *packp = pack;
396 876c234b 2018-09-10 stsp imsg_free(&imsg);
397 876c234b 2018-09-10 stsp return err;
401 876c234b 2018-09-10 stsp main(int argc, char *argv[])
403 876c234b 2018-09-10 stsp const struct got_error *err = NULL;
404 876c234b 2018-09-10 stsp struct imsgbuf ibuf;
405 876c234b 2018-09-10 stsp struct imsg imsg;
406 c59b3346 2018-09-11 stsp struct got_packidx *packidx = NULL;
407 c59b3346 2018-09-11 stsp struct got_pack *pack = NULL;
408 c59b3346 2018-09-11 stsp struct got_object_cache objcache;
410 876c234b 2018-09-10 stsp //static int attached;
411 876c234b 2018-09-10 stsp //while (!attached) sleep(1);
413 876c234b 2018-09-10 stsp imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
415 c59b3346 2018-09-11 stsp err = got_object_cache_init(&objcache, GOT_OBJECT_CACHE_TYPE_OBJ);
417 c59b3346 2018-09-11 stsp err = got_error_from_errno();
418 c59b3346 2018-09-11 stsp got_privsep_send_error(&ibuf, err);
422 2ff12563 2018-09-15 stsp #ifndef PROFILE
423 876c234b 2018-09-10 stsp /* revoke access to most system calls */
424 876c234b 2018-09-10 stsp if (pledge("stdio recvfd", NULL) == -1) {
425 876c234b 2018-09-10 stsp err = got_error_from_errno();
426 876c234b 2018-09-10 stsp got_privsep_send_error(&ibuf, err);
431 876c234b 2018-09-10 stsp err = receive_packidx(&packidx, &ibuf);
433 876c234b 2018-09-10 stsp got_privsep_send_error(&ibuf, err);
437 876c234b 2018-09-10 stsp err = receive_pack(&pack, &ibuf);
439 876c234b 2018-09-10 stsp got_privsep_send_error(&ibuf, err);
443 876c234b 2018-09-10 stsp while (1) {
444 876c234b 2018-09-10 stsp imsg.fd = -1;
446 876c234b 2018-09-10 stsp err = got_privsep_recv_imsg(&imsg, &ibuf, 0);
448 876c234b 2018-09-10 stsp if (err->code == GOT_ERR_PRIVSEP_PIPE)
449 876c234b 2018-09-10 stsp err = NULL;
453 876c234b 2018-09-10 stsp if (imsg.hdr.type == GOT_IMSG_STOP)
456 876c234b 2018-09-10 stsp switch (imsg.hdr.type) {
457 876c234b 2018-09-10 stsp case GOT_IMSG_PACKED_OBJECT_REQUEST:
458 c59b3346 2018-09-11 stsp err = object_request(&imsg, &ibuf, pack, packidx,
459 c59b3346 2018-09-11 stsp &objcache);
461 876c234b 2018-09-10 stsp case GOT_IMSG_COMMIT_REQUEST:
462 c59b3346 2018-09-11 stsp err = commit_request(&imsg, &ibuf, pack, packidx,
463 c59b3346 2018-09-11 stsp &objcache);
465 876c234b 2018-09-10 stsp case GOT_IMSG_TREE_REQUEST:
466 c59b3346 2018-09-11 stsp err = tree_request(&imsg, &ibuf, pack, packidx,
467 c59b3346 2018-09-11 stsp &objcache);
469 876c234b 2018-09-10 stsp case GOT_IMSG_BLOB_REQUEST:
470 c59b3346 2018-09-11 stsp err = blob_request(&imsg, &ibuf, pack, packidx,
471 c59b3346 2018-09-11 stsp &objcache);
474 876c234b 2018-09-10 stsp err = got_error(GOT_ERR_PRIVSEP_MSG);
478 876c234b 2018-09-10 stsp if (imsg.fd != -1)
479 876c234b 2018-09-10 stsp close(imsg.fd);
480 876c234b 2018-09-10 stsp imsg_free(&imsg);
482 876c234b 2018-09-10 stsp if (err->code == GOT_ERR_PRIVSEP_PIPE)
483 876c234b 2018-09-10 stsp err = NULL;
485 876c234b 2018-09-10 stsp got_privsep_send_error(&ibuf, err);
490 c59b3346 2018-09-11 stsp if (packidx)
491 c59b3346 2018-09-11 stsp got_packidx_close(packidx);
493 c59b3346 2018-09-11 stsp got_pack_close(pack);
494 876c234b 2018-09-10 stsp imsg_clear(&ibuf);
496 876c234b 2018-09-10 stsp fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
497 876c234b 2018-09-10 stsp close(GOT_IMSG_FD_CHILD);
498 876c234b 2018-09-10 stsp return err ? 1 : 0;