fix(http): Serve a web-root file from the entry its check pinned
A file of a web client served from a directory (web_root,
SELKIES_WEB_BUNDLE, or the tree's dist/web) was checked to resolve
inside the directory (resolves_inside) and then looked up again by name
by ServeDir, which follows links. A name swapped for a link out of the
directory between the two was served: on 4b73b4b, a name toggled
between a file and a link to a file outside while it was requested
served the outside file in 823 of 4000 requests.
After the check, the entry the name resolves to is pinned through
FileRoot (FileRoot::pin, as the file routes are), and ServeDir runs on a
Backend that opens and stats the pinned entry's /proc/self/fd path
whatever path it is asked for. ServeDir keeps everything else: its path
validation, the directory's 404, the type from the request's name, HEAD,
ranges and the conditionals. An entry gone or swapped since the check
is the 404 the check gives. index.html, manifest.json and ui_icon are
the server's own names and are opened as before.
the_pinned_entry_is_served_as_the_name_was compares the pinned
ServeDir with ServeDir on the name for a file, a type with capitals,
HEAD, a Range, one past the end, the three conditionals, an in-tree
link, a directory with and without its slash, and a .. it refuses:
status, headers and body are equal. a_web_root_name_swapped_after_the_
check_is_not_followed fails on 4b73b4b with the test seam called after
resolves_inside (200 with the outside file) and passes here, and a name
toggled 1000 times while requested is never served as the link's
target. cargo test -p selkies --lib passes, and clippy with -D
warnings. The suites that serve a client from a directory pass in a
sandbox against this server: e2e dashboards-layout and layout-toggle,
secure_mode-dashboards, apps_panel, credentials_in_url, subfolder and
embedded_client-websockets.