2 13b2bc37 2022-10-23 stsp * Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
4 13b2bc37 2022-10-23 stsp * Permission to use, copy, modify, and distribute this software for any
5 13b2bc37 2022-10-23 stsp * purpose with or without fee is hereby granted, provided that the above
6 13b2bc37 2022-10-23 stsp * copyright notice and this permission notice appear in all copies.
8 13b2bc37 2022-10-23 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 13b2bc37 2022-10-23 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 13b2bc37 2022-10-23 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 13b2bc37 2022-10-23 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 13b2bc37 2022-10-23 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 13b2bc37 2022-10-23 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 13b2bc37 2022-10-23 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 13b2bc37 2022-10-23 stsp #define GOTD_UNIX_SOCKET "/var/run/gotd.sock"
19 13b2bc37 2022-10-23 stsp #define GOTD_UNIX_SOCKET_BACKLOG 10
20 13b2bc37 2022-10-23 stsp #define GOTD_USER "_gotd"
21 13b2bc37 2022-10-23 stsp #define GOTD_CONF_PATH "/etc/gotd.conf"
22 d93ecf7d 2022-12-14 stsp #define GOTD_EMPTY_PATH "/var/empty"
24 13b2bc37 2022-10-23 stsp #define GOTD_MAXCLIENTS 1024
25 7a0564e3 2022-12-30 stsp #define GOTD_MAX_CONN_PER_UID 4
26 13b2bc37 2022-10-23 stsp #define GOTD_FD_RESERVE 5
27 13b2bc37 2022-10-23 stsp #define GOTD_FD_NEEDED 6
28 8c6fc146 2022-11-17 stsp #define GOTD_FILENO_MSG_PIPE 3
30 40b85cca 2023-01-03 stsp #define GOTD_DEFAULT_REQUEST_TIMEOUT 3600
32 13b2bc37 2022-10-23 stsp /* Client hash tables need some extra room. */
33 13b2bc37 2022-10-23 stsp #define GOTD_CLIENT_TABLE_SIZE (GOTD_MAXCLIENTS * 4)
35 13b2bc37 2022-10-23 stsp enum gotd_procid {
36 13b2bc37 2022-10-23 stsp PROC_GOTD = 0,
37 d93ecf7d 2022-12-14 stsp PROC_LISTEN,
39 b0614828 2023-06-19 stsp PROC_SESSION_READ,
40 b0614828 2023-06-19 stsp PROC_SESSION_WRITE,
41 13b2bc37 2022-10-23 stsp PROC_REPO_READ,
42 13b2bc37 2022-10-23 stsp PROC_REPO_WRITE,
43 4b3827cd 2023-07-08 stsp PROC_GITWRAPPER,
47 13b2bc37 2022-10-23 stsp struct gotd_imsgev {
48 13b2bc37 2022-10-23 stsp struct imsgbuf ibuf;
49 13b2bc37 2022-10-23 stsp void (*handler)(int, short, void *);
50 13b2bc37 2022-10-23 stsp void *handler_arg;
51 13b2bc37 2022-10-23 stsp struct event ev;
52 13b2bc37 2022-10-23 stsp short events;
55 0ccf3acb 2022-11-16 stsp enum gotd_access {
56 0ccf3acb 2022-11-16 stsp GOTD_ACCESS_PERMITTED = 1,
57 0ccf3acb 2022-11-16 stsp GOTD_ACCESS_DENIED
60 0ccf3acb 2022-11-16 stsp struct gotd_access_rule {
61 0ccf3acb 2022-11-16 stsp STAILQ_ENTRY(gotd_access_rule) entry;
63 0ccf3acb 2022-11-16 stsp enum gotd_access access;
65 0ccf3acb 2022-11-16 stsp int authorization;
66 0ccf3acb 2022-11-16 stsp #define GOTD_AUTH_READ 0x1
67 0ccf3acb 2022-11-16 stsp #define GOTD_AUTH_WRITE 0x2
69 0ccf3acb 2022-11-16 stsp char *identifier;
71 0ccf3acb 2022-11-16 stsp STAILQ_HEAD(gotd_access_rule_list, gotd_access_rule);
73 13b2bc37 2022-10-23 stsp struct gotd_repo {
74 13b2bc37 2022-10-23 stsp TAILQ_ENTRY(gotd_repo) entry;
76 13b2bc37 2022-10-23 stsp char name[NAME_MAX];
77 13b2bc37 2022-10-23 stsp char path[PATH_MAX];
79 0ccf3acb 2022-11-16 stsp struct gotd_access_rule_list rules;
80 9afa3de2 2023-04-04 stsp struct got_pathlist_head protected_tag_namespaces;
81 9afa3de2 2023-04-04 stsp struct got_pathlist_head protected_branch_namespaces;
82 9afa3de2 2023-04-04 stsp struct got_pathlist_head protected_branches;
84 13b2bc37 2022-10-23 stsp TAILQ_HEAD(gotd_repolist, gotd_repo);
86 eac23c30 2023-01-10 stsp enum gotd_session_state {
87 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_LIST_REFS,
88 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_CAPABILITIES,
89 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_WANT,
90 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_REF_UPDATE,
91 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_MORE_REF_UPDATES,
92 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_HAVE,
93 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_PACKFILE,
94 13b2bc37 2022-10-23 stsp GOTD_STATE_EXPECT_DONE,
95 13b2bc37 2022-10-23 stsp GOTD_STATE_DONE,
98 13b2bc37 2022-10-23 stsp struct gotd_client_capability {
100 13b2bc37 2022-10-23 stsp char *value;
103 13b2bc37 2022-10-23 stsp struct gotd_object_id_array {
104 13b2bc37 2022-10-23 stsp struct got_object_id **ids;
105 13b2bc37 2022-10-23 stsp size_t nalloc;
106 13b2bc37 2022-10-23 stsp size_t nids;
109 40b85cca 2023-01-03 stsp struct gotd_uid_connection_limit {
111 40b85cca 2023-01-03 stsp int max_connections;
114 c929736a 2023-06-22 op struct gotd_child_proc;
116 13b2bc37 2022-10-23 stsp struct gotd {
118 13b2bc37 2022-10-23 stsp char unix_socket_path[PATH_MAX];
119 13b2bc37 2022-10-23 stsp char user_name[32];
120 13b2bc37 2022-10-23 stsp struct gotd_repolist repos;
121 13b2bc37 2022-10-23 stsp int nrepos;
122 c929736a 2023-06-22 op struct gotd_child_proc *listen_proc;
123 40b85cca 2023-01-03 stsp struct timeval request_timeout;
124 40b85cca 2023-01-03 stsp struct timeval auth_timeout;
125 40b85cca 2023-01-03 stsp struct gotd_uid_connection_limit *connection_limits;
126 40b85cca 2023-01-03 stsp size_t nconnection_limits;
128 b50a2b46 2022-12-29 stsp char *argv0;
129 b50a2b46 2022-12-29 stsp const char *confpath;
130 b50a2b46 2022-12-29 stsp int daemonize;
131 13b2bc37 2022-10-23 stsp int verbosity;
134 13b2bc37 2022-10-23 stsp enum gotd_imsg_type {
135 13b2bc37 2022-10-23 stsp /* An error occured while processing a request. */
136 13b2bc37 2022-10-23 stsp GOTD_IMSG_ERROR,
138 f1752522 2022-10-29 stsp /* Commands used by gotctl(8). */
139 f1752522 2022-10-29 stsp GOTD_IMSG_INFO,
140 f1752522 2022-10-29 stsp GOTD_IMSG_INFO_REPO,
141 f1752522 2022-10-29 stsp GOTD_IMSG_INFO_CLIENT,
142 f1752522 2022-10-29 stsp GOTD_IMSG_STOP,
144 13b2bc37 2022-10-23 stsp /* Request a list of references. */
145 13b2bc37 2022-10-23 stsp GOTD_IMSG_LIST_REFS,
146 13b2bc37 2022-10-23 stsp GOTD_IMSG_LIST_REFS_INTERNAL,
148 13b2bc37 2022-10-23 stsp /* References. */
149 13b2bc37 2022-10-23 stsp GOTD_IMSG_REFLIST,
150 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF,
151 13b2bc37 2022-10-23 stsp GOTD_IMSG_SYMREF,
153 13b2bc37 2022-10-23 stsp /* Git protocol capabilities. */
154 13b2bc37 2022-10-23 stsp GOTD_IMSG_CAPABILITIES,
155 13b2bc37 2022-10-23 stsp GOTD_IMSG_CAPABILITY,
157 13b2bc37 2022-10-23 stsp /* Git protocol chatter. */
158 13b2bc37 2022-10-23 stsp GOTD_IMSG_WANT, /* The client wants an object. */
159 13b2bc37 2022-10-23 stsp GOTD_IMSG_HAVE, /* The client has an object. */
160 13b2bc37 2022-10-23 stsp GOTD_IMSG_ACK, /* The server has an object or a reference. */
161 13b2bc37 2022-10-23 stsp GOTD_IMSG_NAK, /* The server does not have an object/ref. */
162 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF_UPDATE, /* The client wants to update a reference. */
163 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF_DELETE, /* The client wants to delete a reference. */
164 13b2bc37 2022-10-23 stsp GOTD_IMSG_FLUSH, /* The client sent a flush packet. */
165 13b2bc37 2022-10-23 stsp GOTD_IMSG_DONE, /* The client is done chatting. */
167 13b2bc37 2022-10-23 stsp /* Sending or receiving a pack file. */
168 13b2bc37 2022-10-23 stsp GOTD_IMSG_SEND_PACKFILE, /* The server is sending a pack file. */
169 13b2bc37 2022-10-23 stsp GOTD_IMSG_RECV_PACKFILE, /* The server is receiving a pack file. */
170 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKIDX_FILE, /* Temporary file handle for new pack index. */
171 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_PIPE, /* Pipe to send/receive a pack file stream. */
172 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_PROGRESS, /* Progress reporting. */
173 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_READY, /* Pack file is ready to be sent. */
174 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_STATUS, /* Received pack success/failure status. */
175 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_INSTALL, /* Received pack file can be installed. */
176 13b2bc37 2022-10-23 stsp GOTD_IMSG_PACKFILE_DONE, /* Pack file has been sent/received. */
178 13b2bc37 2022-10-23 stsp /* Reference updates. */
179 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF_UPDATES_START, /* Ref updates starting. */
180 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF_UPDATE_OK, /* Update went OK. */
181 13b2bc37 2022-10-23 stsp GOTD_IMSG_REF_UPDATE_NG, /* Update was not good. */
182 13b2bc37 2022-10-23 stsp GOTD_IMSG_REFS_UPDATED, /* The server proccessed all ref updates. */
184 d93ecf7d 2022-12-14 stsp /* Client connections. */
185 13b2bc37 2022-10-23 stsp GOTD_IMSG_DISCONNECT,
186 d93ecf7d 2022-12-14 stsp GOTD_IMSG_CONNECT,
188 b50a2b46 2022-12-29 stsp /* Child process management. */
189 ae7c1b78 2023-01-10 stsp GOTD_IMSG_CLIENT_SESSION_READY,
190 b50a2b46 2022-12-29 stsp GOTD_IMSG_REPO_CHILD_READY,
191 ae7c1b78 2023-01-10 stsp GOTD_IMSG_CONNECT_REPO_CHILD,
193 5e25db14 2022-12-29 stsp /* Auth child process. */
194 5e25db14 2022-12-29 stsp GOTD_IMSG_AUTHENTICATE,
195 5e25db14 2022-12-29 stsp GOTD_IMSG_ACCESS_GRANTED,
198 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_ERROR. */
199 13b2bc37 2022-10-23 stsp struct gotd_imsg_error {
200 13b2bc37 2022-10-23 stsp int code; /* an error code from got_error.h */
201 13b2bc37 2022-10-23 stsp int errno_code; /* in case code equals GOT_ERR_ERRNO */
202 13b2bc37 2022-10-23 stsp uint32_t client_id;
203 13b2bc37 2022-10-23 stsp char msg[GOT_ERR_MAX_MSG_SIZE];
204 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
206 f1752522 2022-10-29 stsp /* Structure for GOTD_IMSG_INFO. */
207 f1752522 2022-10-29 stsp struct gotd_imsg_info {
209 f1752522 2022-10-29 stsp int verbosity;
210 f1752522 2022-10-29 stsp int nrepos;
211 f1752522 2022-10-29 stsp int nclients;
213 f1752522 2022-10-29 stsp /* Followed by nrepos GOTD_IMSG_INFO_REPO messages. */
214 f1752522 2022-10-29 stsp /* Followed by nclients GOTD_IMSG_INFO_CLIENT messages. */
217 f1752522 2022-10-29 stsp /* Structure for GOTD_IMSG_INFO_REPO. */
218 f1752522 2022-10-29 stsp struct gotd_imsg_info_repo {
219 f1752522 2022-10-29 stsp char repo_name[NAME_MAX];
220 f1752522 2022-10-29 stsp char repo_path[PATH_MAX];
223 f1752522 2022-10-29 stsp /* Structure for GOTD_IMSG_INFO_CLIENT */
224 f1752522 2022-10-29 stsp struct gotd_imsg_info_client {
225 f1752522 2022-10-29 stsp uid_t euid;
226 f1752522 2022-10-29 stsp gid_t egid;
227 f1752522 2022-10-29 stsp char repo_name[NAME_MAX];
228 f1752522 2022-10-29 stsp int is_writing;
229 ae7c1b78 2023-01-10 stsp pid_t session_child_pid;
230 ae7c1b78 2023-01-10 stsp pid_t repo_child_pid;
233 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_LIST_REFS. */
234 13b2bc37 2022-10-23 stsp struct gotd_imsg_list_refs {
235 13b2bc37 2022-10-23 stsp char repo_name[NAME_MAX];
236 13b2bc37 2022-10-23 stsp int client_is_reading; /* 1 if reading, 0 if writing */
239 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_LIST_REFS_INTERNAL. */
240 13b2bc37 2022-10-23 stsp struct gotd_imsg_list_refs_internal {
241 13b2bc37 2022-10-23 stsp uint32_t client_id;
244 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REFLIST. */
245 13b2bc37 2022-10-23 stsp struct gotd_imsg_reflist {
246 13b2bc37 2022-10-23 stsp size_t nrefs;
248 13b2bc37 2022-10-23 stsp /* Followed by nrefs times of gotd_imsg_ref/gotd_imsg_symref data. */
249 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
251 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REF data. */
252 13b2bc37 2022-10-23 stsp struct gotd_imsg_ref {
253 13b2bc37 2022-10-23 stsp uint8_t id[SHA1_DIGEST_LENGTH];
254 13b2bc37 2022-10-23 stsp size_t name_len;
255 13b2bc37 2022-10-23 stsp /* Followed by name_len data bytes. */
256 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
258 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_SYMREF data. */
259 13b2bc37 2022-10-23 stsp struct gotd_imsg_symref {
260 13b2bc37 2022-10-23 stsp size_t name_len;
261 13b2bc37 2022-10-23 stsp size_t target_len;
262 13b2bc37 2022-10-23 stsp uint8_t target_id[SHA1_DIGEST_LENGTH];
265 13b2bc37 2022-10-23 stsp * Followed by name_len + target_len data bytes.
267 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
269 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_CAPABILITIES data. */
270 13b2bc37 2022-10-23 stsp struct gotd_imsg_capabilities {
271 13b2bc37 2022-10-23 stsp size_t ncapabilities;
274 13b2bc37 2022-10-23 stsp * Followed by ncapabilities * GOTD_IMSG_CAPABILITY.
276 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
278 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_CAPABILITY data. */
279 13b2bc37 2022-10-23 stsp struct gotd_imsg_capability {
280 13b2bc37 2022-10-23 stsp size_t key_len;
281 13b2bc37 2022-10-23 stsp size_t value_len;
284 13b2bc37 2022-10-23 stsp * Followed by key_len + value_len data bytes.
286 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
288 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_WANT data. */
289 13b2bc37 2022-10-23 stsp struct gotd_imsg_want {
290 13b2bc37 2022-10-23 stsp uint8_t object_id[SHA1_DIGEST_LENGTH];
291 13b2bc37 2022-10-23 stsp uint32_t client_id;
292 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
294 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_HAVE data. */
295 13b2bc37 2022-10-23 stsp struct gotd_imsg_have {
296 13b2bc37 2022-10-23 stsp uint8_t object_id[SHA1_DIGEST_LENGTH];
297 13b2bc37 2022-10-23 stsp uint32_t client_id;
298 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
300 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_ACK data. */
301 13b2bc37 2022-10-23 stsp struct gotd_imsg_ack {
302 13b2bc37 2022-10-23 stsp uint8_t object_id[SHA1_DIGEST_LENGTH];
303 13b2bc37 2022-10-23 stsp uint32_t client_id;
304 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
306 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_NAK data. */
307 13b2bc37 2022-10-23 stsp struct gotd_imsg_nak {
308 13b2bc37 2022-10-23 stsp uint8_t object_id[SHA1_DIGEST_LENGTH];
309 13b2bc37 2022-10-23 stsp uint32_t client_id;
310 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
312 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_PACKFILE_STATUS data. */
313 13b2bc37 2022-10-23 stsp struct gotd_imsg_packfile_status {
314 13b2bc37 2022-10-23 stsp size_t reason_len;
316 13b2bc37 2022-10-23 stsp /* Followed by reason_len data bytes. */
317 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
320 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REF_UPDATE data. */
321 13b2bc37 2022-10-23 stsp struct gotd_imsg_ref_update {
322 13b2bc37 2022-10-23 stsp uint8_t old_id[SHA1_DIGEST_LENGTH];
323 13b2bc37 2022-10-23 stsp uint8_t new_id[SHA1_DIGEST_LENGTH];
324 13b2bc37 2022-10-23 stsp int ref_is_new;
325 9a8e357c 2023-01-28 op int delete_ref;
326 13b2bc37 2022-10-23 stsp uint32_t client_id;
327 13b2bc37 2022-10-23 stsp size_t name_len;
329 13b2bc37 2022-10-23 stsp /* Followed by name_len data bytes. */
330 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
332 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REF_UPDATES_START data. */
333 13b2bc37 2022-10-23 stsp struct gotd_imsg_ref_updates_start {
334 13b2bc37 2022-10-23 stsp int nref_updates;
335 13b2bc37 2022-10-23 stsp uint32_t client_id;
337 13b2bc37 2022-10-23 stsp /* Followed by nref_updates GOT_IMSG_REF_UPDATE_OK/NG messages. */
340 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REF_UPDATE_OK data. */
341 13b2bc37 2022-10-23 stsp struct gotd_imsg_ref_update_ok {
342 13b2bc37 2022-10-23 stsp uint8_t old_id[SHA1_DIGEST_LENGTH];
343 13b2bc37 2022-10-23 stsp uint8_t new_id[SHA1_DIGEST_LENGTH];
344 13b2bc37 2022-10-23 stsp int ref_is_new;
345 13b2bc37 2022-10-23 stsp uint32_t client_id;
346 13b2bc37 2022-10-23 stsp size_t name_len;
348 13b2bc37 2022-10-23 stsp /* Followed by name_len data bytes. */
349 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
351 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_REF_UPDATE_NG data. */
352 13b2bc37 2022-10-23 stsp struct gotd_imsg_ref_update_ng {
353 13b2bc37 2022-10-23 stsp uint8_t old_id[SHA1_DIGEST_LENGTH];
354 13b2bc37 2022-10-23 stsp uint8_t new_id[SHA1_DIGEST_LENGTH];
355 13b2bc37 2022-10-23 stsp uint32_t client_id;
356 13b2bc37 2022-10-23 stsp size_t name_len;
357 13b2bc37 2022-10-23 stsp size_t reason_len;
359 13b2bc37 2022-10-23 stsp /* Followed by name_len + reason_len data bytes. */
360 13b2bc37 2022-10-23 stsp } __attribute__((__packed__));
362 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_SEND_PACKFILE data. */
363 13b2bc37 2022-10-23 stsp struct gotd_imsg_send_packfile {
364 13b2bc37 2022-10-23 stsp uint32_t client_id;
365 13b2bc37 2022-10-23 stsp int report_progress;
367 13b2bc37 2022-10-23 stsp /* delta cache file is sent as a file descriptor */
369 13b2bc37 2022-10-23 stsp /* followed by two GOTD_IMSG_PACKFILE_PIPE messages */
372 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_RECV_PACKFILE data. */
373 13b2bc37 2022-10-23 stsp struct gotd_imsg_recv_packfile {
374 13b2bc37 2022-10-23 stsp uint32_t client_id;
375 13b2bc37 2022-10-23 stsp int report_status;
377 13b2bc37 2022-10-23 stsp /* pack destination temp file is sent as a file descriptor */
380 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_PACKFILE_PIPE data. */
381 13b2bc37 2022-10-23 stsp struct gotd_imsg_packfile_pipe {
382 13b2bc37 2022-10-23 stsp uint32_t client_id;
385 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_PACKIDX_FILE data. */
386 13b2bc37 2022-10-23 stsp struct gotd_imsg_packidx_file {
387 13b2bc37 2022-10-23 stsp uint32_t client_id;
392 13b2bc37 2022-10-23 stsp * Structure for GOTD_IMSG_PACKFILE_PROGRESS and
393 13b2bc37 2022-10-23 stsp * GOTD_IMSG_PACKFILE_READY data.
395 13b2bc37 2022-10-23 stsp struct gotd_imsg_packfile_progress {
396 13b2bc37 2022-10-23 stsp uint32_t client_id;
397 13b2bc37 2022-10-23 stsp int ncolored;
398 13b2bc37 2022-10-23 stsp int nfound;
399 13b2bc37 2022-10-23 stsp int ntrees;
400 13b2bc37 2022-10-23 stsp off_t packfile_size;
401 13b2bc37 2022-10-23 stsp int ncommits;
402 13b2bc37 2022-10-23 stsp int nobj_total;
403 13b2bc37 2022-10-23 stsp int nobj_deltify;
404 13b2bc37 2022-10-23 stsp int nobj_written;
407 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_PACKFILE_INSTALL. */
408 13b2bc37 2022-10-23 stsp struct gotd_imsg_packfile_install {
409 13b2bc37 2022-10-23 stsp uint32_t client_id;
410 13b2bc37 2022-10-23 stsp uint8_t pack_sha1[SHA1_DIGEST_LENGTH];
413 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_PACKFILE_DONE data. */
414 13b2bc37 2022-10-23 stsp struct gotd_imsg_packfile_done {
415 13b2bc37 2022-10-23 stsp uint32_t client_id;
418 13b2bc37 2022-10-23 stsp /* Structure for GOTD_IMSG_DISCONNECT data. */
419 13b2bc37 2022-10-23 stsp struct gotd_imsg_disconnect {
420 13b2bc37 2022-10-23 stsp uint32_t client_id;
423 d93ecf7d 2022-12-14 stsp /* Structure for GOTD_IMSG_CONNECT. */
424 d93ecf7d 2022-12-14 stsp struct gotd_imsg_connect {
425 d93ecf7d 2022-12-14 stsp uint32_t client_id;
426 365cf0f3 2022-12-29 stsp uid_t euid;
427 365cf0f3 2022-12-29 stsp gid_t egid;
430 ae7c1b78 2023-01-10 stsp /* Structure for GOTD_IMSG_CONNECT_REPO_CHILD. */
431 ae7c1b78 2023-01-10 stsp struct gotd_imsg_connect_repo_child {
432 ae7c1b78 2023-01-10 stsp uint32_t client_id;
433 ae7c1b78 2023-01-10 stsp enum gotd_procid proc_id;
435 ae7c1b78 2023-01-10 stsp /* repo child imsg pipe is passed via imsg fd */
438 5e25db14 2022-12-29 stsp /* Structure for GOTD_IMSG_AUTHENTICATE. */
439 5e25db14 2022-12-29 stsp struct gotd_imsg_auth {
440 5e25db14 2022-12-29 stsp uid_t euid;
441 5e25db14 2022-12-29 stsp gid_t egid;
442 5e25db14 2022-12-29 stsp int required_auth;
443 5e25db14 2022-12-29 stsp uint32_t client_id;
446 4b3827cd 2023-07-08 stsp int parse_config(const char *, enum gotd_procid, struct gotd *);
447 b09c1279 2023-03-28 stsp struct gotd_repo *gotd_find_repo_by_name(const char *, struct gotd *);
448 9afa3de2 2023-04-04 stsp struct gotd_repo *gotd_find_repo_by_path(const char *, struct gotd *);
449 eeb616b7 2023-04-14 stsp struct gotd_uid_connection_limit *gotd_find_uid_connection_limit(
450 eeb616b7 2023-04-14 stsp struct gotd_uid_connection_limit *limits, size_t nlimits, uid_t uid);
451 1963be61 2023-04-14 stsp int gotd_parseuid(const char *s, uid_t *uid);
453 13b2bc37 2022-10-23 stsp /* imsg.c */
454 13b2bc37 2022-10-23 stsp const struct got_error *gotd_imsg_flush(struct imsgbuf *);
455 13b2bc37 2022-10-23 stsp const struct got_error *gotd_imsg_recv(struct imsg *, struct imsgbuf *, size_t);
456 13b2bc37 2022-10-23 stsp const struct got_error *gotd_imsg_poll_recv(struct imsg *, struct imsgbuf *,
458 13b2bc37 2022-10-23 stsp const struct got_error *gotd_imsg_recv_error(uint32_t *client_id,
459 13b2bc37 2022-10-23 stsp struct imsg *imsg);
460 13b2bc37 2022-10-23 stsp int gotd_imsg_send_error(struct imsgbuf *ibuf, uint32_t, uint32_t,
461 13b2bc37 2022-10-23 stsp const struct got_error *);
462 13b2bc37 2022-10-23 stsp int gotd_imsg_send_error_event(struct gotd_imsgev *, uint32_t, uint32_t,
463 13b2bc37 2022-10-23 stsp const struct got_error *);
464 13b2bc37 2022-10-23 stsp void gotd_imsg_event_add(struct gotd_imsgev *);
465 13b2bc37 2022-10-23 stsp int gotd_imsg_compose_event(struct gotd_imsgev *, uint16_t, uint32_t, int,
466 13b2bc37 2022-10-23 stsp void *, uint16_t);
467 13b2bc37 2022-10-23 stsp int gotd_imsg_forward(struct gotd_imsgev *, struct imsg *, int);
469 13b2bc37 2022-10-23 stsp void gotd_imsg_send_ack(struct got_object_id *, struct imsgbuf *,
470 13b2bc37 2022-10-23 stsp uint32_t, pid_t);
471 13b2bc37 2022-10-23 stsp void gotd_imsg_send_nak(struct got_object_id *, struct imsgbuf *,
472 13b2bc37 2022-10-23 stsp uint32_t, pid_t);