Blame


1 e29dbd72 2021-01-23 op /*
2 1a49166d 2021-01-23 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
3 e29dbd72 2021-01-23 op *
4 e29dbd72 2021-01-23 op * Permission to use, copy, modify, and distribute this software for any
5 e29dbd72 2021-01-23 op * purpose with or without fee is hereby granted, provided that the above
6 e29dbd72 2021-01-23 op * copyright notice and this permission notice appear in all copies.
7 e29dbd72 2021-01-23 op *
8 e29dbd72 2021-01-23 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 e29dbd72 2021-01-23 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 e29dbd72 2021-01-23 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 e29dbd72 2021-01-23 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 e29dbd72 2021-01-23 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 e29dbd72 2021-01-23 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 e29dbd72 2021-01-23 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 e29dbd72 2021-01-23 op */
16 e29dbd72 2021-01-23 op
17 dafb57b8 2021-01-15 op #include "gmid.h"
18 281a8852 2023-06-06 op #include "logger.h"
19 71b7eb2f 2021-01-17 op
20 0b62f484 2023-05-08 op #if defined(__OpenBSD__)
21 71b7eb2f 2021-01-17 op
22 71b7eb2f 2021-01-17 op #include <unistd.h>
23 71b7eb2f 2021-01-17 op
24 dafb57b8 2021-01-15 op void
25 1e0b9745 2023-05-08 op sandbox_server_process(void)
26 dafb57b8 2021-01-15 op {
27 fdea6aa0 2021-04-30 op struct vhost *h;
28 fdea6aa0 2021-04-30 op struct location *l;
29 dafb57b8 2021-01-15 op
30 b8e64ccd 2021-03-31 op TAILQ_FOREACH(h, &hosts, vhosts) {
31 fdea6aa0 2021-04-30 op TAILQ_FOREACH(l, &h->locations, locations) {
32 534afd0d 2022-10-05 op if (*l->dir == '\0')
33 fdea6aa0 2021-04-30 op continue;
34 fdea6aa0 2021-04-30 op
35 b24c6fcc 2022-11-27 op if (unveil(l->dir, "rw") == -1)
36 fdea6aa0 2021-04-30 op fatal("unveil %s for domain %s",
37 fdea6aa0 2021-04-30 op l->dir,
38 fdea6aa0 2021-04-30 op h->domain);
39 fdea6aa0 2021-04-30 op }
40 dafb57b8 2021-01-15 op }
41 dafb57b8 2021-01-15 op
42 b24c6fcc 2022-11-27 op if (pledge("stdio recvfd rpath unix inet dns", NULL) == -1)
43 8e56d6ad 2021-02-11 op fatal("pledge");
44 dafb57b8 2021-01-15 op }
45 dafb57b8 2021-01-15 op
46 dafb57b8 2021-01-15 op void
47 62e001b0 2021-03-20 op sandbox_logger_process(void)
48 62e001b0 2021-03-20 op {
49 e952c505 2021-06-15 op if (pledge("stdio recvfd", NULL) == -1)
50 62e001b0 2021-03-20 op err(1, "pledge");
51 62e001b0 2021-03-20 op }
52 62e001b0 2021-03-20 op
53 62e001b0 2021-03-20 op #else
54 62e001b0 2021-03-20 op
55 62e001b0 2021-03-20 op #warning "No sandbox method known for this OS"
56 62e001b0 2021-03-20 op
57 62e001b0 2021-03-20 op void
58 1e0b9745 2023-05-08 op sandbox_server_process(void)
59 62e001b0 2021-03-20 op {
60 62e001b0 2021-03-20 op return;
61 62e001b0 2021-03-20 op }
62 62e001b0 2021-03-20 op
63 62e001b0 2021-03-20 op void
64 62e001b0 2021-03-20 op sandbox_logger_process(void)
65 62e001b0 2021-03-20 op {
66 62e001b0 2021-03-20 op return;
67 62e001b0 2021-03-20 op }
68 62e001b0 2021-03-20 op
69 dafb57b8 2021-01-15 op #endif