move pledge to gw functions to more tightly control promises
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
diff --git a/gotweb/TODO b/gotweb/TODO
index 969f659..061d498 100644
--- a/gotweb/TODO
+++ b/gotweb/TODO
@@ -11,5 +11,3 @@ TODO
- Redo index header, so columns are removed when content is set to not display
in gotweb.conf.
-
-- Move pledge to each function. Only diffing needs wpath and cpath.
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index daa235b..17c61bd 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -267,6 +267,12 @@ gw_blame(struct gw_trans *gw_trans)
char *log, *log_html;
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -289,6 +295,12 @@ gw_commit(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -311,6 +323,12 @@ gw_commitdiff(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -335,6 +353,12 @@ gw_index(struct gw_trans *gw_trans)
char *html, *navs, *next, *prev;
unsigned int prev_disp = 0, next_disp = 1, dir_c = 0;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_conf->got_repos_path, NULL);
if (error)
return error;
@@ -425,6 +449,12 @@ gw_log(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -456,6 +486,12 @@ gw_logbriefs(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -482,6 +518,12 @@ gw_summary(struct gw_trans *gw_trans)
*cloneurl_html, *log, *log_html, *tags, *heads, *tags_html,
*heads_html, *age;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -576,6 +618,12 @@ gw_tag(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -598,6 +646,12 @@ gw_tree(struct gw_trans *gw_trans)
const struct got_error *error = NULL;
char *log, *log_html;
+ if (pledge("stdio rpath proc exec sendfd unveil",
+ NULL) == -1) {
+ error = got_error_from_errno("pledge");
+ return error;
+ }
+
error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
if (error)
return error;
@@ -2654,12 +2708,6 @@ main(int argc, char *argv[])
goto err;
}
- if (pledge("stdio rpath wpath cpath proc exec sendfd unveil",
- NULL) == -1) {
- error = got_error_from_errno("pledge");
- goto err;
- }
-
TAILQ_INIT(&gw_trans->gw_dirs);
gw_trans->page = 0;