fix UI roots round-trip; e2e drives without env override
- action=roots emitted only "path"; the page's Remove button reads r.canonical, so data-rm was empty and roots_remove got 400. Emit canonical too. - do_roots wrote the separator into a buf before buf_init (UB). - e2e shim must not set FS_ALLOWED_ROOTS: an env override outranks roots.json by design, and the page's add/remove round-trips through that file. Seed roots.json with root_a instead.
AuthorPico <picobot@scorpioplayer.com>
Date2026-11-13 22:00:34
Commit24e8b279
Parentsbab80c2c
Changed files
src/plugin_filesystem.c+3−1■■■■
tests/e2e.py+8−1■■■■■
8 files+11−2
Diff
docs/ui-1024-768-dark.png+0−0■
11new file mode 100644
index 0000000..75b0b86
binary image
Binary image file
docs/ui-1024-768-light.png+0−0■
11new file mode 100644
index 0000000..a7b700d
binary image
Binary image file
docs/ui-1440-900-dark.png+0−0■
11new file mode 100644
index 0000000..a96e182
binary image
Binary image file
docs/ui-1440-900-light.png+0−0■
11new file mode 100644
index 0000000..fae74ad
binary image
Binary image file
docs/ui-390-844-dark.png+0−0■
11new file mode 100644
index 0000000..57158d0
binary image
Binary image file
docs/ui-390-844-light.png+0−0■
11new file mode 100644
index 0000000..9ce6c90
binary image
Binary image file
src/plugin_filesystem.c+3−1■■■■
index d98dc11..58a00b8 100644
--- a/src/plugin_filesystem.c
+++ b/src/plugin_filesystem.c
@@ -3166,10 +3166,12 @@ static void do_roots(void)
31663166 const char *base = strrchr(g_roots[i].canonical, '/');
31673167 char label[NAME_SZ];
31683168 buf_t b;
3169- if (i) buf_putc(&b, ',');
31703169 buf_init(&b);
3170+ if (i) buf_putc(&b, ','); /* after init - was UB before it */
31713171 buf_puts(&b, "\n {\"path\":");
31723172 json_str(&b, g_roots[i].canonical);
3173+ buf_puts(&b, ",\"canonical\":");
3174+ json_str(&b, g_roots[i].canonical);
31733175 buf_puts(&b, ",\"configured\":");
31743176 json_str(&b, g_roots[i].configured);
31753177 buf_puts(&b, ",\"name\":");
tests/e2e.py+8−1■■■■■
index cac75b9..e9c34c7 100644
--- a/tests/e2e.py
+++ b/tests/e2e.py
@@ -55,7 +55,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
5555 env["QUERY_STRING"] = u.query
5656 env["REQUEST_METHOD"] = method
5757 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.
5961 env["BOT_PASSWORD"] = PW
6062 # forward the header the page sets, so the shim behaves like the node
6163 if self.headers.get("X-Bot-Password"):
@@ -125,6 +127,11 @@ def main():
125127 f.write("do not read\n")
126128 os.symlink(os.path.join(outside, "secret.txt"), os.path.join(root_a, "escape.txt"))
127129
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+
128135 Handler.conf_dir = conf
129136 Handler.allowed_root = root_a
130137 httpd = socketserver.ThreadingTCPServer(("127.0.0.1", 0), Handler)
131138
docs/ui-1024-768-dark.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..75b0b86index 0000000..75b0b86
binary image
Binary image file
docs/ui-1024-768-light.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..a7b700dindex 0000000..a7b700d
binary image
Binary image file
docs/ui-1440-900-dark.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..a96e182index 0000000..a96e182
binary image
Binary image file
docs/ui-1440-900-light.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..fae74adindex 0000000..fae74ad
binary image
Binary image file
docs/ui-390-844-dark.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..57158d0index 0000000..57158d0
binary image
Binary image file
docs/ui-390-844-light.png+0−0■
1new file mode 1006441new file mode 100644
index 0000000..9ce6c90index 0000000..9ce6c90
binary image
Binary image file
src/plugin_filesystem.c+3−1■■■■
index d98dc11..58a00b8 100644index 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\":");
tests/e2e.py+8−1■■■■■
index cac75b9..e9c34c7 100644index 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.query55 env["QUERY_STRING"] = u.query
56 env["REQUEST_METHOD"] = method56 env["REQUEST_METHOD"] = method
57 env["FS_CONNECTORS_DIR"] = self.conf_dir57 env["FS_CONNECTORS_DIR"] = self.conf_dir
58- env["FS_ALLOWED_ROOTS"] = self.allowed_root58+ # 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"] = PW61 env["BOT_PASSWORD"] = PW
60 # forward the header the page sets, so the shim behaves like the node62 # 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 = conf135 Handler.conf_dir = conf
129 Handler.allowed_root = root_a136 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)
131138