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
20 * run in a separate process with tighter pledge(2) promises.
21 * Data is communicated between processes via imsg_flush(3) and imsg_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 occured 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 /* Re-use 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
[SHA1_DIGEST_LENGTH
];
266 /* Followed by namelen bytes of entry's name, not NUL-terminated. */
267 } __attribute__((__packed__
));
269 /* Structure for GOT_IMSG_TREE_ENTRIES. */
270 struct got_imsg_tree_entries
{
271 size_t nentries
; /* Number of tree entries contained in this message. */
273 /* Followed by nentries * struct got_imsg_tree_entry */
276 /* Structure for GOT_IMSG_TREE_OBJECT_REPLY data. */
277 struct got_imsg_tree_object
{
278 int nentries
; /* This many tree entries follow. */
281 /* Structure for GOT_IMSG_BLOB. */
282 struct got_imsg_blob
{
287 * If size <= GOT_PRIVSEP_INLINE_BLOB_DATA_MAX, blob data follows
288 * in the imsg buffer. Otherwise, blob data has been written to a
289 * file descriptor passed via the GOT_IMSG_BLOB_OUTFD imsg.
291 #define GOT_PRIVSEP_INLINE_BLOB_DATA_MAX \
292 (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_blob))
295 /* Structure for GOT_IMSG_RAW_OBJECT. */
296 struct got_imsg_raw_obj
{
301 * If size <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX, object data follows
302 * in the imsg buffer. Otherwise, object data has been written to a
303 * file descriptor passed via the GOT_IMSG_RAW_OBJECT_OUTFD imsg.
305 #define GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX \
306 (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_raw_obj))
309 /* Structure for GOT_IMSG_RAW_DELTA. */
310 struct got_imsg_raw_delta
{
311 struct got_object_id base_id
;
313 uint64_t result_size
;
315 off_t delta_compressed_size
;
317 off_t delta_out_offset
;
320 * Delta data has been written at delta_out_offset to the file
321 * descriptor passed via the GOT_IMSG_RAW_DELTA_OUTFD imsg.
325 /* Structures for GOT_IMSG_REUSED_DELTAS. */
326 struct got_imsg_reused_delta
{
327 struct got_object_id id
;
328 struct got_object_id base_id
;
330 uint64_t result_size
;
332 off_t delta_compressed_size
;
335 struct got_imsg_reused_deltas
{
339 * Followed by ndeltas * struct got_imsg_reused_delta.
342 #define GOT_IMSG_REUSED_DELTAS_MAX_NDELTAS \
343 ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
344 sizeof(struct got_imsg_reused_deltas)) \
345 / sizeof(struct got_imsg_reused_delta))
348 /* Structure for GOT_IMSG_COMMIT_PAINTING_REQUEST. */
349 struct got_imsg_commit_painting_request
{
350 struct got_object_id id
;
353 } __attribute__((__packed__
));
355 /* Structure for GOT_IMSG_PAINTED_COMMITS. */
356 struct got_imsg_painted_commit
{
357 uint8_t id
[SHA1_DIGEST_LENGTH
];
359 } __attribute__((__packed__
));
361 struct got_imsg_painted_commits
{
365 * Followed by ncommits * struct got_imsg_painted_commit.
367 } __attribute__((__packed__
));
369 /* Structure for GOT_IMSG_TAG data. */
370 struct got_imsg_tag_object
{
371 struct got_object_id id
;
376 time_t tagger_gmtoff
;
380 * Followed by tag_len + tagger_len data bytes
384 * Followed by 'tagmsg_len' bytes of tag message data in
385 * one or more GOT_IMSG_TAG_TAGMSG messages.
387 } __attribute__((__packed__
));
389 /* Structure for GOT_IMSG_FETCH_HAVE_REF data. */
390 struct got_imsg_fetch_have_ref
{
391 struct got_object_id id
;
393 /* Followed by name_len data bytes. */
394 } __attribute__((__packed__
));
396 /* Structure for GOT_IMSG_FETCH_WANTED_BRANCH data. */
397 struct got_imsg_fetch_wanted_branch
{
399 /* Followed by name_len data bytes. */
400 } __attribute__((__packed__
));
402 /* Structure for GOT_IMSG_FETCH_WANTED_REF data. */
403 struct got_imsg_fetch_wanted_ref
{
405 /* Followed by name_len data bytes. */
406 } __attribute__((__packed__
));
408 /* Structure for GOT_IMSG_FETCH_REQUEST data. */
409 struct got_imsg_fetch_request
{
411 int fetch_all_branches
;
414 size_t worktree_branch_len
;
415 size_t remote_head_len
;
417 size_t n_wanted_branches
;
418 size_t n_wanted_refs
;
419 /* Followed by worktree_branch_len bytes of reference name. */
420 /* Followed by remote_head_len bytes of reference name. */
421 /* Followed by n_have_refs GOT_IMSG_FETCH_HAVE_REF messages. */
422 /* Followed by n_wanted_branches times GOT_IMSG_FETCH_WANTED_BRANCH. */
423 /* Followed by n_wanted_refs times GOT_IMSG_FETCH_WANTED_REF. */
424 } __attribute__((__packed__
));
426 /* Structures for GOT_IMSG_FETCH_SYMREFS data. */
427 struct got_imsg_fetch_symref
{
432 * Followed by name_len + target_len data bytes.
434 } __attribute__((__packed__
));
436 struct got_imsg_fetch_symrefs
{
439 /* Followed by nsymrefs times of got_imsg_fetch_symref data. */
440 } __attribute__((__packed__
));
442 /* Structure for GOT_IMSG_FETCH_REF data. */
443 struct got_imsg_fetch_ref
{
444 /* Describes a reference which will be fetched. */
445 struct got_object_id refid
;
446 /* Followed by reference name in remaining data of imsg buffer. */
449 /* Structure for GOT_IMSG_FETCH_DOWNLOAD_PROGRESS data. */
450 struct got_imsg_fetch_download_progress
{
451 /* Number of packfile data bytes downloaded so far. */
452 off_t packfile_bytes
;
455 /* Structure for GOT_IMSG_SEND_REQUEST data. */
456 struct got_imsg_send_request
{
459 /* Followed by nrefs GOT_IMSG_SEND_REF messages. */
460 } __attribute__((__packed__
));
462 /* Structure for GOT_IMSG_SEND_UPLOAD_PROGRESS data. */
463 struct got_imsg_send_upload_progress
{
464 /* Number of packfile data bytes uploaded so far. */
465 off_t packfile_bytes
;
468 /* Structure for GOT_IMSG_SEND_REF data. */
469 struct got_imsg_send_ref
{
470 struct got_object_id id
;
473 /* Followed by name_len data bytes. */
474 } __attribute__((__packed__
));
476 /* Structure for GOT_IMSG_SEND_REMOTE_REF data. */
477 struct got_imsg_send_remote_ref
{
478 struct got_object_id id
;
480 /* Followed by name_len data bytes. */
481 } __attribute__((__packed__
));
483 /* Structure for GOT_IMSG_SEND_REF_STATUS data. */
484 struct got_imsg_send_ref_status
{
488 /* Followed by name_len data bytes. */
489 /* Followed by errmsg_len data bytes. */
490 } __attribute__((__packed__
));
492 /* Structure for GOT_IMSG_IDXPACK_REQUEST data. */
493 struct got_imsg_index_pack_request
{
494 uint8_t pack_hash
[SHA1_DIGEST_LENGTH
];
495 } __attribute__((__packed__
));
497 /* Structure for GOT_IMSG_IDXPACK_PROGRESS data. */
498 struct got_imsg_index_pack_progress
{
499 /* Total number of objects in pack file. */
502 /* Number of objects indexed so far. */
505 /* Number of non-deltified objects in pack file. */
508 /* Number of deltified objects resolved so far. */
512 /* Structure for GOT_IMSG_PACKIDX. */
513 struct got_imsg_packidx
{
516 /* Additionally, a file desciptor is passed via imsg. */
519 /* Structure for GOT_IMSG_PACK. */
520 struct got_imsg_pack
{
521 char path_packfile
[PATH_MAX
];
523 /* Additionally, a file desciptor is passed via imsg. */
524 } __attribute__((__packed__
));
527 * Structure for GOT_IMSG_OBJECT_REQUEST, GOT_IMSG_BLOB_REQUEST,
528 * GOT_IMSG_TREE_REQUEST, GOT_IMSG_COMMIT_REQUEST, and
529 * GOT_IMSG_TAG_REQUEST data.
531 struct got_object_id
;
534 * Structure for GOT_IMSG_PACKED_OBJECT_REQUEST and
535 * GOT_IMSG_PACKED_RAW_OBJECT_REQUEST data.
537 struct got_imsg_packed_object
{
538 struct got_object_id id
;
540 } __attribute__((__packed__
));
543 * Structure for GOT_IMSG_DELTA data.
545 struct got_imsg_delta
{
546 /* These fields are the same as in struct got_delta. */
555 * Structure for GOT_IMSG_RAW_DELTA_REQUEST data.
557 struct got_imsg_raw_delta_request
{
558 struct got_object_id id
;
563 * Structure for GOT_IMSG_OBJ_ID_LIST data.
564 * Multiple such messages may be sent back-to-back, where each message
565 * contains a chunk of IDs. The entire list must be terminated with a
566 * GOT_IMSG_OBJ_ID_LIST_DONE message.
568 struct got_imsg_object_idlist
{
572 * Followed by nids * struct got_object_id.
575 #define GOT_IMSG_OBJ_ID_LIST_MAX_NIDS \
576 ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
577 sizeof(struct got_imsg_object_idlist)) / sizeof(struct got_object_id))
580 /* Structure for GOT_IMSG_COMMIT_TRAVERSAL_REQUEST */
581 struct got_imsg_commit_traversal_request
{
582 struct got_imsg_packed_object iobj
;
584 /* Followed by path_len bytes of path data */
585 } __attribute__((__packed__
));
587 /* Structure for GOT_IMSG_TRAVERSED_COMMITS */
588 struct got_imsg_traversed_commits
{
590 /* Followed by ncommit struct got_object_id */
591 } __attribute__((__packed__
));
593 /* Structure for GOT_IMSG_ENUMERATED_COMMIT */
594 struct got_imsg_enumerated_commit
{
595 uint8_t id
[SHA1_DIGEST_LENGTH
];
597 } __attribute__((__packed__
));
599 /* Structure for GOT_IMSG_ENUMERATED_TREE */
600 struct got_imsg_enumerated_tree
{
601 uint8_t id
[SHA1_DIGEST_LENGTH
]; /* tree ID */
602 int nentries
; /* number of tree entries */
604 /* Followed by tree's path in remaining data of imsg buffer. */
606 /* Followed by nentries * GOT_IMSG_TREE_ENTRY messages. */
607 } __attribute__((__packed__
));
610 * Structure for GOT_IMSG_GOTCONFIG_REMOTE and
611 * GOT_IMSG_GOTCONFIG_REMOTE data.
613 struct got_imsg_remote
{
615 size_t fetch_url_len
;
617 int mirror_references
;
618 int fetch_all_branches
;
623 /* Followed by name_len data bytes. */
624 /* Followed by fetch_url_len + send_url_len data bytes. */
625 /* Followed by nfetch_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
626 /* Followed by nsend_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
627 /* Followed by nfetch_refs GOT_IMSG_GITCONFIG_STR_VAL messages. */
628 } __attribute__((__packed__
));
631 * Structure for GOT_IMSG_GITCONFIG_REMOTES data.
633 struct got_imsg_remotes
{
634 int nremotes
; /* This many GOT_IMSG_GITCONFIG_REMOTE messages follow. */
638 * Structure for GOT_IMSG_GITCONFIG_PAIR.
640 struct got_imsg_gitconfig_pair
{
643 /* Followed by klen data bytes of key string. */
644 /* Followed by vlen data bytes of value string. */
648 * Structure for GOT_IMSG_PATCH data.
650 struct got_imsg_patch
{
660 * Structure for GOT_IMSG_PATCH_HUNK data.
662 struct got_imsg_patch_hunk
{
669 struct got_remote_repo
;
672 struct got_pathlist_head
;
674 const struct got_error
*got_send_ack(pid_t
);
675 const struct got_error
*got_privsep_wait_for_child(pid_t
);
676 const struct got_error
*got_privsep_flush_imsg(struct imsgbuf
*);
677 const struct got_error
*got_privsep_send_stop(int);
678 const struct got_error
*got_privsep_recv_imsg(struct imsg
*, struct imsgbuf
*,
680 void got_privsep_send_error(struct imsgbuf
*, const struct got_error
*);
681 const struct got_error
*got_privsep_send_ack(struct imsgbuf
*);
682 const struct got_error
*got_privsep_wait_ack(struct imsgbuf
*);
683 const struct got_error
*got_privsep_send_obj_req(struct imsgbuf
*, int,
684 struct got_object_id
*);
685 const struct got_error
*got_privsep_send_raw_obj_req(struct imsgbuf
*, int,
686 struct got_object_id
*);
687 const struct got_error
*got_privsep_send_raw_obj_outfd(struct imsgbuf
*, int);
688 const struct got_error
*got_privsep_send_commit_req(struct imsgbuf
*, int,
689 struct got_object_id
*, int);
690 const struct got_error
*got_privsep_send_tree_req(struct imsgbuf
*, int,
691 struct got_object_id
*, int);
692 const struct got_error
*got_privsep_send_tag_req(struct imsgbuf
*, int,
693 struct got_object_id
*, int);
694 const struct got_error
*got_privsep_send_blob_req(struct imsgbuf
*, int,
695 struct got_object_id
*, int);
696 const struct got_error
*got_privsep_send_blob_outfd(struct imsgbuf
*, int);
697 const struct got_error
*got_privsep_send_tmpfd(struct imsgbuf
*, int);
698 const struct got_error
*got_privsep_send_obj(struct imsgbuf
*,
699 struct got_object
*);
700 const struct got_error
*got_privsep_send_index_pack_req(struct imsgbuf
*,
702 const struct got_error
*got_privsep_send_index_pack_outfd(struct imsgbuf
*,
704 const struct got_error
*got_privsep_recv_index_progress(int *, int *, int *,
705 int *, int *, struct imsgbuf
*ibuf
);
706 const struct got_error
*got_privsep_send_fetch_req(struct imsgbuf
*, int,
707 struct got_pathlist_head
*, int, struct got_pathlist_head
*,
708 struct got_pathlist_head
*, int, const char *, const char *, int, int);
709 const struct got_error
*got_privsep_send_fetch_outfd(struct imsgbuf
*, int);
710 const struct got_error
*got_privsep_recv_fetch_progress(int *,
711 struct got_object_id
**, char **, struct got_pathlist_head
*, char **,
712 off_t
*, uint8_t *, struct imsgbuf
*);
713 const struct got_error
*got_privsep_send_send_req(struct imsgbuf
*, int,
714 struct got_pathlist_head
*, struct got_pathlist_head
*, int);
715 const struct got_error
*got_privsep_recv_send_remote_refs(
716 struct got_pathlist_head
*, struct imsgbuf
*);
717 const struct got_error
*got_privsep_send_packfd(struct imsgbuf
*, int);
718 const struct got_error
*got_privsep_recv_send_progress(int *, off_t
*,
719 int *, char **, char **, struct imsgbuf
*);
720 const struct got_error
*got_privsep_get_imsg_obj(struct got_object
**,
721 struct imsg
*, struct imsgbuf
*);
722 const struct got_error
*got_privsep_recv_obj(struct got_object
**,
724 const struct got_error
*got_privsep_send_raw_obj(struct imsgbuf
*, off_t
,
726 const struct got_error
*got_privsep_recv_raw_obj(uint8_t **, off_t
*, size_t *,
728 const struct got_error
*got_privsep_send_commit(struct imsgbuf
*,
729 struct got_commit_object
*);
730 const struct got_error
*got_privsep_recv_commit(struct got_commit_object
**,
732 const struct got_error
*got_privsep_recv_tree(struct got_tree_object
**,
734 struct got_parsed_tree_entry
;
735 const struct got_error
*got_privsep_send_tree(struct imsgbuf
*,
736 struct got_parsed_tree_entry
*, int);
737 const struct got_error
*got_privsep_send_blob(struct imsgbuf
*, size_t, size_t,
739 const struct got_error
*got_privsep_recv_blob(uint8_t **, size_t *, size_t *,
741 const struct got_error
*got_privsep_send_tag(struct imsgbuf
*,
742 struct got_tag_object
*);
743 const struct got_error
*got_privsep_recv_tag(struct got_tag_object
**,
745 const struct got_error
*got_privsep_init_pack_child(struct imsgbuf
*,
746 struct got_pack
*, struct got_packidx
*);
747 const struct got_error
*got_privsep_send_packed_obj_req(struct imsgbuf
*, int,
748 struct got_object_id
*);
749 const struct got_error
*got_privsep_send_packed_raw_obj_req(struct imsgbuf
*,
750 int, struct got_object_id
*);
751 const struct got_error
*got_privsep_send_pack_child_ready(struct imsgbuf
*);
753 const struct got_error
*got_privsep_send_gitconfig_parse_req(struct imsgbuf
*,
755 const struct got_error
*
756 got_privsep_send_gitconfig_repository_format_version_req(struct imsgbuf
*);
757 const struct got_error
*got_privsep_send_gitconfig_repository_extensions_req(
759 const struct got_error
*got_privsep_send_gitconfig_author_name_req(
761 const struct got_error
*got_privsep_send_gitconfig_author_email_req(
763 const struct got_error
*got_privsep_send_gitconfig_remotes_req(
765 const struct got_error
*got_privsep_send_gitconfig_owner_req(struct imsgbuf
*);
766 const struct got_error
*got_privsep_recv_gitconfig_str(char **,
768 const struct got_error
*got_privsep_recv_gitconfig_pair(char **, char **,
770 const struct got_error
*got_privsep_recv_gitconfig_int(int *, struct imsgbuf
*);
771 const struct got_error
*got_privsep_recv_gitconfig_remotes(
772 struct got_remote_repo
**, int *, struct imsgbuf
*);
774 const struct got_error
*got_privsep_send_gotconfig_parse_req(struct imsgbuf
*,
776 const struct got_error
*got_privsep_send_gotconfig_author_req(struct imsgbuf
*);
777 const struct got_error
*got_privsep_send_gotconfig_allowed_signers_req(
779 const struct got_error
*got_privsep_send_gotconfig_revoked_signers_req(
781 const struct got_error
*got_privsep_send_gotconfig_signer_id_req(
783 const struct got_error
*got_privsep_send_gotconfig_remotes_req(
785 const struct got_error
*got_privsep_recv_gotconfig_str(char **,
787 const struct got_error
*got_privsep_recv_gotconfig_remotes(
788 struct got_remote_repo
**, int *, struct imsgbuf
*);
790 const struct got_error
*got_privsep_send_commit_traversal_request(
791 struct imsgbuf
*, struct got_object_id
*, int, const char *);
792 const struct got_error
*got_privsep_recv_traversed_commits(
793 struct got_commit_object
**, struct got_object_id_queue
*,
795 const struct got_error
*got_privsep_send_enumerated_tree(size_t *,
796 struct imsgbuf
*, struct got_object_id
*, const char *,
797 struct got_parsed_tree_entry
*, int);
798 const struct got_error
*got_privsep_send_object_enumeration_request(
800 const struct got_error
*got_privsep_send_object_enumeration_done(
802 const struct got_error
*got_privsep_send_object_enumeration_incomplete(
804 const struct got_error
*got_privsep_send_enumerated_commit(struct imsgbuf
*,
805 struct got_object_id
*, time_t);
806 const struct got_error
*got_privsep_recv_enumerated_objects(int *,
807 struct imsgbuf
*, got_object_enumerate_commit_cb
,
808 got_object_enumerate_tree_cb
, void *, struct got_repository
*);
810 const struct got_error
*got_privsep_send_raw_delta_req(struct imsgbuf
*, int,
811 struct got_object_id
*);
812 const struct got_error
*got_privsep_send_raw_delta_outfd(struct imsgbuf
*, int);
813 const struct got_error
*got_privsep_send_raw_delta(struct imsgbuf
*, uint64_t,
814 uint64_t, off_t
, off_t
, off_t
, off_t
, struct got_object_id
*);
815 const struct got_error
*got_privsep_recv_raw_delta(uint64_t *, uint64_t *,
816 off_t
*, off_t
*, off_t
*, off_t
*, struct got_object_id
**,
819 const struct got_error
*got_privsep_send_object_idlist(struct imsgbuf
*,
820 struct got_object_id
**, size_t);
821 const struct got_error
*got_privsep_send_object_idlist_done(struct imsgbuf
*);
822 const struct got_error
*got_privsep_recv_object_idlist(int *,
823 struct got_object_id
**, size_t *, struct imsgbuf
*);
825 const struct got_error
*got_privsep_send_delta_reuse_req(struct imsgbuf
*);
826 const struct got_error
*got_privsep_send_reused_deltas(struct imsgbuf
*,
827 struct got_imsg_reused_delta
*, size_t);
828 const struct got_error
*got_privsep_send_reused_deltas_done(struct imsgbuf
*);
829 const struct got_error
*got_privsep_recv_reused_deltas(int *,
830 struct got_imsg_reused_delta
*, size_t *, struct imsgbuf
*);
832 const struct got_error
*got_privsep_init_commit_painting(struct imsgbuf
*);
833 const struct got_error
*got_privsep_send_painting_request(struct imsgbuf
*,
834 int, struct got_object_id
*, intptr_t);
835 typedef const struct got_error
*(*got_privsep_recv_painted_commit_cb
)(void *,
836 struct got_object_id
*, intptr_t);
837 const struct got_error
*got_privsep_send_painted_commits(struct imsgbuf
*,
838 struct got_object_id_queue
*, int *, int, int);
839 const struct got_error
*got_privsep_send_painting_commits_done(struct imsgbuf
*);
840 const struct got_error
*got_privsep_recv_painted_commits(
841 struct got_object_id_queue
*, got_privsep_recv_painted_commit_cb
, void *,
844 void got_privsep_exec_child(int[2], const char *, const char *);