Blame


1 7be7cc45 2018-04-02 stsp /*
2 5d56da81 2019-01-13 stsp * Copyright (c) 2018, 2019 Stefan Sperling <stsp@openbsd.org>
3 93658fb9 2020-03-18 stsp * Copyright (c) 2019, Ori Bernstein <ori@openbsd.org>
4 7be7cc45 2018-04-02 stsp *
5 7be7cc45 2018-04-02 stsp * Permission to use, copy, modify, and distribute this software for any
6 7be7cc45 2018-04-02 stsp * purpose with or without fee is hereby granted, provided that the above
7 7be7cc45 2018-04-02 stsp * copyright notice and this permission notice appear in all copies.
8 7be7cc45 2018-04-02 stsp *
9 7be7cc45 2018-04-02 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 7be7cc45 2018-04-02 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 7be7cc45 2018-04-02 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 7be7cc45 2018-04-02 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 7be7cc45 2018-04-02 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 7be7cc45 2018-04-02 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 7be7cc45 2018-04-02 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 7be7cc45 2018-04-02 stsp */
17 7be7cc45 2018-04-02 stsp
18 7be7cc45 2018-04-02 stsp /*
19 7be7cc45 2018-04-02 stsp * All code runs under the same UID but sensitive code paths are
20 7be7cc45 2018-04-02 stsp * run in a separate process with tighter pledge(2) promises.
21 2ca3a24b 2018-04-02 stsp * Data is communicated between processes via imsg_flush(3) and imsg_read(3).
22 7be7cc45 2018-04-02 stsp * This behaviour is transparent to users of the library.
23 7be7cc45 2018-04-02 stsp *
24 1e4880cb 2018-04-02 stsp * We generally transmit data in imsg buffers, split across several messages
25 ff6b18f8 2018-04-24 stsp * if necessary. File descriptors are used in cases where this is impractical,
26 ff6b18f8 2018-04-24 stsp * such as when accessing pack files or when transferring large blobs.
27 7be7cc45 2018-04-02 stsp *
28 ad242220 2018-09-08 stsp * We exec(2) after a fork(2). Parts of our library functionality are
29 ad242220 2018-09-08 stsp * accessible via separate executables in a libexec directory.
30 7be7cc45 2018-04-02 stsp */
31 7be7cc45 2018-04-02 stsp
32 ad242220 2018-09-08 stsp #define GOT_IMSG_FD_CHILD (STDERR_FILENO + 1)
33 ad242220 2018-09-08 stsp
34 ad242220 2018-09-08 stsp #ifndef GOT_LIBEXECDIR
35 ad242220 2018-09-08 stsp #define GOT_LIBEXECDIR /usr/libexec
36 ad242220 2018-09-08 stsp #endif
37 ad242220 2018-09-08 stsp
38 ad242220 2018-09-08 stsp /* Names of helper programs in libexec directory */
39 ad242220 2018-09-08 stsp #define GOT_PROG_READ_OBJECT got-read-object
40 ad242220 2018-09-08 stsp #define GOT_PROG_READ_TREE got-read-tree
41 ad242220 2018-09-08 stsp #define GOT_PROG_READ_COMMIT got-read-commit
42 ad242220 2018-09-08 stsp #define GOT_PROG_READ_BLOB got-read-blob
43 f4a881ce 2018-11-17 stsp #define GOT_PROG_READ_TAG got-read-tag
44 876c234b 2018-09-10 stsp #define GOT_PROG_READ_PACK got-read-pack
45 aba9c984 2019-09-08 stsp #define GOT_PROG_READ_GITCONFIG got-read-gitconfig
46 93658fb9 2020-03-18 stsp #define GOT_PROG_FETCH_PACK got-fetch-pack
47 93658fb9 2020-03-18 stsp #define GOT_PROG_INDEX_PACK got-index-pack
48 93658fb9 2020-03-18 stsp #define GOT_PROG_SEND_PACK got-send-pack
49 ad242220 2018-09-08 stsp
50 ad242220 2018-09-08 stsp #define GOT_STRINGIFY(x) #x
51 ad242220 2018-09-08 stsp #define GOT_STRINGVAL(x) GOT_STRINGIFY(x)
52 ad242220 2018-09-08 stsp
53 ad242220 2018-09-08 stsp /* Paths to helper programs in libexec directory */
54 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_OBJECT \
55 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_OBJECT)
56 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_TREE \
57 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TREE)
58 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_COMMIT \
59 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_COMMIT)
60 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_BLOB \
61 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_BLOB)
62 f4a881ce 2018-11-17 stsp #define GOT_PATH_PROG_READ_TAG \
63 f4a881ce 2018-11-17 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TAG)
64 876c234b 2018-09-10 stsp #define GOT_PATH_PROG_READ_PACK \
65 876c234b 2018-09-10 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_PACK)
66 aba9c984 2019-09-08 stsp #define GOT_PATH_PROG_READ_GITCONFIG \
67 aba9c984 2019-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_GITCONFIG)
68 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_FETCH_PACK \
69 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_FETCH_PACK)
70 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_SEND_PACK \
71 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_SEND_PACK)
72 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_INDEX_PACK \
73 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_INDEX_PACK)
74 ad242220 2018-09-08 stsp
75 876c234b 2018-09-10 stsp struct got_privsep_child {
76 876c234b 2018-09-10 stsp int imsg_fd;
77 876c234b 2018-09-10 stsp pid_t pid;
78 876c234b 2018-09-10 stsp struct imsgbuf *ibuf;
79 876c234b 2018-09-10 stsp };
80 876c234b 2018-09-10 stsp
81 7be7cc45 2018-04-02 stsp enum got_imsg_type {
82 c025a41e 2018-04-02 stsp /* An error occured while processing a request. */
83 c025a41e 2018-04-02 stsp GOT_IMSG_ERROR,
84 c025a41e 2018-04-02 stsp
85 ad242220 2018-09-08 stsp /* Stop the child process. */
86 ad242220 2018-09-08 stsp GOT_IMSG_STOP,
87 1e4880cb 2018-04-02 stsp
88 7be7cc45 2018-04-02 stsp /*
89 7be7cc45 2018-04-02 stsp * Messages concerned with read access to objects in a repository.
90 7be7cc45 2018-04-02 stsp * Object and pack files are opened by the main process, where
91 7be7cc45 2018-04-02 stsp * data may be read as a byte string but without any interpretation.
92 7be7cc45 2018-04-02 stsp * Decompression and parsing of object and pack files occurs in a
93 f0b0c746 2018-09-09 stsp * separate process which runs under pledge("stdio recvfd").
94 7be7cc45 2018-04-02 stsp * This sandboxes our own repository parsing code, as well as zlib.
95 7be7cc45 2018-04-02 stsp */
96 ad242220 2018-09-08 stsp GOT_IMSG_OBJECT_REQUEST,
97 2178c42e 2018-04-22 stsp GOT_IMSG_OBJECT,
98 ad242220 2018-09-08 stsp GOT_IMSG_COMMIT_REQUEST,
99 bff6ca00 2018-04-23 stsp GOT_IMSG_COMMIT,
100 c75f7264 2018-09-11 stsp GOT_IMSG_COMMIT_LOGMSG,
101 ad242220 2018-09-08 stsp GOT_IMSG_TREE_REQUEST,
102 366d86ca 2018-04-23 stsp GOT_IMSG_TREE,
103 d80ab12b 2018-04-02 stsp GOT_IMSG_TREE_ENTRY,
104 ad242220 2018-09-08 stsp GOT_IMSG_BLOB_REQUEST,
105 ad242220 2018-09-08 stsp GOT_IMSG_BLOB_OUTFD,
106 366d86ca 2018-04-23 stsp GOT_IMSG_BLOB,
107 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG_REQUEST,
108 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG,
109 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG_TAGMSG,
110 876c234b 2018-09-10 stsp
111 93658fb9 2020-03-18 stsp /* Messages related to networking. */
112 93658fb9 2020-03-18 stsp GOT_IMSG_FETCH_REQUEST,
113 abe0f35f 2020-03-18 stsp GOT_IMSG_FETCH_SYMREFS,
114 ea7396b9 2020-03-18 stsp GOT_IMSG_FETCH_REF,
115 531c3985 2020-03-18 stsp GOT_IMSG_FETCH_SERVER_PROGRESS,
116 d2cdc636 2020-03-18 stsp GOT_IMSG_FETCH_DOWNLOAD_PROGRESS,
117 93658fb9 2020-03-18 stsp GOT_IMSG_FETCH_DONE,
118 93658fb9 2020-03-18 stsp GOT_IMSG_IDXPACK_REQUEST,
119 baa9fea0 2020-03-18 stsp GOT_IMSG_IDXPACK_PROGRESS,
120 93658fb9 2020-03-18 stsp GOT_IMSG_IDXPACK_DONE,
121 93658fb9 2020-03-18 stsp
122 876c234b 2018-09-10 stsp /* Messages related to pack files. */
123 876c234b 2018-09-10 stsp GOT_IMSG_PACKIDX,
124 876c234b 2018-09-10 stsp GOT_IMSG_PACK,
125 876c234b 2018-09-10 stsp GOT_IMSG_PACKED_OBJECT_REQUEST,
126 ca6e02ac 2020-01-07 stsp GOT_IMSG_COMMIT_TRAVERSAL_REQUEST,
127 ca6e02ac 2020-01-07 stsp GOT_IMSG_TRAVERSED_COMMITS,
128 ca6e02ac 2020-01-07 stsp GOT_IMSG_COMMIT_TRAVERSAL_DONE,
129 3840f4c9 2018-09-12 stsp
130 33ad4cbe 2019-05-12 jcs /* Message sending file descriptor to a temporary file. */
131 3840f4c9 2018-09-12 stsp GOT_IMSG_TMPFD,
132 aba9c984 2019-09-08 stsp
133 aba9c984 2019-09-08 stsp /* Messages related to gitconfig files. */
134 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_PARSE_REQUEST,
135 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_REPOSITORY_FORMAT_VERSION_REQUEST,
136 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_AUTHOR_NAME_REQUEST,
137 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_AUTHOR_EMAIL_REQUEST,
138 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTES_REQUEST,
139 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_INT_VAL,
140 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_STR_VAL,
141 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTES,
142 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTE,
143 9a1cc63f 2020-02-03 stsp GOT_IMSG_GITCONFIG_OWNER_REQUEST,
144 9a1cc63f 2020-02-03 stsp GOT_IMSG_GITCONFIG_OWNER,
145 7be7cc45 2018-04-02 stsp };
146 7be7cc45 2018-04-02 stsp
147 c025a41e 2018-04-02 stsp /* Structure for GOT_IMSG_ERROR. */
148 c025a41e 2018-04-02 stsp struct got_imsg_error {
149 c025a41e 2018-04-02 stsp int code; /* an error code from got_error.h */
150 2178c42e 2018-04-22 stsp int errno_code; /* in case code equals GOT_ERR_ERRNO */
151 291624d8 2018-11-07 stsp } __attribute__((__packed__));
152 c025a41e 2018-04-02 stsp
153 ad242220 2018-09-08 stsp /*
154 1785f84a 2018-12-23 stsp * Structure for GOT_IMSG_TREE_REQUEST and GOT_IMSG_OBJECT data.
155 ad242220 2018-09-08 stsp */
156 f7171542 2018-04-02 stsp struct got_imsg_object {
157 c59b3346 2018-09-11 stsp uint8_t id[SHA1_DIGEST_LENGTH];
158 c59b3346 2018-09-11 stsp
159 7be7cc45 2018-04-02 stsp /* These fields are the same as in struct got_object. */
160 7be7cc45 2018-04-02 stsp int type;
161 7be7cc45 2018-04-02 stsp int flags;
162 7be7cc45 2018-04-02 stsp size_t hdrlen;
163 7be7cc45 2018-04-02 stsp size_t size;
164 876c234b 2018-09-10 stsp off_t pack_offset;
165 c59b3346 2018-09-11 stsp int pack_idx;
166 291624d8 2018-11-07 stsp } __attribute__((__packed__));
167 7be7cc45 2018-04-02 stsp
168 366d86ca 2018-04-23 stsp /* Structure for GOT_IMSG_COMMIT data. */
169 bff6ca00 2018-04-23 stsp struct got_imsg_commit_object {
170 86acc566 2018-04-23 stsp uint8_t tree_id[SHA1_DIGEST_LENGTH];
171 bff6ca00 2018-04-23 stsp size_t author_len;
172 ccb26ccd 2018-11-05 stsp time_t author_time;
173 ccb26ccd 2018-11-05 stsp time_t author_gmtoff;
174 bff6ca00 2018-04-23 stsp size_t committer_len;
175 ccb26ccd 2018-11-05 stsp time_t committer_time;
176 ccb26ccd 2018-11-05 stsp time_t committer_gmtoff;
177 bff6ca00 2018-04-23 stsp size_t logmsg_len;
178 bff6ca00 2018-04-23 stsp int nparents;
179 bff6ca00 2018-04-23 stsp
180 6c281f94 2018-06-11 stsp /*
181 c75f7264 2018-09-11 stsp * Followed by author_len + committer_len data bytes
182 6c281f94 2018-06-11 stsp */
183 bff6ca00 2018-04-23 stsp
184 86acc566 2018-04-23 stsp /* Followed by 'nparents' SHA1_DIGEST_LENGTH length strings */
185 bff6ca00 2018-04-23 stsp
186 c75f7264 2018-09-11 stsp /*
187 c75f7264 2018-09-11 stsp * Followed by 'logmsg_len' bytes of commit log message data in
188 c75f7264 2018-09-11 stsp * one or more GOT_IMSG_COMMIT_LOGMSG messages.
189 c75f7264 2018-09-11 stsp */
190 bff6ca00 2018-04-23 stsp } __attribute__((__packed__));
191 bff6ca00 2018-04-23 stsp
192 f7171542 2018-04-02 stsp
193 48f392b2 2018-04-02 stsp /* Structure for GOT_IMSG_TREE_ENTRY. */
194 48f392b2 2018-04-02 stsp struct got_imsg_tree_entry {
195 e033d803 2018-04-23 stsp char id[SHA1_DIGEST_LENGTH];
196 48f392b2 2018-04-02 stsp mode_t mode;
197 48f392b2 2018-04-02 stsp /* Followed by entry's name in remaining data of imsg buffer. */
198 8d98bcfb 2018-04-02 stsp } __attribute__((__packed__));
199 48f392b2 2018-04-02 stsp
200 d80ab12b 2018-04-02 stsp /* Structure for GOT_IMSG_TREE_OBJECT_REPLY data. */
201 48f392b2 2018-04-02 stsp struct got_imsg_tree_object {
202 48f392b2 2018-04-02 stsp int nentries; /* This many TREE_ENTRY messages follow. */
203 48f392b2 2018-04-02 stsp };
204 48f392b2 2018-04-02 stsp
205 2967a784 2018-04-24 stsp /* Structure for GOT_IMSG_BLOB. */
206 2967a784 2018-04-24 stsp struct got_imsg_blob {
207 2967a784 2018-04-24 stsp size_t size;
208 ebc55e2d 2018-12-24 stsp size_t hdrlen;
209 ac544f8c 2019-01-13 stsp
210 ac544f8c 2019-01-13 stsp /*
211 ac544f8c 2019-01-13 stsp * If size <= GOT_PRIVSEP_INLINE_BLOB_DATA_MAX, blob data follows
212 ac544f8c 2019-01-13 stsp * in the imsg buffer. Otherwise, blob data has been written to a
213 ac544f8c 2019-01-13 stsp * file descriptor passed via the GOT_IMSG_BLOB_OUTFD imsg.
214 ac544f8c 2019-01-13 stsp */
215 ac544f8c 2019-01-13 stsp #define GOT_PRIVSEP_INLINE_BLOB_DATA_MAX \
216 ac544f8c 2019-01-13 stsp (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_blob))
217 2967a784 2018-04-24 stsp };
218 2967a784 2018-04-24 stsp
219 ac544f8c 2019-01-13 stsp
220 f4a881ce 2018-11-17 stsp /* Structure for GOT_IMSG_TAG data. */
221 f4a881ce 2018-11-17 stsp struct got_imsg_tag_object {
222 f4a881ce 2018-11-17 stsp uint8_t id[SHA1_DIGEST_LENGTH];
223 f4a881ce 2018-11-17 stsp int obj_type;
224 f4a881ce 2018-11-17 stsp size_t tag_len;
225 f4a881ce 2018-11-17 stsp size_t tagger_len;
226 f4a881ce 2018-11-17 stsp time_t tagger_time;
227 f4a881ce 2018-11-17 stsp time_t tagger_gmtoff;
228 f4a881ce 2018-11-17 stsp size_t tagmsg_len;
229 f4a881ce 2018-11-17 stsp
230 f4a881ce 2018-11-17 stsp /*
231 f4a881ce 2018-11-17 stsp * Followed by tag_len + tagger_len data bytes
232 f4a881ce 2018-11-17 stsp */
233 f4a881ce 2018-11-17 stsp
234 f4a881ce 2018-11-17 stsp /*
235 f4a881ce 2018-11-17 stsp * Followed by 'tagmsg_len' bytes of tag message data in
236 f4a881ce 2018-11-17 stsp * one or more GOT_IMSG_TAG_TAGMSG messages.
237 f4a881ce 2018-11-17 stsp */
238 abe0f35f 2020-03-18 stsp } __attribute__((__packed__));
239 33501562 2020-03-18 stsp
240 33501562 2020-03-18 stsp /* Structures for GOT_IMSG_FETCH_REQUEST data. */
241 33501562 2020-03-18 stsp struct got_imsg_fetch_have_ref {
242 33501562 2020-03-18 stsp uint8_t id[SHA1_DIGEST_LENGTH];
243 33501562 2020-03-18 stsp size_t name_len;
244 33501562 2020-03-18 stsp /* Followed by name_len data bytes. */
245 33501562 2020-03-18 stsp };
246 33501562 2020-03-18 stsp struct got_imsg_fetch_have_refs {
247 33501562 2020-03-18 stsp size_t n_have_refs;
248 33501562 2020-03-18 stsp /* Followed by n_have_refs times of got_imsg_fetch_have_ref data. */
249 33501562 2020-03-18 stsp };
250 abe0f35f 2020-03-18 stsp
251 abe0f35f 2020-03-18 stsp /* Structures for GOT_IMSG_FETCH_SYMREFS data. */
252 abe0f35f 2020-03-18 stsp struct got_imsg_fetch_symref {
253 abe0f35f 2020-03-18 stsp size_t name_len;
254 abe0f35f 2020-03-18 stsp size_t target_len;
255 abe0f35f 2020-03-18 stsp
256 abe0f35f 2020-03-18 stsp /*
257 d45e6863 2020-03-18 stsp * Followed by name_len + target_len data bytes.
258 abe0f35f 2020-03-18 stsp */
259 abe0f35f 2020-03-18 stsp } __attribute__((__packed__));
260 abe0f35f 2020-03-18 stsp
261 abe0f35f 2020-03-18 stsp struct got_imsg_fetch_symrefs {
262 abe0f35f 2020-03-18 stsp size_t nsymrefs;
263 abe0f35f 2020-03-18 stsp
264 abe0f35f 2020-03-18 stsp /* Followed by nsymrefs times of got_imsg_fetch_symref data. */
265 f4a881ce 2018-11-17 stsp } __attribute__((__packed__));
266 b9f99abf 2020-03-18 stsp
267 ea7396b9 2020-03-18 stsp /* Structure for GOT_IMSG_FETCH_REF data. */
268 ea7396b9 2020-03-18 stsp struct got_imsg_fetch_ref {
269 abe0f35f 2020-03-18 stsp /* Describes a reference which will be fetched. */
270 b9f99abf 2020-03-18 stsp uint8_t refid[SHA1_DIGEST_LENGTH];
271 b9f99abf 2020-03-18 stsp /* Followed by reference name in remaining data of imsg buffer. */
272 b9f99abf 2020-03-18 stsp };
273 f4a881ce 2018-11-17 stsp
274 d2cdc636 2020-03-18 stsp /* Structure for GOT_IMSG_FETCH_DOWNLOAD_PROGRESS data. */
275 d2cdc636 2020-03-18 stsp struct got_imsg_fetch_download_progress {
276 d2cdc636 2020-03-18 stsp /* Number of packfile data bytes downloaded so far. */
277 d2cdc636 2020-03-18 stsp off_t packfile_bytes;
278 baa9fea0 2020-03-18 stsp };
279 668a20f6 2020-03-18 stsp
280 668a20f6 2020-03-18 stsp /* Structure for GOT_IMSG_IDXPACK_REQUEST data. */
281 668a20f6 2020-03-18 stsp struct got_imsg_index_pack_request {
282 668a20f6 2020-03-18 stsp uint8_t pack_hash[SHA1_DIGEST_LENGTH];
283 668a20f6 2020-03-18 stsp } __attribute__((__packed__));
284 baa9fea0 2020-03-18 stsp
285 baa9fea0 2020-03-18 stsp /* Structure for GOT_IMSG_IDXPACK_PROGRESS data. */
286 baa9fea0 2020-03-18 stsp struct got_imsg_index_pack_progress {
287 baa9fea0 2020-03-18 stsp /* Total number of objects in pack file. */
288 668a20f6 2020-03-18 stsp int nobj_total;
289 668a20f6 2020-03-18 stsp
290 baa9fea0 2020-03-18 stsp /* Number of objects indexed so far. */
291 668a20f6 2020-03-18 stsp int nobj_indexed;
292 668a20f6 2020-03-18 stsp
293 668a20f6 2020-03-18 stsp /* Number of non-deltified objects in pack file. */
294 668a20f6 2020-03-18 stsp int nobj_loose;
295 668a20f6 2020-03-18 stsp
296 668a20f6 2020-03-18 stsp /* Number of deltified objects resolved so far. */
297 668a20f6 2020-03-18 stsp int nobj_resolved;
298 d2cdc636 2020-03-18 stsp };
299 d2cdc636 2020-03-18 stsp
300 876c234b 2018-09-10 stsp /* Structure for GOT_IMSG_PACKIDX. */
301 876c234b 2018-09-10 stsp struct got_imsg_packidx {
302 876c234b 2018-09-10 stsp size_t len;
303 876c234b 2018-09-10 stsp /* Additionally, a file desciptor is passed via imsg. */
304 876c234b 2018-09-10 stsp };
305 876c234b 2018-09-10 stsp
306 876c234b 2018-09-10 stsp /* Structure for GOT_IMSG_PACK. */
307 876c234b 2018-09-10 stsp struct got_imsg_pack {
308 876c234b 2018-09-10 stsp char path_packfile[PATH_MAX];
309 876c234b 2018-09-10 stsp size_t filesize;
310 876c234b 2018-09-10 stsp /* Additionally, a file desciptor is passed via imsg. */
311 291624d8 2018-11-07 stsp } __attribute__((__packed__));
312 876c234b 2018-09-10 stsp
313 876c234b 2018-09-10 stsp /*
314 876c234b 2018-09-10 stsp * Structure for GOT_IMSG_PACKED_OBJECT_REQUEST data.
315 876c234b 2018-09-10 stsp */
316 876c234b 2018-09-10 stsp struct got_imsg_packed_object {
317 106807b4 2018-09-15 stsp uint8_t id[SHA1_DIGEST_LENGTH];
318 876c234b 2018-09-10 stsp int idx;
319 291624d8 2018-11-07 stsp } __attribute__((__packed__));
320 876c234b 2018-09-10 stsp
321 ca6e02ac 2020-01-07 stsp /* Structure for GOT_IMSG_COMMIT_TRAVERSAL_REQUEST */
322 ca6e02ac 2020-01-07 stsp struct got_imsg_commit_traversal_request {
323 ca6e02ac 2020-01-07 stsp uint8_t id[SHA1_DIGEST_LENGTH];
324 ca6e02ac 2020-01-07 stsp int idx;
325 ca6e02ac 2020-01-07 stsp size_t path_len;
326 ca6e02ac 2020-01-07 stsp /* Followed by path_len bytes of path data */
327 ca6e02ac 2020-01-07 stsp } __attribute__((__packed__));
328 ca6e02ac 2020-01-07 stsp
329 ca6e02ac 2020-01-07 stsp /* Structure for GOT_IMSG_TRAVERSED_COMMITS */
330 ca6e02ac 2020-01-07 stsp struct got_imsg_traversed_commits {
331 ca6e02ac 2020-01-07 stsp size_t ncommits;
332 ca6e02ac 2020-01-07 stsp /* Followed by ncommit IDs of SHA1_DIGEST_LENGTH each */
333 ca6e02ac 2020-01-07 stsp } __attribute__((__packed__));
334 ca6e02ac 2020-01-07 stsp
335 cd95becd 2019-11-29 stsp /*
336 cd95becd 2019-11-29 stsp * Structure for GOT_IMSG_GITCONFIG_REMOTE data.
337 cd95becd 2019-11-29 stsp */
338 cd95becd 2019-11-29 stsp struct got_imsg_remote {
339 cd95becd 2019-11-29 stsp size_t name_len;
340 cd95becd 2019-11-29 stsp size_t url_len;
341 cd95becd 2019-11-29 stsp
342 cd95becd 2019-11-29 stsp /* Followed by name_len + url_len data bytes. */
343 cd95becd 2019-11-29 stsp };
344 cd95becd 2019-11-29 stsp
345 cd95becd 2019-11-29 stsp /*
346 cd95becd 2019-11-29 stsp * Structure for GOT_IMSG_GITCONFIG_REMOTES data.
347 cd95becd 2019-11-29 stsp */
348 cd95becd 2019-11-29 stsp struct got_imsg_remotes {
349 cd95becd 2019-11-29 stsp int nremotes; /* This many GOT_IMSG_GITCONFIG_REMOTE messages follow. */
350 cd95becd 2019-11-29 stsp };
351 cd95becd 2019-11-29 stsp
352 cd95becd 2019-11-29 stsp struct got_remote_repo;
353 876c234b 2018-09-10 stsp struct got_pack;
354 876c234b 2018-09-10 stsp struct got_packidx;
355 3022d272 2019-11-14 stsp struct got_pathlist_head;
356 876c234b 2018-09-10 stsp
357 93658fb9 2020-03-18 stsp const struct got_error *got_send_ack(pid_t);
358 876c234b 2018-09-10 stsp const struct got_error *got_privsep_wait_for_child(pid_t);
359 ad242220 2018-09-08 stsp const struct got_error *got_privsep_send_stop(int);
360 ad242220 2018-09-08 stsp const struct got_error *got_privsep_recv_imsg(struct imsg *, struct imsgbuf *,
361 ad242220 2018-09-08 stsp size_t);
362 2178c42e 2018-04-22 stsp void got_privsep_send_error(struct imsgbuf *, const struct got_error *);
363 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_send_ack(struct imsgbuf *);
364 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_wait_ack(struct imsgbuf *);
365 aea5f015 2018-12-24 stsp const struct got_error *got_privsep_send_obj_req(struct imsgbuf *, int);
366 1785f84a 2018-12-23 stsp const struct got_error *got_privsep_send_commit_req(struct imsgbuf *, int,
367 1785f84a 2018-12-23 stsp struct got_object_id *, int);
368 13c729f7 2018-12-24 stsp const struct got_error *got_privsep_send_tree_req(struct imsgbuf *, int,
369 13c729f7 2018-12-24 stsp struct got_object_id *, int);
370 268f7291 2018-12-24 stsp const struct got_error *got_privsep_send_tag_req(struct imsgbuf *, int,
371 268f7291 2018-12-24 stsp struct got_object_id *, int);
372 ebc55e2d 2018-12-24 stsp const struct got_error *got_privsep_send_blob_req(struct imsgbuf *, int,
373 ebc55e2d 2018-12-24 stsp struct got_object_id *, int);
374 55da3778 2018-09-10 stsp const struct got_error *got_privsep_send_blob_outfd(struct imsgbuf *, int);
375 3840f4c9 2018-09-12 stsp const struct got_error *got_privsep_send_tmpfd(struct imsgbuf *, int);
376 2178c42e 2018-04-22 stsp const struct got_error *got_privsep_send_obj(struct imsgbuf *,
377 876c234b 2018-09-10 stsp struct got_object *);
378 668a20f6 2020-03-18 stsp const struct got_error *got_privsep_send_index_pack_req(struct imsgbuf *,
379 668a20f6 2020-03-18 stsp uint8_t *, int);
380 baa9fea0 2020-03-18 stsp const struct got_error *got_privsep_send_index_pack_progress(struct imsgbuf *,
381 668a20f6 2020-03-18 stsp int, int, int, int);
382 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_send_index_pack_done(struct imsgbuf *);
383 baa9fea0 2020-03-18 stsp const struct got_error *got_privsep_recv_index_progress(int *, int *, int *,
384 668a20f6 2020-03-18 stsp int *, int *, struct imsgbuf *ibuf);
385 33501562 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_req(struct imsgbuf *, int,
386 33501562 2020-03-18 stsp struct got_pathlist_head *);
387 abe0f35f 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_symrefs(struct imsgbuf *,
388 abe0f35f 2020-03-18 stsp struct got_pathlist_head *);
389 ea7396b9 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_ref(struct imsgbuf *,
390 b9f99abf 2020-03-18 stsp struct got_object_id *, const char *);
391 531c3985 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_server_progress(struct imsgbuf *,
392 531c3985 2020-03-18 stsp const char *, size_t);
393 d2cdc636 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_download_progress(struct imsgbuf *,
394 d2cdc636 2020-03-18 stsp off_t);
395 8f2d01a6 2020-03-18 stsp const struct got_error *got_privsep_recv_fetch_progress(int *,
396 abe0f35f 2020-03-18 stsp struct got_object_id **, char **, struct got_pathlist_head *,
397 d2cdc636 2020-03-18 stsp char **, off_t *, struct imsgbuf *);
398 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_done(struct imsgbuf *,
399 93658fb9 2020-03-18 stsp struct got_object_id);
400 cfd633c2 2018-09-10 stsp const struct got_error *got_privsep_get_imsg_obj(struct got_object **,
401 cfd633c2 2018-09-10 stsp struct imsg *, struct imsgbuf *);
402 2178c42e 2018-04-22 stsp const struct got_error *got_privsep_recv_obj(struct got_object **,
403 2178c42e 2018-04-22 stsp struct imsgbuf *);
404 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_send_commit(struct imsgbuf *,
405 bff6ca00 2018-04-23 stsp struct got_commit_object *);
406 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_recv_commit(struct got_commit_object **,
407 bff6ca00 2018-04-23 stsp struct imsgbuf *);
408 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_recv_tree(struct got_tree_object **,
409 e033d803 2018-04-23 stsp struct imsgbuf *);
410 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_send_tree(struct imsgbuf *,
411 3022d272 2019-11-14 stsp struct got_pathlist_head *, int);
412 ac544f8c 2019-01-13 stsp const struct got_error *got_privsep_send_blob(struct imsgbuf *, size_t, size_t,
413 ac544f8c 2019-01-13 stsp const uint8_t *);
414 ac544f8c 2019-01-13 stsp const struct got_error *got_privsep_recv_blob(uint8_t **, size_t *, size_t *,
415 ebc55e2d 2018-12-24 stsp struct imsgbuf *);
416 f4a881ce 2018-11-17 stsp const struct got_error *got_privsep_send_tag(struct imsgbuf *,
417 f4a881ce 2018-11-17 stsp struct got_tag_object *);
418 f4a881ce 2018-11-17 stsp const struct got_error *got_privsep_recv_tag(struct got_tag_object **,
419 f4a881ce 2018-11-17 stsp struct imsgbuf *);
420 876c234b 2018-09-10 stsp const struct got_error *got_privsep_init_pack_child(struct imsgbuf *,
421 876c234b 2018-09-10 stsp struct got_pack *, struct got_packidx *);
422 106807b4 2018-09-15 stsp const struct got_error *got_privsep_send_packed_obj_req(struct imsgbuf *, int,
423 106807b4 2018-09-15 stsp struct got_object_id *);
424 41fa1437 2018-11-05 stsp const struct got_error *got_privsep_send_pack_child_ready(struct imsgbuf *);
425 aba9c984 2019-09-08 stsp
426 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_parse_req(struct imsgbuf *,
427 aba9c984 2019-09-08 stsp int);
428 aba9c984 2019-09-08 stsp const struct got_error *
429 aba9c984 2019-09-08 stsp got_privsep_send_gitconfig_repository_format_version_req(struct imsgbuf *);
430 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_author_name_req(
431 aba9c984 2019-09-08 stsp struct imsgbuf *);
432 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_author_email_req(
433 aba9c984 2019-09-08 stsp struct imsgbuf *);
434 cd95becd 2019-11-29 stsp const struct got_error *got_privsep_send_gitconfig_remotes_req(
435 cd95becd 2019-11-29 stsp struct imsgbuf *);
436 9a1cc63f 2020-02-03 stsp const struct got_error *got_privsep_send_gitconfig_owner_req(struct imsgbuf *);
437 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_str(struct imsgbuf *,
438 aba9c984 2019-09-08 stsp const char *);
439 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_recv_gitconfig_str(char **,
440 aba9c984 2019-09-08 stsp struct imsgbuf *);
441 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_int(struct imsgbuf *, int);
442 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_recv_gitconfig_int(int *, struct imsgbuf *);
443 cd95becd 2019-11-29 stsp const struct got_error *got_privsep_send_gitconfig_remotes(struct imsgbuf *,
444 cd95becd 2019-11-29 stsp struct got_remote_repo *, int);
445 cd95becd 2019-11-29 stsp const struct got_error *got_privsep_recv_gitconfig_remotes(
446 cd95becd 2019-11-29 stsp struct got_remote_repo **, int *, struct imsgbuf *);
447 aba9c984 2019-09-08 stsp
448 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_send_commit_traversal_request(
449 ca6e02ac 2020-01-07 stsp struct imsgbuf *, struct got_object_id *, int, const char *);
450 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_recv_traversed_commits(
451 ca6e02ac 2020-01-07 stsp struct got_commit_object **, struct got_object_id **,
452 ca6e02ac 2020-01-07 stsp struct got_object_id_queue *, struct imsgbuf *);
453 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_send_traversed_commits(
454 ca6e02ac 2020-01-07 stsp struct got_object_id *, size_t, struct imsgbuf *);
455 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_send_commit_traversal_done(
456 ca6e02ac 2020-01-07 stsp struct imsgbuf *);
457 ca6e02ac 2020-01-07 stsp
458 aba9c984 2019-09-08 stsp void got_privsep_exec_child(int[2], const char *, const char *);