Blob


1 /*
2 * Copyright (c) 2019 Ori Bernstein <ori@openbsd.org>
3 * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
18 #include <sys/types.h>
19 #include <sys/queue.h>
20 #include <sys/uio.h>
21 #include <sys/time.h>
22 #include <sys/stat.h>
24 #include <stdint.h>
25 #include <errno.h>
26 #include <imsg.h>
27 #include <limits.h>
28 #include <signal.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <ctype.h>
33 #include <sha1.h>
34 #include <fcntl.h>
35 #include <unistd.h>
36 #include <zlib.h>
37 #include <err.h>
39 #include "got_error.h"
40 #include "got_object.h"
41 #include "got_path.h"
42 #include "got_version.h"
43 #include "got_fetch.h"
44 #include "got_reference.h"
46 #include "got_lib_sha1.h"
47 #include "got_lib_delta.h"
48 #include "got_lib_object.h"
49 #include "got_lib_object_parse.h"
50 #include "got_lib_privsep.h"
51 #include "got_lib_pack.h"
52 #include "got_lib_pkt.h"
53 #include "got_lib_gitproto.h"
54 #include "got_lib_ratelimit.h"
56 #ifndef nitems
57 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
58 #endif
60 struct got_object *indexed;
61 static int chattygot;
63 static const struct got_capability got_capabilities[] = {
64 { GOT_CAPA_AGENT, "got/" GOT_VERSION_STR },
65 { GOT_CAPA_OFS_DELTA, NULL },
66 #if 0
67 { GOT_CAPA_SIDE_BAND_64K, NULL },
68 #endif
69 { GOT_CAPA_REPORT_STATUS, NULL },
70 { GOT_CAPA_DELETE_REFS, NULL },
71 };
73 static const struct got_error *
74 send_upload_progress(struct imsgbuf *ibuf, off_t bytes,
75 struct got_ratelimit *rl)
76 {
77 const struct got_error *err = NULL;
78 int elapsed = 0;
80 if (rl) {
81 err = got_ratelimit_check(&elapsed, rl);
82 if (err || !elapsed)
83 return err;
84 }
86 if (imsg_compose(ibuf, GOT_IMSG_SEND_UPLOAD_PROGRESS, 0, 0, -1,
87 &bytes, sizeof(bytes)) == -1)
88 return got_error_from_errno(
89 "imsg_compose SEND_UPLOAD_PROGRESS");
91 return got_privsep_flush_imsg(ibuf);
92 }
94 static const struct got_error *
95 send_pack_request(struct imsgbuf *ibuf)
96 {
97 if (imsg_compose(ibuf, GOT_IMSG_SEND_PACK_REQUEST, 0, 0, -1,
98 NULL, 0) == -1)
99 return got_error_from_errno("imsg_compose SEND_PACK_REQUEST");
100 return got_privsep_flush_imsg(ibuf);
103 static const struct got_error *
104 send_done(struct imsgbuf *ibuf)
106 if (imsg_compose(ibuf, GOT_IMSG_SEND_DONE, 0, 0, -1, NULL, 0) == -1)
107 return got_error_from_errno("imsg_compose SEND_DONE");
108 return got_privsep_flush_imsg(ibuf);
111 static const struct got_error *
112 recv_packfd(int *packfd, struct imsgbuf *ibuf)
114 const struct got_error *err;
115 struct imsg imsg;
117 *packfd = -1;
119 err = got_privsep_recv_imsg(&imsg, ibuf, 0);
120 if (err)
121 return err;
123 if (imsg.hdr.type == GOT_IMSG_STOP) {
124 err = got_error(GOT_ERR_CANCELLED);
125 goto done;
128 if (imsg.hdr.type != GOT_IMSG_SEND_PACKFD) {
129 err = got_error(GOT_ERR_PRIVSEP_MSG);
130 goto done;
133 if (imsg.hdr.len - IMSG_HEADER_SIZE != 0) {
134 err = got_error(GOT_ERR_PRIVSEP_LEN);
135 goto done;
138 *packfd = imsg.fd;
139 done:
140 imsg_free(&imsg);
141 return err;
144 static const struct got_error *
145 send_pack_file(int sendfd, int packfd, struct imsgbuf *ibuf)
147 const struct got_error *err;
148 unsigned char buf[8192];
149 ssize_t r, w;
150 off_t wtotal = 0;
151 struct got_ratelimit rl;
153 if (lseek(packfd, 0L, SEEK_SET) == -1)
154 return got_error_from_errno("lseek");
156 got_ratelimit_init(&rl, 0, 500);
158 for (;;) {
159 r = read(packfd, buf, sizeof(buf));
160 if (r == -1)
161 return got_error_from_errno("read");
162 if (r == 0)
163 break;
164 w = write(sendfd, buf, r);
165 if (w == -1)
166 return got_error_from_errno("write");
167 if (w != r)
168 return got_error(GOT_ERR_IO);
169 wtotal += w;
170 err = send_upload_progress(ibuf, wtotal, &rl);
171 if (err)
172 return err;
175 return send_upload_progress(ibuf, wtotal, NULL);
178 static const struct got_error *
179 send_error(const char *buf, size_t len)
181 static char msg[1024];
182 size_t i;
184 for (i = 0; i < len && i < sizeof(msg) - 1; i++) {
185 if (!isprint(buf[i]))
186 return got_error_msg(GOT_ERR_BAD_PACKET,
187 "non-printable error message received from server");
188 msg[i] = buf[i];
190 msg[i] = '\0';
191 return got_error_msg(GOT_ERR_SEND_FAILED, msg);
194 static const struct got_error *
195 send_their_ref(struct imsgbuf *ibuf, struct got_object_id *refid,
196 const char *refname)
198 const struct got_error *err = NULL;
199 struct ibuf *wbuf;
200 size_t len, reflen = strlen(refname);
202 len = sizeof(struct got_imsg_send_remote_ref) + reflen;
203 if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
204 return got_error(GOT_ERR_NO_SPACE);
206 wbuf = imsg_create(ibuf, GOT_IMSG_SEND_REMOTE_REF, 0, 0, len);
207 if (wbuf == NULL)
208 return got_error_from_errno("imsg_create SEND_REMOTE_REF");
210 /* Keep in sync with struct got_imsg_send_remote_ref definition! */
211 if (imsg_add(wbuf, refid->sha1, SHA1_DIGEST_LENGTH) == -1) {
212 err = got_error_from_errno("imsg_add SEND_REMOTE_REF");
213 ibuf_free(wbuf);
214 return err;
216 if (imsg_add(wbuf, &reflen, sizeof(reflen)) == -1) {
217 err = got_error_from_errno("imsg_add SEND_REMOTE_REF");
218 ibuf_free(wbuf);
219 return err;
221 if (imsg_add(wbuf, refname, reflen) == -1) {
222 err = got_error_from_errno("imsg_add SEND_REMOTE_REF");
223 ibuf_free(wbuf);
224 return err;
227 wbuf->fd = -1;
228 imsg_close(ibuf, wbuf);
229 return got_privsep_flush_imsg(ibuf);
232 static const struct got_error *
233 send_ref_status(struct imsgbuf *ibuf, const char *refname, int success,
234 struct got_pathlist_head *refs, struct got_pathlist_head *delete_refs)
236 const struct got_error *err = NULL;
237 struct ibuf *wbuf;
238 size_t len, reflen = strlen(refname);
239 struct got_pathlist_entry *pe;
240 int ref_valid = 0;
241 char *eol;
243 eol = strchr(refname, '\n');
244 if (eol == NULL) {
245 return got_error_msg(GOT_ERR_BAD_PACKET,
246 "unexpected message from server");
248 *eol = '\0';
250 TAILQ_FOREACH(pe, refs, entry) {
251 if (strcmp(refname, pe->path) == 0) {
252 ref_valid = 1;
253 break;
256 if (!ref_valid) {
257 TAILQ_FOREACH(pe, delete_refs, entry) {
258 if (strcmp(refname, pe->path) == 0) {
259 ref_valid = 1;
260 break;
264 if (!ref_valid) {
265 return got_error_msg(GOT_ERR_BAD_PACKET,
266 "unexpected message from server");
269 len = sizeof(struct got_imsg_send_ref_status) + reflen;
270 if (len >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
271 return got_error(GOT_ERR_NO_SPACE);
273 wbuf = imsg_create(ibuf, GOT_IMSG_SEND_REF_STATUS,
274 0, 0, len);
275 if (wbuf == NULL)
276 return got_error_from_errno("imsg_create SEND_REF_STATUS");
278 /* Keep in sync with struct got_imsg_send_ref_status definition! */
279 if (imsg_add(wbuf, &success, sizeof(success)) == -1) {
280 err = got_error_from_errno("imsg_add SEND_REF_STATUS");
281 ibuf_free(wbuf);
282 return err;
284 if (imsg_add(wbuf, &reflen, sizeof(reflen)) == -1) {
285 err = got_error_from_errno("imsg_add SEND_REF_STATUS");
286 ibuf_free(wbuf);
287 return err;
289 if (imsg_add(wbuf, refname, reflen) == -1) {
290 err = got_error_from_errno("imsg_add SEND_REF_STATUS");
291 ibuf_free(wbuf);
292 return err;
295 wbuf->fd = -1;
296 imsg_close(ibuf, wbuf);
297 return got_privsep_flush_imsg(ibuf);
300 static const struct got_error *
301 describe_refchange(int *n, int *sent_my_capabilites,
302 const char *my_capabilities, char *buf, size_t bufsize,
303 const char *refname, const char *old_hashstr, const char *new_hashstr)
305 *n = snprintf(buf, bufsize, "%s %s %s",
306 old_hashstr, new_hashstr, refname);
307 if (*n >= bufsize)
308 return got_error(GOT_ERR_NO_SPACE);
310 /*
311 * We must announce our capabilities along with the first
312 * reference. Unfortunately, the protocol requires an embedded
313 * NUL as a separator between reference name and capabilities,
314 * which we have to deal with here.
315 * It also requires a linefeed for terminating packet data.
316 */
317 if (!*sent_my_capabilites && my_capabilities != NULL) {
318 int m;
319 if (*n >= bufsize - 1)
320 return got_error(GOT_ERR_NO_SPACE);
321 m = snprintf(buf + *n + 1, /* offset after '\0' */
322 bufsize - (*n + 1), "%s\n", my_capabilities);
323 if (*n + m >= bufsize)
324 return got_error(GOT_ERR_NO_SPACE);
325 *n += m;
326 *sent_my_capabilites = 1;
327 } else {
328 *n = strlcat(buf, "\n", bufsize);
329 if (*n >= bufsize)
330 return got_error(GOT_ERR_NO_SPACE);
333 return NULL;
336 static const struct got_error *
337 send_pack(int fd, struct got_pathlist_head *refs,
338 struct got_pathlist_head *delete_refs, struct imsgbuf *ibuf)
340 const struct got_error *err = NULL;
341 char buf[GOT_PKT_MAX];
342 const unsigned char zero_id[SHA1_DIGEST_LENGTH] = { 0 };
343 char old_hashstr[SHA1_DIGEST_STRING_LENGTH];
344 char new_hashstr[SHA1_DIGEST_STRING_LENGTH];
345 struct got_pathlist_head their_refs;
346 int is_firstpkt = 1;
347 int n, nsent = 0;
348 int packfd = -1;
349 char *id_str = NULL, *refname = NULL;
350 struct got_object_id *id = NULL;
351 char *server_capabilities = NULL, *my_capabilities = NULL;
352 struct got_pathlist_entry *pe;
353 int sent_my_capabilites = 0;
355 TAILQ_INIT(&their_refs);
357 if (TAILQ_EMPTY(refs) && TAILQ_EMPTY(delete_refs))
358 return got_error(GOT_ERR_SEND_EMPTY);
360 while (1) {
361 err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
362 if (err)
363 goto done;
364 if (n == 0)
365 break;
366 if (n >= 4 && strncmp(buf, "ERR ", 4) == 0) {
367 err = send_error(&buf[4], n - 4);
368 goto done;
370 free(id_str);
371 free(refname);
372 err = got_gitproto_parse_refline(&id_str, &refname,
373 &server_capabilities, buf, n);
374 if (err)
375 goto done;
376 if (is_firstpkt) {
377 if (chattygot && server_capabilities[0] != '\0')
378 fprintf(stderr, "%s: server capabilities: %s\n",
379 getprogname(), server_capabilities);
380 err = got_gitproto_match_capabilities(&my_capabilities,
381 NULL, server_capabilities, got_capabilities,
382 nitems(got_capabilities));
383 if (err)
384 goto done;
385 if (chattygot)
386 fprintf(stderr, "%s: my capabilities:%s\n",
387 getprogname(), my_capabilities);
388 is_firstpkt = 0;
390 if (strstr(refname, "^{}")) {
391 if (chattygot) {
392 fprintf(stderr, "%s: ignoring %s\n",
393 getprogname(), refname);
395 continue;
398 id = malloc(sizeof(*id));
399 if (id == NULL) {
400 err = got_error_from_errno("malloc");
401 goto done;
403 if (!got_parse_sha1_digest(id->sha1, id_str)) {
404 err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
405 goto done;
407 err = send_their_ref(ibuf, id, refname);
408 if (err)
409 goto done;
411 err = got_pathlist_append(&their_refs, refname, id);
412 if (chattygot)
413 fprintf(stderr, "%s: remote has %s %s\n",
414 getprogname(), refname, id_str);
415 free(id_str);
416 id_str = NULL;
417 refname = NULL; /* do not free; owned by their_refs */
418 id = NULL; /* do not free; owned by their_refs */
421 if (!TAILQ_EMPTY(delete_refs)) {
422 if (my_capabilities == NULL ||
423 strstr(my_capabilities, GOT_CAPA_DELETE_REFS) == NULL) {
424 err = got_error(GOT_ERR_CAPA_DELETE_REFS);
425 goto done;
429 TAILQ_FOREACH(pe, delete_refs, entry) {
430 const char *refname = pe->path;
431 struct got_pathlist_entry *their_pe;
432 struct got_object_id *their_id = NULL;
434 TAILQ_FOREACH(their_pe, &their_refs, entry) {
435 const char *their_refname = their_pe->path;
436 if (got_path_cmp(refname, their_refname,
437 strlen(refname), strlen(their_refname)) == 0) {
438 their_id = their_pe->data;
439 break;
442 if (their_id == NULL) {
443 err = got_error_fmt(GOT_ERR_NOT_REF,
444 "%s does not exist in remote repository",
445 refname);
446 goto done;
449 got_sha1_digest_to_str(their_id->sha1, old_hashstr,
450 sizeof(old_hashstr));
451 got_sha1_digest_to_str(zero_id, new_hashstr,
452 sizeof(new_hashstr));
453 err = describe_refchange(&n, &sent_my_capabilites,
454 my_capabilities, buf, sizeof(buf), refname,
455 old_hashstr, new_hashstr);
456 if (err)
457 goto done;
458 err = got_pkt_writepkt(fd, buf, n, chattygot);
459 if (err)
460 goto done;
461 if (chattygot) {
462 fprintf(stderr, "%s: deleting %s %s\n",
463 getprogname(), refname, old_hashstr);
465 nsent++;
468 TAILQ_FOREACH(pe, refs, entry) {
469 const char *refname = pe->path;
470 struct got_object_id *id = pe->data;
471 struct got_object_id *their_id = NULL;
472 struct got_pathlist_entry *their_pe;
474 TAILQ_FOREACH(their_pe, &their_refs, entry) {
475 const char *their_refname = their_pe->path;
476 if (got_path_cmp(refname, their_refname,
477 strlen(refname), strlen(their_refname)) == 0) {
478 their_id = their_pe->data;
479 break;
482 if (their_id) {
483 if (got_object_id_cmp(id, their_id) == 0) {
484 if (chattygot) {
485 fprintf(stderr,
486 "%s: no change for %s\n",
487 getprogname(), refname);
489 continue;
491 got_sha1_digest_to_str(their_id->sha1, old_hashstr,
492 sizeof(old_hashstr));
493 } else {
494 got_sha1_digest_to_str(zero_id, old_hashstr,
495 sizeof(old_hashstr));
497 got_sha1_digest_to_str(id->sha1, new_hashstr,
498 sizeof(new_hashstr));
499 err = describe_refchange(&n, &sent_my_capabilites,
500 my_capabilities, buf, sizeof(buf), refname,
501 old_hashstr, new_hashstr);
502 if (err)
503 goto done;
504 err = got_pkt_writepkt(fd, buf, n, chattygot);
505 if (err)
506 goto done;
507 if (chattygot) {
508 if (their_id) {
509 fprintf(stderr, "%s: updating %s %s -> %s\n",
510 getprogname(), refname, old_hashstr,
511 new_hashstr);
512 } else {
513 fprintf(stderr, "%s: creating %s %s\n",
514 getprogname(), refname, new_hashstr);
517 nsent++;
519 err = got_pkt_flushpkt(fd, chattygot);
520 if (err)
521 goto done;
523 err = send_pack_request(ibuf);
524 if (err)
525 goto done;
527 err = recv_packfd(&packfd, ibuf);
528 if (err)
529 goto done;
531 if (packfd != -1) {
532 err = send_pack_file(fd, packfd, ibuf);
533 if (err)
534 goto done;
537 err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
538 if (err)
539 goto done;
540 if (n >= 4 && strncmp(buf, "ERR ", 4) == 0) {
541 err = send_error(&buf[4], n - 4);
542 goto done;
543 } else if (n < 10 || strncmp(buf, "unpack ok\n", 10) != 0) {
544 err = got_error_msg(GOT_ERR_BAD_PACKET,
545 "unexpected message from server");
546 goto done;
549 while (nsent > 0) {
550 err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
551 if (err)
552 goto done;
553 if (n < 3) {
554 err = got_error_msg(GOT_ERR_BAD_PACKET,
555 "unexpected message from server");
556 goto done;
557 } else if (strncmp(buf, "ok ", 3) == 0) {
558 err = send_ref_status(ibuf, buf + 3, 1,
559 refs, delete_refs);
560 if (err)
561 goto done;
562 } else if (strncmp(buf, "ng ", 3) == 0) {
563 err = send_ref_status(ibuf, buf + 3, 0,
564 refs, delete_refs);
565 if (err)
566 goto done;
567 } else {
568 err = got_error_msg(GOT_ERR_BAD_PACKET,
569 "unexpected message from server");
570 goto done;
572 nsent--;
575 err = send_done(ibuf);
576 done:
577 TAILQ_FOREACH(pe, &their_refs, entry) {
578 free((void *)pe->path);
579 free(pe->data);
581 got_pathlist_free(&their_refs);
582 free(id_str);
583 free(id);
584 free(refname);
585 free(server_capabilities);
586 return err;
589 int
590 main(int argc, char **argv)
592 const struct got_error *err = NULL;
593 int sendfd;
594 struct imsgbuf ibuf;
595 struct imsg imsg;
596 struct got_pathlist_head refs;
597 struct got_pathlist_head delete_refs;
598 struct got_pathlist_entry *pe;
599 struct got_imsg_send_request send_req;
600 struct got_imsg_send_ref href;
601 size_t datalen, i;
602 #if 0
603 static int attached;
604 while (!attached)
605 sleep (1);
606 #endif
608 TAILQ_INIT(&refs);
609 TAILQ_INIT(&delete_refs);
611 imsg_init(&ibuf, GOT_IMSG_FD_CHILD);
612 #ifndef PROFILE
613 /* revoke access to most system calls */
614 if (pledge("stdio recvfd", NULL) == -1) {
615 err = got_error_from_errno("pledge");
616 got_privsep_send_error(&ibuf, err);
617 return 1;
619 #endif
620 if ((err = got_privsep_recv_imsg(&imsg, &ibuf, 0)) != 0) {
621 if (err->code == GOT_ERR_PRIVSEP_PIPE)
622 err = NULL;
623 goto done;
625 if (imsg.hdr.type == GOT_IMSG_STOP)
626 goto done;
627 if (imsg.hdr.type != GOT_IMSG_SEND_REQUEST) {
628 err = got_error(GOT_ERR_PRIVSEP_MSG);
629 goto done;
631 datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
632 if (datalen < sizeof(send_req)) {
633 err = got_error(GOT_ERR_PRIVSEP_LEN);
634 goto done;
636 memcpy(&send_req, imsg.data, sizeof(send_req));
637 sendfd = imsg.fd;
638 imsg_free(&imsg);
640 if (send_req.verbosity > 0)
641 chattygot += send_req.verbosity;
643 for (i = 0; i < send_req.nrefs; i++) {
644 struct got_object_id *id;
645 char *refname;
647 if ((err = got_privsep_recv_imsg(&imsg, &ibuf, 0)) != 0) {
648 if (err->code == GOT_ERR_PRIVSEP_PIPE)
649 err = NULL;
650 goto done;
652 if (imsg.hdr.type == GOT_IMSG_STOP)
653 goto done;
654 if (imsg.hdr.type != GOT_IMSG_SEND_REF) {
655 err = got_error(GOT_ERR_PRIVSEP_MSG);
656 goto done;
658 datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
659 if (datalen < sizeof(href)) {
660 err = got_error(GOT_ERR_PRIVSEP_LEN);
661 goto done;
663 memcpy(&href, imsg.data, sizeof(href));
664 if (datalen - sizeof(href) < href.name_len) {
665 err = got_error(GOT_ERR_PRIVSEP_LEN);
666 goto done;
668 refname = malloc(href.name_len + 1);
669 if (refname == NULL) {
670 err = got_error_from_errno("malloc");
671 goto done;
673 memcpy(refname, imsg.data + sizeof(href), href.name_len);
674 refname[href.name_len] = '\0';
676 /*
677 * Prevent sending of references that won't make any
678 * sense outside the local repository's context.
679 */
680 if (strncmp(refname, "refs/got/", 9) == 0 ||
681 strncmp(refname, "refs/remotes/", 13) == 0) {
682 err = got_error_fmt(GOT_ERR_SEND_BAD_REF,
683 "%s", refname);
684 goto done;
687 id = malloc(sizeof(*id));
688 if (id == NULL) {
689 free(refname);
690 err = got_error_from_errno("malloc");
691 goto done;
693 memcpy(id->sha1, href.id, SHA1_DIGEST_LENGTH);
694 if (href.delete)
695 err = got_pathlist_append(&delete_refs, refname, id);
696 else
697 err = got_pathlist_append(&refs, refname, id);
698 if (err) {
699 free(refname);
700 free(id);
701 goto done;
704 imsg_free(&imsg);
707 err = send_pack(sendfd, &refs, &delete_refs, &ibuf);
708 done:
709 TAILQ_FOREACH(pe, &refs, entry) {
710 free((char *)pe->path);
711 free(pe->data);
713 got_pathlist_free(&refs);
714 TAILQ_FOREACH(pe, &delete_refs, entry) {
715 free((char *)pe->path);
716 free(pe->data);
718 got_pathlist_free(&delete_refs);
719 if (sendfd != -1 && close(sendfd) == -1 && err == NULL)
720 err = got_error_from_errno("close");
721 if (err != NULL && err->code != GOT_ERR_CANCELLED) {
722 fprintf(stderr, "%s: %s\n", getprogname(), err->msg);
723 got_privsep_send_error(&ibuf, err);
726 exit(0);