Skip to content

[12/40] Hand chown its arguments instead of a command line, and let a rule hide a volume - #453

Merged
vikramsoni2 merged 12 commits into
nxzai:mainfrom
cerede2000:p3-23
Sep 27, 2026
Merged

vikramsoni2 merged 12 commits into
nxzai:mainfrom
cerede2000:p3-23

Conversation

@cerede2000

Copy link
Copy Markdown

Stacked on #433–#452. The last commit is the one to read.

Related to #450: the same pattern, a different route. Same offer — say the word and I will move both to a private advisory.

chown was given a command line

POST /api/permissions/chown builds a string and hands it to a shell:

chownCmd = `chown "${owner}:${group}" "${resolved.absolutePath}"`;
await execAsync(chownCmd);

owner and group come straight from the request body. It is an administrator's route — but that is the difference between "may change ownership on this volume" and "may run anything as the user this server runs as", and that is not a difference to leave to a pair of quotes. chmod -R and the two id lookups interpolate the path and the numeric ids the same way.

They take their arguments as an array now, through execFile, with no shell anywhere. And because an argument list is not a free pass either, an account name has to look like one: --reference=/etc/shadow is not a name, and chown would have read it as an option and copied another file's ownership onto the target.

A rule that hides a folder now hides it everywhere

The listing said one thing and the rule another in several places:

  • a read-only rule left an administrator the Create button;
  • a hidden rule left the folder's name in a search result;
  • a symbolic link pointing out of a share was followed as though it were part of it.

Access is one question asked in one place now, and the answer carries the reason it was refused rather than each caller inventing one.

A personal folder name outlives its account

Deleting an account freed its folder name. The next account deriving the same one — jean.dupont → jean — was handed a folder still full of somebody else's files. Schema 23 adds the reservations table, and at the upgrade removes what earlier deletions left behind: folder_preferences and recent_destinations point at users through no foreign key, so nothing ever removed those rows.

One file deliberately not taken from the fork

routes/volumes.js here already drops the volumes a caller may not reach (#425), and the fork has not caught up. Taking the fork's version would have put every hidden volume's name back in the sidebar. It stays.

Proof

tests/routes/permissions.test.js — what may reach chown, including --reference=/etc/shadow, -R, root nobody, root;id, .hidden and -; the special bits a folder already had; and a path reached through a share. Against the previous route ten of its tests fail.

Whole suite: 2859 passed, 2 failed — the two that already fail on main. Build clean; prettier drops to 18 files from main's 21; eslint at its main baseline.

cerede2000 pushed a commit to cerede2000/NextExplorer that referenced this pull request Sep 27, 2026
chown was handed a command line built from the request body, and volumes.js
here is older than upstream: taking it would have put every hidden volume back
in the sidebar.
Benjy added 12 commits September 27, 2026 19:24
Two routes built a command line with values from the request in it and gave the line
to a shell. `routes/usage.js` pasted a folder's path into `du -sb "…"` and
`df -Pk "…"`; `routes/permissions.js` pasted an owner, a group, a mode and a path
into `chown`, `chgrp`, `chmod -R` and two `id` lookups.

A name is not a shell string. Anything that closes the quoting leaves the rest for
`/bin/sh` to run, as the user the server runs as. The usage one needs no privilege
at all: any account that can create a folder can name one, and where AUTH_ENABLED is
false that is anybody who can reach the server.

`execFile` takes the arguments as a list, so there is no line for a shell to read
and no shell. The commands, their output and the answers are unchanged — this is
deliberately the smallest change that closes it, and not the rewrite that stands in
nxzai#450 and nxzai#453.

An argument list is not a free pass on its own: `chown` reads a leading dash as an
option, so `--reference=/etc/shadow` would have copied another file's ownership onto
the target. An account or group name has to look like one.

`tests/routes/no-shell.test.js` — three cases. Two of them name a folder, and an
owner, with a payload that creates a file, and check the file is not there; the
third asks for `--reference=/etc/shadow` and expects a refusal. All three fail
against the routes as they are, the first two by running the command. The payload
only ever touches the working directory, and it is removed whatever an assertion
does, so a run that does execute leaves nothing behind.
Two things about OIDC that this fixes.

**Which of two failures it was.** A sign-in that cannot start has one of two causes:
nothing was configured, or what was configured could not be made to work. The first
is answered by filling in OIDC_ISSUER and the rest; the second is answered by looking
at the provider. Both answered 404 "OIDC is not configured", so an administrator whose
provider was unreachable was sent to change a configuration that was already right.
`configureOidc` now records what it concluded and why, and the routes read it: 404
AUTH_OIDC_NOT_CONFIGURED for the first, 503 AUTH_OIDC_PROVIDER_UNAVAILABLE for the
second, and neither carries the network's own words — no ENOTFOUND, no internal host
name, in the body or in the address bar.

A browser asking for one of those addresses is looking at a page, not reading JSON, so
it is sent back to the sign-in screen with the code beside the sentence. The screen can
then say what the code means in the reader's own language.

**Where the callback comes back to.** The return address was built from a fixed
`baseURL`, so a deployment reached through a reverse proxy on a different name sent
people back to the wrong origin. It is now resolved from the request — but only from a
forwarded host behind a trusted proxy, and only when the result exactly matches an
origin the operator configured. A redirect target that a request header could choose
is an open redirect with extra steps.

The path is still held to a relative, same-site one, as before.

Also here, because it is the same files:

- `claimsFromIdToken` in the middleware and `uniqueOrigins` in the routes were local
  copies of things `utils/idToken.js` and the new `utils/oidcRedirect.js` do; both go.
- The guest-session cookie was cleared on `/api` only, at five sign-in and sign-out
  paths. A guest session left on `/` outlived the sign-in that should have ended it.
- `ServiceUnavailableError` (503) and the two AUTH_OIDC_* codes, which nothing had yet.

The account lockout that `routes/auth.js` also differs in is deliberately not here: it
is a different subject and goes with releasing a locked account.

## Checks

Seven test files, 107 tests, including three this fork had and `main` did not:
`oidc-middleware`, `oidcOrigin` and `auth-oidc-routes`. Neutralising
`getOidcAvailability` so it reports one verdict for both causes turns three of them
red — the three that tell the two apart.

Whole backend suite: 2 391 passed, 2 failed, the two that fail on `main` on its own
(`auth.test.js` on the current password, `browse-hidden-files.test.js`). `npm run lint`
reports 146 against `main`'s 143, the three being the parse error on `backend/tests/**`
that 141 of `main`'s own test files already draw. Formatting clean. Frontend builds,
backend loads, documentation site builds.

One test assertion was rewritten rather than ported as it stood: it matched the wording
`express-openid-connect` uses for a callback with no sign-in in progress, and that
wording differs between 2.19 and 2.20. It now asserts the refusal.

One box, one name for it
------------------------

The sign-in box takes an email address or a username, so it is neither: it is
whatever was typed, and this calls it `identifier` from the screen to the route.
The screen and the client were renamed and the store and the route were not, so
the store passed `email` to a client expecting `identifier`. `JSON.stringify`
drops a key whose value is undefined, and the request went out carrying a
password and nobody to sign in. The answer was "invalid credentials", which is
what a wrong password looks like — so nothing about it read as a defect.

`attemptLocalLogin` already took `identifier`; the route is what had not caught
up. `email` and `username` still work, for a script or an older client that
sends them.

The identifier was the half that failed loudly. The screen also reads
`totpPending`, `oidcStatus`, `cancelTotp`, `ensureStatus` and `forgetSession`
off the store, and none of them were there: `totpPending` read undefined, so the
box for the code from the authenticator never appeared, and a correct password
on an account with a second factor landed on a screen that looked like it had
done nothing. Undefined is not an error in a template — it is a `v-if` that is
false. The store is here in full, with the code step read back from the server
on every start so a reload in the middle of one lands back on the code.

tests/routes/sign-in-identifier.test.js signs in with each of the three names,
refuses a wrong password, and reads the three frontend files to check they all
use the one name — the chain is four files long and three of them have no runner
here, which is how it broke silently in the middle.

And what a refusal says
-----------------------

A code that names the kind of refusal — FORBIDDEN, NOT_FOUND, CONFLICT,
RATE_LIMIT_EXCEEDED — is translated for the reader, and the server's own
sentence, which says *which* refusal, went underneath rather than being lost.
A lock that arrives with a duration gets a sentence of its own rather than a
placeholder in the plain one, so it can never read "{minutes}". And the
handler no longer asks vue-i18n for a key before checking it has it, which was
a console warning for every refusal the catalogue has no entry for, twice.
Two reports the server makes about itself at start, neither of which existed.

**What releases up to 1.1.7 left in the cache.** The database and app-config.json lived
in CACHE_DIR until 1.1.8, which moved them to CONFIG_DIR and left links behind; 2.0.3
removed that move from the entrypoint. So an installation that started on 1.1.7 or
earlier and skipped the releases in between comes up on a new, empty app.db in CONFIG_DIR
with its accounts, shares and settings sitting unread in the cache. Nothing said so: the
server started, the sign-in page offered to create the first administrator, and the
answer looked like a fresh installation rather than a lost one.

It is a notice and nothing more — nothing is moved, nothing is deleted. It names what it
found and where, and says what to do with it.

**What the process is costing.** `services/performanceDiagnostics.js` samples CPU,
resident memory as the cgroup sees it rather than as the host does, event-loop delay at
p99, and the queues that can grow: thumbnails, folder sizes, transfers. Off unless
PERFORMANCE_DIAGNOSTICS_ENABLED is set, and then it reports only the intervals that pass
a threshold — a diagnostic that logs every interval by default is a diagnostic that fills
a disk. PERFORMANCE_DIAGNOSTICS_LOG_EVERY_INTERVAL asks for all of them.

An interval below its floor is held to the default: a sampler on a 1 ms interval costs
more than whatever it was meant to diagnose, and 1 ms is what an emptied field sends.

Each queue reports itself through an optional call. One that has no report is a queue
this installation has nothing to say about, not a reason for the whole record to fail —
a diagnostic that throws says nothing at the moment it is most wanted.

## Checks

`legacy-cache-check.test.js`, 3 tests: a cache holding the old names is named, one
holding the links 1.1.8 left is named differently, and an ordinary cache says nothing.
Making the inspection always see an empty cache turns all three red.

`performance-diagnostics.test.js`, 7 tests: silent unless asked for, says what it will
watch and by which thresholds, holds an interval below its floor to the default, reports
nothing of an ordinary interval, reports one that passes a threshold and says which kind
it was, reports every interval when told to, and samples the machine rather than guessing.
Making it start whether or not it was asked for turns the first red.

Whole backend suite: 2 556 passed, 2 failed — the two that fail on `main` on its own.
`/api/features` already offers `preview.maxRenderBytes` to the screen, and the
configuration had no such value, so it answered `null` and the preview rendered whatever
it was given. A document large enough to render slowly renders slowly for everybody on
the machine, and nobody could raise or lower the point at which it stops trying.
PREVIEW_MAX_RENDER_SIZE sets it; 16 MB when it is not set, and a value below zero or
unparseable is that default rather than a ceiling of nothing.

And the listing: `GET /api/browse` answers with what is true at that moment — which
documents somebody has open in an editor, what a folder weighs, whether a write would be
refused. A GET with no cache header is cacheable by default, so a proxy or a browser was
free to keep it and serve a folder as it was: a deleted file still listed, a document
shown as open by somebody who closed it an hour ago. `private, no-store` says what it is.

## Checks

`browse-caching.test.js` asserts both halves of the header, and taking the header away
turns it red.

The ceiling is read through `/api/features`, which has offered the field since the batch
that brought the features route and was answering `null` for it.

Whole backend suite: 2 556 passed, 2 failed — the two that fail on `main` on its own.
`getDb` checks whether a connection is already open and opens one when it is not. Every
caller that arrives before the first has finished sees "not open" and opens another —
and everything that starts with the server asks at once: the session store, the settings,
the trash sweep, the search index, the favourites. So a start opened app.db four times,
ran `migrate` over the same file four times in parallel, and whichever finished last
became the one everybody used.

One opening is shared now. `openDb` does the work, `getDb` hands every caller the same
promise while it is in flight and the same connection afterwards, and `closeDb` lets a
test take it away again — which is what a suite opening a database per case needs.

And `prepared(db, sql)`: `db.prepare` compiles the SQL every time it is called, and the
hot paths called it per row — a listing asking whether each of a thousand entries is a
favourite compiled the same statement a thousand times. Kept in a WeakMap keyed on the
connection, so the cache goes when the connection does and a statement is never handed to
a connection that did not compile it.

## Checks

`db-single-open.test.js`, 5 tests. Five callers in one turn get one connection — counted
on the connection objects rather than on anything the code says about itself. A later
caller gets the one already open. After `closeDb` the next caller gets a new, working one.
The same SQL twice compiles once, and the same SQL against a new connection compiles again.

Putting the per-caller opening back turns the first red.

Whole backend suite: 2 561 passed, 2 failed — the two that fail on `main` on its own.

Two files were in this batch and are not: `betterSqliteSessionStore.js` and
`bootstrap.js`. `main`'s versions are the newer ones — it opens the session database on
first use rather than when the module is required, which is what keeps
`require('./backend/src/app.js')` working where the cache directory does not exist yet.
Bringing the fork's versions over them would have broken that check.
Each account's per-folder choices were two JSON values under `user_settings`:
one map of sorts, one of views, read and rewritten whole on every change. Three
things followed, and all three are gone here.

Two tabs on different folders overwrote each other. Each save sent the whole
map, so whichever tab saved last won and the other folder's choice was lost.
A preference is now written one folder at a time, through
`PATCH /api/settings` with `{ folderSort: { path, sort } }`, and the row's
UPSERT keeps the half it was not given: setting a folder's view no longer
erases its sort.

The map had a ceiling of a hundred folders, because it shipped entire on every
load and was rewritten entire on every change; the hundred-and-first folder
silently forgot the oldest. Rows have no ceiling.

And nothing could ever clean it up. A folder deleted or renamed left its
preferences behind on every account that had ever opened it, on a path that no
longer existed. As rows they can be removed with the folder they describe.

Schema 20 creates `folder_preferences` and carries the old values over: one row
per account and folder, merged under the later of the two times, and the values
it read are removed so nothing can read them back. A value it cannot parse
costs that folder its remembered sort rather than failing the startup.

Also here, because they are the same screen and the same service:

- A default view for folders that have none of their own. `null` means the
  built-in one; a mode there is no such thing as is refused rather than read as
  null, which used to put every folder back to the built-in view.
- Markdown opens in the editor, for whoever mostly writes it, instead of going
  through the preview and clicking Edit every time. Only markdown: it is the one
  kind of file that has both, so it is the only one where opening it is a choice.
- An access rule that cannot be stored is refused with its reason instead of
  being dropped from the answer. Saving `../Secret` used to answer 200 with a
  list the page then adopted, and an administrator was left believing a folder
  was hidden that never was. Worse, a permission that was not one of the three
  became `rw`, so a mistyped `readonly` opened a folder for writing.
- Every section of a save is checked before any of it is written. A payload
  carrying a valid section and a refused one used to store the first and answer
  400 — a request reported as refused that had changed something.
- One list of what a preference is. It was three: the keys the route allowed,
  the chain of if/else that sanitised them, and the defaults in the client store.
  A key in one and missing from another was accepted, silently dropped, and
  answered with its previous value, which the client applied — so the switch
  flicked itself back off. `markdownOpensInEditor` did exactly that.

`PATCH /api/settings` now answers with the settings read back from storage
rather than an echo of what was sent, so what the caller applies to its own
state is what a later request would read. `tests/routes/settings-preferences.js`
was asserting the echo, and now asserts the value of each preference it saved.
`USER_SETTING_KEYS` is `WRITABLE_USER_SETTINGS`, which says what it holds.

tests/services/folder-preferences-as-rows.test.js covers the eight claims
above. Each was put back to the old behaviour to check the right one goes red:
overwriting instead of keeping the other half, deleting the account's rows on
every write, reading without the owner, a LIMIT of 100, accepting any word as a
view mode, and dropping the carry-over.

Whole suite: 2685 passed, 2 failed — the two that already fail on main
(auth.test.js on the wrong current password, browse-hidden-files.test.js on a
FOREIGN KEY). Built, started, and driven in a browser: a folder keeps the view
it was left in while its neighbour keeps the default, and markdown goes to the
editor only when the preference says so.
Moving or copying meant typing a path, or navigating to the destination first
and coming back. This is the dialog the rest of the application will use for
that — mounted once with the layout, opened from anywhere, and answering with a
folder or with nothing.

It opens on a list rather than at the root, because the folder somebody wants is
nearly always one they have used before. Nobody curates that list: it is written
by the transfers themselves, so it stays true to how the person really files
things, and every route into a folder counts — the picker, a drag onto a
favorite, a paste. Kept per account: a shared favourite is a deliberate
bookmark, this is a trace of one person's habits, and showing someone else's
would be both wrong and a small leak of where they work.

The list is filtered against what the account can reach right now. A folder can
be deleted, or have its access revoked, long after it was last used, and
offering it as a destination would only produce a failure at the end of the
flow. Anything gone is forgotten on the way out, so the list heals itself.

Schema 21 adds `recent_destinations`, one row per account and path, trimmed to
ten on write so it cannot grow for somebody who never opens the picker. A
destination that fails to be remembered never fails the transfer that reached
it: remembering is a convenience, and a convenience must not break the thing it
is convenient for.

`ModalDialog` gains a footer. Without it the dialog rendered — title, recents,
the folder tree, all correct — and had no confirm button anywhere in the page:
what it asked for sat inside the scrolling part, and there was no way to answer
except Escape. Driving the dialog in a browser is the only thing that would have
caught it, and it is why the footer is here rather than in the batch that
rewrites this component.

The archive preview is the first screen to use it: "Extract to…" beside
"Extract here", so an archive can be unpacked somewhere other than the folder it
sits in. Closing the dialog without choosing means do nothing — not the root,
and not the default.

tests/routes/recent-destinations.test.js covers the six claims: that a transfer
is remembered without being asked to, that the most recent comes first, that
using a destination again moves it up rather than listing it twice, that one
account's habits stay out of another's list, that a destination since deleted is
dropped, and that a write it cannot perform is swallowed rather than failing the
transfer. Each was put back to the old behaviour to check the right one goes
red: no recording at all, no filtering, the error rethrown, and the read without
its owner.

The route is described in the OpenAPI document and walked by the tour, because
upstream holds every mounted route to both.

Whole suite: 2691 passed, 2 failed — the two that already fail on main. Built,
started, and driven in a browser end to end: two moves, the dialog opened from
an archive, the folder chosen from the recents, and the entries landing there
rather than beside the archive.
…tal B

`archiveCacheService` reads two bounds and nothing defined either of them. In
JavaScript that is not an error: it is `undefined`, and every comparison against
`undefined` is false. So both guards were the wrong way round, in two different
directions at once.

`innerSize > archives.browseMaxBytes` was never true, so no archive was ever too
large to look inside. A compound archive — a .tar.gz and its family — has to be
decompressed before anything inside it can be named, and that bound is the only
thing standing between "show me what is in this" and unpacking a backup of any
size into the cache. It refused nothing.

`total <= archives.cacheMaxBytes` was never true either, so the sweep never
returned early and its loop never broke. It removed every cached copy it found,
on every pass, and each archive was decompressed again from scratch the next
time somebody opened it — the cache did the opposite of its job.

Both are now what the code has always assumed: two gigabytes to look inside,
eight for the copies altogether, either of them settable with
MAX_BROWSABLE_ARCHIVE_SIZE and ARCHIVE_CACHE_MAX_SIZE.

Which is where the second defect came out. `parseByteSize` rejected `5MB` for
the capital B — `5m` and `5mb` were read, `5MB` and `2GB` were not — and a
rejected size is null, which every setting reads as "not set" and answers with
its default. Ten settings took their default from a value that had been given:
the upload chunk size, the search and editor ceilings, the JSON body limit, the
direct-upload limit, the storage reserve, both archive bounds, the trash quota
and the preview ceiling. The README writes `5MB`.

Also here, because they are the same operations: extracting from an archive and
compressing into one now tell the folder-size index what they wrote. The comment
above the extraction already said it queued the refresh; nothing did. And
`archiveTree` reads the access section as a section — an `access` that is not an
object used to read as "no rules at all", which for a zip somebody downloads is
every hidden folder inside it.

tests/config/archive-bounds.test.js covers both: that each bound is a finite
number, that the comparisons the service writes mean something against it, that
an administrator's value is taken and a value that is not a size falls back, and
every written form of a size. Putting the bounds back to undefined turns five
red; putting the capital B back to a refusal turns four.

Whole suite: 2707 passed, 2 failed — the two that already fail on main.
How full a volume is was two commands with the path pasted into them:

    du -sb "<path>"
    df -Pk "<path>"

A folder name is not a shell string. A folder called

    x";<anything>;echo "

closes the quote and leaves whatever follows for the shell to run, as the user
the server runs as, the moment somebody opens that folder. Any account that can
create a folder can do it; with AUTH_ENABLED=false that is anybody who can reach
the server. Reproduced against main: a file that did not exist before the
request existed after it.

`fs.statfs` answers the same question with no shell and no subprocess. It is
also the reason the answer is instant: `du -sb` walked the whole tree to report
a number the filesystem already had, on every request, for every volume — which
on a volume of any size is a full disk read to draw a bar.

The answer gains `used` and `percentUsed`, computed where the numbers are rather
than in each caller, and a path that cannot be read answers zeroes as before
rather than failing.

The bar itself comes with it: a volume in the sidebar shows how full it is when
SHOW_VOLUME_USAGE is on, which is the setting `/api/features` has always
reported and nothing has ever drawn.

tests/routes/usage-no-shell.test.js makes a folder whose name says to create a
file, asks for its usage, and checks the file is not there. Against the previous
route all three of its tests fail, the first of them by running the command.

Whole suite: 2722 passed, 2 failed — the two that already fail on main.
A share was read-only or read-write and nothing else. This gives it the five
permissions the dialog has always had room for — delete, create a folder,
create a file, upload, download — and makes the interface that shows them.

Downloads are the one worth naming on its own. It is deliberately not tied to
read-write like the other four: a read-only share is exactly where withholding
downloads means something, "read this" rather than "take a copy of this". Every
share that already exists keeps every permission it had; a migration decides
nothing for an owner.

`accessManager` is where the permissions are read, so it is where they had to be
answered. A share's listing now says per file what may be done with it, rather
than the route refusing at the end of a click that looked available.

Counting changed with it. Every fetch of `/file/...` used to be a download, so
reading a text file in the browser — which never leaves the page — was written
down as a copy taken away, and an owner reading "downloaded 40 times" was
reading how many times somebody had looked at it. It is counted the way the file
is delivered now: inline is an opening, an attachment is a download, the same
split POST /api/download already used. `tests/routes/share-counters.js` asserted
the old rule and now asserts both halves of the new one.

The list of shares gains what an owner actually needs: a search box, a filter, a
sort, an empty state that says which of the two it is, and the activity behind
each share — when it was last opened and from where, when it was last downloaded
and from where. A share can be edited without being deleted and made again,
which is what changing an expiry used to mean.

Schema 22 adds the five permission columns, defaulting to allowed, and the two
columns for the last download. `versions_visible` and `versions_download` are
switched on for shares with named accounts, because those accounts could already
see what they hold.

One upstream test changed for a reason rather than a rename:
`public-endpoints-hardening` looked at the first `guestSession=` header, and
there are two now. The cookie moved from `/api` to the root — an <img> asking
/static for a thumbnail cannot carry a header, and a cookie scoped to /api never
reaches it — so the old one is cleared in the same answer.

Whole suite: 2795 passed, 2 failed — the two that already fail on main. Putting
`canDownload` back to always-true turns five red; counting every fetch as a
download turns one.
The index walked past four folder names: `.git`, `node_modules`, `dist`,
`build`. That is an editor's habit, and this is a file server, where those are
ordinary folder names somebody may have a year of work in. A file under one of
them could not be found, by name or by content, with nothing in the answer to
say why (#11). The same four names were written down three times — as ripgrep
globs, in the walker, and here; the first two were corrected in nxzai#419 and
the index is the one that was left. Only dot-folders are walked past now, for
the two reasons that are this application's own: the trash and the file versions
live in one, and the rest are hidden things the search does not show unless the
reader asked. What is not worth finding is the administrator's exclusion list to
say, which is visible in Settings.

A folder gets a row of its own, so it can be found by its name without anybody
knowing what is inside it. `search-index.test.js` counted two rows leaving when
a folder of two files was removed; it is three now, and says why.

A result says how it was found: by its name, by what it says, or by both. It was
one list with no explanation, so a file matching only its contents looked like a
file whose name nearly matched.

A search says when it stopped rather than pretending it finished. Three things
it never said: that the term was too short to run, that it had reached its
ceiling and there were more, and that it answered from the first engine alone.
And it can be asked for more, in steps, instead of the answer being all there
ever was.

One thing this batch deliberately does not take from the fork. The fork's search
answers from the catalogue and lets a row point at a file that is no longer
there, because a sweep tidies the index later. Upstream stats the page of
results it is about to hand out and drops what is gone, which is the better
answer — a search result that opens nothing is worse than a search that missed
something — and it costs one lstat per result rather than a walk. It stays, and
the fork's test asserting the opposite was not ported.

Whole suite: 2805 passed, 2 failed — the two that already fail on main. Putting
the four names back turns three red; taking the existence check out turns four.
…de a volume

`POST /api/permissions/chown` built a command line and gave it to a shell:

    chown "<owner>:<group>" "<path>"

`owner` and `group` come from the request body. It is an administrator's route,
but that is the difference between "may change ownership on this volume" and
"may run anything as the user this server runs as", which is not a difference to
leave to a pair of quotes. `chmod -R` and the two `id` lookups did the same with
the path and the numeric ids.

They take their arguments as an array now, through execFile, with no shell
anywhere. And because an argument list is not a free pass either, an account
name has to look like one: `--reference=/etc/shadow` is not a name, and chown
would have read it as an option and copied another file's ownership.

A rule that hides a folder now hides what is inside it consistently. The listing
said one thing and the rule another in several places: a read-only rule left an
administrator the Create button, a hidden rule left the folder's name in a
search result, and a symbolic link out of a share was followed as if it were
part of it. Access is one question asked in one place, and the answer carries
the reason it was refused.

A personal folder name outlives the account it belonged to, while its folder is
still on disk. Deleting an account freed its name, and the next account deriving
the same one was handed a folder full of somebody else's files. Schema 23 adds
the reservations table and, at the upgrade, removes the rows that accounts
deleted before it left behind — `folder_preferences` and `recent_destinations`
point at users through no foreign key, so nothing ever removed them.

One file this batch deliberately does not take from the fork. `routes/volumes.js`
here already drops the volumes a caller may not reach, which nxzai#425 added and
the fork has not caught up with; taking the fork's would have put every hidden
volume's name back in the sidebar. It stays.

tests/routes/permissions.test.js covers what may reach chown, including
`--reference=/etc/shadow` and `root;id`. Against the previous route ten of its
tests fail.

Whole suite: 2859 passed, 2 failed — the two that already fail on main.
@cerede2000 cerede2000 changed the title Hand chown its arguments instead of a command line, and let a rule hide a volume [12/40] Hand chown its arguments instead of a command line, and let a rule hide a volume Sep 27, 2026
@vikramsoni2
vikramsoni2 merged commit 7f06c8b into nxzai:main Sep 27, 2026
1 check passed
cerede2000 pushed a commit to cerede2000/NextExplorer that referenced this pull request Sep 27, 2026
Every axis in parity.mjs looks past the tests on purpose: a test of ours travels
with the batch that brings what it tests, so comparing them file by file would
call the whole suite a divergence. One direction was therefore never measured —
a test written on a batch branch, which never came home — and P3-57 walked into
it: `settings-preferences.test.js` is on the stack and not here, so the batch went
red in its own tree where `integration` was green. Found by accident. This is the
accident on purpose.

    node scripts/test-drift.mjs p3-57

Compared by the cases and not by the files. The first version of this compared
paths and reported forty files missing, of which `two-factor.test.js` — under
`services/` here and `routes/` there — was a file moved, not a file gone. A case
is what a suite is; where it lives is filing.

Against P3-57: 303 cases the stack has and this tree does not, 37 of them in files
nothing here answers to. That is a list to read rather than a verdict, and the
script says so — a case renamed while porting reads as a case missing, and so does
a suite the porting work split under other names, which is most of our
`onlyoffice-*` files against theirs.

The first one read was not a rewording. `no-shell.test.js` holds the two remote
executions of nxzai#450 and nxzai#453 to their fix: a folder name that would be run as
a command, an owner name likewise, and a name that would be read as an option. It
went upstream with the fix. This tree had the fix and nothing holding it there —
so it comes home, and it still bites here: with `ACCOUNT_NAME_PATTERN` loosened to
`/.*/`, the third case fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants