Repository navigation
Conversation
Collaborator
Author
|
Closed in favour of #2599, which declares the same issue, was opened six minutes earlier, covers strictly more (its The readings below were taken independently on master
That ordering is the one thing worth carrying into #2599's own tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2598
A session id becomes a directory, so an id no directory can carry is now refused before
mkdirruns, by a sentence that names the name rather than the operating system.What was measured before the change
On Windows Server 2022, master
6ddb7cc, withemrg.__file__printed by the probe:CON,con.txtandcom1failed the same way;nulgot one step further and failed on thememorysubdirectory (FileNotFoundError [WinError 3]); and an id ending in a space or a dot is folded by Windows instead of refused, so it names a different directory than the id says (..mkdir'd "successfully" and the first write into it raisedFileNotFoundError).Both doors already ask the predicate — an inbound client message via
_refuse_an_unsafe_session_id, and server-side creation via_get_or_create_session(two productioncreate_with_idcall sites) — so the name passed both and failed later, deep in the filesystem. The host's symptom was a session that does not save, or a turn that dies, with a message aboutWinError 267.The change
emrg/session.py—session_id_refusal()is the one writer of the verdict and of the sentence beside it;is_safe_session_id()is it returningNone. Two refusals are added: a reserved device name (CON,PRN,AUX,NUL,COM1–COM9,LPT1–LPT9, judged on the base name before the first., case-insensitively), and an id whose last character is a space or a dot.UnsafeSessionIdis raised bycreate_with_idbefore any directory is attempted.emrg/server/daemon.py— the door passes the refusal sentence to the client. A device name is one path component, so it must not receive the path-escape sentence; a path escape still gets exactly(a session id is one path component), which an existing test pins.tests/test_session_id_names_a_directory.py— 33 tests, both directions.The refusals are platform-independent, on the predicate's existing ground: an id reaches a path on whichever platform runs the host, and a name that names nothing on one of them is not portable. The guard is the reserved set, not a prefix:
console,con-artist,com10,com0andlpt0stay accepted, and a space or a CJK name is still an ordinary session name.Verification, with the tree and interpreter named
tests/test_session_delete_path.py): 52 passed one9daa97,emrg.__file__= this checkout.tests/test_daemon.py -k session_id): 2 passed — the pinnedinvalid session id: '../../../evil' (a session id is one path component)is unchanged.git hash-object emrg/session.py=791a485fef23d8a8431e20e42a63c0e3d2852a69after each):test_creating_a_session_with_a_device_name_is_refused_by_nameandtest_the_two_refusals_are_two_sentences.conandcon.still fail under arm B because the device rule catches them, which is what makes the two arms discriminate.e9daa97in this checkout (emrg.__file__printed): 5456 passed, 512 skipped in 927.79s.tests/test_wake.py+tests/test_scheduler.pyon the same tree — 164 passed, 16 skipped.What a reviewer should know
The running daemon renders the installed tree (
~/.emrg/install/source), not this checkout, so this fix is not in effect for the running instance until the host refreshes the install; merging it changes the source, not the running body. Nothing here starts, stops or restarts a daemon, and no test in it touches the upgrade chain.— cycle cyc20261026-204851