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 dd038bc6 2021-09-21 thomas.ad #define GOT_LIBEXECDIR /usr/local/bin
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 257add31 2020-09-09 stsp #define GOT_PROG_READ_GOTCONFIG got-read-gotconfig
47 069bbb86 2022-03-07 thomas #define GOT_PROG_READ_PATCH got-read-patch
48 93658fb9 2020-03-18 stsp #define GOT_PROG_FETCH_PACK got-fetch-pack
49 93658fb9 2020-03-18 stsp #define GOT_PROG_INDEX_PACK got-index-pack
50 93658fb9 2020-03-18 stsp #define GOT_PROG_SEND_PACK got-send-pack
51 ad242220 2018-09-08 stsp
52 ad242220 2018-09-08 stsp #define GOT_STRINGIFY(x) #x
53 ad242220 2018-09-08 stsp #define GOT_STRINGVAL(x) GOT_STRINGIFY(x)
54 ad242220 2018-09-08 stsp
55 ad242220 2018-09-08 stsp /* Paths to helper programs in libexec directory */
56 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_OBJECT \
57 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_OBJECT)
58 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_TREE \
59 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TREE)
60 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_COMMIT \
61 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_COMMIT)
62 ad242220 2018-09-08 stsp #define GOT_PATH_PROG_READ_BLOB \
63 ad242220 2018-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_BLOB)
64 f4a881ce 2018-11-17 stsp #define GOT_PATH_PROG_READ_TAG \
65 f4a881ce 2018-11-17 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_TAG)
66 876c234b 2018-09-10 stsp #define GOT_PATH_PROG_READ_PACK \
67 876c234b 2018-09-10 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_PACK)
68 aba9c984 2019-09-08 stsp #define GOT_PATH_PROG_READ_GITCONFIG \
69 aba9c984 2019-09-08 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_GITCONFIG)
70 257add31 2020-09-09 stsp #define GOT_PATH_PROG_READ_GOTCONFIG \
71 257add31 2020-09-09 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_GOTCONFIG)
72 069bbb86 2022-03-07 thomas #define GOT_PATH_PROG_READ_PATCH \
73 069bbb86 2022-03-07 thomas GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_READ_PATCH)
74 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_FETCH_PACK \
75 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_FETCH_PACK)
76 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_SEND_PACK \
77 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_SEND_PACK)
78 93658fb9 2020-03-18 stsp #define GOT_PATH_PROG_INDEX_PACK \
79 93658fb9 2020-03-18 stsp GOT_STRINGVAL(GOT_LIBEXECDIR) "/" GOT_STRINGVAL(GOT_PROG_INDEX_PACK)
80 ad242220 2018-09-08 stsp
81 876c234b 2018-09-10 stsp struct got_privsep_child {
82 876c234b 2018-09-10 stsp int imsg_fd;
83 876c234b 2018-09-10 stsp pid_t pid;
84 876c234b 2018-09-10 stsp struct imsgbuf *ibuf;
85 876c234b 2018-09-10 stsp };
86 876c234b 2018-09-10 stsp
87 7be7cc45 2018-04-02 stsp enum got_imsg_type {
88 c025a41e 2018-04-02 stsp /* An error occured while processing a request. */
89 c025a41e 2018-04-02 stsp GOT_IMSG_ERROR,
90 c025a41e 2018-04-02 stsp
91 ad242220 2018-09-08 stsp /* Stop the child process. */
92 ad242220 2018-09-08 stsp GOT_IMSG_STOP,
93 1e4880cb 2018-04-02 stsp
94 7be7cc45 2018-04-02 stsp /*
95 7be7cc45 2018-04-02 stsp * Messages concerned with read access to objects in a repository.
96 7be7cc45 2018-04-02 stsp * Object and pack files are opened by the main process, where
97 7be7cc45 2018-04-02 stsp * data may be read as a byte string but without any interpretation.
98 7be7cc45 2018-04-02 stsp * Decompression and parsing of object and pack files occurs in a
99 f0b0c746 2018-09-09 stsp * separate process which runs under pledge("stdio recvfd").
100 7be7cc45 2018-04-02 stsp * This sandboxes our own repository parsing code, as well as zlib.
101 7be7cc45 2018-04-02 stsp */
102 ad242220 2018-09-08 stsp GOT_IMSG_OBJECT_REQUEST,
103 2178c42e 2018-04-22 stsp GOT_IMSG_OBJECT,
104 ad242220 2018-09-08 stsp GOT_IMSG_COMMIT_REQUEST,
105 bff6ca00 2018-04-23 stsp GOT_IMSG_COMMIT,
106 c75f7264 2018-09-11 stsp GOT_IMSG_COMMIT_LOGMSG,
107 ad242220 2018-09-08 stsp GOT_IMSG_TREE_REQUEST,
108 366d86ca 2018-04-23 stsp GOT_IMSG_TREE,
109 06de99ad 2022-05-19 thomas GOT_IMSG_TREE_ENTRIES,
110 ad242220 2018-09-08 stsp GOT_IMSG_BLOB_REQUEST,
111 ad242220 2018-09-08 stsp GOT_IMSG_BLOB_OUTFD,
112 366d86ca 2018-04-23 stsp GOT_IMSG_BLOB,
113 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG_REQUEST,
114 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG,
115 f4a881ce 2018-11-17 stsp GOT_IMSG_TAG_TAGMSG,
116 876c234b 2018-09-10 stsp
117 93658fb9 2020-03-18 stsp /* Messages related to networking. */
118 93658fb9 2020-03-18 stsp GOT_IMSG_FETCH_REQUEST,
119 4ba14133 2020-03-20 stsp GOT_IMSG_FETCH_HAVE_REF,
120 4ba14133 2020-03-20 stsp GOT_IMSG_FETCH_WANTED_BRANCH,
121 0e4002ca 2020-03-21 stsp GOT_IMSG_FETCH_WANTED_REF,
122 f826addf 2020-03-18 stsp GOT_IMSG_FETCH_OUTFD,
123 abe0f35f 2020-03-18 stsp GOT_IMSG_FETCH_SYMREFS,
124 ea7396b9 2020-03-18 stsp GOT_IMSG_FETCH_REF,
125 531c3985 2020-03-18 stsp GOT_IMSG_FETCH_SERVER_PROGRESS,
126 d2cdc636 2020-03-18 stsp GOT_IMSG_FETCH_DOWNLOAD_PROGRESS,
127 93658fb9 2020-03-18 stsp GOT_IMSG_FETCH_DONE,
128 93658fb9 2020-03-18 stsp GOT_IMSG_IDXPACK_REQUEST,
129 73ab1060 2020-03-18 stsp GOT_IMSG_IDXPACK_OUTFD,
130 baa9fea0 2020-03-18 stsp GOT_IMSG_IDXPACK_PROGRESS,
131 93658fb9 2020-03-18 stsp GOT_IMSG_IDXPACK_DONE,
132 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_REQUEST,
133 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_REF,
134 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_REMOTE_REF,
135 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_REF_STATUS,
136 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_PACK_REQUEST,
137 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_PACKFD,
138 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_UPLOAD_PROGRESS,
139 f8a36e22 2021-08-26 stsp GOT_IMSG_SEND_DONE,
140 93658fb9 2020-03-18 stsp
141 876c234b 2018-09-10 stsp /* Messages related to pack files. */
142 876c234b 2018-09-10 stsp GOT_IMSG_PACKIDX,
143 876c234b 2018-09-10 stsp GOT_IMSG_PACK,
144 876c234b 2018-09-10 stsp GOT_IMSG_PACKED_OBJECT_REQUEST,
145 ca6e02ac 2020-01-07 stsp GOT_IMSG_COMMIT_TRAVERSAL_REQUEST,
146 ca6e02ac 2020-01-07 stsp GOT_IMSG_TRAVERSED_COMMITS,
147 ca6e02ac 2020-01-07 stsp GOT_IMSG_COMMIT_TRAVERSAL_DONE,
148 3840f4c9 2018-09-12 stsp
149 33ad4cbe 2019-05-12 jcs /* Message sending file descriptor to a temporary file. */
150 3840f4c9 2018-09-12 stsp GOT_IMSG_TMPFD,
151 aba9c984 2019-09-08 stsp
152 aba9c984 2019-09-08 stsp /* Messages related to gitconfig files. */
153 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_PARSE_REQUEST,
154 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_REPOSITORY_FORMAT_VERSION_REQUEST,
155 20b7abb3 2020-10-22 stsp GOT_IMSG_GITCONFIG_REPOSITORY_EXTENSIONS_REQUEST,
156 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_AUTHOR_NAME_REQUEST,
157 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_AUTHOR_EMAIL_REQUEST,
158 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTES_REQUEST,
159 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_INT_VAL,
160 aba9c984 2019-09-08 stsp GOT_IMSG_GITCONFIG_STR_VAL,
161 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTES,
162 cd95becd 2019-11-29 stsp GOT_IMSG_GITCONFIG_REMOTE,
163 9a1cc63f 2020-02-03 stsp GOT_IMSG_GITCONFIG_OWNER_REQUEST,
164 9a1cc63f 2020-02-03 stsp GOT_IMSG_GITCONFIG_OWNER,
165 257add31 2020-09-09 stsp
166 257add31 2020-09-09 stsp /* Messages related to gotconfig files. */
167 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_PARSE_REQUEST,
168 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_AUTHOR_REQUEST,
169 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_REMOTES_REQUEST,
170 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_INT_VAL,
171 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_STR_VAL,
172 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_REMOTES,
173 257add31 2020-09-09 stsp GOT_IMSG_GOTCONFIG_REMOTE,
174 59d1e4a0 2021-03-10 stsp
175 59d1e4a0 2021-03-10 stsp /* Raw object access. Uncompress object data but do not parse it. */
176 59d1e4a0 2021-03-10 stsp GOT_IMSG_RAW_OBJECT_REQUEST,
177 59d1e4a0 2021-03-10 stsp GOT_IMSG_RAW_OBJECT_OUTFD,
178 59d1e4a0 2021-03-10 stsp GOT_IMSG_PACKED_RAW_OBJECT_REQUEST,
179 59d1e4a0 2021-03-10 stsp GOT_IMSG_RAW_OBJECT,
180 f9c2e8e5 2022-02-13 thomas
181 f9c2e8e5 2022-02-13 thomas /* Read raw delta data from pack files. */
182 f9c2e8e5 2022-02-13 thomas GOT_IMSG_RAW_DELTA_OUTFD,
183 f9c2e8e5 2022-02-13 thomas GOT_IMSG_RAW_DELTA_REQUEST,
184 f9c2e8e5 2022-02-13 thomas GOT_IMSG_RAW_DELTA,
185 069bbb86 2022-03-07 thomas
186 7d0d4920 2022-05-12 thomas /* Re-use deltas found in a pack file. */
187 7d0d4920 2022-05-12 thomas GOT_IMSG_DELTA_REUSE_REQUEST,
188 7d0d4920 2022-05-12 thomas GOT_IMSG_REUSED_DELTAS,
189 7d0d4920 2022-05-12 thomas GOT_IMSG_DELTA_REUSE_DONE,
190 7d0d4920 2022-05-12 thomas
191 7d0d4920 2022-05-12 thomas /* Transfer a list of object IDs. */
192 7d0d4920 2022-05-12 thomas GOT_IMSG_OBJ_ID_LIST,
193 7d0d4920 2022-05-12 thomas GOT_IMSG_OBJ_ID_LIST_DONE,
194 7d0d4920 2022-05-12 thomas
195 069bbb86 2022-03-07 thomas /* Messages related to patch files. */
196 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH_FILE,
197 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH_HUNK,
198 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH_DONE,
199 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH_LINE,
200 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH,
201 069bbb86 2022-03-07 thomas GOT_IMSG_PATCH_EOF,
202 7be7cc45 2018-04-02 stsp };
203 7be7cc45 2018-04-02 stsp
204 c025a41e 2018-04-02 stsp /* Structure for GOT_IMSG_ERROR. */
205 c025a41e 2018-04-02 stsp struct got_imsg_error {
206 c025a41e 2018-04-02 stsp int code; /* an error code from got_error.h */
207 2178c42e 2018-04-22 stsp int errno_code; /* in case code equals GOT_ERR_ERRNO */
208 291624d8 2018-11-07 stsp } __attribute__((__packed__));
209 c025a41e 2018-04-02 stsp
210 ad242220 2018-09-08 stsp /*
211 1785f84a 2018-12-23 stsp * Structure for GOT_IMSG_TREE_REQUEST and GOT_IMSG_OBJECT data.
212 ad242220 2018-09-08 stsp */
213 f7171542 2018-04-02 stsp struct got_imsg_object {
214 c59b3346 2018-09-11 stsp uint8_t id[SHA1_DIGEST_LENGTH];
215 c59b3346 2018-09-11 stsp
216 7be7cc45 2018-04-02 stsp /* These fields are the same as in struct got_object. */
217 7be7cc45 2018-04-02 stsp int type;
218 7be7cc45 2018-04-02 stsp int flags;
219 7be7cc45 2018-04-02 stsp size_t hdrlen;
220 7be7cc45 2018-04-02 stsp size_t size;
221 876c234b 2018-09-10 stsp off_t pack_offset;
222 c59b3346 2018-09-11 stsp int pack_idx;
223 291624d8 2018-11-07 stsp } __attribute__((__packed__));
224 7be7cc45 2018-04-02 stsp
225 366d86ca 2018-04-23 stsp /* Structure for GOT_IMSG_COMMIT data. */
226 bff6ca00 2018-04-23 stsp struct got_imsg_commit_object {
227 86acc566 2018-04-23 stsp uint8_t tree_id[SHA1_DIGEST_LENGTH];
228 bff6ca00 2018-04-23 stsp size_t author_len;
229 ccb26ccd 2018-11-05 stsp time_t author_time;
230 ccb26ccd 2018-11-05 stsp time_t author_gmtoff;
231 bff6ca00 2018-04-23 stsp size_t committer_len;
232 ccb26ccd 2018-11-05 stsp time_t committer_time;
233 ccb26ccd 2018-11-05 stsp time_t committer_gmtoff;
234 bff6ca00 2018-04-23 stsp size_t logmsg_len;
235 bff6ca00 2018-04-23 stsp int nparents;
236 bff6ca00 2018-04-23 stsp
237 6c281f94 2018-06-11 stsp /*
238 c75f7264 2018-09-11 stsp * Followed by author_len + committer_len data bytes
239 6c281f94 2018-06-11 stsp */
240 bff6ca00 2018-04-23 stsp
241 86acc566 2018-04-23 stsp /* Followed by 'nparents' SHA1_DIGEST_LENGTH length strings */
242 bff6ca00 2018-04-23 stsp
243 c75f7264 2018-09-11 stsp /*
244 c75f7264 2018-09-11 stsp * Followed by 'logmsg_len' bytes of commit log message data in
245 c75f7264 2018-09-11 stsp * one or more GOT_IMSG_COMMIT_LOGMSG messages.
246 c75f7264 2018-09-11 stsp */
247 bff6ca00 2018-04-23 stsp } __attribute__((__packed__));
248 bff6ca00 2018-04-23 stsp
249 48f392b2 2018-04-02 stsp struct got_imsg_tree_entry {
250 e033d803 2018-04-23 stsp char id[SHA1_DIGEST_LENGTH];
251 48f392b2 2018-04-02 stsp mode_t mode;
252 06de99ad 2022-05-19 thomas size_t namelen;
253 06de99ad 2022-05-19 thomas /* Followed by namelen bytes of entry's name, not NUL-terminated. */
254 8d98bcfb 2018-04-02 stsp } __attribute__((__packed__));
255 06de99ad 2022-05-19 thomas
256 06de99ad 2022-05-19 thomas /* Structure for GOT_IMSG_TREE_ENTRIES. */
257 06de99ad 2022-05-19 thomas struct got_imsg_tree_entries {
258 06de99ad 2022-05-19 thomas size_t nentries; /* Number of tree entries contained in this message. */
259 48f392b2 2018-04-02 stsp
260 06de99ad 2022-05-19 thomas /* Followed by nentries * struct got_imsg_tree_entry */
261 06de99ad 2022-05-19 thomas };
262 06de99ad 2022-05-19 thomas
263 d80ab12b 2018-04-02 stsp /* Structure for GOT_IMSG_TREE_OBJECT_REPLY data. */
264 48f392b2 2018-04-02 stsp struct got_imsg_tree_object {
265 06de99ad 2022-05-19 thomas int nentries; /* This many tree entries follow. */
266 48f392b2 2018-04-02 stsp };
267 48f392b2 2018-04-02 stsp
268 2967a784 2018-04-24 stsp /* Structure for GOT_IMSG_BLOB. */
269 2967a784 2018-04-24 stsp struct got_imsg_blob {
270 2967a784 2018-04-24 stsp size_t size;
271 ebc55e2d 2018-12-24 stsp size_t hdrlen;
272 ac544f8c 2019-01-13 stsp
273 ac544f8c 2019-01-13 stsp /*
274 ac544f8c 2019-01-13 stsp * If size <= GOT_PRIVSEP_INLINE_BLOB_DATA_MAX, blob data follows
275 ac544f8c 2019-01-13 stsp * in the imsg buffer. Otherwise, blob data has been written to a
276 ac544f8c 2019-01-13 stsp * file descriptor passed via the GOT_IMSG_BLOB_OUTFD imsg.
277 ac544f8c 2019-01-13 stsp */
278 ac544f8c 2019-01-13 stsp #define GOT_PRIVSEP_INLINE_BLOB_DATA_MAX \
279 ac544f8c 2019-01-13 stsp (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_blob))
280 2967a784 2018-04-24 stsp };
281 2967a784 2018-04-24 stsp
282 59d1e4a0 2021-03-10 stsp /* Structure for GOT_IMSG_RAW_OBJECT. */
283 59d1e4a0 2021-03-10 stsp struct got_imsg_raw_obj {
284 59d1e4a0 2021-03-10 stsp off_t size;
285 59d1e4a0 2021-03-10 stsp size_t hdrlen;
286 59d1e4a0 2021-03-10 stsp
287 59d1e4a0 2021-03-10 stsp /*
288 59d1e4a0 2021-03-10 stsp * If size <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX, object data follows
289 59d1e4a0 2021-03-10 stsp * in the imsg buffer. Otherwise, object data has been written to a
290 59d1e4a0 2021-03-10 stsp * file descriptor passed via the GOT_IMSG_RAW_OBJECT_OUTFD imsg.
291 59d1e4a0 2021-03-10 stsp */
292 59d1e4a0 2021-03-10 stsp #define GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX \
293 59d1e4a0 2021-03-10 stsp (MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof(struct got_imsg_raw_obj))
294 f9c2e8e5 2022-02-13 thomas };
295 f9c2e8e5 2022-02-13 thomas
296 f9c2e8e5 2022-02-13 thomas /* Structure for GOT_IMSG_RAW_DELTA. */
297 f9c2e8e5 2022-02-13 thomas struct got_imsg_raw_delta {
298 f9c2e8e5 2022-02-13 thomas uint8_t base_id[SHA1_DIGEST_LENGTH];
299 7d0d4920 2022-05-12 thomas uint64_t base_size;
300 7d0d4920 2022-05-12 thomas uint64_t result_size;
301 7d0d4920 2022-05-12 thomas off_t delta_size;
302 7d0d4920 2022-05-12 thomas off_t delta_compressed_size;
303 7d0d4920 2022-05-12 thomas off_t delta_offset;
304 7d0d4920 2022-05-12 thomas off_t delta_out_offset;
305 7d0d4920 2022-05-12 thomas
306 7d0d4920 2022-05-12 thomas /*
307 7d0d4920 2022-05-12 thomas * Delta data has been written at delta_out_offset to the file
308 7d0d4920 2022-05-12 thomas * descriptor passed via the GOT_IMSG_RAW_DELTA_OUTFD imsg.
309 7d0d4920 2022-05-12 thomas */
310 7d0d4920 2022-05-12 thomas };
311 7d0d4920 2022-05-12 thomas
312 7d0d4920 2022-05-12 thomas /* Structures for GOT_IMSG_REUSED_DELTAS. */
313 7d0d4920 2022-05-12 thomas struct got_imsg_reused_delta {
314 7d0d4920 2022-05-12 thomas struct got_object_id id;
315 7d0d4920 2022-05-12 thomas struct got_object_id base_id;
316 f9c2e8e5 2022-02-13 thomas uint64_t base_size;
317 f9c2e8e5 2022-02-13 thomas uint64_t result_size;
318 f9c2e8e5 2022-02-13 thomas off_t delta_size;
319 9249e7e3 2022-05-12 thomas off_t delta_compressed_size;
320 f9c2e8e5 2022-02-13 thomas off_t delta_offset;
321 f9c2e8e5 2022-02-13 thomas off_t delta_out_offset;
322 f9c2e8e5 2022-02-13 thomas
323 f9c2e8e5 2022-02-13 thomas /*
324 f9c2e8e5 2022-02-13 thomas * Delta data has been written at delta_out_offset to the file
325 f9c2e8e5 2022-02-13 thomas * descriptor passed via the GOT_IMSG_RAW_DELTA_OUTFD imsg.
326 f9c2e8e5 2022-02-13 thomas */
327 59d1e4a0 2021-03-10 stsp };
328 7d0d4920 2022-05-12 thomas struct got_imsg_reused_deltas {
329 7d0d4920 2022-05-12 thomas size_t ndeltas;
330 ac544f8c 2019-01-13 stsp
331 7d0d4920 2022-05-12 thomas /*
332 7d0d4920 2022-05-12 thomas * Followed by ndeltas * struct got_imsg_reused_delta.
333 7d0d4920 2022-05-12 thomas */
334 7d0d4920 2022-05-12 thomas
335 7d0d4920 2022-05-12 thomas #define GOT_IMSG_REUSED_DELTAS_MAX_NDELTAS \
336 7d0d4920 2022-05-12 thomas ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
337 7d0d4920 2022-05-12 thomas sizeof(struct got_imsg_reused_deltas)) \
338 7d0d4920 2022-05-12 thomas / sizeof(struct got_imsg_reused_delta))
339 7d0d4920 2022-05-12 thomas };
340 7d0d4920 2022-05-12 thomas
341 f4a881ce 2018-11-17 stsp /* Structure for GOT_IMSG_TAG data. */
342 f4a881ce 2018-11-17 stsp struct got_imsg_tag_object {
343 f4a881ce 2018-11-17 stsp uint8_t id[SHA1_DIGEST_LENGTH];
344 f4a881ce 2018-11-17 stsp int obj_type;
345 f4a881ce 2018-11-17 stsp size_t tag_len;
346 f4a881ce 2018-11-17 stsp size_t tagger_len;
347 f4a881ce 2018-11-17 stsp time_t tagger_time;
348 f4a881ce 2018-11-17 stsp time_t tagger_gmtoff;
349 f4a881ce 2018-11-17 stsp size_t tagmsg_len;
350 f4a881ce 2018-11-17 stsp
351 f4a881ce 2018-11-17 stsp /*
352 f4a881ce 2018-11-17 stsp * Followed by tag_len + tagger_len data bytes
353 f4a881ce 2018-11-17 stsp */
354 f4a881ce 2018-11-17 stsp
355 f4a881ce 2018-11-17 stsp /*
356 f4a881ce 2018-11-17 stsp * Followed by 'tagmsg_len' bytes of tag message data in
357 f4a881ce 2018-11-17 stsp * one or more GOT_IMSG_TAG_TAGMSG messages.
358 f4a881ce 2018-11-17 stsp */
359 abe0f35f 2020-03-18 stsp } __attribute__((__packed__));
360 33501562 2020-03-18 stsp
361 4ba14133 2020-03-20 stsp /* Structure for GOT_IMSG_FETCH_HAVE_REF data. */
362 33501562 2020-03-18 stsp struct got_imsg_fetch_have_ref {
363 33501562 2020-03-18 stsp uint8_t id[SHA1_DIGEST_LENGTH];
364 33501562 2020-03-18 stsp size_t name_len;
365 33501562 2020-03-18 stsp /* Followed by name_len data bytes. */
366 7848a0e1 2020-03-19 stsp } __attribute__((__packed__));
367 7848a0e1 2020-03-19 stsp
368 4ba14133 2020-03-20 stsp /* Structure for GOT_IMSG_FETCH_WANTED_BRANCH data. */
369 4ba14133 2020-03-20 stsp struct got_imsg_fetch_wanted_branch {
370 0e4002ca 2020-03-21 stsp size_t name_len;
371 0e4002ca 2020-03-21 stsp /* Followed by name_len data bytes. */
372 0e4002ca 2020-03-21 stsp } __attribute__((__packed__));
373 0e4002ca 2020-03-21 stsp
374 0e4002ca 2020-03-21 stsp /* Structure for GOT_IMSG_FETCH_WANTED_REF data. */
375 0e4002ca 2020-03-21 stsp struct got_imsg_fetch_wanted_ref {
376 4ba14133 2020-03-20 stsp size_t name_len;
377 4ba14133 2020-03-20 stsp /* Followed by name_len data bytes. */
378 4ba14133 2020-03-20 stsp } __attribute__((__packed__));
379 4ba14133 2020-03-20 stsp
380 4ba14133 2020-03-20 stsp /* Structure for GOT_IMSG_FETCH_REQUEST data. */
381 659e7fbd 2020-03-20 stsp struct got_imsg_fetch_request {
382 659e7fbd 2020-03-20 stsp int fetch_all_branches;
383 41b0de12 2020-03-21 stsp int list_refs_only;
384 2690194b 2020-03-21 stsp int verbosity;
385 33501562 2020-03-18 stsp size_t n_have_refs;
386 4ba14133 2020-03-20 stsp size_t n_wanted_branches;
387 0e4002ca 2020-03-21 stsp size_t n_wanted_refs;
388 4ba14133 2020-03-20 stsp /* Followed by n_have_refs GOT_IMSG_FETCH_HAVE_REF messages. */
389 4ba14133 2020-03-20 stsp /* Followed by n_wanted_branches times GOT_IMSG_FETCH_WANTED_BRANCH. */
390 0e4002ca 2020-03-21 stsp /* Followed by n_wanted_refs times GOT_IMSG_FETCH_WANTED_REF. */
391 659e7fbd 2020-03-20 stsp } __attribute__((__packed__));
392 abe0f35f 2020-03-18 stsp
393 abe0f35f 2020-03-18 stsp /* Structures for GOT_IMSG_FETCH_SYMREFS data. */
394 abe0f35f 2020-03-18 stsp struct got_imsg_fetch_symref {
395 abe0f35f 2020-03-18 stsp size_t name_len;
396 abe0f35f 2020-03-18 stsp size_t target_len;
397 abe0f35f 2020-03-18 stsp
398 abe0f35f 2020-03-18 stsp /*
399 d45e6863 2020-03-18 stsp * Followed by name_len + target_len data bytes.
400 abe0f35f 2020-03-18 stsp */
401 abe0f35f 2020-03-18 stsp } __attribute__((__packed__));
402 abe0f35f 2020-03-18 stsp
403 abe0f35f 2020-03-18 stsp struct got_imsg_fetch_symrefs {
404 abe0f35f 2020-03-18 stsp size_t nsymrefs;
405 abe0f35f 2020-03-18 stsp
406 abe0f35f 2020-03-18 stsp /* Followed by nsymrefs times of got_imsg_fetch_symref data. */
407 f4a881ce 2018-11-17 stsp } __attribute__((__packed__));
408 b9f99abf 2020-03-18 stsp
409 ea7396b9 2020-03-18 stsp /* Structure for GOT_IMSG_FETCH_REF data. */
410 ea7396b9 2020-03-18 stsp struct got_imsg_fetch_ref {
411 abe0f35f 2020-03-18 stsp /* Describes a reference which will be fetched. */
412 b9f99abf 2020-03-18 stsp uint8_t refid[SHA1_DIGEST_LENGTH];
413 b9f99abf 2020-03-18 stsp /* Followed by reference name in remaining data of imsg buffer. */
414 b9f99abf 2020-03-18 stsp };
415 f4a881ce 2018-11-17 stsp
416 d2cdc636 2020-03-18 stsp /* Structure for GOT_IMSG_FETCH_DOWNLOAD_PROGRESS data. */
417 d2cdc636 2020-03-18 stsp struct got_imsg_fetch_download_progress {
418 d2cdc636 2020-03-18 stsp /* Number of packfile data bytes downloaded so far. */
419 d2cdc636 2020-03-18 stsp off_t packfile_bytes;
420 baa9fea0 2020-03-18 stsp };
421 f8a36e22 2021-08-26 stsp
422 f8a36e22 2021-08-26 stsp /* Structure for GOT_IMSG_SEND_REQUEST data. */
423 f8a36e22 2021-08-26 stsp struct got_imsg_send_request {
424 f8a36e22 2021-08-26 stsp int verbosity;
425 f8a36e22 2021-08-26 stsp size_t nrefs;
426 f8a36e22 2021-08-26 stsp /* Followed by nrefs GOT_IMSG_SEND_REF messages. */
427 f8a36e22 2021-08-26 stsp } __attribute__((__packed__));
428 f8a36e22 2021-08-26 stsp
429 f8a36e22 2021-08-26 stsp /* Structure for GOT_IMSG_SEND_UPLOAD_PROGRESS data. */
430 f8a36e22 2021-08-26 stsp struct got_imsg_send_upload_progress {
431 f8a36e22 2021-08-26 stsp /* Number of packfile data bytes uploaded so far. */
432 f8a36e22 2021-08-26 stsp off_t packfile_bytes;
433 f8a36e22 2021-08-26 stsp };
434 f8a36e22 2021-08-26 stsp
435 f8a36e22 2021-08-26 stsp /* Structure for GOT_IMSG_SEND_REF data. */
436 f8a36e22 2021-08-26 stsp struct got_imsg_send_ref {
437 f8a36e22 2021-08-26 stsp uint8_t id[SHA1_DIGEST_LENGTH];
438 f8a36e22 2021-08-26 stsp int delete;
439 f8a36e22 2021-08-26 stsp size_t name_len;
440 f8a36e22 2021-08-26 stsp /* Followed by name_len data bytes. */
441 f8a36e22 2021-08-26 stsp } __attribute__((__packed__));
442 668a20f6 2020-03-18 stsp
443 f8a36e22 2021-08-26 stsp /* Structure for GOT_IMSG_SEND_REMOTE_REF data. */
444 f8a36e22 2021-08-26 stsp struct got_imsg_send_remote_ref {
445 f8a36e22 2021-08-26 stsp uint8_t id[SHA1_DIGEST_LENGTH];
446 f8a36e22 2021-08-26 stsp size_t name_len;
447 f8a36e22 2021-08-26 stsp /* Followed by name_len data bytes. */
448 f8a36e22 2021-08-26 stsp } __attribute__((__packed__));
449 f8a36e22 2021-08-26 stsp
450 f8a36e22 2021-08-26 stsp /* Structure for GOT_IMSG_SEND_REF_STATUS data. */
451 f8a36e22 2021-08-26 stsp struct got_imsg_send_ref_status {
452 f8a36e22 2021-08-26 stsp int success;
453 f8a36e22 2021-08-26 stsp size_t name_len;
454 f8a36e22 2021-08-26 stsp /* Followed by name_len data bytes. */
455 f8a36e22 2021-08-26 stsp } __attribute__((__packed__));
456 f8a36e22 2021-08-26 stsp
457 668a20f6 2020-03-18 stsp /* Structure for GOT_IMSG_IDXPACK_REQUEST data. */
458 668a20f6 2020-03-18 stsp struct got_imsg_index_pack_request {
459 668a20f6 2020-03-18 stsp uint8_t pack_hash[SHA1_DIGEST_LENGTH];
460 668a20f6 2020-03-18 stsp } __attribute__((__packed__));
461 baa9fea0 2020-03-18 stsp
462 baa9fea0 2020-03-18 stsp /* Structure for GOT_IMSG_IDXPACK_PROGRESS data. */
463 baa9fea0 2020-03-18 stsp struct got_imsg_index_pack_progress {
464 baa9fea0 2020-03-18 stsp /* Total number of objects in pack file. */
465 668a20f6 2020-03-18 stsp int nobj_total;
466 668a20f6 2020-03-18 stsp
467 baa9fea0 2020-03-18 stsp /* Number of objects indexed so far. */
468 668a20f6 2020-03-18 stsp int nobj_indexed;
469 668a20f6 2020-03-18 stsp
470 668a20f6 2020-03-18 stsp /* Number of non-deltified objects in pack file. */
471 668a20f6 2020-03-18 stsp int nobj_loose;
472 668a20f6 2020-03-18 stsp
473 668a20f6 2020-03-18 stsp /* Number of deltified objects resolved so far. */
474 668a20f6 2020-03-18 stsp int nobj_resolved;
475 d2cdc636 2020-03-18 stsp };
476 d2cdc636 2020-03-18 stsp
477 876c234b 2018-09-10 stsp /* Structure for GOT_IMSG_PACKIDX. */
478 876c234b 2018-09-10 stsp struct got_imsg_packidx {
479 876c234b 2018-09-10 stsp size_t len;
480 c3564dfa 2021-07-15 stsp off_t packfile_size;
481 876c234b 2018-09-10 stsp /* Additionally, a file desciptor is passed via imsg. */
482 876c234b 2018-09-10 stsp };
483 876c234b 2018-09-10 stsp
484 876c234b 2018-09-10 stsp /* Structure for GOT_IMSG_PACK. */
485 876c234b 2018-09-10 stsp struct got_imsg_pack {
486 876c234b 2018-09-10 stsp char path_packfile[PATH_MAX];
487 876c234b 2018-09-10 stsp size_t filesize;
488 876c234b 2018-09-10 stsp /* Additionally, a file desciptor is passed via imsg. */
489 291624d8 2018-11-07 stsp } __attribute__((__packed__));
490 876c234b 2018-09-10 stsp
491 876c234b 2018-09-10 stsp /*
492 d5c81d44 2021-07-08 stsp * Structure for GOT_IMSG_OBJECT_REQUEST, GOT_IMSG_BLOB_REQUEST,
493 d5c81d44 2021-07-08 stsp * GOT_IMSG_TREE_REQUEST, GOT_IMSG_COMMIT_REQUEST, and
494 d5c81d44 2021-07-08 stsp * GOT_IMSG_TAG_REQUEST data.
495 d5c81d44 2021-07-08 stsp */
496 d5c81d44 2021-07-08 stsp struct got_object_id;
497 d5c81d44 2021-07-08 stsp
498 d5c81d44 2021-07-08 stsp /*
499 59d1e4a0 2021-03-10 stsp * Structure for GOT_IMSG_PACKED_OBJECT_REQUEST and
500 59d1e4a0 2021-03-10 stsp * GOT_IMSG_PACKED_RAW_OBJECT_REQUEST data.
501 876c234b 2018-09-10 stsp */
502 876c234b 2018-09-10 stsp struct got_imsg_packed_object {
503 106807b4 2018-09-15 stsp uint8_t id[SHA1_DIGEST_LENGTH];
504 876c234b 2018-09-10 stsp int idx;
505 291624d8 2018-11-07 stsp } __attribute__((__packed__));
506 f9c2e8e5 2022-02-13 thomas
507 f9c2e8e5 2022-02-13 thomas /*
508 f9c2e8e5 2022-02-13 thomas * Structure for GOT_IMSG_DELTA data.
509 f9c2e8e5 2022-02-13 thomas */
510 f9c2e8e5 2022-02-13 thomas struct got_imsg_delta {
511 f9c2e8e5 2022-02-13 thomas /* These fields are the same as in struct got_delta. */
512 f9c2e8e5 2022-02-13 thomas off_t offset;
513 f9c2e8e5 2022-02-13 thomas size_t tslen;
514 f9c2e8e5 2022-02-13 thomas int type;
515 f9c2e8e5 2022-02-13 thomas size_t size;
516 f9c2e8e5 2022-02-13 thomas off_t data_offset;
517 f9c2e8e5 2022-02-13 thomas };
518 876c234b 2018-09-10 stsp
519 f9c2e8e5 2022-02-13 thomas /*
520 f9c2e8e5 2022-02-13 thomas * Structure for GOT_IMSG_RAW_DELTA_REQUEST data.
521 f9c2e8e5 2022-02-13 thomas */
522 f9c2e8e5 2022-02-13 thomas struct got_imsg_raw_delta_request {
523 f9c2e8e5 2022-02-13 thomas uint8_t id[SHA1_DIGEST_LENGTH];
524 f9c2e8e5 2022-02-13 thomas int idx;
525 7d0d4920 2022-05-12 thomas };
526 7d0d4920 2022-05-12 thomas
527 7d0d4920 2022-05-12 thomas /*
528 7d0d4920 2022-05-12 thomas * Structure for GOT_IMSG_OBJ_ID_LIST data.
529 7d0d4920 2022-05-12 thomas * Multiple such messages may be sent back-to-back, where each message
530 7d0d4920 2022-05-12 thomas * contains a chunk of IDs. The entire list must be terminated with a
531 7d0d4920 2022-05-12 thomas * GOT_IMSG_OBJ_ID_LIST_DONE message.
532 7d0d4920 2022-05-12 thomas */
533 7d0d4920 2022-05-12 thomas struct got_imsg_object_idlist {
534 7d0d4920 2022-05-12 thomas size_t nids;
535 7d0d4920 2022-05-12 thomas
536 7d0d4920 2022-05-12 thomas /*
537 7d0d4920 2022-05-12 thomas * Followed by nids * struct got_object_id.
538 7d0d4920 2022-05-12 thomas */
539 7d0d4920 2022-05-12 thomas
540 7d0d4920 2022-05-12 thomas #define GOT_IMSG_OBJ_ID_LIST_MAX_NIDS \
541 7d0d4920 2022-05-12 thomas ((MAX_IMSGSIZE - IMSG_HEADER_SIZE - \
542 7d0d4920 2022-05-12 thomas sizeof(struct got_imsg_object_idlist)) / sizeof(struct got_object_id))
543 f9c2e8e5 2022-02-13 thomas };
544 f9c2e8e5 2022-02-13 thomas
545 ca6e02ac 2020-01-07 stsp /* Structure for GOT_IMSG_COMMIT_TRAVERSAL_REQUEST */
546 ca6e02ac 2020-01-07 stsp struct got_imsg_commit_traversal_request {
547 ca6e02ac 2020-01-07 stsp uint8_t id[SHA1_DIGEST_LENGTH];
548 ca6e02ac 2020-01-07 stsp int idx;
549 ca6e02ac 2020-01-07 stsp size_t path_len;
550 ca6e02ac 2020-01-07 stsp /* Followed by path_len bytes of path data */
551 ca6e02ac 2020-01-07 stsp } __attribute__((__packed__));
552 ca6e02ac 2020-01-07 stsp
553 ca6e02ac 2020-01-07 stsp /* Structure for GOT_IMSG_TRAVERSED_COMMITS */
554 ca6e02ac 2020-01-07 stsp struct got_imsg_traversed_commits {
555 ca6e02ac 2020-01-07 stsp size_t ncommits;
556 ca6e02ac 2020-01-07 stsp /* Followed by ncommit IDs of SHA1_DIGEST_LENGTH each */
557 ca6e02ac 2020-01-07 stsp } __attribute__((__packed__));
558 ca6e02ac 2020-01-07 stsp
559 cd95becd 2019-11-29 stsp /*
560 6480c871 2021-08-30 stsp * Structure for GOT_IMSG_GOTCONFIG_REMOTE and
561 6480c871 2021-08-30 stsp * GOT_IMSG_GOTCONFIG_REMOTE data.
562 cd95becd 2019-11-29 stsp */
563 cd95becd 2019-11-29 stsp struct got_imsg_remote {
564 cd95becd 2019-11-29 stsp size_t name_len;
565 6480c871 2021-08-30 stsp size_t fetch_url_len;
566 6480c871 2021-08-30 stsp size_t send_url_len;
567 469dd726 2020-03-20 stsp int mirror_references;
568 0c8b29c5 2021-01-05 stsp int fetch_all_branches;
569 6480c871 2021-08-30 stsp int nfetch_branches;
570 6480c871 2021-08-30 stsp int nsend_branches;
571 6480c871 2021-08-30 stsp int nfetch_refs;
572 cd95becd 2019-11-29 stsp
573 6480c871 2021-08-30 stsp /* Followed by name_len data bytes. */
574 6480c871 2021-08-30 stsp /* Followed by fetch_url_len + send_url_len data bytes. */
575 6480c871 2021-08-30 stsp /* Followed by nfetch_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
576 6480c871 2021-08-30 stsp /* Followed by nsend_branches GOT_IMSG_GITCONFIG_STR_VAL messages. */
577 6480c871 2021-08-30 stsp /* Followed by nfetch_refs GOT_IMSG_GITCONFIG_STR_VAL messages. */
578 4ba14133 2020-03-20 stsp } __attribute__((__packed__));
579 cd95becd 2019-11-29 stsp
580 cd95becd 2019-11-29 stsp /*
581 cd95becd 2019-11-29 stsp * Structure for GOT_IMSG_GITCONFIG_REMOTES data.
582 cd95becd 2019-11-29 stsp */
583 cd95becd 2019-11-29 stsp struct got_imsg_remotes {
584 cd95becd 2019-11-29 stsp int nremotes; /* This many GOT_IMSG_GITCONFIG_REMOTE messages follow. */
585 cd95becd 2019-11-29 stsp };
586 cd95becd 2019-11-29 stsp
587 069bbb86 2022-03-07 thomas /*
588 069bbb86 2022-03-07 thomas * Structure for GOT_IMSG_PATCH data.
589 069bbb86 2022-03-07 thomas */
590 069bbb86 2022-03-07 thomas struct got_imsg_patch {
591 d9db2ff9 2022-04-16 thomas int git;
592 069bbb86 2022-03-07 thomas char old[PATH_MAX];
593 069bbb86 2022-03-07 thomas char new[PATH_MAX];
594 069bbb86 2022-03-07 thomas };
595 069bbb86 2022-03-07 thomas
596 069bbb86 2022-03-07 thomas /*
597 069bbb86 2022-03-07 thomas * Structure for GOT_IMSG_PATCH_HUNK data.
598 069bbb86 2022-03-07 thomas */
599 069bbb86 2022-03-07 thomas struct got_imsg_patch_hunk {
600 069bbb86 2022-03-07 thomas long oldfrom;
601 069bbb86 2022-03-07 thomas long oldlines;
602 069bbb86 2022-03-07 thomas long newfrom;
603 069bbb86 2022-03-07 thomas long newlines;
604 069bbb86 2022-03-07 thomas };
605 069bbb86 2022-03-07 thomas
606 cd95becd 2019-11-29 stsp struct got_remote_repo;
607 876c234b 2018-09-10 stsp struct got_pack;
608 876c234b 2018-09-10 stsp struct got_packidx;
609 3022d272 2019-11-14 stsp struct got_pathlist_head;
610 876c234b 2018-09-10 stsp
611 93658fb9 2020-03-18 stsp const struct got_error *got_send_ack(pid_t);
612 876c234b 2018-09-10 stsp const struct got_error *got_privsep_wait_for_child(pid_t);
613 e70bf110 2020-03-22 stsp const struct got_error *got_privsep_flush_imsg(struct imsgbuf *);
614 ad242220 2018-09-08 stsp const struct got_error *got_privsep_send_stop(int);
615 ad242220 2018-09-08 stsp const struct got_error *got_privsep_recv_imsg(struct imsg *, struct imsgbuf *,
616 ad242220 2018-09-08 stsp size_t);
617 2178c42e 2018-04-22 stsp void got_privsep_send_error(struct imsgbuf *, const struct got_error *);
618 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_send_ack(struct imsgbuf *);
619 93658fb9 2020-03-18 stsp const struct got_error *got_privsep_wait_ack(struct imsgbuf *);
620 d5c81d44 2021-07-08 stsp const struct got_error *got_privsep_send_obj_req(struct imsgbuf *, int,
621 d5c81d44 2021-07-08 stsp struct got_object_id *);
622 d5c81d44 2021-07-08 stsp const struct got_error *got_privsep_send_raw_obj_req(struct imsgbuf *, int,
623 d5c81d44 2021-07-08 stsp struct got_object_id *);
624 59d1e4a0 2021-03-10 stsp const struct got_error *got_privsep_send_raw_obj_outfd(struct imsgbuf *, int);
625 1785f84a 2018-12-23 stsp const struct got_error *got_privsep_send_commit_req(struct imsgbuf *, int,
626 1785f84a 2018-12-23 stsp struct got_object_id *, int);
627 13c729f7 2018-12-24 stsp const struct got_error *got_privsep_send_tree_req(struct imsgbuf *, int,
628 13c729f7 2018-12-24 stsp struct got_object_id *, int);
629 268f7291 2018-12-24 stsp const struct got_error *got_privsep_send_tag_req(struct imsgbuf *, int,
630 268f7291 2018-12-24 stsp struct got_object_id *, int);
631 ebc55e2d 2018-12-24 stsp const struct got_error *got_privsep_send_blob_req(struct imsgbuf *, int,
632 ebc55e2d 2018-12-24 stsp struct got_object_id *, int);
633 55da3778 2018-09-10 stsp const struct got_error *got_privsep_send_blob_outfd(struct imsgbuf *, int);
634 3840f4c9 2018-09-12 stsp const struct got_error *got_privsep_send_tmpfd(struct imsgbuf *, int);
635 2178c42e 2018-04-22 stsp const struct got_error *got_privsep_send_obj(struct imsgbuf *,
636 876c234b 2018-09-10 stsp struct got_object *);
637 668a20f6 2020-03-18 stsp const struct got_error *got_privsep_send_index_pack_req(struct imsgbuf *,
638 668a20f6 2020-03-18 stsp uint8_t *, int);
639 73ab1060 2020-03-18 stsp const struct got_error *got_privsep_send_index_pack_outfd(struct imsgbuf *,
640 73ab1060 2020-03-18 stsp int);
641 baa9fea0 2020-03-18 stsp const struct got_error *got_privsep_recv_index_progress(int *, int *, int *,
642 668a20f6 2020-03-18 stsp int *, int *, struct imsgbuf *ibuf);
643 33501562 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_req(struct imsgbuf *, int,
644 0e4002ca 2020-03-21 stsp struct got_pathlist_head *, int, struct got_pathlist_head *,
645 0e4002ca 2020-03-21 stsp struct got_pathlist_head *, int, int);
646 f826addf 2020-03-18 stsp const struct got_error *got_privsep_send_fetch_outfd(struct imsgbuf *, int);
647 8f2d01a6 2020-03-18 stsp const struct got_error *got_privsep_recv_fetch_progress(int *,
648 1d72a2a0 2020-03-24 stsp struct got_object_id **, char **, struct got_pathlist_head *, char **,
649 1d72a2a0 2020-03-24 stsp off_t *, uint8_t *, struct imsgbuf *);
650 f8a36e22 2021-08-26 stsp const struct got_error *got_privsep_send_send_req(struct imsgbuf *, int,
651 abc59930 2021-09-05 naddy struct got_pathlist_head *, struct got_pathlist_head *, int);
652 f8a36e22 2021-08-26 stsp const struct got_error *got_privsep_recv_send_remote_refs(
653 f8a36e22 2021-08-26 stsp struct got_pathlist_head *, struct imsgbuf *);
654 f8a36e22 2021-08-26 stsp const struct got_error *got_privsep_send_packfd(struct imsgbuf *, int);
655 f8a36e22 2021-08-26 stsp const struct got_error *got_privsep_recv_send_progress(int *, off_t *,
656 f8a36e22 2021-08-26 stsp int *, char **, struct imsgbuf *);
657 cfd633c2 2018-09-10 stsp const struct got_error *got_privsep_get_imsg_obj(struct got_object **,
658 cfd633c2 2018-09-10 stsp struct imsg *, struct imsgbuf *);
659 2178c42e 2018-04-22 stsp const struct got_error *got_privsep_recv_obj(struct got_object **,
660 2178c42e 2018-04-22 stsp struct imsgbuf *);
661 59d1e4a0 2021-03-10 stsp const struct got_error *got_privsep_send_raw_obj(struct imsgbuf *, off_t,
662 59d1e4a0 2021-03-10 stsp size_t, uint8_t *);
663 59d1e4a0 2021-03-10 stsp const struct got_error *got_privsep_recv_raw_obj(uint8_t **, off_t *, size_t *,
664 59d1e4a0 2021-03-10 stsp struct imsgbuf *);
665 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_send_commit(struct imsgbuf *,
666 bff6ca00 2018-04-23 stsp struct got_commit_object *);
667 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_recv_commit(struct got_commit_object **,
668 bff6ca00 2018-04-23 stsp struct imsgbuf *);
669 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_recv_tree(struct got_tree_object **,
670 e033d803 2018-04-23 stsp struct imsgbuf *);
671 78e7b7b8 2022-05-19 thomas struct got_parsed_tree_entry;
672 068fd2bf 2018-04-24 stsp const struct got_error *got_privsep_send_tree(struct imsgbuf *,
673 78e7b7b8 2022-05-19 thomas struct got_parsed_tree_entry *, int);
674 ac544f8c 2019-01-13 stsp const struct got_error *got_privsep_send_blob(struct imsgbuf *, size_t, size_t,
675 ac544f8c 2019-01-13 stsp const uint8_t *);
676 ac544f8c 2019-01-13 stsp const struct got_error *got_privsep_recv_blob(uint8_t **, size_t *, size_t *,
677 ebc55e2d 2018-12-24 stsp struct imsgbuf *);
678 f4a881ce 2018-11-17 stsp const struct got_error *got_privsep_send_tag(struct imsgbuf *,
679 f4a881ce 2018-11-17 stsp struct got_tag_object *);
680 f4a881ce 2018-11-17 stsp const struct got_error *got_privsep_recv_tag(struct got_tag_object **,
681 f4a881ce 2018-11-17 stsp struct imsgbuf *);
682 876c234b 2018-09-10 stsp const struct got_error *got_privsep_init_pack_child(struct imsgbuf *,
683 876c234b 2018-09-10 stsp struct got_pack *, struct got_packidx *);
684 106807b4 2018-09-15 stsp const struct got_error *got_privsep_send_packed_obj_req(struct imsgbuf *, int,
685 106807b4 2018-09-15 stsp struct got_object_id *);
686 59d1e4a0 2021-03-10 stsp const struct got_error *got_privsep_send_packed_raw_obj_req(struct imsgbuf *,
687 59d1e4a0 2021-03-10 stsp int, struct got_object_id *);
688 41fa1437 2018-11-05 stsp const struct got_error *got_privsep_send_pack_child_ready(struct imsgbuf *);
689 aba9c984 2019-09-08 stsp
690 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_parse_req(struct imsgbuf *,
691 aba9c984 2019-09-08 stsp int);
692 aba9c984 2019-09-08 stsp const struct got_error *
693 aba9c984 2019-09-08 stsp got_privsep_send_gitconfig_repository_format_version_req(struct imsgbuf *);
694 20b7abb3 2020-10-22 stsp const struct got_error *got_privsep_send_gitconfig_repository_extensions_req(
695 20b7abb3 2020-10-22 stsp struct imsgbuf *);
696 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_author_name_req(
697 aba9c984 2019-09-08 stsp struct imsgbuf *);
698 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_send_gitconfig_author_email_req(
699 aba9c984 2019-09-08 stsp struct imsgbuf *);
700 cd95becd 2019-11-29 stsp const struct got_error *got_privsep_send_gitconfig_remotes_req(
701 cd95becd 2019-11-29 stsp struct imsgbuf *);
702 9a1cc63f 2020-02-03 stsp const struct got_error *got_privsep_send_gitconfig_owner_req(struct imsgbuf *);
703 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_recv_gitconfig_str(char **,
704 aba9c984 2019-09-08 stsp struct imsgbuf *);
705 aba9c984 2019-09-08 stsp const struct got_error *got_privsep_recv_gitconfig_int(int *, struct imsgbuf *);
706 cd95becd 2019-11-29 stsp const struct got_error *got_privsep_recv_gitconfig_remotes(
707 257add31 2020-09-09 stsp struct got_remote_repo **, int *, struct imsgbuf *);
708 257add31 2020-09-09 stsp
709 257add31 2020-09-09 stsp const struct got_error *got_privsep_send_gotconfig_parse_req(struct imsgbuf *,
710 257add31 2020-09-09 stsp int);
711 257add31 2020-09-09 stsp const struct got_error *got_privsep_send_gotconfig_author_req(struct imsgbuf *);
712 257add31 2020-09-09 stsp const struct got_error *got_privsep_send_gotconfig_remotes_req(
713 257add31 2020-09-09 stsp struct imsgbuf *);
714 257add31 2020-09-09 stsp const struct got_error *got_privsep_recv_gotconfig_str(char **,
715 257add31 2020-09-09 stsp struct imsgbuf *);
716 257add31 2020-09-09 stsp const struct got_error *got_privsep_recv_gotconfig_remotes(
717 cd95becd 2019-11-29 stsp struct got_remote_repo **, int *, struct imsgbuf *);
718 aba9c984 2019-09-08 stsp
719 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_send_commit_traversal_request(
720 ca6e02ac 2020-01-07 stsp struct imsgbuf *, struct got_object_id *, int, const char *);
721 ca6e02ac 2020-01-07 stsp const struct got_error *got_privsep_recv_traversed_commits(
722 ca6e02ac 2020-01-07 stsp struct got_commit_object **, struct got_object_id **,
723 ca6e02ac 2020-01-07 stsp struct got_object_id_queue *, struct imsgbuf *);
724 ca6e02ac 2020-01-07 stsp
725 f9c2e8e5 2022-02-13 thomas const struct got_error *got_privsep_send_raw_delta_req(struct imsgbuf *, int,
726 f9c2e8e5 2022-02-13 thomas struct got_object_id *);
727 f9c2e8e5 2022-02-13 thomas const struct got_error *got_privsep_send_raw_delta_outfd(struct imsgbuf *, int);
728 f9c2e8e5 2022-02-13 thomas const struct got_error *got_privsep_send_raw_delta(struct imsgbuf *, uint64_t,
729 9249e7e3 2022-05-12 thomas uint64_t, off_t, off_t, off_t, off_t, struct got_object_id *);
730 f9c2e8e5 2022-02-13 thomas const struct got_error *got_privsep_recv_raw_delta(uint64_t *, uint64_t *,
731 9249e7e3 2022-05-12 thomas off_t *, off_t *, off_t *, off_t *, struct got_object_id **,
732 9249e7e3 2022-05-12 thomas struct imsgbuf *);
733 f9c2e8e5 2022-02-13 thomas
734 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_send_object_idlist(struct imsgbuf *,
735 7d0d4920 2022-05-12 thomas struct got_object_id **, size_t);
736 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_send_object_idlist_done(struct imsgbuf *);
737 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_recv_object_idlist(int *,
738 7d0d4920 2022-05-12 thomas struct got_object_id **, size_t *, struct imsgbuf *);
739 7d0d4920 2022-05-12 thomas
740 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_send_delta_reuse_req(struct imsgbuf *);
741 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_send_reused_deltas(struct imsgbuf *,
742 7d0d4920 2022-05-12 thomas struct got_imsg_reused_delta *, size_t);
743 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_send_reused_deltas_done(struct imsgbuf *);
744 7d0d4920 2022-05-12 thomas const struct got_error *got_privsep_recv_reused_deltas(int *,
745 7d0d4920 2022-05-12 thomas struct got_imsg_reused_delta *, size_t *, struct imsgbuf *);
746 7d0d4920 2022-05-12 thomas
747 aba9c984 2019-09-08 stsp void got_privsep_exec_child(int[2], const char *, const char *);