2 * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
3 * Copyright (c) 2019, Ori Bernstein <ori@openbsd.org>
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.
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.
19 * All code runs under the same UID but sensitive code paths are run in a
20 * separate process with tighter pledge(2) promises; data is communicated
21 * between processes via imsgbuf_flush(3) and imsgbuf_read(3).
22 * This behaviour is transparent to users of the library.
24 * We generally transmit data in imsg buffers, split across several messages
25 * if necessary. File descriptors are used in cases where this is impractical,
26 * such as when accessing pack files or when transferring large blobs.
28 * We exec(2) after a fork(2). Parts of our library functionality are
29 * accessible via separate executables in a libexec directory.
32 #define GOT_IMSG_FD_CHILD (STDERR_FILENO + 1)
34 #ifndef GOT_LIBEXECDIR
35 #define GOT_LIBEXECDIR /usr/local/bin
38 /* Names of helper programs in libexec directory */
39 #define GOT_PROG_READ_OBJECT got-read-object
40 #define GOT_PROG_READ_TREE got-read-tree
41 #define GOT_PROG_READ_COMMIT got-read-commit
42 #define GOT_PROG_READ_BLOB got-read-blob
43 #define GOT_PROG_READ_TAG got-read-tag
44 #define GOT_PROG_READ_PACK got-read-pack
45 #define GOT_PROG_READ_GITCONFIG got-read-gitconfig
46 #define GOT_PROG_READ_GOTCONFIG got-read-gotconfig
47 #define GOT_PROG_READ_PATCH got-read-patch
48 #define GOT_PROG_FETCH_PACK got-fetch-pack
49 #define GOT_PROG_INDEX_PACK got-index-pack
50 #define GOT_PROG_SEND_PACK got-send-pack
51 #define GOT_PROG_FETCH_HTTP got-fetch-http
53 #define GOT_STRINGIFY(x) #x
54 #define GOT_STRINGVAL(x) GOT_STRINGIFY(x)
56 /* Paths to helper programs in libexec directory */
57 #define GOT_PATH_PROG_READ_OBJECT \
58 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_OBJECT)
59 #define GOT_PATH_PROG_READ_TREE \
60 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TREE)
61 #define GOT_PATH_PROG_READ_COMMIT \
62 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_COMMIT)
63 #define GOT_PATH_PROG_READ_BLOB \
64 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_BLOB)
65 #define GOT_PATH_PROG_READ_TAG \
66 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TAG)
67 #define GOT_PATH_PROG_READ_PACK \
68 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_PACK)
69 #define GOT_PATH_PROG_READ_GITCONFIG \
70 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_GITCONFIG)
71 #define GOT_PATH_PROG_READ_GOTCONFIG \
72 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_GOTCONFIG)
73 #define GOT_PATH_PROG_READ_PATCH \
74 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_PATCH)
75 #define GOT_PATH_PROG_FETCH_PACK \
76 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_FETCH_PACK)
77 #define GOT_PATH_PROG_SEND_PACK \
78 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_SEND_PACK)
79 #define GOT_PATH_PROG_INDEX_PACK \
80 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_INDEX_PACK)
81 #define GOT_PATH_PROG_FETCH_HTTP \
82 GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_FETCH_HTTP)
85 /* An error occurred while processing a request. */
88 /* Stop the child process. */
92 * Messages concerned with read access to objects in a repository.
93 * Object and pack files are opened by the main process, where
94 * data may be read as a byte string but without any interpretation.
95 * Decompression and parsing of object and pack files occurs in a
96 * separate process which runs under pledge("stdio recvfd").
97 * This sandboxes our own repository parsing code, as well as zlib.
99 GOT_IMSG_OBJECT_REQUEST
,
101 GOT_IMSG_COMMIT_REQUEST
,
103 GOT_IMSG_COMMIT_LOGMSG
,
104 GOT_IMSG_TREE_REQUEST
,
106 GOT_IMSG_TREE_ENTRIES
,
107 GOT_IMSG_BLOB_REQUEST
,
110 GOT_IMSG_TAG_REQUEST
,
114 /* Messages related to networking. */
115 GOT_IMSG_FETCH_REQUEST
,
116 GOT_IMSG_FETCH_HAVE_REF
,
117 GOT_IMSG_FETCH_WANTED_BRANCH
,
118 GOT_IMSG_FETCH_WANTED_REF
,
119 GOT_IMSG_FETCH_OUTFD
,
120 GOT_IMSG_FETCH_SYMREFS
,
122 GOT_IMSG_FETCH_SERVER_PROGRESS
,
123 GOT_IMSG_FETCH_DOWNLOAD_PROGRESS
,
125 GOT_IMSG_IDXPACK_REQUEST
,
126 GOT_IMSG_IDXPACK_OUTFD
,
127 GOT_IMSG_IDXPACK_PROGRESS
,
128 GOT_IMSG_IDXPACK_DONE
,
129 GOT_IMSG_SEND_REQUEST
,
131 GOT_IMSG_SEND_REMOTE_REF
,
132 GOT_IMSG_SEND_REF_STATUS
,
133 GOT_IMSG_SEND_PACK_REQUEST
,
134 GOT_IMSG_SEND_PACKFD
,
135 GOT_IMSG_SEND_UPLOAD_PROGRESS
,
138 /* Messages related to pack files. */
141 GOT_IMSG_PACKED_OBJECT_REQUEST
,
142 GOT_IMSG_COMMIT_TRAVERSAL_REQUEST
,
143 GOT_IMSG_TRAVERSED_COMMITS
,
144 GOT_IMSG_COMMIT_TRAVERSAL_DONE
,
145 GOT_IMSG_OBJECT_ENUMERATION_REQUEST
,
146 GOT_IMSG_ENUMERATED_COMMIT
,
147 GOT_IMSG_ENUMERATED_TREE
,
148 GOT_IMSG_TREE_ENUMERATION_DONE
,
149 GOT_IMSG_OBJECT_ENUMERATION_DONE
,
150 GOT_IMSG_OBJECT_ENUMERATION_INCOMPLETE
,
152 /* Message sending file descriptor to a temporary file. */
155 /* Messages related to gitconfig files. */
156 GOT_IMSG_GITCONFIG_PARSE_REQUEST
,
157 GOT_IMSG_GITCONFIG_REPOSITORY_FORMAT_VERSION_REQUEST
,
158 GOT_IMSG_GITCONFIG_REPOSITORY_EXTENSIONS_REQUEST
,
159 GOT_IMSG_GITCONFIG_AUTHOR_NAME_REQUEST
,
160 GOT_IMSG_GITCONFIG_AUTHOR_EMAIL_REQUEST
,
161 GOT_IMSG_GITCONFIG_REMOTES_REQUEST
,
162 GOT_IMSG_GITCONFIG_INT_VAL
,
163 GOT_IMSG_GITCONFIG_STR_VAL
,
164 GOT_IMSG_GITCONFIG_PAIR
,
165 GOT_IMSG_GITCONFIG_REMOTES
,
166 GOT_IMSG_GITCONFIG_REMOTE
,
167 GOT_IMSG_GITCONFIG_OWNER_REQUEST
,
168 GOT_IMSG_GITCONFIG_OWNER
,
170 /* Messages related to gotconfig files. */
171 GOT_IMSG_GOTCONFIG_PARSE_REQUEST
,
172 GOT_IMSG_GOTCONFIG_AUTHOR_REQUEST
,
173 GOT_IMSG_GOTCONFIG_ALLOWEDSIGNERS_REQUEST
,
174 GOT_IMSG_GOTCONFIG_REVOKEDSIGNERS_REQUEST
,
175 GOT_IMSG_GOTCONFIG_SIGNERID_REQUEST
,
176 GOT_IMSG_GOTCONFIG_REMOTES_REQUEST
,
177 GOT_IMSG_GOTCONFIG_INT_VAL
,
178 GOT_IMSG_GOTCONFIG_STR_VAL
,
179 GOT_IMSG_GOTCONFIG_REMOTES
,
180 GOT_IMSG_GOTCONFIG_REMOTE
,
182 /* Raw object access. Uncompress object data but do not parse it. */
183 GOT_IMSG_RAW_OBJECT_REQUEST
,
184 GOT_IMSG_RAW_OBJECT_OUTFD
,
185 GOT_IMSG_PACKED_RAW_OBJECT_REQUEST
,
188 /* Read raw delta data from pack files. */
189 GOT_IMSG_RAW_DELTA_OUTFD
,
190 GOT_IMSG_RAW_DELTA_REQUEST
,
193 /* Reuse deltas found in a pack file. */
194 GOT_IMSG_DELTA_REUSE_REQUEST
,
195 GOT_IMSG_REUSED_DELTAS
,
196 GOT_IMSG_DELTA_REUSE_DONE
,
198 /* Commit coloring in got-read-pack. */
199 GOT_IMSG_COMMIT_PAINTING_INIT
,
200 GOT_IMSG_COMMIT_PAINTING_REQUEST
,
201 GOT_IMSG_PAINTED_COMMITS
,
202 GOT_IMSG_COMMIT_PAINTING_DONE
,
204 /* Transfer a list of object IDs. */
205 GOT_IMSG_OBJ_ID_LIST
,
206 GOT_IMSG_OBJ_ID_LIST_DONE
,
208 /* Messages related to patch files. */
217 /* Structure for GOT_IMSG_ERROR. */
218 struct got_imsg_error
{
219 int code
; /* an error code from got_error.h */
220 int errno_code
; /* in case code equals GOT_ERR_ERRNO */
221 } __attribute__((__packed__
));
224 * Structure for GOT_IMSG_TREE_REQUEST and GOT_IMSG_OBJECT data.
226 struct got_imsg_object
{
227 struct got_object_id id
;
229 /* These fields are the same as in struct got_object. */
236 } __attribute__((__packed__
));
238 /* Structure for GOT_IMSG_COMMIT data. */
239 struct got_imsg_commit_object
{
240 struct got_object_id tree_id
;
243 time_t author_gmtoff
;
244 size_t committer_len
;
245 time_t committer_time
;
246 time_t committer_gmtoff
;
251 * Followed by author_len + committer_len data bytes
254 /* Followed by 'nparents' struct got_object_id */
257 * Followed by 'logmsg_len' bytes of commit log message data in
258 * one or more GOT_IMSG_COMMIT_LOGMSG messages.
260 } __attribute__((__packed__
));
262 struct got_imsg_tree_entry
{
263 char id
[GOT_HASH_DIGEST_MAXLEN
];
267 /* Followed by namelen bytes of entry's name, not NUL-terminated. */
268 } __attribute__((__packed__
));
270 /* Structure for GOT_IMSG_TREE_ENTRIES. */
271 struct got_imsg_tree_entries
{
272 size_t nentries
; /* Number of tree entries contained in this message. */
274 /* Followed by nentries * struct got_imsg_tree_entry */
277 /* Structure for GOT_IMSG_TREE_OBJECT_REPLY data. */
278 struct got_imsg_tree_object
{
279 int nentries
; /* This many tree entries follow. */
282 /* Structure for GOT_IMSG_BLOB. */
283 struct got_imsg_blob
{
288 * If size <= GOT_PRIVSEP_INLINE_BLOB_DATA_MAX, blob data follows
289 * in the imsg buffer. Otherwise, blob data has been written to a
290 * file descriptor passed via the GOT_IMSG_BLOB_OUTFD imsg.
292 #define GOT_PRIVSEP_INLINE_BLOB_DATA_MAX \
293 (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_blob))
296 /* Structure for GOT_IMSG_RAW_OBJECT. */
297 struct got_imsg_raw_obj
{
302 * If size <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX, object data follows
303 * in the imsg buffer. Otherwise, object data has been written to a
304 * file descriptor passed via the GOT_IMSG_RAW_OBJECT_OUTFD imsg.
306 #define GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX \
307 (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_raw_obj))
310 /* Structure for GOT_IMSG_RAW_DELTA. */
311 struct got_imsg_raw_delta
{
312 struct got_object_id base_id
;
314 uint64_t result_size
;
316 off_t delta_compressed_size
;
318 off_t delta_out_offset
;
321 * Delta data has been written at delta_out_offset to the file
322 * descriptor passed via the GOT_IMSG_RAW_DELTA_OUTFD imsg.
326 /* Structures for GOT_IMSG_REUSED_DELTAS. */
327 struct got_imsg_reused_delta
{
328 struct got_object_id id
;
329 struct got_object_id base_id
;
331 uint64_t result_size
;
333 off_t delta_compressed_size
;
336 struct got_imsg_reused_deltas
{
340 * Followed by ndeltas * struct got_imsg_reused_delta.
343 #define GOT_IMSG_REUSED_DELTAS_MAX_NDELTAS \
344 ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
345 sizeof(struct got_imsg_reused_deltas)) \
346 / sizeof(struct got_imsg_reused_delta))
349 /* Structure for GOT_IMSG_COMMIT_PAINTING_REQUEST. */
350 struct got_imsg_commit_painting_request
{
351 struct got_object_id id
;
354 } __attribute__((__packed__
));
356 /* Structure for GOT_IMSG_PAINTED_COMMITS. */
357 struct got_imsg_painted_commit
{
358 struct got_object_id id
;
360 } __attribute__((__packed__
));
362 struct got_imsg_painted_commits
{
366 * Followed by ncommits * struct got_imsg_painted_commit.
368 } __attribute__((__packed__
));
370 /* Structure for GOT_IMSG_TAG data. */
371 struct got_imsg_tag_object
{
372 struct got_object_id id
;
377 time_t tagger_gmtoff
;
381 * Followed by tag_len + tagger_len data bytes
385 * Followed by 'tagmsg_len' bytes of tag message data in
386 * one or more GOT_IMSG_TAG_TAGMSG messages.
388 } __attribute__((__packed__
));
390 /* Structure for GOT_IMSG_FETCH_HAVE_REF data. */
391 struct got_imsg_fetch_have_ref
{
392 struct got_object_id id
;
394 /* Followed by name_len data bytes. */
395 } __attribute__((__packed__
));
397 /* Structure for GOT_IMSG_FETCH_WANTED_BRANCH data. */
398 struct got_imsg_fetch_wanted_branch
{
400 /* Followed by name_len data bytes. */
401 } __attribute__((__packed__
));
403 /* Structure for GOT_IMSG_FETCH_WANTED_REF data. */
404 struct got_imsg_fetch_wanted_ref
{
406 /* Followed by name_len data bytes. */
407 } __attribute__((__packed__
));
409 /* Structure for GOT_IMSG_FETCH_REQUEST data. */
410 struct got_imsg_fetch_request
{
412 int fetch_all_branches
;
415 size_t worktree_branch_len
;
416 size_t remote_head_len
;
418 size_t n_wanted_branches
;
419 size_t n_wanted_refs
;
420 /* Followed by worktree_branch_len bytes of reference name. */
421 /* Followed by remote_head_len bytes of reference name. */
422 /* Followed by n_have_refs GOT_IMSG_FETCH_HAVE_REF messages. */
423 /* Followed by n_wanted_branches times GOT_IMSG_FETCH_WANTED_BRANCH. */
424 /* Followed by n_wanted_refs times GOT_IMSG_FETCH_WANTED_REF. */
425 } __attribute__((__packed__
));
427 /* Structures for GOT_IMSG_FETCH_SYMREFS data. */
428 struct got_imsg_fetch_symref
{
433 * Followed by name_len + target_len data bytes.
435 } __attribute__((__packed__
));
437 struct got_imsg_fetch_symrefs
{
440 /* Followed by nsymrefs times of got_imsg_fetch_symref data. */
441 } __attribute__((__packed__
));
443 /* Structure for GOT_IMSG_FETCH_REF data. */
444 struct got_imsg_fetch_ref
{
445 /* Describes a reference which will be fetched. */
446 struct got_object_id refid
;
447 /* Followed by reference name in remaining data of imsg buffer. */
450 /* Structure for GOT_IMSG_FETCH_DOWNLOAD_PROGRESS data. */
451 struct got_imsg_fetch_download_progress
{
452 /* Number of packfile data bytes downloaded so far. */
453 off_t packfile_bytes
;
456 /* Structure for GOT_IMSG_SEND_REQUEST data. */
457 struct got_imsg_send_request
{
460 /* Followed by nrefs GOT_IMSG_SEND_REF messages. */
461 } __attribute__((__packed__
));
463 /* Structure for GOT_IMSG_SEND_UPLOAD_PROGRESS data. */
464 struct got_imsg_send_upload_progress
{
465 /* Number of packfile data bytes uploaded so far. */
466 off_t packfile_bytes
;
469 /* Structure for GOT_IMSG_SEND_REF data. */
470 struct got_imsg_send_ref
{
471 struct got_object_id id
;
474 /* Followed by name_len data bytes. */
475 } __attribute__((__packed__
));
477 /* Structure for GOT_IMSG_SEND_REMOTE_REF data. */
478 struct got_imsg_send_remote_ref
{
479 struct got_object_id id
;
481 /* Followed by name_len data bytes. */
482 } __attribute__((__packed__
));
484 /* Structure for GOT_IMSG_SEND_REF_STATUS data. */
485 struct got_imsg_send_ref_status
{
489 /* Followed by name_len data bytes. */
490 /* Followed by errmsg_len data bytes. */
491 } __attribute__((__packed__
));
493 /* Structure for GOT_IMSG_IDXPACK_REQUEST data. */
494 struct got_imsg_index_pack_request
{
495 struct got_object_id id
;
496 } __attribute__((__packed__
));
498 /* Structure for GOT_IMSG_IDXPACK_PROGRESS data. */
499 struct got_imsg_index_pack_progress
{
500 /* Total number of objects in pack file. */
503 /* Number of objects indexed so far. */
506 /* Number of non-deltified objects in pack file. */
509 /* Number of deltified objects resolved so far. */
513 /* Structure for GOT_IMSG_PACKIDX. */
514 struct got_imsg_packidx
{
518 /* Additionally, a file descriptor is passed via imsg. */
521 /* Structure for GOT_IMSG_PACK. */
522 struct got_imsg_pack
{
523 char path_packfile
[PATH_MAX
];
526 /* Additionally, a file descriptor is passed via imsg. */
527 } __attribute__((__packed__
));
530 * Structure for GOT_IMSG_OBJECT_REQUEST, GOT_IMSG_BLOB_REQUEST,
531 * GOT_IMSG_TREE_REQUEST, GOT_IMSG_COMMIT_REQUEST, and
532 * GOT_IMSG_TAG_REQUEST data.
534 struct got_object_id
;
537 * Structure for GOT_IMSG_PACKED_OBJECT_REQUEST and
538 * GOT_IMSG_PACKED_RAW_OBJECT_REQUEST data.
540 struct got_imsg_packed_object
{
541 struct got_object_id id
;
543 } __attribute__((__packed__
));
546 * Structure for GOT_IMSG_DELTA data.
548 struct got_imsg_delta
{
549 /* These fields are the same as in struct got_delta. */
558 * Structure for GOT_IMSG_RAW_DELTA_REQUEST data.
560 struct got_imsg_raw_delta_request
{
561 struct got_object_id id
;
566 * Structure for GOT_IMSG_OBJ_ID_LIST data.
567 * Multiple such messages may be sent back-to-back, where each message
568 * contains a chunk of IDs. The entire list must be terminated with a
569 * GOT_IMSG_OBJ_ID_LIST_DONE message.
571 struct got_imsg_object_idlist
{
575 * Followed by nids * struct got_object_id.
578 #define GOT_IMSG_OBJ_ID_LIST_MAX_NIDS \
579 ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
580 sizeof(struct got_imsg_object_idlist)) / sizeof(struct got_object_id))
583 /* Structure for GOT_IMSG_COMMIT_TRAVERSAL_REQUEST */
584 struct got_imsg_commit_traversal_request
{
585 struct got_imsg_packed_object iobj
;
587 /* Followed by path_len bytes of path data */
588 } __attribute__((__packed__
));
590 /* Structure for GOT_IMSG_TRAVERSED_COMMITS */
591 struct got_imsg_traversed_commits
{
593 /* Followed by ncommit struct got_object_id */
594 } __attribute__((__packed__
));
596 /* Structure for GOT_IMSG_ENUMERATED_COMMIT */
597 struct got_imsg_enumerated_commit
{
598 struct got_object_id id
;
600 } __attribute__((__packed__
));
602 /* Structure for GOT_IMSG_ENUMERATED_TREE */
603 struct got_imsg_enumerated_tree
{
604 struct got_object_id id
; /* tree ID */
605 int nentries
; /* number of tree entries */
607 /* Followed by tree's path in remaining data of imsg buffer. */
609 /* Followed by nentries * GOT_IMSG_TREE_ENTRY messages. */
610 } __attribute__((__packed__
));
613 * Structure for GOT_IMSG_GOTCONFIG_REMOTE and
614 * GOT_IMSG_GOTCONFIG_REMOTE data.
616 struct got_imsg_remote
{
618 size_t fetch_url_len
;
620 int mirror_references
;
621 int fetch_all_branches
;
626 /* Followed by name_len data bytes. */
627 /* Followed by fetch_url_len + send_url_len data bytes. */
628 /* Followed by nfetch_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
629 /* Followed by nsend_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
630 /* Followed by nfetch_refs GOT_IMSG_GITCONFIG_STR_VAL messages. */
631 } __attribute__((__packed__
));
634 * Structure for GOT_IMSG_GITCONFIG_REMOTES data.
636 struct got_imsg_remotes
{
637 int nremotes
; /* This many GOT_IMSG_GITCONFIG_REMOTE messages follow. */
641 * Structure for GOT_IMSG_GITCONFIG_PAIR.
643 struct got_imsg_gitconfig_pair
{
646 /* Followed by klen data bytes of key string. */
647 /* Followed by vlen data bytes of value string. */
651 * Structure for GOT_IMSG_PATCH data.
653 struct got_imsg_patch
{
658 char cid
[GOT_HASH_DIGEST_STRING_MAXLEN
];
659 char blob
[GOT_HASH_DIGEST_STRING_MAXLEN
];
663 * Structure for GOT_IMSG_PATCH_HUNK data.
665 struct got_imsg_patch_hunk
{
672 struct got_remote_repo
;
675 struct got_pathlist_head
;
677 const struct got_error
*got_send_ack(pid_t
);
678 const struct got_error
*got_privsep_wait_for_child(pid_t
);
679 const struct got_error
*got_privsep_flush_imsg(struct imsgbuf
*);
680 const struct got_error
*got_privsep_send_stop(int);
681 const struct got_error
*got_privsep_recv_imsg(struct imsg
*, struct imsgbuf
*,
683 void got_privsep_send_error(struct imsgbuf
*, const struct got_error
*);
684 const struct got_error
*got_privsep_send_ack(struct imsgbuf
*);
685 const struct got_error
*got_privsep_wait_ack(struct imsgbuf
*);
686 const struct got_error
*got_privsep_send_obj_req(struct imsgbuf
*, int,
687 struct got_object_id
*);
688 const struct got_error
*got_privsep_send_raw_obj_req(struct imsgbuf
*, int,
689 struct got_object_id
*);
690 const struct got_error
*got_privsep_send_raw_obj_outfd(struct imsgbuf
*, int);
691 const struct got_error
*got_privsep_send_commit_req(struct imsgbuf
*, int,
692 struct got_object_id
*, int);
693 const struct got_error
*got_privsep_send_tree_req(struct imsgbuf
*, int,
694 struct got_object_id
*, int);
695 const struct got_error
*got_privsep_send_tag_req(struct imsgbuf
*, int,
696 struct got_object_id
*, int);
697 const struct got_error
*got_privsep_send_blob_req(struct imsgbuf
*, int,
698 struct got_object_id
*, int);
699 const struct got_error
*got_privsep_send_blob_outfd(struct imsgbuf
*, int);
700 const struct got_error
*got_privsep_send_tmpfd(struct imsgbuf
*, int);
701 const struct got_error
*got_privsep_send_obj(struct imsgbuf
*,
702 struct got_object
*);
703 const struct got_error
*got_privsep_send_index_pack_req(struct imsgbuf
*,
704 struct got_object_id
*, int);
705 const struct got_error
*got_privsep_send_index_pack_outfd(struct imsgbuf
*,
707 const struct got_error
*got_privsep_recv_index_progress(int *, int *, int *,
708 int *, int *, struct imsgbuf
*ibuf
);
709 const struct got_error
*got_privsep_send_fetch_req(struct imsgbuf
*, int,
710 struct got_pathlist_head
*, int, struct got_pathlist_head
*,
711 struct got_pathlist_head
*, int, const char *, const char *, int, int);
712 const struct got_error
*got_privsep_send_fetch_outfd(struct imsgbuf
*, int);
713 const struct got_error
*got_privsep_recv_fetch_progress(int *,
714 struct got_object_id
**, char **, struct got_pathlist_head
*, char **,
715 off_t
*, uint8_t *, struct imsgbuf
*);
716 const struct got_error
*got_privsep_send_send_req(struct imsgbuf
*, int,
717 struct got_pathlist_head
*, struct got_pathlist_head
*, int);
718 const struct got_error
*got_privsep_recv_send_remote_refs(
719 struct got_pathlist_head
*, struct imsgbuf
*);
720 const struct got_error
*got_privsep_send_packfd(struct imsgbuf
*, int);
721 const struct got_error
*got_privsep_recv_send_progress(int *, off_t
*,
722 int *, char **, char **, struct imsgbuf
*);
723 const struct got_error
*got_privsep_get_imsg_obj(struct got_object
**,
724 struct imsg
*, struct imsgbuf
*);
725 const struct got_error
*got_privsep_recv_obj(struct got_object
**,
727 const struct got_error
*got_privsep_send_raw_obj(struct imsgbuf
*, off_t
,
729 const struct got_error
*got_privsep_recv_raw_obj(uint8_t **, off_t
*, size_t *,
731 const struct got_error
*got_privsep_send_commit(struct imsgbuf
*,
732 struct got_commit_object
*);
733 const struct got_error
*got_privsep_recv_commit(struct got_commit_object
**,
735 const struct got_error
*got_privsep_recv_tree(struct got_tree_object
**,
737 struct got_parsed_tree_entry
;
738 const struct got_error
*got_privsep_send_tree(struct imsgbuf
*,
739 struct got_parsed_tree_entry
*, int);
740 const struct got_error
*got_privsep_send_blob(struct imsgbuf
*, size_t, size_t,
742 const struct got_error
*got_privsep_recv_blob(uint8_t **, size_t *, size_t *,
744 const struct got_error
*got_privsep_send_tag(struct imsgbuf
*,
745 struct got_tag_object
*);
746 const struct got_error
*got_privsep_recv_tag(struct got_tag_object
**,
748 const struct got_error
*got_privsep_init_pack_child(struct imsgbuf
*,
749 struct got_pack
*, struct got_packidx
*);
750 const struct got_error
*got_privsep_send_packed_obj_req(struct imsgbuf
*, int,
751 struct got_object_id
*);
752 const struct got_error
*got_privsep_send_packed_raw_obj_req(struct imsgbuf
*,
753 int, struct got_object_id
*);
754 const struct got_error
*got_privsep_send_pack_child_ready(struct imsgbuf
*);
756 const struct got_error
*got_privsep_send_gitconfig_parse_req(struct imsgbuf
*,
758 const struct got_error
*
759 got_privsep_send_gitconfig_repository_format_version_req(struct imsgbuf
*);
760 const struct got_error
*got_privsep_send_gitconfig_repository_extensions_req(
762 const struct got_error
*got_privsep_send_gitconfig_author_name_req(
764 const struct got_error
*got_privsep_send_gitconfig_author_email_req(
766 const struct got_error
*got_privsep_send_gitconfig_remotes_req(
768 const struct got_error
*got_privsep_send_gitconfig_owner_req(struct imsgbuf
*);
769 const struct got_error
*got_privsep_recv_gitconfig_str(char **,
771 const struct got_error
*got_privsep_recv_gitconfig_pair(char **, char **,
773 const struct got_error
*got_privsep_recv_gitconfig_int(int *, struct imsgbuf
*);
774 const struct got_error
*got_privsep_recv_gitconfig_remotes(
775 struct got_remote_repo
**, int *, struct imsgbuf
*);
777 const struct got_error
*got_privsep_send_gotconfig_parse_req(struct imsgbuf
*,
779 const struct got_error
*got_privsep_send_gotconfig_author_req(struct imsgbuf
*);
780 const struct got_error
*got_privsep_send_gotconfig_allowed_signers_req(
782 const struct got_error
*got_privsep_send_gotconfig_revoked_signers_req(
784 const struct got_error
*got_privsep_send_gotconfig_signer_id_req(
786 const struct got_error
*got_privsep_send_gotconfig_remotes_req(
788 const struct got_error
*got_privsep_recv_gotconfig_str(char **,
790 const struct got_error
*got_privsep_recv_gotconfig_remotes(
791 struct got_remote_repo
**, int *, struct imsgbuf
*);
793 const struct got_error
*got_privsep_send_commit_traversal_request(
794 struct imsgbuf
*, struct got_object_id
*, int, const char *);
795 const struct got_error
*got_privsep_recv_traversed_commits(
796 struct got_commit_object
**, struct got_object_id_queue
*,
798 const struct got_error
*got_privsep_send_enumerated_tree(size_t *,
799 struct imsgbuf
*, struct got_object_id
*, const char *,
800 struct got_parsed_tree_entry
*, int);
801 const struct got_error
*got_privsep_send_object_enumeration_request(
803 const struct got_error
*got_privsep_send_object_enumeration_done(
805 const struct got_error
*got_privsep_send_object_enumeration_incomplete(
807 const struct got_error
*got_privsep_send_enumerated_commit(struct imsgbuf
*,
808 struct got_object_id
*, time_t);
809 const struct got_error
*got_privsep_recv_enumerated_objects(int *,
810 struct imsgbuf
*, got_object_enumerate_commit_cb
,
811 got_object_enumerate_tree_cb
, void *, struct got_repository
*);
813 const struct got_error
*got_privsep_send_raw_delta_req(struct imsgbuf
*, int,
814 struct got_object_id
*);
815 const struct got_error
*got_privsep_send_raw_delta_outfd(struct imsgbuf
*, int);
816 const struct got_error
*got_privsep_send_raw_delta(struct imsgbuf
*, uint64_t,
817 uint64_t, off_t
, off_t
, off_t
, off_t
, struct got_object_id
*);
818 const struct got_error
*got_privsep_recv_raw_delta(uint64_t *, uint64_t *,
819 off_t
*, off_t
*, off_t
*, off_t
*, struct got_object_id
**,
822 const struct got_error
*got_privsep_send_object_idlist(struct imsgbuf
*,
823 struct got_object_id
**, size_t);
824 const struct got_error
*got_privsep_send_object_idlist_done(struct imsgbuf
*);
825 const struct got_error
*got_privsep_recv_object_idlist(int *,
826 struct got_object_id
**, size_t *, struct imsgbuf
*);
828 const struct got_error
*got_privsep_send_delta_reuse_req(struct imsgbuf
*);
829 const struct got_error
*got_privsep_send_reused_deltas(struct imsgbuf
*,
830 struct got_imsg_reused_delta
*, size_t);
831 const struct got_error
*got_privsep_send_reused_deltas_done(struct imsgbuf
*);
832 const struct got_error
*got_privsep_recv_reused_deltas(int *,
833 struct got_imsg_reused_delta
*, size_t *, struct imsgbuf
*);
835 const struct got_error
*got_privsep_init_commit_painting(struct imsgbuf
*);
836 const struct got_error
*got_privsep_send_painting_request(struct imsgbuf
*,
837 int, struct got_object_id
*, intptr_t);
838 typedef const struct got_error
*(*got_privsep_recv_painted_commit_cb
)(void *,
839 struct got_object_id
*, intptr_t);
840 const struct got_error
*got_privsep_send_painted_commits(struct imsgbuf
*,
841 struct got_object_id_queue
*, int *, int, int);
842 const struct got_error
*got_privsep_send_painting_commits_done(struct imsgbuf
*);
843 const struct got_error
*got_privsep_recv_painted_commits(
844 struct got_object_id_queue
*, got_privsep_recv_painted_commit_cb
, void *,
847 void got_privsep_exec_child(int[2], const char *, const char *);