Blame


1 56324ebe 2022-07-14 thomas /*
2 56324ebe 2022-07-14 thomas * Copyright (c) 2016, 2019, 2020-2022 Tracey Emery <tracey@traceyemery.net>
3 56324ebe 2022-07-14 thomas * Copyright (c) 2015 Mike Larkin <mlarkin@openbsd.org>
4 56324ebe 2022-07-14 thomas * Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
5 56324ebe 2022-07-14 thomas * Copyright (c) 2013 Florian Obser <florian@openbsd.org>
6 56324ebe 2022-07-14 thomas *
7 56324ebe 2022-07-14 thomas * Permission to use, copy, modify, and distribute this software for any
8 56324ebe 2022-07-14 thomas * purpose with or without fee is hereby granted, provided that the above
9 56324ebe 2022-07-14 thomas * copyright notice and this permission notice appear in all copies.
10 56324ebe 2022-07-14 thomas *
11 56324ebe 2022-07-14 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 56324ebe 2022-07-14 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 56324ebe 2022-07-14 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 56324ebe 2022-07-14 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 56324ebe 2022-07-14 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 56324ebe 2022-07-14 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 56324ebe 2022-07-14 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 56324ebe 2022-07-14 thomas */
19 56324ebe 2022-07-14 thomas
20 56324ebe 2022-07-14 thomas #include <netinet/in.h>
21 56324ebe 2022-07-14 thomas #include <net/if.h>
22 56324ebe 2022-07-14 thomas #include <sys/queue.h>
23 56324ebe 2022-07-14 thomas
24 56324ebe 2022-07-14 thomas #include <limits.h>
25 56324ebe 2022-07-14 thomas #include <stdio.h>
26 56324ebe 2022-07-14 thomas
27 56324ebe 2022-07-14 thomas #ifdef DEBUG
28 56324ebe 2022-07-14 thomas #define dprintf(x...) do { log_debug(x); } while(0)
29 56324ebe 2022-07-14 thomas #else
30 56324ebe 2022-07-14 thomas #define dprintf(x...)
31 56324ebe 2022-07-14 thomas #endif /* DEBUG */
32 56324ebe 2022-07-14 thomas
33 56324ebe 2022-07-14 thomas #ifndef nitems
34 56324ebe 2022-07-14 thomas #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
35 56324ebe 2022-07-14 thomas #endif
36 56324ebe 2022-07-14 thomas
37 56324ebe 2022-07-14 thomas /* GOTWEBD DEFAULTS */
38 56324ebe 2022-07-14 thomas #define GOTWEBD_CONF "/etc/gotwebd.conf"
39 56324ebe 2022-07-14 thomas
40 56324ebe 2022-07-14 thomas #define GOTWEBD_USER "www"
41 56324ebe 2022-07-14 thomas
42 56324ebe 2022-07-14 thomas #define GOTWEBD_MAXCLIENTS 1024
43 56324ebe 2022-07-14 thomas #define GOTWEBD_MAXTEXT 511
44 56324ebe 2022-07-14 thomas #define GOTWEBD_MAXNAME 64
45 56324ebe 2022-07-14 thomas #define GOTWEBD_MAXPORT 6
46 56324ebe 2022-07-14 thomas #define GOTWEBD_NUMPROC 3
47 56324ebe 2022-07-14 thomas #define GOTWEBD_MAXIFACE 16
48 56324ebe 2022-07-14 thomas
49 56324ebe 2022-07-14 thomas /* GOTWEB DEFAULTS */
50 56324ebe 2022-07-14 thomas #define MAX_QUERYSTRING 2048
51 56324ebe 2022-07-14 thomas #define MAX_DOCUMENT_ROOT 255
52 56324ebe 2022-07-14 thomas #define MAX_SERVER_NAME 255
53 56324ebe 2022-07-14 thomas
54 56324ebe 2022-07-14 thomas #define GOTWEB_GOT_DIR ".got"
55 56324ebe 2022-07-14 thomas #define GOTWEB_GIT_DIR ".git"
56 56324ebe 2022-07-14 thomas
57 56324ebe 2022-07-14 thomas #define D_HTTPD_CHROOT "/var/www"
58 56324ebe 2022-07-14 thomas #define D_UNIX_SOCKET "/run/gotweb.sock"
59 56324ebe 2022-07-14 thomas #define D_FCGI_PORT "9000"
60 56324ebe 2022-07-14 thomas #define D_GOTPATH "/got/public"
61 56324ebe 2022-07-14 thomas #define D_SITENAME "Gotweb"
62 56324ebe 2022-07-14 thomas #define D_SITEOWNER "Got Owner"
63 56324ebe 2022-07-14 thomas #define D_SITELINK "Repos"
64 56324ebe 2022-07-14 thomas #define D_GOTLOGO "got.png"
65 56324ebe 2022-07-14 thomas #define D_GOTURL "https://gameoftrees.org"
66 56324ebe 2022-07-14 thomas #define D_GOTWEBCSS "gotweb.css"
67 56324ebe 2022-07-14 thomas
68 56324ebe 2022-07-14 thomas #define D_SHOWROWNER 1
69 56324ebe 2022-07-14 thomas #define D_SHOWSOWNER 1
70 56324ebe 2022-07-14 thomas #define D_SHOWAGE 1
71 56324ebe 2022-07-14 thomas #define D_SHOWDESC 1
72 56324ebe 2022-07-14 thomas #define D_SHOWURL 1
73 56324ebe 2022-07-14 thomas #define D_MAXREPO 0
74 56324ebe 2022-07-14 thomas #define D_MAXREPODISP 25
75 56324ebe 2022-07-14 thomas #define D_MAXSLCOMMDISP 10
76 56324ebe 2022-07-14 thomas #define D_MAXCOMMITDISP 25
77 56324ebe 2022-07-14 thomas
78 56324ebe 2022-07-14 thomas #define BUF 8192
79 56324ebe 2022-07-14 thomas
80 56324ebe 2022-07-14 thomas #define TIMEOUT_DEFAULT 120
81 56324ebe 2022-07-14 thomas
82 56324ebe 2022-07-14 thomas #define FCGI_CONTENT_SIZE 65535
83 56324ebe 2022-07-14 thomas #define FCGI_PADDING_SIZE 255
84 56324ebe 2022-07-14 thomas #define FCGI_RECORD_SIZE \
85 56324ebe 2022-07-14 thomas (sizeof(struct fcgi_record_header) + FCGI_CONTENT_SIZE + FCGI_PADDING_SIZE)
86 56324ebe 2022-07-14 thomas
87 56324ebe 2022-07-14 thomas #define FCGI_ALIGNMENT 8
88 56324ebe 2022-07-14 thomas #define FCGI_ALIGN(n) \
89 56324ebe 2022-07-14 thomas (((n) + (FCGI_ALIGNMENT - 1)) & ~(FCGI_ALIGNMENT - 1))
90 56324ebe 2022-07-14 thomas
91 56324ebe 2022-07-14 thomas #define FD_RESERVE 5
92 56324ebe 2022-07-14 thomas #define FD_NEEDED 6
93 56324ebe 2022-07-14 thomas
94 56324ebe 2022-07-14 thomas #define FCGI_BEGIN_REQUEST 1
95 56324ebe 2022-07-14 thomas #define FCGI_ABORT_REQUEST 2
96 56324ebe 2022-07-14 thomas #define FCGI_END_REQUEST 3
97 56324ebe 2022-07-14 thomas #define FCGI_PARAMS 4
98 56324ebe 2022-07-14 thomas #define FCGI_STDIN 5
99 56324ebe 2022-07-14 thomas #define FCGI_STDOUT 6
100 56324ebe 2022-07-14 thomas #define FCGI_STDERR 7
101 56324ebe 2022-07-14 thomas #define FCGI_DATA 8
102 56324ebe 2022-07-14 thomas #define FCGI_GET_VALUES 9
103 56324ebe 2022-07-14 thomas #define FCGI_GET_VALUES_RESULT 10
104 56324ebe 2022-07-14 thomas #define FCGI_UNKNOWN_TYPE 11
105 56324ebe 2022-07-14 thomas #define FCGI_MAXTYPE (FCGI_UNKNOWN_TYPE)
106 56324ebe 2022-07-14 thomas
107 56324ebe 2022-07-14 thomas #define FCGI_REQUEST_COMPLETE 0
108 56324ebe 2022-07-14 thomas #define FCGI_CANT_MPX_CONN 1
109 56324ebe 2022-07-14 thomas #define FCGI_OVERLOADED 2
110 56324ebe 2022-07-14 thomas #define FCGI_UNKNOWN_ROLE 3
111 56324ebe 2022-07-14 thomas
112 56324ebe 2022-07-14 thomas /* XXX: move this later after ig */
113 56324ebe 2022-07-14 thomas #define GOT_PACK_NUM_TEMPFILES 32
114 56324ebe 2022-07-14 thomas
115 56324ebe 2022-07-14 thomas enum imsg_type {
116 56324ebe 2022-07-14 thomas IMSG_CFG_SRV = IMSG_PROC_MAX,
117 56324ebe 2022-07-14 thomas IMSG_CFG_SOCK,
118 56324ebe 2022-07-14 thomas IMSG_CFG_FD,
119 56324ebe 2022-07-14 thomas IMSG_CFG_DONE,
120 56324ebe 2022-07-14 thomas IMSG_CTL_START,
121 56324ebe 2022-07-14 thomas };
122 56324ebe 2022-07-14 thomas
123 56324ebe 2022-07-14 thomas struct env_val {
124 56324ebe 2022-07-14 thomas SLIST_ENTRY(env_val) entry;
125 56324ebe 2022-07-14 thomas char *val;
126 56324ebe 2022-07-14 thomas };
127 56324ebe 2022-07-14 thomas SLIST_HEAD(env_head, env_val);
128 56324ebe 2022-07-14 thomas
129 56324ebe 2022-07-14 thomas struct fcgi_record_header {
130 56324ebe 2022-07-14 thomas uint8_t version;
131 56324ebe 2022-07-14 thomas uint8_t type;
132 56324ebe 2022-07-14 thomas uint16_t id;
133 56324ebe 2022-07-14 thomas uint16_t content_len;
134 56324ebe 2022-07-14 thomas uint8_t padding_len;
135 56324ebe 2022-07-14 thomas uint8_t reserved;
136 56324ebe 2022-07-14 thomas }__packed;
137 56324ebe 2022-07-14 thomas
138 56324ebe 2022-07-14 thomas struct fcgi_response {
139 56324ebe 2022-07-14 thomas TAILQ_ENTRY(fcgi_response) entry;
140 56324ebe 2022-07-14 thomas uint8_t data[FCGI_RECORD_SIZE];
141 56324ebe 2022-07-14 thomas size_t data_pos;
142 56324ebe 2022-07-14 thomas size_t data_len;
143 56324ebe 2022-07-14 thomas };
144 56324ebe 2022-07-14 thomas
145 56324ebe 2022-07-14 thomas struct repo_dir {
146 56324ebe 2022-07-14 thomas char *name;
147 56324ebe 2022-07-14 thomas char *owner;
148 56324ebe 2022-07-14 thomas char *description;
149 56324ebe 2022-07-14 thomas char *url;
150 56324ebe 2022-07-14 thomas char *age;
151 56324ebe 2022-07-14 thomas char *path;
152 56324ebe 2022-07-14 thomas };
153 56324ebe 2022-07-14 thomas
154 56324ebe 2022-07-14 thomas struct repo_tag {
155 56324ebe 2022-07-14 thomas TAILQ_ENTRY(repo_tag) entry;
156 56324ebe 2022-07-14 thomas char *commit_id;
157 56324ebe 2022-07-14 thomas char *tag_name;
158 56324ebe 2022-07-14 thomas char *tag_commit;
159 56324ebe 2022-07-14 thomas char *commit_msg;
160 56324ebe 2022-07-14 thomas char *tagger;
161 56324ebe 2022-07-14 thomas time_t tagger_time;
162 56324ebe 2022-07-14 thomas };
163 56324ebe 2022-07-14 thomas
164 56324ebe 2022-07-14 thomas struct repo_commit {
165 56324ebe 2022-07-14 thomas TAILQ_ENTRY(repo_commit) entry;
166 56324ebe 2022-07-14 thomas char *path;
167 56324ebe 2022-07-14 thomas char *refs_str;
168 56324ebe 2022-07-14 thomas char *commit_id; /* id_str1 */
169 56324ebe 2022-07-14 thomas char *parent_id; /* id_str2 */
170 56324ebe 2022-07-14 thomas char *tree_id;
171 56324ebe 2022-07-14 thomas char *author;
172 56324ebe 2022-07-14 thomas char *committer;
173 56324ebe 2022-07-14 thomas char *commit_msg;
174 56324ebe 2022-07-14 thomas time_t committer_time;
175 56324ebe 2022-07-14 thomas };
176 56324ebe 2022-07-14 thomas
177 56324ebe 2022-07-14 thomas struct got_repository;
178 56324ebe 2022-07-14 thomas struct transport {
179 56324ebe 2022-07-14 thomas TAILQ_HEAD(repo_commits_head, repo_commit) repo_commits;
180 56324ebe 2022-07-14 thomas TAILQ_HEAD(repo_tags_head, repo_tag) repo_tags;
181 56324ebe 2022-07-14 thomas struct got_repository *repo;
182 56324ebe 2022-07-14 thomas struct repo_dir *repo_dir;
183 56324ebe 2022-07-14 thomas struct querystring *qs;
184 56324ebe 2022-07-14 thomas char *next_id;
185 56324ebe 2022-07-14 thomas char *prev_id;
186 56324ebe 2022-07-14 thomas unsigned int repos_total;
187 56324ebe 2022-07-14 thomas unsigned int next_disp;
188 56324ebe 2022-07-14 thomas unsigned int prev_disp;
189 56324ebe 2022-07-14 thomas unsigned int tag_count;
190 56324ebe 2022-07-14 thomas };
191 56324ebe 2022-07-14 thomas
192 56324ebe 2022-07-14 thomas enum socket_priv_fds {
193 56324ebe 2022-07-14 thomas DIFF_FD_1,
194 56324ebe 2022-07-14 thomas DIFF_FD_2,
195 56324ebe 2022-07-14 thomas DIFF_FD_3,
196 56324ebe 2022-07-14 thomas DIFF_FD_4,
197 56324ebe 2022-07-14 thomas DIFF_FD_5,
198 56324ebe 2022-07-14 thomas BLAME_FD_1,
199 56324ebe 2022-07-14 thomas BLAME_FD_2,
200 56324ebe 2022-07-14 thomas BLAME_FD_3,
201 56324ebe 2022-07-14 thomas BLAME_FD_4,
202 56324ebe 2022-07-14 thomas BLAME_FD_5,
203 56324ebe 2022-07-14 thomas BLAME_FD_6,
204 56324ebe 2022-07-14 thomas BLOB_FD_1,
205 56324ebe 2022-07-14 thomas BLOB_FD_2,
206 56324ebe 2022-07-14 thomas PRIV_FDS__MAX,
207 56324ebe 2022-07-14 thomas };
208 56324ebe 2022-07-14 thomas
209 56324ebe 2022-07-14 thomas struct request {
210 56324ebe 2022-07-14 thomas struct socket *sock;
211 56324ebe 2022-07-14 thomas struct server *srv;
212 56324ebe 2022-07-14 thomas struct transport *t;
213 56324ebe 2022-07-14 thomas struct event ev;
214 56324ebe 2022-07-14 thomas struct event tmo;
215 56324ebe 2022-07-14 thomas
216 56324ebe 2022-07-14 thomas uint16_t id;
217 56324ebe 2022-07-14 thomas int fd;
218 56324ebe 2022-07-14 thomas int priv_fd[PRIV_FDS__MAX];
219 56324ebe 2022-07-14 thomas
220 56324ebe 2022-07-14 thomas uint8_t buf[FCGI_RECORD_SIZE];
221 56324ebe 2022-07-14 thomas size_t buf_pos;
222 56324ebe 2022-07-14 thomas size_t buf_len;
223 56324ebe 2022-07-14 thomas
224 56324ebe 2022-07-14 thomas char querystring[MAX_QUERYSTRING];
225 56324ebe 2022-07-14 thomas char http_host[GOTWEBD_MAXTEXT];
226 56324ebe 2022-07-14 thomas char document_root[MAX_DOCUMENT_ROOT];
227 56324ebe 2022-07-14 thomas char server_name[MAX_SERVER_NAME];
228 56324ebe 2022-07-14 thomas
229 56324ebe 2022-07-14 thomas struct env_head env;
230 56324ebe 2022-07-14 thomas int env_count;
231 56324ebe 2022-07-14 thomas
232 56324ebe 2022-07-14 thomas uint8_t request_started;
233 56324ebe 2022-07-14 thomas };
234 56324ebe 2022-07-14 thomas
235 56324ebe 2022-07-14 thomas struct fcgi_begin_request_body {
236 56324ebe 2022-07-14 thomas uint16_t role;
237 56324ebe 2022-07-14 thomas uint8_t flags;
238 56324ebe 2022-07-14 thomas uint8_t reserved[5];
239 c0597f5b 2022-07-15 thomas }__attribute__((__packed__));
240 56324ebe 2022-07-14 thomas
241 56324ebe 2022-07-14 thomas struct fcgi_end_request_body {
242 56324ebe 2022-07-14 thomas uint32_t app_status;
243 56324ebe 2022-07-14 thomas uint8_t protocol_status;
244 56324ebe 2022-07-14 thomas uint8_t reserved[3];
245 c0597f5b 2022-07-15 thomas }__attribute__((__packed__));
246 56324ebe 2022-07-14 thomas
247 56324ebe 2022-07-14 thomas struct address {
248 56324ebe 2022-07-14 thomas TAILQ_ENTRY(address) entry;
249 56324ebe 2022-07-14 thomas struct sockaddr_storage ss;
250 56324ebe 2022-07-14 thomas int ipproto;
251 56324ebe 2022-07-14 thomas int prefixlen;
252 56324ebe 2022-07-14 thomas in_port_t port;
253 56324ebe 2022-07-14 thomas char ifname[IFNAMSIZ];
254 56324ebe 2022-07-14 thomas };
255 56324ebe 2022-07-14 thomas TAILQ_HEAD(addresslist, address);
256 56324ebe 2022-07-14 thomas
257 56324ebe 2022-07-14 thomas struct server {
258 56324ebe 2022-07-14 thomas TAILQ_ENTRY(server) entry;
259 56324ebe 2022-07-14 thomas struct addresslist *al;
260 56324ebe 2022-07-14 thomas
261 56324ebe 2022-07-14 thomas char name[GOTWEBD_MAXTEXT];
262 56324ebe 2022-07-14 thomas
263 56324ebe 2022-07-14 thomas char repos_path[PATH_MAX];
264 56324ebe 2022-07-14 thomas char site_name[GOTWEBD_MAXNAME];
265 56324ebe 2022-07-14 thomas char site_owner[GOTWEBD_MAXNAME];
266 56324ebe 2022-07-14 thomas char site_link[GOTWEBD_MAXTEXT];
267 56324ebe 2022-07-14 thomas char logo[GOTWEBD_MAXTEXT];
268 56324ebe 2022-07-14 thomas char logo_url[GOTWEBD_MAXTEXT];
269 56324ebe 2022-07-14 thomas char custom_css[PATH_MAX];
270 56324ebe 2022-07-14 thomas
271 56324ebe 2022-07-14 thomas size_t max_repos;
272 56324ebe 2022-07-14 thomas size_t max_repos_display;
273 56324ebe 2022-07-14 thomas size_t max_commits_display;
274 56324ebe 2022-07-14 thomas
275 56324ebe 2022-07-14 thomas int show_site_owner;
276 56324ebe 2022-07-14 thomas int show_repo_owner;
277 56324ebe 2022-07-14 thomas int show_repo_age;
278 56324ebe 2022-07-14 thomas int show_repo_description;
279 56324ebe 2022-07-14 thomas int show_repo_cloneurl;
280 56324ebe 2022-07-14 thomas
281 56324ebe 2022-07-14 thomas int unix_socket;
282 56324ebe 2022-07-14 thomas char unix_socket_name[PATH_MAX];
283 56324ebe 2022-07-14 thomas
284 56324ebe 2022-07-14 thomas int fcgi_socket;
285 56324ebe 2022-07-14 thomas char fcgi_socket_bind[GOTWEBD_MAXTEXT];
286 56324ebe 2022-07-14 thomas in_port_t fcgi_socket_port;
287 56324ebe 2022-07-14 thomas };
288 56324ebe 2022-07-14 thomas TAILQ_HEAD(serverlist, server);
289 56324ebe 2022-07-14 thomas
290 56324ebe 2022-07-14 thomas enum client_action {
291 56324ebe 2022-07-14 thomas CLIENT_CONNECT,
292 56324ebe 2022-07-14 thomas CLIENT_DISCONNECT,
293 56324ebe 2022-07-14 thomas };
294 56324ebe 2022-07-14 thomas
295 56324ebe 2022-07-14 thomas enum sock_type {
296 56324ebe 2022-07-14 thomas UNIX,
297 56324ebe 2022-07-14 thomas FCGI,
298 56324ebe 2022-07-14 thomas };
299 56324ebe 2022-07-14 thomas
300 56324ebe 2022-07-14 thomas struct socket_conf {
301 56324ebe 2022-07-14 thomas struct addresslist *al;
302 56324ebe 2022-07-14 thomas
303 56324ebe 2022-07-14 thomas char name[GOTWEBD_MAXTEXT];
304 56324ebe 2022-07-14 thomas char srv_name[GOTWEBD_MAXTEXT];
305 56324ebe 2022-07-14 thomas
306 56324ebe 2022-07-14 thomas int id;
307 56324ebe 2022-07-14 thomas int child_id;
308 56324ebe 2022-07-14 thomas int parent_id;
309 56324ebe 2022-07-14 thomas
310 56324ebe 2022-07-14 thomas int ipv4;
311 56324ebe 2022-07-14 thomas int ipv6;
312 56324ebe 2022-07-14 thomas
313 56324ebe 2022-07-14 thomas int type;
314 56324ebe 2022-07-14 thomas char unix_socket_name[PATH_MAX];
315 56324ebe 2022-07-14 thomas in_port_t fcgi_socket_port;
316 56324ebe 2022-07-14 thomas };
317 56324ebe 2022-07-14 thomas
318 56324ebe 2022-07-14 thomas struct socket {
319 56324ebe 2022-07-14 thomas TAILQ_ENTRY(socket) entry;
320 56324ebe 2022-07-14 thomas struct socket_conf conf;
321 56324ebe 2022-07-14 thomas
322 56324ebe 2022-07-14 thomas int fd;
323 56324ebe 2022-07-14 thomas int pack_fds[GOT_PACK_NUM_TEMPFILES];
324 56324ebe 2022-07-14 thomas int priv_fd[PRIV_FDS__MAX];
325 56324ebe 2022-07-14 thomas
326 56324ebe 2022-07-14 thomas struct event evt;
327 56324ebe 2022-07-14 thomas struct event ev;
328 56324ebe 2022-07-14 thomas struct event pause;
329 56324ebe 2022-07-14 thomas
330 56324ebe 2022-07-14 thomas int client_status;
331 56324ebe 2022-07-14 thomas };
332 56324ebe 2022-07-14 thomas TAILQ_HEAD(socketlist, socket);
333 56324ebe 2022-07-14 thomas
334 56324ebe 2022-07-14 thomas struct gotwebd {
335 56324ebe 2022-07-14 thomas struct serverlist *servers;
336 56324ebe 2022-07-14 thomas struct socketlist *sockets;
337 56324ebe 2022-07-14 thomas
338 56324ebe 2022-07-14 thomas struct privsep *gotwebd_ps;
339 56324ebe 2022-07-14 thomas const char *gotwebd_conffile;
340 56324ebe 2022-07-14 thomas
341 56324ebe 2022-07-14 thomas int gotwebd_debug;
342 56324ebe 2022-07-14 thomas int gotwebd_verbose;
343 56324ebe 2022-07-14 thomas int gotwebd_noaction;
344 56324ebe 2022-07-14 thomas
345 56324ebe 2022-07-14 thomas uint16_t prefork_gotwebd;
346 56324ebe 2022-07-14 thomas int gotwebd_reload;
347 56324ebe 2022-07-14 thomas
348 56324ebe 2022-07-14 thomas int server_cnt;
349 56324ebe 2022-07-14 thomas
350 56324ebe 2022-07-14 thomas char httpd_chroot[PATH_MAX];
351 56324ebe 2022-07-14 thomas
352 56324ebe 2022-07-14 thomas int unix_socket;
353 56324ebe 2022-07-14 thomas char unix_socket_name[PATH_MAX];
354 56324ebe 2022-07-14 thomas
355 56324ebe 2022-07-14 thomas int fcgi_socket;
356 56324ebe 2022-07-14 thomas char fcgi_socket_bind[GOTWEBD_MAXTEXT];
357 56324ebe 2022-07-14 thomas in_port_t fcgi_socket_port;
358 56324ebe 2022-07-14 thomas };
359 56324ebe 2022-07-14 thomas
360 56324ebe 2022-07-14 thomas struct querystring {
361 56324ebe 2022-07-14 thomas uint8_t action;
362 56324ebe 2022-07-14 thomas char *commit;
363 56324ebe 2022-07-14 thomas char *previd;
364 56324ebe 2022-07-14 thomas char *prevset;
365 56324ebe 2022-07-14 thomas char *file;
366 56324ebe 2022-07-14 thomas char *folder;
367 56324ebe 2022-07-14 thomas char *headref;
368 56324ebe 2022-07-14 thomas int index_page;
369 56324ebe 2022-07-14 thomas char *index_page_str;
370 56324ebe 2022-07-14 thomas char *path;
371 56324ebe 2022-07-14 thomas int page;
372 56324ebe 2022-07-14 thomas char *page_str;
373 56324ebe 2022-07-14 thomas };
374 56324ebe 2022-07-14 thomas
375 56324ebe 2022-07-14 thomas struct querystring_keys {
376 56324ebe 2022-07-14 thomas const char *name;
377 56324ebe 2022-07-14 thomas int element;
378 56324ebe 2022-07-14 thomas };
379 56324ebe 2022-07-14 thomas
380 56324ebe 2022-07-14 thomas struct action_keys {
381 56324ebe 2022-07-14 thomas const char *name;
382 56324ebe 2022-07-14 thomas int action;
383 56324ebe 2022-07-14 thomas };
384 56324ebe 2022-07-14 thomas
385 56324ebe 2022-07-14 thomas enum querystring_elements {
386 56324ebe 2022-07-14 thomas ACTION,
387 56324ebe 2022-07-14 thomas COMMIT,
388 56324ebe 2022-07-14 thomas RFILE,
389 56324ebe 2022-07-14 thomas FOLDER,
390 56324ebe 2022-07-14 thomas HEADREF,
391 56324ebe 2022-07-14 thomas INDEX_PAGE,
392 56324ebe 2022-07-14 thomas PATH,
393 56324ebe 2022-07-14 thomas PAGE,
394 56324ebe 2022-07-14 thomas PREVID,
395 56324ebe 2022-07-14 thomas QSELEM__MAX,
396 56324ebe 2022-07-14 thomas };
397 56324ebe 2022-07-14 thomas
398 56324ebe 2022-07-14 thomas enum query_actions {
399 56324ebe 2022-07-14 thomas BLAME,
400 56324ebe 2022-07-14 thomas BLOB,
401 56324ebe 2022-07-14 thomas BRIEFS,
402 56324ebe 2022-07-14 thomas COMMITS,
403 56324ebe 2022-07-14 thomas DIFF,
404 56324ebe 2022-07-14 thomas ERR,
405 56324ebe 2022-07-14 thomas INDEX,
406 56324ebe 2022-07-14 thomas SUMMARY,
407 56324ebe 2022-07-14 thomas TAG,
408 56324ebe 2022-07-14 thomas TAGS,
409 56324ebe 2022-07-14 thomas TREE,
410 56324ebe 2022-07-14 thomas ACTIONS__MAX,
411 56324ebe 2022-07-14 thomas };
412 56324ebe 2022-07-14 thomas
413 56324ebe 2022-07-14 thomas extern struct gotwebd *gotwebd_env;
414 56324ebe 2022-07-14 thomas
415 56324ebe 2022-07-14 thomas /* sockets.c */
416 56324ebe 2022-07-14 thomas void sockets(struct privsep *, struct privsep_proc *);
417 56324ebe 2022-07-14 thomas void sockets_shutdown(void);
418 56324ebe 2022-07-14 thomas void sockets_parse_sockets(struct gotwebd *);
419 56324ebe 2022-07-14 thomas void sockets_socket_accept(int, short, void *);
420 56324ebe 2022-07-14 thomas int sockets_privinit(struct gotwebd *, struct socket *);
421 56324ebe 2022-07-14 thomas
422 56324ebe 2022-07-14 thomas /* gotweb.c */
423 56324ebe 2022-07-14 thomas const struct got_error *gotweb_render_content_type(struct request *,
424 56324ebe 2022-07-14 thomas const uint8_t *);
425 56324ebe 2022-07-14 thomas const struct got_error
426 56324ebe 2022-07-14 thomas *gotweb_render_content_type_file(struct request *, const uint8_t *, char *);
427 56324ebe 2022-07-14 thomas const struct got_error *gotweb_get_time_str(char **, time_t, int);
428 56324ebe 2022-07-14 thomas const struct got_error *gotweb_init_transport(struct transport **);
429 56324ebe 2022-07-14 thomas const struct got_error *gotweb_escape_html(char **, const char *);
430 56324ebe 2022-07-14 thomas void gotweb_free_repo_commit(struct repo_commit *);
431 56324ebe 2022-07-14 thomas void gotweb_free_repo_tag(struct repo_tag *);
432 56324ebe 2022-07-14 thomas void gotweb_process_request(struct request *);
433 56324ebe 2022-07-14 thomas void gotweb_free_transport(struct transport *);
434 56324ebe 2022-07-14 thomas
435 56324ebe 2022-07-14 thomas /* parse.y */
436 56324ebe 2022-07-14 thomas int parse_config(const char *, struct gotwebd *);
437 56324ebe 2022-07-14 thomas int cmdline_symset(char *);
438 56324ebe 2022-07-14 thomas
439 56324ebe 2022-07-14 thomas /* fcgi.c */
440 56324ebe 2022-07-14 thomas void fcgi_request(int, short, void *);
441 56324ebe 2022-07-14 thomas void fcgi_timeout(int, short, void *);
442 56324ebe 2022-07-14 thomas void fcgi_cleanup_request(struct request *);
443 56324ebe 2022-07-14 thomas void fcgi_create_end_record(struct request *);
444 56324ebe 2022-07-14 thomas void dump_fcgi_record(const char *, struct fcgi_record_header *);
445 56324ebe 2022-07-14 thomas int fcgi_gen_response(struct request *, const char *);
446 56324ebe 2022-07-14 thomas int fcgi_gen_binary_response(struct request *, const uint8_t *, int);
447 56324ebe 2022-07-14 thomas
448 56324ebe 2022-07-14 thomas /* got_operations.c */
449 56324ebe 2022-07-14 thomas const struct got_error *got_get_repo_owner(char **, struct request *, char *);
450 56324ebe 2022-07-14 thomas const struct got_error *got_get_repo_age(char **, struct request *, char *,
451 56324ebe 2022-07-14 thomas const char *, int);
452 56324ebe 2022-07-14 thomas const struct got_error *got_get_repo_commits(struct request *, int);
453 56324ebe 2022-07-14 thomas const struct got_error *got_get_repo_tags(struct request *, int);
454 56324ebe 2022-07-14 thomas const struct got_error *got_get_repo_heads(struct request *);
455 56324ebe 2022-07-14 thomas const struct got_error *got_output_repo_diff(struct request *);
456 56324ebe 2022-07-14 thomas const struct got_error *got_output_repo_tree(struct request *);
457 56324ebe 2022-07-14 thomas const struct got_error *got_output_file_blob(struct request *);
458 56324ebe 2022-07-14 thomas const struct got_error *got_output_file_blame(struct request *);
459 56324ebe 2022-07-14 thomas
460 56324ebe 2022-07-14 thomas /* config.c */
461 56324ebe 2022-07-14 thomas int config_setserver(struct gotwebd *, struct server *);
462 56324ebe 2022-07-14 thomas int config_getserver(struct gotwebd *, struct imsg *);
463 56324ebe 2022-07-14 thomas int config_setsock(struct gotwebd *, struct socket *);
464 56324ebe 2022-07-14 thomas int config_getsock(struct gotwebd *, struct imsg *);
465 56324ebe 2022-07-14 thomas int config_setfd(struct gotwebd *, struct socket *);
466 56324ebe 2022-07-14 thomas int config_getfd(struct gotwebd *, struct imsg *);
467 56324ebe 2022-07-14 thomas int config_getcfg(struct gotwebd *, struct imsg *);
468 56324ebe 2022-07-14 thomas int config_init(struct gotwebd *);