| 1 | 1 | new file mode 100644 |
| index 0000000..75b0b86 |

| 1 | 1 | new file mode 100644 |
| index 0000000..a7b700d |

| 1 | 1 | new file mode 100644 |
| index 0000000..a96e182 |

| 1 | 1 | new file mode 100644 |
| index 0000000..fae74ad |

| 1 | 1 | new file mode 100644 |
| index 0000000..57158d0 |

| 1 | 1 | new file mode 100644 |
| index 0000000..9ce6c90 |

| index d98dc11..58a00b8 100644 | ||
| --- a/src/plugin_filesystem.c | ||
| +++ b/src/plugin_filesystem.c | ||
| @@ -3166,10 +3166,12 @@ static void do_roots(void) | ||
| 3166 | 3166 | const char *base = strrchr(g_roots[i].canonical, '/'); |
| 3167 | 3167 | char label[NAME_SZ]; |
| 3168 | 3168 | buf_t b; |
| 3169 | - if (i) buf_putc(&b, ','); | |
| 3170 | 3169 | buf_init(&b); |
| 3170 | + if (i) buf_putc(&b, ','); /* after init - was UB before it */ | |
| 3171 | 3171 | buf_puts(&b, "\n {\"path\":"); |
| 3172 | 3172 | json_str(&b, g_roots[i].canonical); |
| 3173 | + buf_puts(&b, ",\"canonical\":"); | |
| 3174 | + json_str(&b, g_roots[i].canonical); | |
| 3173 | 3175 | buf_puts(&b, ",\"configured\":"); |
| 3174 | 3176 | json_str(&b, g_roots[i].configured); |
| 3175 | 3177 | buf_puts(&b, ",\"name\":"); |
| index cac75b9..e9c34c7 100644 | ||
| --- a/tests/e2e.py | ||
| +++ b/tests/e2e.py | ||
| @@ -55,7 +55,9 @@ class Handler(http.server.BaseHTTPRequestHandler): | ||
| 55 | 55 | env["QUERY_STRING"] = u.query |
| 56 | 56 | env["REQUEST_METHOD"] = method |
| 57 | 57 | env["FS_CONNECTORS_DIR"] = self.conf_dir |
| 58 | - env["FS_ALLOWED_ROOTS"] = self.allowed_root | |
| 58 | + # deliberately NOT FS_ALLOWED_ROOTS: an env override outranks | |
| 59 | + # roots.json, so a page whose add/remove must round-trip through the | |
| 60 | + # config file has to be driven without it. | |
| 59 | 61 | env["BOT_PASSWORD"] = PW |
| 60 | 62 | # forward the header the page sets, so the shim behaves like the node |
| 61 | 63 | if self.headers.get("X-Bot-Password"): |
| @@ -125,6 +127,11 @@ def main(): | ||
| 125 | 127 | f.write("do not read\n") |
| 126 | 128 | os.symlink(os.path.join(outside, "secret.txt"), os.path.join(root_a, "escape.txt")) |
| 127 | 129 | |
| 130 | + os.makedirs(os.path.join(conf, "plugin_filesystem"), exist_ok=True) | |
| 131 | + with open(os.path.join(conf, "plugin_filesystem", "roots.json"), "w", | |
| 132 | + encoding="utf-8") as f: | |
| 133 | + json.dump({"roots": [root_a], "denied": [], "permissions": {}}, f) | |
| 134 | + | |
| 128 | 135 | Handler.conf_dir = conf |
| 129 | 136 | Handler.allowed_root = root_a |
| 130 | 137 | httpd = socketserver.ThreadingTCPServer(("127.0.0.1", 0), Handler) |
| 131 | 138 |
| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..75b0b86 | index 0000000..75b0b86 |

| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..a7b700d | index 0000000..a7b700d |

| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..a96e182 | index 0000000..a96e182 |

| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..fae74ad | index 0000000..fae74ad |

| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..57158d0 | index 0000000..57158d0 |

| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..9ce6c90 | index 0000000..9ce6c90 |

| index d98dc11..58a00b8 100644 | index d98dc11..58a00b8 100644 | ||
| --- a/src/plugin_filesystem.c | --- a/src/plugin_filesystem.c | ||
| +++ b/src/plugin_filesystem.c | +++ b/src/plugin_filesystem.c | ||
| @@ -3166,10 +3166,12 @@ static void do_roots(void) | @@ -3166,10 +3166,12 @@ static void do_roots(void) | ||
| 3166 | const char *base = strrchr(g_roots[i].canonical, '/'); | 3166 | const char *base = strrchr(g_roots[i].canonical, '/'); |
| 3167 | char label[NAME_SZ]; | 3167 | char label[NAME_SZ]; |
| 3168 | buf_t b; | 3168 | buf_t b; |
| 3169 | - if (i) buf_putc(&b, ','); | ||
| 3170 | buf_init(&b); | 3169 | buf_init(&b); |
| 3170 | + if (i) buf_putc(&b, ','); /* after init - was UB before it */ | ||
| 3171 | buf_puts(&b, "\n {\"path\":"); | 3171 | buf_puts(&b, "\n {\"path\":"); |
| 3172 | json_str(&b, g_roots[i].canonical); | 3172 | json_str(&b, g_roots[i].canonical); |
| 3173 | + buf_puts(&b, ",\"canonical\":"); | ||
| 3174 | + json_str(&b, g_roots[i].canonical); | ||
| 3173 | buf_puts(&b, ",\"configured\":"); | 3175 | buf_puts(&b, ",\"configured\":"); |
| 3174 | json_str(&b, g_roots[i].configured); | 3176 | json_str(&b, g_roots[i].configured); |
| 3175 | buf_puts(&b, ",\"name\":"); | 3177 | buf_puts(&b, ",\"name\":"); |
| index cac75b9..e9c34c7 100644 | index cac75b9..e9c34c7 100644 | ||
| --- a/tests/e2e.py | --- a/tests/e2e.py | ||
| +++ b/tests/e2e.py | +++ b/tests/e2e.py | ||
| @@ -55,7 +55,9 @@ class Handler(http.server.BaseHTTPRequestHandler): | @@ -55,7 +55,9 @@ class Handler(http.server.BaseHTTPRequestHandler): | ||
| 55 | env["QUERY_STRING"] = u.query | 55 | env["QUERY_STRING"] = u.query |
| 56 | env["REQUEST_METHOD"] = method | 56 | env["REQUEST_METHOD"] = method |
| 57 | env["FS_CONNECTORS_DIR"] = self.conf_dir | 57 | env["FS_CONNECTORS_DIR"] = self.conf_dir |
| 58 | - env["FS_ALLOWED_ROOTS"] = self.allowed_root | 58 | + # deliberately NOT FS_ALLOWED_ROOTS: an env override outranks |
| 59 | + # roots.json, so a page whose add/remove must round-trip through the | ||
| 60 | + # config file has to be driven without it. | ||
| 59 | env["BOT_PASSWORD"] = PW | 61 | env["BOT_PASSWORD"] = PW |
| 60 | # forward the header the page sets, so the shim behaves like the node | 62 | # forward the header the page sets, so the shim behaves like the node |
| 61 | if self.headers.get("X-Bot-Password"): | 63 | if self.headers.get("X-Bot-Password"): |
| @@ -125,6 +127,11 @@ def main(): | @@ -125,6 +127,11 @@ def main(): | ||
| 125 | f.write("do not read\n") | 127 | f.write("do not read\n") |
| 126 | os.symlink(os.path.join(outside, "secret.txt"), os.path.join(root_a, "escape.txt")) | 128 | os.symlink(os.path.join(outside, "secret.txt"), os.path.join(root_a, "escape.txt")) |
| 127 | 129 | ||
| 130 | + os.makedirs(os.path.join(conf, "plugin_filesystem"), exist_ok=True) | ||
| 131 | + with open(os.path.join(conf, "plugin_filesystem", "roots.json"), "w", | ||
| 132 | + encoding="utf-8") as f: | ||
| 133 | + json.dump({"roots": [root_a], "denied": [], "permissions": {}}, f) | ||
| 134 | + | ||
| 128 | Handler.conf_dir = conf | 135 | Handler.conf_dir = conf |
| 129 | Handler.allowed_root = root_a | 136 | Handler.allowed_root = root_a |
| 130 | httpd = socketserver.ThreadingTCPServer(("127.0.0.1", 0), Handler) | 137 | httpd = socketserver.ThreadingTCPServer(("127.0.0.1", 0), Handler) |
| 131 | 138 |