Blame


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