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