Skip to content

Latest commit

 

History

History
1366 lines (1136 loc) · 116 KB

m5-notes.md

File metadata and controls

1366 lines (1136 loc) · 116 KB

M5 notes

Scope of this branch (wip/r7-svc, part 1)

The service core of shelldrive-host.exe service (03 §1.3, §2.2, §2.6, §3.2, §4.5; D6, D17, D35), the global mount path through sd_mount and Dokany, the service pipe methods, the shelldrive service CLI verbs and the tests. Not in this part: the global WebDAV spike (D11), the elevated admin UI and the tray attention flow (03 §2.6 rule 3, UI side), hostkey add --machine --from-server, the SCM install/uninstall/start/stop/repair-data verbs, and the items listed under "Left" below.

Files

Path What
apps/shelldrive-host/service.c, service.h service core: svc_run (one core for the SCM and the console), SCM dispatch and control handler, service-debug console mode, pipe handlers, machine profile loading, mount records and their control-thread jobs, prompt routing, secrets
apps/shelldrive-host/svc_access.c, svc_access.h pure rules: the decision table (svc_decide), list resolution (svc_acl_build), profile refusals (svc_validate_profile), volume SDDL (svc_volume_sddl), identity path rule
apps/shelldrive-host/main.c service and service-debug modes
apps/shelldrive/cli_service.c `shelldrive service list
l10n/svc/*.po service strings (svc domain, six locales)
tests/unit/sd_svc/ sd-test-svc.exe: pure rules and the in-process core with the fake backend (unit.svc)

Contract changes

Changes to shared interfaces made in this branch. Additive unless stated.

sd_ipc (03 §2.2, §2.4)

  • sd_ipc_server_cfg gets a new last member topic_allowed (int (*)(void *ctx, sd_ipc_client *, const char *)). Called for every valid topic of a subscribe request before anything is subscribed; 0 refuses the whole request with access_denied. The service uses it for prompt, log and hostkeys (elevated admins only, TM-R25).
  • New sd_ipc_client_member_of(client, PSID, int *member): whether the client's token has the SID enabled (or is the client's own user SID). Pipe thread, from a handler only (the client is impersonated for the check). Fails closed.
  • New test hook sd_ipc_test_set_service_owner(sid): creates the service pipe with that owner instead of S-1-5-18 (an unelevated test process cannot give a pipe the SYSTEM owner). The DACL is unchanged. Never set by shipping code.
  • Service pipe limits in this build: one 64 KiB request cap for every client (03 §2.2 says 1 MiB for elevated admins); max_per_sid 4, max_requests_per_sec 10 and idle_timeout 60 s as in 03 §2.2.
  • Service hello features: list, status, mount, unmount, selftest, secret.set, secret.delete, prompt.list, prompt.answer, config.reload, prompt.routing.

sd_mount (03 §1.11)

  • sd_mount_params gets global_mount, volume_sd, volume_sd_len (last members). A global mount has no DOKAN_OPTION_CURRENT_SESSION and must carry the volume security descriptor; without it sd_mount_create returns SD_E_INVALID_PARAM.
  • The sd_vfs_options.global_mount flag is set from the params.

sd_dokan (02 §6.4)

  • sd_dokan_mount_start accepts global_mount (it was refused with SD_E_UNSUPPORTED before M5). It requires volume_sd.

tests/unit/sd_mount (test helper, not shipped)

  • fake_backend_pre_trust(host): marks a host trusted as if its key had been stored, so service tests can mount without a TOFU prompt.

CLI (03 §6.1, §6.2)

  • New command word service (CLI_CMD_SERVICE). Verbs: list, mount <profile>, unmount <profile|X:>, status <profile|X:>. install, uninstall, start, stop and repair-data are parsed and exit 1 with a localized "not part of this build yet".
  • Exit codes: 9 for mount and unmount from a console that is not elevated (no self-elevation, 6.1); 8 when the service pipe is unreachable (service_not_installed spelling); the IPC error code's exit code otherwise.
  • shelldrive help service and the general help list gain the service line.

Service error codes (IPC, 6.2 spellings)

Used by the service and mapped by the CLI through the existing table: access_denied, not_mounted, profile_not_found, already_mounted, target_in_use, prompt_unavailable, host_key_unknown, secret_not_found, usage (refused profile, with the offending key in detail). No new error code was added.

Events (03 §2.4)

  • mount.state on topic mount carries only mount_id, target and state for every subscriber (the full data is in status, admins only). prompt.request, prompt.closed on topic prompt; attention {count} on topic attention whenever the number of open routed prompts changes (0 included), and once to each new subscriber with the current count. prompt.list entries carry the prompt.request fields (kind is the name, not a number).

Decisions taken in this part

  • A global mount is Dokany only (backend = auto and dokan are the same; webdav is refused with usage, mount.backend). The WebDAV spike (D11) decides the others later.
  • No trust on first use for the service (03 §2.6 rule 2): a TOFU host-key prompt is refused with host_key_unknown even when an admin UI is subscribed. Admins pin keys first.
  • Password and passphrase prompts go to an elevated admin that subscribed to prompt with the prompts.ui capability. With none, the mount fails with prompt_unavailable. A routed prompt that is not answered within 120 s is rejected by the control thread.
  • Service mounts never save a secret they were given (can_save is false).
  • A failed mount keeps its record and drive letter until someone unmounts it (03 §1.11). list and status show it.
  • service_access is resolved to SID strings when the machine profile is loaded (names through LookupAccountNameW, resolved at run time). An unresolved name drops the profile (fail closed).
  • Access, decided per caller token (svc_decide): the letter is always visible; state is visible to members of service_access and to elevated admins; details (host, user, remote path, last error) and every admin method need an elevated admin. use needs membership; write needs membership and (service_access_write or elevated admin). An admin outside service_access manages the drive but does not use it (D35).
  • The volume security descriptor is built from the resolved lists: SYSTEM and Administrators full control, each access SID FRFX, each write SID FA, inherited to containers and objects.
  • Machine secrets are DPAPI files under service\secrets\ (service scope, CryptProtectData in the process user scope; under the service that is LocalSystem, no CRYPTPROTECT_LOCAL_MACHINE). Only password secrets are accepted in this part; the tests exercise the round trip in the test user's scope (LocalSystem decryption is a lab item).
  • Test hooks: SD_SVC_TEST_HOOKS (compiled into sd-test-svc and sd-test-host-fake only) enables svc_opts.test_all_admin, which treats a client whose hello kind is testadmin as an elevated admin. Every other client, including the restricted-token client, gets the real check.
  • Import and ISA floors: LookupAccountNameW is resolved at run time (not on the static floor list); the CRT wcsstr is not used (it has SSE code, forbidden in the x86-ia32 flavour).

Tests and verification

Check Result
x64-modern Debug, full build clean, zero warnings
x64-modern ctest, default labels (`-LE "matrix bench
unit.svc (sd-test-svc.exe), 16 tests all pass: attention count on change and on subscribe (svc_attention_counts_the_open_prompts), decision table, list resolution, profile refusals, volume SDDL parses, identity path rule, core start and selftest, profile loading (D17), non-admin restricted token refused for every admin method and for the topic gate, admin mount/status/unmount, prompt refused without UI (prompt_unavailable), TOFU refused (host_key_unknown), password prompt answered over the pipe, DPAPI secret round trip, list visibility for restricted tokens, stop with nothing left behind
x64-xp Debug, shelldrive-host and shelldrive clean; XP SP2 x64 import audit passes
x86-ia32 Debug, shelldrive-host and shelldrive clean; IA32 ISA audit passes

The tests run in-process: no SCM registration, no child process, no real drive. The restricted-token tests need the interactive-user ACE on the pipe (they accept a refused connect as the refusal).

Part 2: service registration and Event Log

Files

Path What
apps/shelldrive-host/svc_scm.c, svc_scm.h `shelldrive service install
apps/shelldrive-host/svc_events.mc Event Log message table, English only (10.3). mc.exe writes svc_events.h and svc_events.rc into generated/svc_events/<config>; the .rc is linked into shelldrive-host.exe, which is the event message file
apps/shelldrive-host/service.c Event Log events from the core (start, stop, start failure, mounted, unmounted, mount failed) through svc_opts.event; the SCM path sets it to svc_eventlog_write (ReportEventW)
apps/shelldrive/cli_service.c the four verbs; repair-data is still "not part of this build"
tests/unit/sd_svc/test_scm.c 12 tests against a fake SCM; no test calls svc_scm_real_ops

Contract changes

  • svc_opts gets event and event_ctx (svc_event_fn). NULL means no Event Log writes: console mode and the unit tests. Additive.
  • CLI: install, uninstall, start and stop now run (no longer "not part of this build"). Exit codes: 9 when not elevated (ERROR_ACCESS_DENIED, the same as mount), 1 for the other SCM errors (already_installed, not_installed, already_running, not_running, scm_failed with the Win32 code), 0 on success.
  • New CLI strings (cli domain, six locales): cli.service.installed, uninstalled, started, stopped, already_installed, not_installed, already_running, not_running, scm_failed, description. cli.help.service lists the new verbs.

Decisions taken in this part

  • Registration (CreateServiceW): LocalSystem (null start name), SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, dependency Tcpip only (1.3). Failure actions: restart after 5 s, 30 s, then 5 min; the count resets after one day. SERVICE_SID_TYPE_UNRESTRICTED only on Vista and later (checked with GetVersionExW); XP skips it.
  • Installation order: create, description, failure actions, SID type, Event Log source. A failure after create deletes the service again. A failed register does not unregister the source (it was not ours to remove). An existing service is not touched.
  • Uninstall stops the service (a service that is not running is fine), deletes it, then removes the Event Log source key. A missing source is not an error. Secrets are not removed here; that stays with the installer (4.7).
  • Event source ShellDrive under ...\Services\EventLog\Application\ShellDrive: EventMessageFile is the path of shelldrive-host.exe (REG_EXPAND_SZ), TypesSupported = 7 (DWORD).
  • Start waits up to 30 s for SERVICE_RUNNING; stop waits up to 60 s for SERVICE_STOPPED.
  • Event IDs (10.3): 1000 started (%1 version), 1001 stopped, 1100 mounted (%1 profile, %2 target), 1101 unmounted (same inserts), 2100 mount failed (%1 profile, %2 IPC code, %3 detail), 2110 start failed (%1 reason). Deviation from 10.3: 1100 has no host name (%3 in the design) so that no server name reaches the Event Log by default (settings.log_privacy). 3100 (configuration invalid) is not emitted yet.
  • The description is localized at install time in the language of the installing console (cli domain); it is written once with ChangeServiceConfig2W. The display name is the English product name, not an indirect string.
  • The svc domain has no new strings: the service writes no user-facing text in this part.

Tests and verification

Check Result
unit.svc (sd-test-svc.exe), 27 tests: the 15 of part 1 and 12 new fake-SCM tests in test_scm.c (install order and spec, SID type per OS, refusal without elevation, rollbacks, existing service, uninstall order, missing service and source, start/stop elevation and results, host spec) all pass in x64-modern, x64-xp, x86-ia32 (Debug)
svc_core_stops_and_leaves_nothing_behind also checks the Event Log sink order: 1000 first, mounted, unmounted, mount failed, 1001 last pass
x64-modern Debug, ctest `-LE "matrix bench
x64-xp Debug, ctest, 76 tests all pass; XP SP2 x64 import audit passes (DeleteService and QueryServiceStatus added to the floor list, both documented from Windows 2000)
x86-ia32 Debug, ctest, 97 tests all pass; IA32 ISA audit passes

Build notes: mc.exe runs on the .mc file in ANSI mode (no -u; the file is ASCII and has no comments, because mc copies comment lines into the generated header). The message file is MSG00409.bin (named after the English LCID).

Part 3: service status and repair-data

Files

Path What
apps/shelldrive-host/svc_scm.c, svc_scm.h svc_scm_status (the rules, over the seam) and svc_path_check_of; the seam gets query_service and query_source (read-only); svc_scm_real_ops fills them
apps/shelldrive-host/svc_repair.c, svc_repair.h svc_repair_data: the machine data folder repair over a base folder, with the owner rule and the extra-ACE seam
apps/shelldrive/cli_service.c service status (no argument) and service repair-data; `service status <profile
tests/unit/sd_svc/test_scm.c (6 new), test_repair.c (8 new) the status rules against the fake SCM; the repair on a temp folder under %TEMP%
l10n/cli/*.po 26 new cli.service.* entries per locale (status, state and start type words, repair messages); cli.service.unimplemented removed; cli.help.service lists repair-data

Contract changes

  • svc_scm_ops gets query_service and query_source (last members, additive). The fake fills them in the tests.
  • CLI: service status with no argument reports the service; exit 0 whenever the facts could be read, also when the service is not installed. A failed SCM query is exit 1. service repair-data is exit 9 without elevation (before anything else), 0 on success, 1 when the base is a link or a Win32 call fails.
  • JSON (--json), English keys: installed, state (running, stopped, starting, stopping, paused, unknown, not_installed), start_type (automatic, manual, disabled, unknown), program (path, check: ok, unquoted, other, unknown), event_source (state: registered, missing, other, unknown; message_file), pipe (null unless running; else reachable, healthy, global_drives, prompts). repair-data --json: moved, moved_to, folders.

Decisions taken in this part

  • The program check is exact: the registered ImagePath must equal this install's "<dir>\shelldrive-host.exe" service (case-insensitive). An unquoted path is its own result, because an unquoted service path is refused. The Event Log source is ok only when its EventMessageFile is this install's shelldrive-host.exe.
  • Status of a running service asks the pipe: selftest for the layout (healthy), list for the global drives (visible ones plus the reserved letters), and the content-free attention count for the open administrator prompts. Subscribing to attention needs no elevation, so the count is shown to every user, not only admins. No new service method was added.
  • repair-data works on the machine tree in this order: the vendor folder LibreStatic (its own DACL only), then ShellDrive with the whole tree scanned (a link, a foreign-owned folder, an unreadable entry or more than 20000 entries makes the tree untrusted: fail closed), then the subfolders and stores at their 3.2 DACLs. An untrusted folder is renamed to <name>.untrusted-<n> (a link is renamed itself, never followed) and a fresh one is created; nothing from the renamed folder is imported. A link in the base folder itself refuses the repair (nothing changed).
  • Every check and every security change goes through one handle opened with FILE_FLAG_OPEN_REPARSE_POINT: GetFileInformationByHandle and GetSecurityInfo for the owner, SetSecurityInfo for the DACL. Folders created by the repair get the default owner of the creating token (Administrators under UAC, SYSTEM under the service); the DACL text is not given an explicit owner, which keeps the XP and non-elevated paths simple.
  • The owner rule (shipping): SYSTEM or BUILTIN\Administrators (IsWellKnownSid). The tests replace it with a seam that trusts every owner or none, and the owner rule itself is tested with the well-known SIDs.
  • The seam extra_ace (svc_repair_ops) is NULL in the shipping build. The tests set (A;OICI;FA;;;OW) so the non-elevated test process, which owns the folders it creates, can build and remove the tree.
  • The repair does not stop the service. A running service that holds service.log open makes the rename fail (sharing violation); the error is reported and nothing is changed. Stopping the service first is the documented way.

Tests and verification

Check Result
unit.svc (sd-test-svc.exe), 42 tests: the 28 of parts 1 and 2 (main.c lists 28 at the previous commit), 6 status tests in test_scm.c (missing service and source, our install as ok, unquoted and foreign paths, host program missing gives UNKNOWN, query failures passed through, the exact path check; none records a call) and 8 repair tests in test_repair.c (empty base builds the tree, sound tree kept, junction at logs moved aside and the sentinel untouched, junction at the vendor folder, untrusted owner moved aside and nothing imported, link as the base refused, missing base, owner rule with well-known SIDs) pass in x64-modern, x64-xp, x86-ia32 (Debug)
x64-modern Debug, ctest `-LE "matrix bench
x64-xp Debug, ctest, 76 tests 76 pass; XP SP2 x64 import audit passes after IsWellKnownSid, QueryServiceConfigW and lstrcmpW were added to xp-sp2-x64.txt and xp-sp3-x86.txt (documented from Windows 2000 or earlier)
x86-ia32 Debug, ctest, 97 tests 96 pass, 1 skipped (dokany.mount, always skipped under WOW64); IA32 ISA audit passes
sdl10n (build) the six cli catalogs are complete for the new entries (every CLDR form for es, fr, pt-BR, it; two forms for en, de)

The tests never query or change a real service and never touch the real %ProgramData%; the repair tests use a folder under %TEMP% that they create and remove, and they need no elevation.

Manual check (read-only, not elevated, no service installed on this machine): shelldrive service status prints "The ShellDrive service is not installed." and "The Event Log source is not registered." and exits 0; shelldrive --json service status gives installed: false; shelldrive service repair-data exits 9 without changing anything.

Part 4: machine folder check at start and Event 3102

Files

Path What
apps/shelldrive-host/svc_folder.c, svc_folder.h the machine folder trust check shared by the service start and svc_repair: open with FILE_FLAG_OPEN_REPARSE_POINT, reparse point, kind, owner (GetSecurityInfo on the handle); the shipping owner rule (SYSTEM or BUILTIN\Administrators, svc_folder_owner_shipping); reason text for the event
apps/shelldrive-host/service.c, service.h svc_ensure_layout checks each existing machine folder through svc_folder (the vendor folder too, default location only); the first refusal is logged and written as Event 3102; svc_opts.owner_trusted (NULL = shipping rule)
apps/shelldrive-host/svc_repair.c uses svc_folder instead of its own open/owner code (same rules, same results)
apps/shelldrive-host/svc_events.mc message 3102 (warning): %1 folder, %2 reason
tests/unit/sd_svc/test_service.c fixture trusts every owner (the temp folders belong to this process); one new core run refuses the root on owner and checks the 3102 insert strings and that nothing was created
tests/unit/sd_svc/test_repair.c one new test: reparse point, file where a folder belongs, owner decision, store file (no owner rule), missing path
tests/unit/sd_svc/main.c, CMakeLists.txt (sd_svc, shelldrive, shelldrive-host) the new tests; svc_folder.c is compiled into the three targets

Decisions taken in this part

  • At start the service stays idle (no repair) when a machine folder is a reparse point or its owner is not SYSTEM or Administrators. The check order per folder: open (never follows a link), reparse point, folder kind, owner. An existing folder that cannot be opened or checked is refused too (reason acl). A missing folder is created with its 3.2 DACL as before.
  • Checked at start: %ProgramData%\LibreStatic (default location only), ShellDrive, logs, profiles, service, service\secrets, service\keys. Store files (known_hosts, settings.ini) are not checked at start, as before.
  • Event 3102 is written once per start, for the first refused folder: %1 the folder path, %2 the reason. Its severity is Warning. The message is English only (10.3, and AGENTS.md: event log payloads are English).
  • The reason vocabulary is owner, reparse_point, acl plus not_directory for a file where a folder belongs; 10.3 lists all four.
  • Tests never write to the Event Log: the sink is a seam (svc_opts.event). Tests never touch %ProgramData%.
  • The owner seam (svc_opts.owner_trusted) is for tests only in practice: the SCM path leaves it NULL.

Tests and verification

Check Result
unit.svc (sd-test-svc.exe): new svc_refuses_a_machine_folder_with_a_foreign_owner_at_start and folder_check_reports_reparse_kind_and_owner; svc_core_stops_and_leaves_nothing_behind also checks that no 3102 was written for the trusted fixture pass (x64-modern Release and Debug)

The reparse-point start refusal (a junction at a machine folder) has the same code path as the owner refusal and the shared check tests, but no end-to-end test of its own (the junction helper lives in test_repair.c).

Part 5: hostkey add and the machine gate (partial)

Found on this branch: there was no hostkey add --from-server in any scope (per-user or machine). hostkey accept-announced existed for the per-user store only (agent IPC). The service pipe has no hostkey.* method, and service.c only logs announcements (svc_on_hostkeys). The CLI has no SSH connect of its own: sd_ssh_conn_create is used by sd_sftp alone. So the connect-and-store part below is not built; this part adds the command surface and the elevation rule.

Files

Path What
apps/shelldrive/cli_args.c, cli.h hostkey add --from-server host[:port] [--type T] [--expect SHA256:...], the --machine option (hostkey add and accept-announced only), --from-server and --expect (hostkey add only); the parse checks
apps/shelldrive/cli_cmds2.c hk_add, the machine gate on accept-announced --machine; the not-built answer
apps/shelldrive/cli_cmds.c help: the hostkey add line, the three options
apps/shelldrive/cli_common.c, cli_int.h cli_is_elevated() (moved from cli_service.c, which now calls it) with the test seam below
l10n/cli/*.po 5 entries per locale: cli.help.opt_from_server, cli.help.opt_expect, cli.help.opt_machine, cli.hk.need_admin, cli.hk.not_built
tests/apps/test_cli_args.c, test_smoke.c, main.c cli_parse_hostkey_add_machine (parser), smoke_hostkey_add_machine (exit codes and text through sd-test-cli.exe)

Behaviour

  • hostkey add without --from-server, with a bad host, a bad --expect (must be SHA256: plus base64 characters) or with a positional argument: usage, exit 2.
  • hostkey add --machine and hostkey accept-announced <id> --machine from a non-elevated console: exit 9, the localized "needs an elevated console" line (JSON: access_denied). Nothing is read or written.
  • Elevated, or without --machine: exit 1 with "not part of this build yet" (JSON: not_implemented). Nothing is written.
  • --machine, --from-server and --expect on any other command: unknown option (exit 2). --machine before the command word is accepted, as the other global options.

Test seam

SHELLDRIVE_TEST_ELEVATED=0 makes cli_is_elevated() report a non-elevated token (the same style as the other SHELLDRIVE_TEST_* variables). Only the value 0 is read, so a test can deny elevation but cannot grant it. The elevated path is not exercised by any test.

Not done (open)

  • The connect: the verified connection with the stored key types only (01 §4.3, TM-R04), sd_ssh_conn_fetch_hostkeys for the other types (exists since M2, no caller yet), the fingerprint confirmation and --expect, and the write.
  • Where the machine store is written from: through the service pipe (new hostkey.* methods, the service serves hostkey.announced.list and .accept as 5.6 describes) or by the elevated CLI directly (sd_known_hosts on the %ProgramData% store, with the 3.2 owner rule). 03 §2.6 rule 2 says the elevated CLI "connects through the service", so the service-pipe route is the one to build.
  • hostkey list --announced --machine; the service's announcement store (service.c only logs, Event 2300 is not written).
  • Per-user hostkey add --from-server (the same connect path without --machine).

Part 6: per-user hostkey add (wip/r13-hkuser)

Part 5 left hostkey add --from-server without --machine as "not part of this build". This part builds the per-user path: the agent connects, the CLI asks. The machine store (--machine) is unchanged: still exit 1 when elevated, exit 9 when not.

Files

Path What
src/sd_mount/include/sd_mount/sd_mount.h sd_mount_hk_fetch (verified, lookup name, keys), sd_mount_hostkey moved above the backend table, the new backend member hostkeys_fetch (last, NULL in old fakes), sd_mount_hostkeys_fetch()
src/sd_mount/mount.c sd_mount_hostkeys_fetch(): the core shared by the agent and, later, the service. Validates the host, sets the lookup name, calls the backend, rejects more than 8 keys
src/sd_mount/mount_real.c real_hostkeys_fetch: returns SD_E_UNSUPPORTED (see "Not done")
apps/shelldrive-host/agent.c hostkey.add (handle_hostkey_add, dispatched in ipc_handler)
apps/shelldrive/cli_cmds2.c hk_add_user (the question and the answer; the agent is started on demand through connect_agent), hk_accept_offer, print_applied; hk_add routes --machine as before
apps/shelldrive/cli_args.c, cli_cmds.c --stdin is accepted by hostkey add (answers the question from standard input, as for mount); help line
tests/apps/host_fake_backend.c hostkeys_fetch scripted by the host name (below); kh_apply_hostkeys writes the real user store under the test root
tests/apps/test_smoke.c, main.c smoke_hostkey_add_offers (new, at the end of the file); smoke_hostkey_add_machine checks the user-add exit codes too (the agent is started on demand and stopped at the end)
l10n/cli/*.po 4 entries per locale: cli.hk.add_none, cli.hk.add_offer (plural), cli.hk.add_first_question, cli.hk.add_choices

IPC method hostkey.add {host, port, lookup, type?, expect?} (user agent pipe, no capability, like hostkey.announced.*; not on the service pipe yet). lookup is the known_hosts name the CLI computed (host, or [host]:port). The agent:

  1. connects through the backend (sd_mount_hostkeys_fetch): offering only the stored key types of the host (TM-R04), the other host keys inside that connection (or only type). The agent recomputes every fingerprint from the blob and drops keys of other types than type;
  2. with expect: stores only the key whose SHA-256 fingerprint is expect (user store, add only), no question. No match: host_key_mismatch (exit 6) when the host is verified by a stored key, host_key_rejected (exit 5) on first contact. Reply {host, lookup_name, verified, added: 1, removed: 0, keys[]};
  3. without expect: keeps the keys as an announcement (a-<n>, the same list as hostkey.announced.list) and replies {host, lookup_name, verified, keys[{type, fingerprint}], id}. No keys: no id.

The CLI then asks and, on yes, calls the existing hostkey.announced.accept {id, add_only: true}. So the store write, the removal rule and the # updated-by comment are the ones of 5.6. A refused offer is not deleted: it stays in hostkey list --announced like an announcement left at "Not now" (there is no reject method).

Behaviour (CLI, hostkey add --from-server host[:port] [--type T] [--expect SHA256:...])

  • --expect given: stored with no question, the "Updated the host keys" line, exit 0.
  • Verified host (a stored key matched): " also has N other host key(s). Add it?" with each key listed, then [y]es, [N]o:. Yes stores them; anything else exits 5 (host_key_rejected).
  • First contact (no stored key, 5.2): the "authenticity can't be established" text with the presented key and its fingerprint, Add this key? [y]es, [N]o:. Yes stores it (the trust decision); no exits 5.
  • --json only offers (no question): the reply holds the id for hostkey accept-announced <id> --add-only.
  • The server offers nothing new (or nothing of --type): "has no other host keys to add", exit 0.
  • --stdin reads the answer from standard input (as mount does). Without it and without a console the question gets no answer and the offer is refused (exit 5).
  • No agent running: the CLI starts it, as mount does; if that fails, agent_unavailable (exit 8).
  • --machine: unchanged (exit 9 without elevation, exit 1 with it).

Test seam

sd-test-host-fake scripts hostkeys_fetch by host name: *.known.test verified (ECDSA and ssh-rsa besides the stored key), *.changed.test a mismatch, any other name a first contact with one ssh-ed25519 key. The keys are synthetic blobs (the fingerprints are real SHA-256 of those blobs). The fake is wrapped in host_fake_backend.c, so tests/unit/sd_mount is unchanged. Its own kh_apply_hostkeys only counts, so the wrapper writes the user store through sd_known_hosts under the test configuration root; the tests read the keys back with hostkey list.

Result of the last run (ci-local -Presets x64-modern -ReleaseOnly -TestRegex unit.apps|unit.ssh|unit.ipc): all five groups pass. smoke_hostkey_add_offers is new; smoke_hostkey_add_machine now also checks the user-add exit codes.

Finding that blocks the real connect

sd_ssh reaches SSH_ST_CONNECTED only after user authentication (ssh_on_authenticated, conn.c). fetch_hostkeys requires that state (hostkey_update.c, fetch_run), and hostkeys-prove-00 is sent only after authentication too. So a connect that offers only the stored key types can still not collect the other keys without credentials, and hostkey add --from-server host[:port] has none. The spec's flow (01 §4.3, 03 §6.1) assumes a connection that is verified but not yet authenticated. That needs a decision: an auth method for this command (the user's agent keys, a profile, or a password prompt), or an sd_ssh "post-KEX" connect mode that stops before ssh-userauth.

Not done (open)

  • The real connect (real_hostkeys_fetch answers SD_E_UNSUPPORTED, which the CLI reports as "not part of this build yet"). Blocked by the authentication question above. Also still to do with it: run the blocking connect on a worker (the handler runs on the IPC thread), route its host-key prompt (TOFU) through the prompt broker instead of the two-step offer, and use sd_ssh_conn_fetch_hostkeys for the re-key path.
  • The first-contact flow in the real backend: 5.2 wants the TOFU prompt from the connect itself. The offer model here gives the same question, but the other keys of a first contact are only learned after a second, verified connect (not built).
  • Service side: hostkey.add on the service pipe and the machine store (--machine), as before.
  • Refused offers stay in the announcement list until the agent restarts.
  • Spec text: 03 §2 lists the method; 03 §6.1 is unchanged (the offer model is an implementation detail of this part). 01 (~lines 759 and 2589) and TM-R04 are unchanged.

Left (not in this part)

  • Global WebDAV (D11 spike, system / link / attach modes, 03 §1.3).
  • The display name as an indirect string (@<path>,-<id>, Vista+); the service's own re-set of the description at first start (1.3); the Event Log 3100 and the other 2xxx/3xxx ids of 10.3 that depend on features not in this part. Event 3102 is written (part 4).
  • hostkey add --machine --from-server and hostkey accept-announced --machine (5.6 machine store): the command surface and the elevation rule are in part 5; the connect, the store write and the service side are not (the per-user connect of part 6 is blocked on authentication, see there).
  • Chains (proxy.jump), proxies, and the system proxy for service profiles: done in part 11. Still open there: the machine policy AllowSystemProxy is not read by this build, so proxy = system stays refused (as on the per-user path), and there is no admin verb for proxy secrets of the service store.
  • Identity files: the path rule and the handle checks (owner, reparse point, DACL) are done in part 6 for the identity file of a service profile. Still open: certificate files (no service profile loads one yet), file-level checks of machine profiles, known_hosts and settings.ini (only the folder rule covers them), passphrase secrets and identity_store keys for service profiles.
  • Re-applying the 3.2 DACLs of existing machine folders at service start (3.2): done in part 6 for trusted folders. Untrusted folders are still only refused at start; service repair-data (part 3) moves them aside.
  • Power events and session changes are logged only; the admin session list for the attention flow (2.6) is not kept.
  • Admin UI, not done: a list window of pending service prompts (the admin mode shows one prompt dialog per open prompt instead); host-key announcements of the service machine store in the admin UI (hostkey.announced on the service is not served yet); --elevated-view (03 §1.7.2) is a CLI flag of the WebDAV elevated mapping and has no UI mode here.
  • Admin UI, done (shelldrive-ui.exe part, ui_svc.c, ui_admin_model.c): the attention watch of a logged-on administrator (linked token on Vista+, membership on XP) and the tray state and menu item that relaunch the UI with --elevated-admin (runas on Vista+, plain open on XP). The admin mode connects to the service pipe only, has no tray icon and no mutex (it never forwards to the running UI), lists the open prompts, shows their dialogs and sends prompt.answer over the service pipe. It leaves when the service goes away or after 60 s with no prompt.
  • Secret types other than password; secret.set for passphrases needs the key fingerprint target.
  • Lab items: a real Dokany global mount (visible to a second session, before logon), LocalSystem decryption of the service secrets, and the SYSTEM-owned service pipe as a non-test client.

Part 6: key file trust (TM-R27) and the start re-apply of the 3.2 DACLs

Closes the two "Left" items on identity files and on the start re-apply (both above).

Files

Path What
apps/shelldrive-host/svc_folder.c, svc_folder.h svc_file_read_trusted (checked read of a key file), svc_folder_apply_dacl (3.2 DACL compare and set), the DACL check (dacl_untrusted_write), reasons acl and not_file
apps/shelldrive-host/service.c identity file read in job_start (the bytes go to sd_mount as a hop key_blob, label = the path); svc_check_existing re-applies the DACL of a trusted folder; svc_event_key_refused (Event 3102 with the file as %1); the 3.2 SDDL constants are file-scope
apps/shelldrive-host/service.h svc_opts.dacl_extra_ace (test seam, honoured only in SD_SVC_TEST_HOOKS builds)
tests/unit/sd_svc/test_identity.c (new), main.c, CMakeLists.txt the seven identity and DACL cases below
tests/unit/sd_svc/test_service.c the fixture writes service\keys\key1.ppk (the identity profiles name it) and sets dacl_extra_ace

Behaviour (2.6 rule 1, TM-R27, T-51)

  • The identity file path must be under <machine root>\service\ (unchanged rule, svc_path_under).
  • Every folder between the service folder and the file is opened with FILE_FLAG_OPEN_REPARSE_POINT and checked on its handle: not a reparse point, a folder, owner SYSTEM or Administrators (the owner rule), and a DACL that grants no write to an untrusted principal.
  • The file is opened without following a link (FILE_FLAG_OPEN_REPARSE_POINT), checked on that handle: not a reparse point, a plain file of 1 B to 256 KiB, owner trusted, DACL with no write, modify, delete, WRITE_DAC or WRITE_OWNER for a principal other than SYSTEM, Administrators, the owner, CREATOR OWNER and OWNER RIGHTS. A NULL DACL and an ACE type the check does not understand (object or callback ACEs) are refused. Deny ACEs are not counted.
  • The bytes are read from that same handle, which is opened with FILE_SHARE_READ only, so no writer can open the file while it is read. The mount then receives the bytes (sd_mount_hop.key_blob, the SD_ID_BLOB path of sd_ssh), not the path: there is no second open. The bytes are wiped after sd_mount_create.
  • A refused file: Event 3102 (%1 = the file, %2 = owner, reparse_point, not_directory, acl or not_file) and the mount fails with usage ("identity file refused ... (TM-R27)"). A file that cannot be opened or read fails the mount with usage and no event. The service itself stays up. The 3102 text says "Machine folder ... stays idle", which is not what happens for a key file; the message text is not changed here (open).
  • Start, for a trusted folder (owner and no reparse point, 3.2): the DACL is compared with the 3.2 SDDL (protected, the same ACEs in order) and set back when it differs. The folder is opened with WRITE_DAC when the service can; without it, the check still runs and a wrong DACL is refused with acl. An untrusted folder is still not fixed here (repair-data moves it aside, part 3).

Test seam

svc_opts.dacl_extra_ace appends an ACE to every machine DACL the start sets or checks (tests only). The test process is the owner of its folders, so the tests pass (A;OICI;FA;;;OW), as svc_repair does. The shipping build never reads it.

Tests (unit.svc, new cases)

  • identity_file_through_a_junction_is_refused: a junction for the keys folder into a sentinel folder: reparse_point.
  • identity_file_symlink_or_link_tag_is_refused: a file symbolic link when the process may create one; otherwise a file with a user-defined reparse tag (same refusal).
  • identity_file_with_a_foreign_owner_is_refused: owner.
  • identity_file_with_a_user_writable_acl_is_refused: a key file, then a keys folder, that Everyone may write: acl.
  • identity_file_good_is_read_from_the_checked_handle: accepted, bytes equal.
  • identity_path_that_is_a_folder_is_not_a_file: not_directory.
  • machine_folder_dacl_is_reapplied_once_then_left_alone: first set changes the DACL, the second call writes nothing.
  • The existing service cases (svc_admin_mounts_reports_and_unmounts and the others that use key1.ppk) now go through the handle read and the blob hop; they pass the fixture key file.
  • Every test uses a fresh folder under %TEMP% named with the PID and a QueryPerformanceCounter value, removed at the end of the test. Nothing touches %ProgramData%, the registry, the Event Log or the SCM.

Not done (open)

  • Certificate files (auth.certificate for service profiles): no service profile loads one; the same helper applies when one is wired.
  • File-level checks of machine profiles, known_hosts and settings.ini (03 §2.6 names them): only the folder rule covers them today.
  • The Event 3102 text is written for machine folders ("stays idle"); a key file refusal reuses it.
  • The mount-level refusal is not tested end to end through the core (the helper and the blob hop are tested on their own and through the existing core cases that read the fixture key).
  • The DACL re-apply is tested on a folder with the helper directly, not through a full core start on a folder with a wrong DACL.

Part 7: per-request access in sd_vfs

Spec. 02 §6.7 (requestor check, write right), §7.7 (SSPI caller, service_access_write), §8 (sd_vfs_caller, access_sids / write_sids), TM-R24 and D35 (no default audience). The spec puts the caller in sd_vfs_caller and the lists in the options; the vfs now enforces them.

Files

Path What
src/sd_vfs/vfs_access.c new: mount-time copy of the lists and the well-known SIDs; vfs_access_check (per request)
src/sd_vfs/vfs_ops.c sd_vfs_create checks before any work (write request = write-class access or a create/truncate disposition; MAXIMUM_ALLOWED is a read); sd_vfs_stat_path takes the caller
src/sd_vfs/vfs_core.c global_mount accepted; lists copied at mount
src/sd_mount/mount.c, sd_mount.h sd_mount_params.access_sids / write_sids (copied at create; a global mount needs n_access >= 1)
src/sd_dokan/dokan_mount.c global mounts: requestor token user and enabled, non-deny-only groups go to the vfs; a request without a token is refused
src/sd_webdav/wd_methods.c, wd_server.c sd_vfs_stat_path gets the caller; groups NULL
apps/shelldrive-host/service.c the resolved service_access / service_access_write strings become SIDs for the mount

Decisions

  • Per-user mounts: the caller's SID must equal the mount owner (a NULL caller stays allowed for host-internal use).
  • Global mounts: no caller or no SID is refused. LocalSystem is allowed in full only with allow_system. Any access needs the caller (SID or an enabled group) in service_access. A write also needs caller->can_write, a SID or group in service_access_write, or an enabled BUILTIN\Administrators group. A UAC-filtered admin token does not count.
  • Empty service_access on a global mount: refused at mount with SD_VFS_E_ACCESS_DENIED (D35). Empty service_access_write: members are read-only.
  • A write by a member without the write right fails with SD_VFS_E_ACCESS_DENIED (403 / STATUS_ACCESS_DENIED), not SD_VFS_E_READ_ONLY, as 6.7 says.
  • Read-class checks: lookups (stat_path) are reads, so a non-member gets nothing.

Limitations and open items

  • Dokany reads the requestor token on every create (no 60 s per-(LUID, SID) cache from 6.7 yet).
  • WebDAV has no token groups on the per-user SSPI path, so group entries in service_access only match by user SID there. Global WebDAV is still the attach fallback (D11), so this does not reach a global mount yet.
  • SD_VFS_EV_AUDIT (Event 1200, TM-R24) is not raised yet.
  • The Dokany requestor check is not unit-tested (the callbacks are static); the vfs rules are.

Tests. tests/unit/sd_vfs/test_vfs_access.c (8 tests): global mount needs service_access; per-user owner only and NULL caller; read needs the access list (and stat_path); a member without the write right is read-only, with create/truncate/delete/rename denied and nothing changed; the write list grants write; group matching and admins writing; a group in the write list; SYSTEM with and without allow_system; the frontend can_write flag restricts. test_mount.c gives its global-mount case a service_access SID.

Build. ci-local.ps1 -Presets 'x64-modern' -ReleaseOnly -NoFixture -AllowSkip -TestRegex 'vfs|webdav|dokany': pass, 4 of 4 tests (unit.vfs, unit.webdav, webdav.redirector, dokany.mount).

Service pipe: non-admin cap, reserved administrator instances, Event 3101 (TM-R25)

Closes the "Left" item on the non-admin request cap and the reserved administrator slots of the service pipe (03 §2.2, TM-R25). The 4-per-SID and 10-per-second limits were already in place and are unchanged.

Spec values (03 §2.2, 05 TM-R25, 03 §10.3): request cap 1 MiB for elevated admins and 64 KiB for every other client, also before hello; 32 instances of which 2 are reserved: once 30 other instances are connected, a client that is not an elevated admin is closed at hello with too_many_connections; 4 instances per SID; 10 requests per second for non-admins; Event 3101 at most once per SID per 10 minutes (%1 SID, %2 reason).

Changes

  • src/sd_ipc/include/sd_ipc/sd_ipc.h, src/sd_ipc/ipc_server.c: sd_ipc_server_cfg gets four members at the end, all zero or NULL for the agent (its behaviour is unchanged): max_message_nonadmin (request cap of non-admins, checked per read; before hello the non-admin cap applies), reserved_admin_instances (checked at hello, after the client kind is known), is_admin (the service's caller_is_admin, so the test admin override applies) and on_refused (called on the pipe thread for reasons token, per_sid, reserved and rate). New accessor sd_ipc_client_sid.
  • apps/shelldrive-host/service.c: admin cap SD_IPC_MAX_MESSAGE (1 MiB), non-admin cap 64 KiB, 2 reserved instances, and svc_on_refused, which writes Event 3101 through the existing svc_event seam.
  • apps/shelldrive-host/svc_access.c, svc_access.h: svc_refuse_log_due, the 10-minute per-SID throttle for 3101 (32 slots; a full table reuses the entry logged longest ago). Takes the clock as a parameter, so tests use fake times.
  • apps/shelldrive-host/svc_events.mc: Event 3101 SVC_MSG_CLIENT_REFUSED.

Tests (tests/unit/sd_svc, sd-test-svc.exe, 67 of 67 pass):

  • refuse_log_is_once_per_sid_per_window: fake clock; first event due, same SID inside the window not due, due again after 10 minutes, another SID due at once, eviction of the oldest entry.
  • svc_pipe_caps_and_reserved_admin_instances: a restricted-token client's 100 KiB request is refused and the same request from testadmin is accepted; with 30 raw pipe instances held (connected, no hello), a restricted client is refused at hello, two such refusals write at most one 3101, and a new testadmin connection still succeeds.

Build. ci-local.ps1 -Presets 'x64-modern' -ReleaseOnly -NoFixture -AllowSkip -Jobs 4 -TestRegex 'unit\.svc|unit\.ipc|unit\.apps': pass, 3 of 3 (unit.svc, unit.ipc, unit.apps).

Open items

  • A client that connects and never sends hello holds an instance until the 60 s idle timeout, and the reservation is decided at hello (as 03 §2.2 describes). Thirty-two hello-less connections can therefore still block administrators for up to a minute. A connect-time token check would close that gap; it is not done.
  • The non-admin cap check in svc_pipe_caps_and_reserved_admin_instances only runs when the restricted-token connect succeeds, which depends on the pipe ACE in the test session (the same convention as the existing tests). The check was not separately confirmed to run in this session.
  • Event 3101 is not written for a refusal before the token gives a SID (token refusals with no SID).
  • Event 3101 is English only, like the other 3xxx events in svc_events.mc; it is not in the svc l10n catalogs.
  • Not exercised on a real elevated admin token or on XP; TST-23 in 05 §7 covers that in the lab.

Part 8: the per-user hostkey connect (wip/r14-hkconn)

Part 6 left real_hostkeys_fetch answering SD_E_UNSUPPORTED: sd_ssh reaches SSH_ST_CONNECTED only after user authentication, and the fetch needs that state. This part makes hostkey add --from-server (per user, without --machine) connect for real. The machine store is unchanged.

Decision (01 §4.3, 03 §6.1). The connect is a normal connection with the matching profile's authentication and prompts, offering only the stored host-key types; sd_ssh_conn_fetch_hostkeys() runs inside that verified connection. A host with no stored key is a first contact (TOFU, 5.2): the presented key is taken with SD_HK_ACCEPT_ONCE, nothing is stored, and the CLI's question is the trust decision.

Shape. The hostkeys_fetch backend member (a blocking call with no prompt context) is replaced by a hostkey mount: sd_mount_params.hostkey_fetch (with hostkey_type) makes sd_mount connect through sd_ssh without an sftp session and without a vfs. The prompts, the broker and the deferred IPC reply are the ones of profile.test, so the work runs on the agent's control thread and the sd_ssh I/O thread; the IPC thread only queues the request. The connection's own callbacks stay in mount.c, which is what answers the broker's prompts by id.

Files

Path What
src/sd_mount/include/sd_mount/sd_mount.h sd_mount_params.hostkey_fetch, .hostkey_type; backend members hk_conn_create, hk_conn_connect, hk_conn_fetch, hk_conn_destroy (replace hostkeys_fetch); sd_mount_get_hostkeys() (replaces sd_mount_hostkeys_fetch())
src/sd_mount/mount.c build_ssh_config() (the hop configuration, shared with the sftp start); hk_start, hk_on_connected, hk_on_fetched, hk_finish; EV_HK_DONE; first-contact TOFU prompt in ssh_on_prompt (ACCEPT_ONCE, the presented key kept); update_host_keys = no on the hops (announcements are not stored by this path)
src/sd_mount/mount_real.c the four members as thin wrappers over sd_ssh
src/sd_ssh/include/sd_ssh/sd_prompt.h, kex.c, prompt.c, conn_internal.h sd_hostkey_prompt_info.blob/blob_len: the presented key, owned by the prompt (needed to store a first-contact key after the CLI's yes)
apps/shelldrive-host/agent.c handle_hostkey_add (profile matched by host and port as mount finds one, else the --host defaults; handle_mount_body(..., test = 2) makes the connect-only record), reply_hostkey_add (the deferred reply, from on_state), hk_complete (expect rule, announcement list, the reply members), hk_error_text
tests/apps/host_fake_backend.c the fake sd_ssh connection (hk_fake_*): a stored host (*.known.test), a mismatch (*.changed.test), first contact (anything else); the TOFU prompt goes through the mount's own ssh_on_prompt
tests/unit/sd_ssh/test_interop.c interop_hostkeys_fetch_none_offered, interop_hostkeys_fetch_first_contact_refused (WSL fixture, label interop, wsl_sshd_fixture)
docs/design/01-ssh-sftp-crypto.md §4.3, §9; docs/design/05-threat-model.md TM-R04 status notes

Behaviour

  • Stored key of the host: the connection is MATCH (or a mismatch, which fails like a mount). The keys returned are the server's other host keys: announced keys are proven with hostkeys-prove-00; each requested type that was not announced is obtained by a re-key restricted to that type. The default list is ed25519, ECDSA P-256/384/521 and ssh-rsa (the legacy type only where the legacy policy allows it); --type T asks for T alone.
  • The server offers none of the stored types: host_key_type_unavailable (exit 6) as for a mount.
  • First contact: no fetch (01 §4.3: a fetch needs a key trusted before the connection). The reply has the one presented key with verified: false, and nothing is stored until the CLI's yes (hostkey.announced.accept). --expect stores the key with that fingerprint without a question, as before.
  • The fingerprints are recomputed from the blobs in the agent, as before; only --type keys are kept.

Test seam and results

  • The smoke tests (sd-test-apps.exe --filter hostkey, 5 of 5) run the agent path on the fake connection: smoke_hostkey_add_offers and smoke_hostkey_add_machine pass unchanged.
  • ci-local.ps1 -Presets 'x64-modern' -ReleaseOnly -AllowSkip -Jobs 4 -TestRegex 'unit\.ssh|unit\.apps|unit\.mount|interop\.ssh': build passes; unit.ssh, unit.ssh_transport, unit.ssh_auth, unit.mount, unit.apps pass; interop.ssh is skipped.
  • Interop not run. The WSL sshd fixture on port 2222 is running but belongs to another worktree; this worktree has no tests/fixtures/wsl-sshd/state/env, so sd-test-ssh-interop.exe exits 77 ("fixture not started"). The two new tests are compiled and linked but have never run against a server. To run them: start the fixture for this worktree (tests/fixtures/wsl-sshd/start.ps1 once port 2222 is free, or SD_SSH_WSL_FIXTURE_DIR), then sd-test-ssh-interop.exe --filter hostkeys_fetch.
  • No unit test in tests/unit/sd_mount covers the hostkey mount: the fake backend there has no hk members, so the hostkey path is covered by the apps smoke tests only.

Not done (open)

  • Interop run of interop_hostkeys_fetch_* (see above) and an interop case with several server host keys (the matrix fixture in run-matrix.ps1 has them; rotate ab). Until then the re-key path for a type the server does offer is unverified against a real server (01 §15 item 9).
  • Announcements race: OpenSSH may send hostkeys-00 after USERAUTH_SUCCESS; the fetch starts when the connect is done, so an announced key may not be proven by hostkeys-prove-00 and is re-keyed instead. Correct, but it costs one re-key per type. Measure on the interop run.
  • A first contact is not fetched, so hostkey add on a new host gives only the one key the server presents (5.2); the other types need a second hostkey add after the first key is stored.
  • The service pipe (hostkey.add on the service, the machine store with --machine) is still not built.
  • Refused offers stay in the announcement list until the agent restarts (unchanged from Part 6).

Part 7 follow-up: Dokany requestor cache and Event 1200

Closes two of the open items above (the Dokany 60 s cache and SD_VFS_EV_AUDIT). The WebDAV item stays open.

Dokany cache (02 6.7). src/sd_dokan/dokan_cache.c (private) keeps the enabled groups of a requestor token for 60 s, bounded to 32 entries, guarded by one critical section, with lookups that return copies. dokan_mount.c reads TOKEN_STATISTICS (one query) and the user SID on every create, and the groups only on a miss. Decisions:

  • The key is (TokenId, ModifiedId, user SID). TokenId identifies one token object: a UAC-filtered, restricted, privilege-stripped or duplicated token has its own, even when it shares the logon LUID and the SID with its parent. ModifiedId changes when the token's groups or privileges are adjusted, so an entry from before the change is not reused. The LUID is not part of the key.
  • The earlier key (LUID, elevation type, SID) was not enough. A privilege-stripped token with deny-only groups kept the LUID, SID and elevation type of its parent, so within 60 s it could hit the parent's entry and inherit an enabled Administrators group it does not have, which grants write. The residual is closed by the TokenId key.
  • Restricted tokens are cached too, under their own TokenId. There is no restriction query on the path any more.
  • A failed token query returns "denied" and stores nothing. The 60 s window is measured from the store; a hit does not extend it.
  • Hit rate depends on DokanOpenRequestorToken returning the same token object for repeated opens from one process. If it duplicates the token on each call, each open gets a new TokenId and misses. Not verified on a live mount.

Open. Verify the hit rate on a live Dokany mount (the TokenId stability above). Without a stable token object the cache saves nothing, but it still never grants more than a fresh read.

Event 1200 (03 10.3, TM-R24). The vfs raises SD_VFS_EV_AUDIT in vfs_access.c (vfs_audit) after a successful mutating operation on a global mount: create (new file), write_open (one per open for write), delete (from cleanup, with the requestor of the handle), rename, setattr (winattrs and times) and set_security. Requestor SIDs come from the create that opened the handle. Denied requests raise nothing: Event 1200 records changes. Per-user mounts never raise it. Coalescing is per (requestor SID, operation, path) in a 60 s window (VFS_AUDIT_WINDOW_MS) with a 32-slot table; suppressed repeats are dropped, not counted. The clock is v->audit_now (sd_tick_ms by default; the tests replace it).

The host seam: sd_mount_callbacks.on_audit (control thread, the SID valid during the call) carries the event from mount.c. service.c resolves the account name on the control thread and raises SVC_MSG_AUDIT (1200, Information, svc_events.mc) with the Event Log sink, which tests replace. The agent leaves on_audit NULL: it never mounts a global drive, and the spec writes Event 1200 from the service only.

Remaining gaps.

  • Handle-based operations (setattr, rename, set_security, delete at cleanup) use the handle's node key as the path. The key is case-folded in the insensitive view, so the path can differ in case from the one the client sent.
  • WebDAV reaches the vfs with a caller, so it should raise the same events; this round did not test it.
  • The delete_path recursion audits each child delete under its own path, so one recursive delete raises one event per child, subject to coalescing.

Tests. tests/unit/sd_vfs/test_vfs_access.c: vfs_audit_raised_for_global_changes (reads and denied opens silent; create, write_open, setattr, rename and delete raised once each), vfs_audit_coalesces_per_window (fake clock: inside the window coalesced, other SID / path / operation raised, raised again at exactly 60 s), vfs_audit_never_raised_on_per_user_mount. tests/unit/sd_dokan/test_dokan.c: dokan_cache_hit_expiry_and_keys (hit inside 60 s; expiry at 60 s; another user misses), dokan_cache_different_token_object_misses (same LUID and SID, different TokenId: miss), dokan_cache_changed_modified_id_misses (adjusted ModifiedId: miss), dokan_cache_wraps_and_refreshes, dokan_cache_failures_are_not_stored, dokan_cache_is_bounded_and_evicts_oldest. tests/unit/sd_svc/test_service.c (svc_admin_mounts_reports_and_unmounts): a fake vfs audit reaches the Event Log seam as SVC_MSG_AUDIT. The Dokany requestor path itself (requestor_identity) is not unit-tested: it needs a live requestor token.

Part 9: the service side of host keys (wip/r15-svcmachine)

Closes "the service pipe (hostkey.add on the service, the machine store with --machine) is still not built" from Part 8.

Decisions.

  • The service methods keep the agent's names and reply shapes: hostkey.add, hostkey.announced.list, hostkey.announced.accept (03 §2.4). All three need an elevated administrator (need_admin).
  • A machine hostkey.add uses the machine profile whose host and port match, or the one named by profile. There are no default credentials for the service, so an unknown host is profile_not_found (exit 3), not a host-only default as in the agent.
  • The connection is a hostkey mount (hostkey_fetch) with the profile's service credentials. The service answers no prompt: sd_mount takes the first-contact host-key question itself (5.2), and every other prompt (password, passphrase, keyboard-interactive) is refused in svc_hk_on_prompt. The service never routes a hostkey.add prompt to a UI.
  • sd_mount_create requires a drive letter even for a hostkey mount, so the service passes Z: as a label. The mount never mounts a drive.
  • The hops use update_host_keys = no. The hostkey connection does not produce its own announcements.
  • Writes to the machine known_hosts go through sd_mount_apply_hostkeys_to(..., SD_KH_STORE_MACHINE, ...), a new function. sd_mount_apply_hostkeys is now a wrapper with SD_KH_STORE_USER. The file is checked first by svc_store_check (svc_folder.c): a plain file, owner trusted, DACL with no write for an untrusted principal, opened without following links. A missing file is accepted because it is created inside the already-checked data folder.
  • Mount announcements (UpdateHostKeys ask) are kept in the same list, raise Event 2300 (SVC_MSG_HOSTKEYS_ANNOUNCED, Warning, English), and are broadcast on the hostkeys topic (admin only). The list keeps 32 entries and drops the oldest when full.
  • hostkey.add is deferred (sd_ipc_defer). At most 2 requests run at once (SVC_MAX_HK). The reply is sent from on_state when the mount is final, and the record and mount are released in svc_tick. On shutdown, open hostkey mounts are stopped and the teardown waits for them.
  • A hostkey connection that ends with no verified keys and no first-contact key is reported as connect_failed. It is not an empty success.

Files.

Path What
apps/shelldrive-host/service.c svc_identity_hop (identity file as a hop, shared by mounts and hostkey requests); announcement store ann_keep, svc_on_hostkeys, svc_event_announced; svc_machine_apply; job_hk_start, svc_hk_on_state, svc_hk_reply, svc_hk_complete, svc_hk_release; pipe handlers handle_hk_add, handle_hk_list, handle_hk_accept; dispatch and hello features; reap in svc_tick; shutdown in svc_shutdown_all
apps/shelldrive-host/svc_folder.c, .h svc_store_check
apps/shelldrive-host/svc_events.mc 2300 SVC_MSG_HOSTKEYS_ANNOUNCED
src/sd_mount/mount.c, include/sd_mount/sd_mount.h sd_mount_apply_hostkeys_to; apply_on takes the target store
apps/shelldrive/cli_cmds2.c hk_add_user(a, machine), hk_announced(a, machine), hk_accept(a, machine), hk_accept_offer(a, id, machine); hk_not_built removed
apps/shelldrive/cli_service.c, cli_int.h connect_service exported for the --machine commands
apps/shelldrive/cli_args.c hostkey list --announced --machine accepted (a plain list --machine is still refused)
l10n/cli/*.po removed cli.hk.not_built; appended cli.hk.machine_scope and cli.error.hk_no_profile in all six locales
tests/unit/sd_mount/fake_backend.c, .h fake_backend_hostkeys() (hostkey connection scripted by host name, as tests/apps/host_fake_backend.c); kh_apply accepts the machine store; fake_backend_apply_machine_calls()
tests/unit/sd_svc/test_service.c, main.c five tests (below); fixture profiles hk.known.test, hk.changed.test, hk.first.test, rotate.example; profile count 5 to 9
tests/apps/test_smoke.c, test_cli_args.c non-elevated list --announced --machine (exit 9, access_denied); parse of list --announced --machine
docs/design/03-apps-platform.md hostkey.add method row: service column and behaviour

Behaviour.

  • hostkey.add (admin): connects with the machine profile, offers the stored types (or --type), keeps the other keys as an announcement id. --expect writes the one matching key to the machine store with no question. A first contact is offered and stored only by the accept or by --expect.
  • hostkey.announced.accept {id, add_only} (admin): writes the announcement to the machine store and removes it from the list; a failed write puts it back.
  • CLI: hostkey add --machine, hostkey accept-announced <id> --machine and hostkey list --announced --machine need an elevated console (exit 9 otherwise), then talk to the service pipe. With no service: "service unavailable", exit 8. A profile_not_found from the service is printed as cli.error.hk_no_profile (exit 3). Before the question, cli.hk.machine_scope says where the keys go.
  • The agent's not_implemented (a backend without a hostkey connection) is now a generic error, not the removed "not part of this build" text.

Tests.

  • tests/unit/sd_svc over the real pipe, with the scripted hostkey connection: svc_hostkey_add_offers_then_accept_writes_the_machine_store (type restriction, offer, list, accept, accept again is not found), svc_hostkey_first_contact_is_offered_and_expect_stores_it, svc_hostkey_add_refuses_a_changed_key_and_an_unknown_host (6, profile_not_found), svc_hostkey_methods_are_for_elevated_admins, svc_mount_announcement_is_kept_and_accepted_into_the_machine_store (Event 2300 seen, removals applied).
  • The CLI is not tested end to end against the service: no test starts the service pipe for the CLI process. The --machine smoke tests cover the elevation and argument paths only.

Build. ci-local.ps1 -Presets 'x64-modern','x64-analysis' -ReleaseOnly -NoFixture -AllowSkip -TestRegex 'unit\.svc|unit\.apps|unit\.mount|unit\.ipc|l10n': both presets pass. No Win32 import was added to the shipping binaries, so the x86-ia32 import check was not run.

Open.

  • No live run against a real sshd or the real service. The hostkey path is tested on the fake connection only.
  • UpdateHostKeys = 2 (automatic machine-store update, policy) is not built. Every service announcement waits for an administrator.
  • Declined offers stay in the list until the service restarts (as in the agent). There is no reject method.
  • A stop during a hostkey connection relies on sd_mount's teardown; sd_mount finishes such a mount without destroying the hostkey connection until its I/O thread reports back. Not exercised by a test.
  • Replies to in-flight hostkey.add requests are lost if the pipe closes at shutdown.
  • No Event 2300 test through the Event Log sink beyond the seam (svc_event test sink).

Service page: service.status and service.repair_data (wip/r15-uisvc)

The frontend hand-off (item 2) asked for a service page and left a decision: run the CLI elevated, or share the code. Decision: share the code and add two service-pipe methods; the UI never shells out to shelldrive.exe.

Shared code. apps/shelldrive-host/svc_status.c (new, pure) holds the words and the JSON members of the status report (svc_status_write_members: installed, state, start_type, program, event_source, pipe, and for the pipe method also machine) and of a repair result (svc_status_write_repair). shelldrive service status --json and service repair-data --json write through it, so their output is unchanged (same keys, same order); the CLI keeps its own localized text. svc_scm.c, svc_repair.c and svc_status.c are now also compiled into shelldrive-host.exe (and the test hosts); svc_scm.c, svc_repair.c and svc_folder.c into shelldrive-ui.exe (read-only SCM status and the in-process repair). The import floor is unchanged: the CLI already linked the same functions.

service.status (any client, no secrets): the CLI members, pipe {reachable: true, healthy, global_drives, prompts} and machine {state: ok|refused, reason?, path?, profiles}. The SCM part is the service's own query (svc_opts.scm_ops; NULL is the real SCM, except in SD_SVC_TEST_HOOKS builds, where NULL reports "not installed" and never reaches the SCM). The machine part comes from the start check of Part 4: the service keeps the reason and the first refused folder (g.refused_why, g.refused_path) next to g.idle. The refused folder's path is written only for an elevated administrator; the reason and the profile count are open.

service.repair_data (elevated administrator, access_denied otherwise): runs svc_repair_data on %ProgramData% (svc_opts.repair_base and repair_ops are the test seams; a test build with no base refuses the call, so a test never touches the real machine folder). Rules the CLI does not need:

  • Refused with busy while any global mount exists, or while another repair runs: the repair can move the folder that holds the secrets of a mounted drive.
  • While it runs the service stops serving profiles (idle, profiles freed under the lock) and closes its log, because an open file in logs\ blocks the rename of the folder. Afterwards it runs svc_ensure_layout exactly like the start, sets idle and the refusal from the result, reopens the log and, when the layout is trusted, loads the machine profiles. So a service that stayed idle after a foreign-owner refusal recovers without a restart.
  • Reply: {moved, moved_to, folders, healthy}; errors busy, repair_refused (a link at the base, nothing changed), io_error. The call is logged in service.log; no new Event Log id was added.

UI. ui_service.c (window) and ui_service_model.c (pure model): the Service page under Tools and in the tray menu. Status and repair run in a short worker thread that connects to the service pipe for one call (no start of the service); an older service that answers hello but not service.status (usage) shows "older version". The 5 s timer refreshes while the page is visible. Repair data... modes (ui_svc_repair_mode_of): off for a user who is not an administrator, run for an elevated administrator, and "elevate" (UAC shield on Vista+, BCM_SETSHIELD) for an administrator whose token is filtered. Elevate relaunches shelldrive-ui.exe --elevated-service with runas (plain launch on XP, where there is no filtering): a process that shows only the Service page, no tray, no agent, no service thread, and exits when the page is closed. --elevated-view is a CLI flag of the WebDAV elevated mapping (03 1.7.2) and has nothing to do with this page. The repair goes through service.repair_data when the service answers, and runs svc_repair_data in the UI process otherwise (stopped or not installed service). The confirmation puts the default on Cancel. Closing the page is ignored while a repair runs.

Tests. tests/unit/sd_svc/test_service.c (shared core, fake SCM seam): svc_status_method_reports_the_scm_the_pipe_and_the_machine_folder, svc_status_is_open_to_a_non_admin_and_repair_is_not (restricted token), svc_repair_is_busy_while_a_global_drive_exists. tests/unit/sd_svc/test_svcrepair.c (a core of its own per test, owner rule flipped by the test, repair base under %TEMP%): svc_status_names_a_refused_machine_folder_for_admins_only, svc_repair_moves_the_folder_aside_and_the_service_recovers. tests/ui/test_service.c: the view from the reply and from the SCM, the lines per state, repair enablement and shield, route and result classification, the --elevated-service verb. --test-windows creates the page hidden and checks that Repair data is off for a non-administrator.

Not done. Install, uninstall, start and stop stay CLI verbs. The page was not exercised against a real service, SCM or UAC prompt (no real service in the test runs); the elevated relaunch is covered by the model rules only. A repair that moves the folder needs the log and secret handles of the service closed: the service closes its own log, but a second process holding a file under the folder (an antivirus scan, a CLI) makes the rename fail with io_error; the page shows the generic failure with the Win32 or IPC code.

Part 10: hostkey reject, UpdateHostKeys under policy, the pipe class at connect, checked reads (wip/r16-hkpolicy)

Closes four follow-ups: the refused offer that stays listed (Parts 6 and 9), the machine store update under policy (Part 9, "Open"), the hello-less instances of the service pipe (Service pipe section, "Open items") and the file checks of the service's reads (Part 6, "Not done").

1. hostkey.announced.reject {id} (03 §2.4). Agent and service, the same reply {host, rejected: true}. It drops the announcement and changes no store. An unknown or already answered id is announcement_not_found (exit 3). The service method needs an elevated administrator (need_admin), as hostkey.announced.accept does. The CLI sends it on the "no" branch of hostkey add (hk_reject_offer in cli_cmds2.c, through the agent or, with --machine, the service). The exit stays 5 (host_key_rejected). A failed reject is not reported: the offer then stays listed, as before this part.

2. UpdateHostKeys under policy (03 §3.5, §5.6; 01 §7.5 step 4). svc_policy_hk_accept() (service.c) reads the policy UpdateHostKeys through sd_policy_get_dword at each announcement. Only the value 2 acts. With 2, and an announcement with new keys, the proven new keys go to the machine known_hosts at once through svc_machine_apply(a, 1): the accept's checked write (svc_store_check on the handle), add only. On success, the removals, if any, stay in the list as an announcement with no additions (Event 2300 as usual). On a failed write the whole announcement is kept for review. With 0, 1 or no value nothing changes (kept for review, Event 2300). A service mount's hop stays ask: the mount never writes the machine store itself, the service does.

3. The pipe class at connect and the hello deadline (03 §2.2, TM-R25; src/sd_ipc/ipc_server.c).

  • on_connected reads the client token before the first read (classify_at_connect, the same impersonation as check_client_token): the user SID (per-SID quota, Event 3101) and the admin class (token_admin_class: a member of BUILTIN\Administrators, elevated on Vista+). The class is c->conn_admin. Only the service sets the rules that use it (reserved_admin_instances or hello_timeout_ms), so the agent never impersonates at connect.
  • The reserved rule moved from handle_hello to connect. When the other non-closing instances reach max_instances - reserved (30 of 32), a non-admin is refused at once: too_many_connections is the only message it gets, the refusal is counted as reserved (Event 3101 through on_refused), and nothing is read from the instance.
  • idle_sweep closes a non-admin instance that has not sent hello within hello_timeout_ms, 5 s (SVC_HELLO_MS; 03 gives no value). Admin instances keep the 60 s idle timeout.
  • sd_ipc_server_cfg gets hello_timeout_ms and admin_at_connect (a callback that forces the connect class; the service returns 0 in shipping builds, so the token decides). Both are zero in the agent.
  • Unchanged: the request caps (before hello the non-admin cap applies), the per-SID quota (still checked at hello, with the SID read at connect), the rate limit, and the testadmin override of the service tests (at hello).

4. Checked reads of the service's files (TM-R27, 2.6 rule 1).

  • Machine profiles: svc_profile_read (service.c) reads each *.ini through svc_file_read_trusted(g.root, ...). Every folder from the machine root to the file and the file itself are checked on their handles (reparse point, owner, DACL, size); then the bytes are parsed with sd_ini_parse and sd_profile_from_ini. A refused file is logged and not loaded; the others load. The service no longer calls sd_profile_load_file.
  • Machine known_hosts, reads: svc_kh_read_check() runs svc_store_check on the file before the two places that hand the file to sd_mount (the mount start and the hostkey connection). A refused file fails the request with usage ("machine known_hosts refused ... (TM-R27)"). A missing file is accepted (no stored key). The mount opens the file itself, so a change between the check and that open is not excluded (open items).
  • settings.ini: the service does not read it. Nothing in the service reads the file: svc_gw_mode_parse and svc_gw_decide have no caller in the service, and svc_repair.c only lists its ACL. No read was added, because a check on a read that does not exist would be a fake. The check belongs to the change that makes the service read the file.

Test seams (SD_SVC_TEST_HOOKS only, service.h): svc_test_hk_policy(forced, value) replaces the registry value; svc_test_connect_admin(on) counts every new connection as an admin at connect. The reserved-instance test uses the second for its 30 raw instances and its administrator, since an unelevated test process is not an admin by its token.

Tests (tests/unit/sd_svc: test_service.c, main.c; tests/apps: test_smoke.c):

  • svc_hostkey_offer_can_be_rejected: a refused offer leaves the list and nothing is stored; a second reject and an accept of the same id are announcement_not_found; a restricted-token client is refused with access_denied.
  • svc_mount_announcement_under_policy_writes_the_machine_store_only_with_accept: policy 2 stores the new key once (add only), keeps the removal for review, and raises Event 2300. One mount only (see the open items for why). The ask case (policy 1: kept, nothing stored) is the existing svc_mount_announcement_is_kept_and_accepted_into_the_machine_store.
  • svc_profile_file_with_an_open_acl_is_not_loaded: a profile file whose DACL gives Everyone write is not loaded (config.reload counts 8 instead of 9); its DACL is set back and the count returns to 9.
  • svc_non_admin_that_never_says_hello_is_closed_in_time: a restricted-token instance that never says hello is closed after the deadline (7 s wait, PeekNamedPipe); an administrator-class instance is still open after the same wait.
  • svc_pipe_caps_and_reserved_admin_instances (updated): the 30 raw instances and the administrator count as admin at connect; the restricted clients are refused at connect.
  • smoke_hostkey_add_offers (tests/apps/test_smoke.c): after a "no" answer, hostkey list --announced --json does not list the host.

Open items

  • The UI's "Don't add" (ui_hostkeys.c) calls hostkey.announced.reject since round 17 (agent pipe only; the UI does not use the service's announcements).
  • settings.ini has no read in the service, so the file check is not applied to it (see above).
  • Between the handle check and the mount's own open of the machine known_hosts, the file can change. Closing it needs the mount to take the bytes, or to keep the checked handle. Not done. (Profiles are parsed from the checked bytes: no gap.)
  • The policy is read through sd_policy, which reads HKLM, then HKCU. For the service (LocalSystem) HKCU is the SYSTEM profile, not a user's setting, but 03 §3.5 says HKLM wins; a machine-only read would be stricter. Not changed.
  • The connect refusal writes too_many_connections before the client has sent hello. A client whose hello write lands after the server closed the instance sees a pipe error, not the code (the CLI then reports the busy exit). Not checked against a real client race.
  • The hello deadline (5 s) is this build's choice; 03 §2.2 gives none. A slow client on a loaded machine is the case to measure in the lab (TST-23 in 05 §7).
  • Heap corruption on a second mount of the same profile — CLOSED 2026-10-30, see "Part 14" below: it was a double free in the test harness (wait_state kept a status reply that the next call freed again), fixed by json_drop in e2c3df5, with the regression test svc_one_profile_mounted_twice_keeps_both_announcements. The original record: In unit.svc, two mounts of the rotate profile one after the other (each raising an UpdateHostKeys announcement, each then unmounted) end the test process with 0xC0000374 after the second announcement callback, before the second wait_state. It happens with the policy ask (1) in both mounts, with no reject, and with the machine-store write stubbed out, so it is not the announcement code of this part; the trigger is the second mount of the profile (fake backend, sd_mount teardown or the svc mount slot). Not checked against the code before this part. The policy test mounts once for that reason. Next step: a run under the debug CRT (or a page-heap run) of the double mount, then the owner of the corruption.
  • Verified in this part with a single run of sd-test-svc.exe (81 tests, all pass). The x86-ia32 build was not run: this part adds no Win32 import to a shipping binary (the SDDL and SetNamedSecurityInfo calls are in the test only).
  • Not run on a real elevated administrator token or on XP (TST-23 in 05 §7).

Part 11: chains, proxies and proxy = system for service profiles (wip/r16-svcproxy)

Closes the "Left" item on chains and proxies (2.6 rule 1). The machine policy AllowSystemProxy is not read by this build, so the shipping proxy = system leg is refused, as it is on the per-user path.

Files

Path What
apps/shelldrive-host/service.c svc_chain_build (sd_chain_resolve over the machine profiles through svc_chain_lookup), svc_chain_hop, svc_chain_identity, svc_chain_leg, svc_chain_free, svc_proxy_secret_present; job_start and job_hk_start use them in place of svc_identity_hop; svc_sysproxy_machine_read, k_sysproxy_shipping
apps/shelldrive-host/svc_access.c, svc_access.h svc_chain_hop_check (one hop), svc_proxy_leg_check (one proxy leg); svc_validate_profile no longer refuses proxy.jump or proxies
apps/shelldrive-host/service.h svc_sysproxy_ops (allow, read, ctx) and svc_opts.sysproxy_ops (NULL = the shipping ops: allow 0, the real read)
src/sd_ssh/proxy_system.c, src/sd_ssh/include/sd_ssh/sd_ssh.h sd_ssh_proxy_machine: the WinHTTP machine configuration through the existing resolver (service path, static answer only). WinHttpGetDefaultProxyConfiguration is resolved at run time, so there is no new static import
src/sd_mount/mount.c hostkey add (hostkey_fetch) takes a first-contact key once for the target hop only; an unknown key of a jump host is an ordinary host-key prompt
tests/unit/sd_mount/fake_backend.c, fake_backend.h per-hop accessors of the last connect (proxy host, user, port, proxy_auth, key blob, host key mode, auth methods); the hostkey connection raises a prompt for an untrusted jump hop and waits for its answer (fake_backend_hk_jump_prompts)
tests/unit/sd_svc/test_service.c, test_access.c, main.c nine fixture profiles (hop1, chain, hopuser, chainuser, proxypw, proxysec, sysproxy, sysbasic, hkchain); the loaded count goes from 9 to 18; json_drop for status replies

Behaviour (2.6 rule 1, 2.6 rule 2, TM-R27)

  • The chain of a service profile comes from sd_chain_resolve, whose lookup sees the loaded machine profiles only. A jump name that is not a machine profile parses as a host spec and inherits the referencing profile's [auth].
  • Every hop, the target included, passes svc_chain_hop_check: at most one identity, no certificate, no identity_store, no agent (Pageant or OpenSSH), no agent_keys, no keyboard-interactive, and publickey or password. The agent of every hop is 0 (D17); no_save is set on every hop.
  • The identity of every hop must be under the service folder (svc_path_under), is read through svc_file_read_trusted (TM-R27) and is passed to sd_mount as a key blob. A refused file is written as Event 3102.
  • Known hosts: the machine store only, read-only, for the whole mount (unchanged). A host-key prompt of a service mount is refused with host_key_unknown on every hop. A jump hop never updates host keys; the target keeps the caller's mode (ask for a mount, no for hostkey add).
  • hostkey add of a profile with a chain connects through the same hops. Only the target's first-contact key can be offered; an unknown jump host key is refused (host_key_rejected), so a jump host has to be pinned first and its key is never offered under the target's name.
  • Proxies: leg k reaches hop k. An HTTP or SOCKS5 leg with a user (HTTP with any proxy_auth but none, or SOCKS5) needs a proxy secret in the service store (target http:user@host:port or socks5:..., kind proxy), checked before the connect; sd_mount reads it through cb.secret_get. Without it the mount fails with usage. A leg with no user sends no password.
  • proxy = system: the leg is read through svc_sysproxy_ops.read for the target host. The answer becomes an HTTP or SOCKS5 leg with auth 0 (no SSPI towards it, TM-R10); a direct answer means no proxy; with proxy_fallback_direct a failed read connects directly. The leg is refused with usage when allow is 0 (the shipping value) and when its proxy_auth is basic or negotiate.
  • Behaviour change: a service profile that sets auth.certificate, auth.identity_store, more than one auth.identity, or auth.agent_keys is now refused at mount with usage (before, the service ignored those keys).

Tests (verified by tools/ci-local.ps1 -Presets x64-modern,x64-analysis, Release and Debug)

  • test_access.c: chain_hop_and_proxy_leg_rules (each hop and proxy-leg refusal row); validate_profile_refusals asserts that a jump and a proxy pass the load check.
  • test_service.c (shared core, fake backend, stub svc_sysproxy_ops): svc_chain_two_hops_are_mounted_with_the_service_rules (two hops, key blobs, no agent, no kbdint, host key modes); svc_chain_refuses_a_hop_with_a_user_path_identity; svc_proxy_basic_without_a_service_secret_is_refused; svc_proxy_with_a_service_secret_is_mounted_and_answered_from_the_store (the leg and the store answer); svc_system_proxy_is_read_through_the_seam_and_policy_refuses_it (the stub is asked for the target host, the leg is the stub's proxy with auth 0; with allow 0 a second mount of the same profile fails with usage and the stub is not called); svc_system_proxy_refuses_basic_auth_on_its_leg; svc_hostkey_add_through_an_unknown_jump_host_is_refused; svc_one_profile_mounted_twice_keeps_both_announcements (regression: one profile mounted twice in one process).
  • No test reads the real WinHTTP configuration: sd_ssh_proxy_machine itself is not exercised by a test.

Fixed while testing

  • The proxy and system-proxy fixture profiles had no identity, so the target asked for a password the service cannot give (prompt_unavailable); they now carry the service identity.
  • A test freed the status reply that wait_state keeps in *last and then passed the same pointer to a second wait_state, which freed it again (heap corruption, 0xC0000374). json_drop frees and clears the pointer; every test uses it.

Not done (open)

  • The machine policies AllowSystemProxy and AllowSystemProxySspi are not read (no policy reader in this build), so proxy = system is refused in the shipping build.
  • No admin verb sets a proxy secret of the service store (secret.set takes profile passwords only).
  • More than one identity per hop, and certificate files, are refused rather than supported.
  • A live chain (two real SSH hosts) and a real WinHTTP machine proxy are lab items. The x86-ia32 preset was not built for this part (no new static import).

Part 12: policies in the service, the machine-only reads, the proxy secret verb, the hostkey mount without a letter (wip/r17-svcpol)

Closes the four follow-ups of Parts 10 and 11: proxy = system for service profiles can be allowed by policy, the service reads its policies from HKLM only, an administrator can store the password of a service proxy leg, and a hostkey mount has no drive letter any more.

Files

Path What
src/sd_policy/include/sd_policy/sd_policy.h, src/sd_policy/sd_policy.c sd_policy_machine_get_dword, sd_policy_machine_get_sz: the same readers, HKLM only (2.6 rule 1: the service never reads HKCU)
apps/shelldrive-host/service.c svc_sysproxy_allowed, svc_sysproxy_sspi, svc_sysproxy_policy_flag (the machine policies of proxy = system); svc_chain_leg (SSPI decision and auth of the system leg); svc_policy_hk_accept reads UpdateHostKeys from HKLM only; handle_proxy_secret (secret.set and secret.delete with kind: "proxy"); job_hk_start passes letter 0
apps/shelldrive-host/service.h svc_sysproxy_ops.allow takes the value -1 (read the policy); svc_test_sysproxy_policy (SD_SVC_TEST_HOOKS)
apps/shelldrive-host/agent.c a hostkey mount (test = 2) gets letter 0; the profile.test letter Z stays (see open items)
src/sd_mount/mount.c, src/sd_mount/include/sd_mount/sd_mount.h sd_mount_create accepts letter 0 for hostkey_fetch only; mount_log_letter writes - in the log lines of a mount without a letter
apps/shelldrive/cli.h, cli_args.c, cli_cmds.c, cli_service.c CLI_CMD_SECRET, `shelldrive secret set
l10n/cli/*.po (six locales) cli.help.secret, cli.secret.need_admin, cli.secret.bad_proxy, cli.secret.prompt, cli.secret.empty, cli.secret.stored, cli.secret.deleted
tests/unit/sd_policy/* machine readers refuse a type or id mismatch; the proxy policies are boolean in the table
tests/unit/sd_svc/test_service.c, main.c svc_system_proxy_policy_is_read_from_the_machine_values, svc_secret_proxy_set_and_delete_through_the_pipe
tests/unit/sd_mount/test_mount.c, main.c mount_hostkey_fetch_has_no_drive_letter
tests/apps/test_cli_args.c, main.c cli_parse_secret_proxy
docs/design/03-apps-platform.md §3.5 (machine reads, system proxy policies), §6.1 (secret verb), the service-table row for secret.set / secret.delete

1. proxy = system allowed by policy (2.6 rule 1, 3.5, 3.8). The shipping seam is { allow -1, real read, NULL }: at each leg the service reads AllowSystemProxy from HKLM. 0 (or a missing value) refuses the leg with usage before the read, as before. A stub seam keeps allow 0 or 1 as its own answer. AllowSystemProxySspi is read with the same rule, and only when the seam says -1. With 0 the leg has no SSPI (the auth stays 0, as in Part 11). With 1 the leg gets SD_PROXY_AUTH_SSPI_KERBEROS when its proxy_auth is auto (Kerberos only), and allow_discovered_sspi is set. Basic and Negotiate on a system leg stay refused (the machine configuration gives no credentials, TM-R10). none gets no SSPI whatever the policy.

2. Machine-only policy reads. sd_policy_machine_get_dword and sd_policy_machine_get_sz read HKLM and nothing else. The service uses them for UpdateHostKeys and for both system-proxy policies. 03 §3.5 states HKLM-then-HKCU for the product as a whole; the service does not follow that order, because its HKCU is the SYSTEM profile and 2.6 rule 1 says it never reads HKCU. The agent and the UI keep the order of §3.5 (their code is unchanged).

3. shelldrive secret set|delete --machine --proxy SPEC [--stdin]. The spec had no CLI syntax for this (03 §6.1 lists the service verbs only), so the verb is new. --machine is required because the store is the service's. SPEC is http://user@host:port or socks5://user@host:port (sd_proxy_spec_parse; user:pass@ is refused). The password is read with cli_read_line without echo (or one line from stdin with --stdin) into a buffer that is wiped after the request, and the request is built in a secret writer (sd_wr_init_secret). The service method is secret.set or secret.delete with kind: "proxy", proxy (the spec) and value. The target is the one svc_proxy_secret_present reads for the leg, so a leg configured in a profile finds the password. The reply is {"stored": true} or {"deleted": true}; no secret is printed or returned. Admins only (need_admin), exit 9 otherwise. The user-scope store is not touched.

4. Hostkey mounts have no drive letter. sd_mount_create accepts letter 0 when params.hostkey_fetch is set. The mount makes itself test-only (no vfs, no backend, no drive is started). Any other mount still needs A..Z, and a letter outside A..Z (other than 0) is refused for every mount. The places that used the letter of a hostkey mount: the log lines of mount.c (mount_log_letter writes - for letter 0), sd_mount_letter and sd_mount_get_attach (0), and the state snapshot (state_producer.c already writes 0 for a letter outside A..Z). Hostkey mounts are not listed in the agent or the service, so no reply or event shows their letter. The agent's letter_in_use_locked ignores test mounts, so a hostkey mount never blocks a drive letter. The two L'Z' workarounds for hostkey mounts are gone (service.c job_hk_start, agent.c handle_mount_body with hk).

Tests (tests/unit/sd_policy, tests/unit/sd_svc, tests/unit/sd_mount, tests/apps; no HKLM write, no real proxy, no real Credential Manager: the service tests use the test secret root and the seam and policy stubs):

  • policy_machine_reads_refuse_type_and_id_mismatch, policy_system_proxy_policies_are_boolean_machine_ready.
  • svc_system_proxy_policy_is_read_from_the_machine_values: policy 1 with SSPI 0 (mounted, auth 0), policy 0 (refused before any read, usage), policy 1 with SSPI 1 (SD_PROXY_AUTH_SSPI_KERBEROS on the leg).
  • svc_secret_proxy_set_and_delete_through_the_pipe: secret.set stores under the leg's target (checked with sd_secret_get); a spec with a password or without a user is usage and stores nothing; secret.delete removes it; a second delete is secret_not_found.
  • mount_hostkey_fetch_has_no_drive_letter: a hostkey mount with letter 0 ends UNMOUNTED with no vfs and no letter mapped; a drive mount with letter 0, and a hostkey mount with letter 1, are refused.
  • cli_parse_secret_proxy: the verbs, the required --machine and --proxy, the extra argument, and the options refused for this verb; the other verbs keep their rules.

Open items

  • SSPI towards a system proxy with AllowSystemProxySspi = 1. sd_ssh_proxy_machine returns the machine proxy without its origin, so the service cannot tell a WPAD/PAC-discovered proxy from a configured one. With the policy on, SSPI is allowed towards whatever the machine configuration names; the policy is the admin's statement that this is wanted (3.8). A machine read that reports the origin would let a configured proxy keep SSPI when the policy is off. Not done.
  • The agent's profile.test still passes letter Z (handle_mount_body, test = 1). sd_mount requires a letter for a connect-only test that is not a hostkey mount, so that Z stays. Allowing letter 0 for test_only is the same change; it is not in this part.
  • No user-scope proxy secret verb (secret --user). Secrets are write-only (4.5), so there is no read-back verb.
  • A live machine WinHTTP proxy and a real elevated administrator token were not exercised (lab, TST-23 in 05 §7). The sd_ssh_proxy_machine read itself is not covered by a test.
  • The HKLM-only read is covered by the type and id checks only: a test cannot write HKLM without touching the machine, so the service tests force the values through svc_test_sysproxy_policy and svc_test_hk_policy.

Part 13: end-to-end tests of the CLI over the service pipe (wip/r19-svce2e)

Closes the gap noted in parts 9 to 12: no test started the service pipe for the CLI process. The CLI smoke tests of tests/apps cover the argument and elevation paths only.

Files

Path What
tests/e2e/CMakeLists.txt sd-test-e2e.exe (unit.e2e): the service core sources with SD_SVC_TEST_HOOKS, as in tests/unit/sd_svc; e2e.shipping_has_no_test_hooks
tests/e2e/e2e_host.c, e2e_host.h the core runs on a thread of the test process (svc_run, fake mount backend, temp machine root, per-run pipe suffix, svc_test_connect_admin); e2e_run_cli starts sd-test-cli.exe as a child process with the test variables set and reads its output and exit code
tests/e2e/test_cli_service.c, main.c six tests (below)
tests/e2e/check_no_test_hooks.ps1 the shipping shelldrive.exe and shelldrive-host.exe contain no SHELLDRIVE_TEST_ name (ASCII or UTF-16LE)
apps/shelldrive/cli_service.c SD_CLI_TEST_HOOKS only: `SHELLDRIVE_TEST_SCM=running
apps/shelldrive/cli_common.c cli_is_elevated reads SHELLDRIVE_TEST_ELEVATED only under SD_CLI_TEST_HOOKS; 1 grants elevation, 0 denies
apps/shelldrive/main.c SHELLDRIVE_TEST_EXPECTED_OWNER (test hooks only) sets the owner the CLI requires of the service pipe

Change of behaviour. Before this part the shipping CLI read SHELLDRIVE_TEST_ELEVATED and denied elevation when it was 0. The read is now compiled only into the test build, so the shipping CLI ignores the variable.

Test seams of the CLI (test builds only)

  • SHELLDRIVE_TEST_INSTANCE: the pipe suffix (existing), shared by the test host and the child CLI.
  • SHELLDRIVE_TEST_EXPECTED_OWNER: the owner SID the service pipe must have. The host runs as the test user, so the pipe is owned by that user, not SYSTEM; the child must expect the same.
  • SHELLDRIVE_TEST_ELEVATED=0|1: deny or grant elevation. Granting is the test-only addition.
  • SHELLDRIVE_TEST_SCM=running|absent: the service state seen by service status, so the pipe path runs without the service installed.
  • SHELLDRIVE_TEST_CONFIG_DIR (existing): a temp configuration root.

Tests (unit.e2e, one core per process, the last test stops it)

  • e2e_status_reaches_the_service_over_the_pipe: service status --json with the service running reports reachable and healthy.
  • e2e_status_without_an_installed_service_does_not_query_the_pipe: no reachable member when the service is absent.
  • e2e_service_mount_and_unmount_need_elevation: service mount and service unmount exit 9 when denied and leave the drive as it was; granted, the profile mounted mounts and unmounts, and service status <profile> reports mounted in between.
  • e2e_hostkey_offer_is_listed_and_accepted_into_the_machine_store: hostkey add --machine and hostkey list --announced --machine exit 9 when denied; granted, the offer for hk.first.test is listed by its id, nothing is written to the machine store until hostkey accept-announced <id> --add-only --machine (one machine write), the offer leaves the list, and a second accept fails.
  • e2e_secret_set_and_delete_machine_proxy_through_the_service: secret set --machine --proxy ... --stdin exits 9 when denied and stores nothing; granted, the password is stored under the leg's target (read back in-process from the service store), it is never printed, and secret delete removes it.
  • e2e_core_stops_and_the_cli_no_longer_reaches_the_pipe: after the core stops, service status reports reachable false.
  • e2e.shipping_has_no_test_hooks: no SHELLDRIVE_TEST_ name in the shipping executables.

Not covered. The real SCM (install, start, stop) and the Event Log are not reached. The core is in the test process (as in unit.svc), not in a separate host process; the CLI is the separate process, and every CLI request crosses the named pipe. An elevated administrator token and the real --machine UI prompts are not exercised (lab).

Event Log messages in six languages (round 21, branch wip/r21-evloc)

Owner decision: the service's Event Log messages are user-visible, so they are localized into en, es (Rioplatense voseo), fr (vous), pt-BR, it (informal imperative) and de (informal du), like every other user-facing string. This supersedes the English-only rule of 03 10.3 and the reading of AGENTS.md under which event log messages stay English. AGENTS.md is not edited in this round; its wording on event log payloads should be revisited by the owner.

  • Source of truth. The svc catalog (l10n/svc/<lang>.po) now carries the ten Event Log messages as entries evt.* (1000, 1001, 1100, 1101, 2100, 2110, 3101, 3102, 1200, 2300). Each English entry has a #. sdl10n:event=<id>,<Severity>,<SYMBOL> translator comment, which gives the MessageId, severity and symbolic name. The insert placeholders %1..%5 keep their numbers and their order in every language. Insert values (paths, SIDs, reason codes such as owner, reparse_point, acl, not_directory) are data and are not translated.
  • Generation. tools/sdl10n gained --out-mc <file.mc>: it validates the whole catalog and writes the Event Log table as UTF-16LE with a byte order mark, one Language= block per language for every id (LanguageNames: English 0x409, Spanish 0x2C0A (es-AR, the voseo text, the same LCID the MSI uses for its Spanish transform), French 0x40C, PortugueseBrazil 0x416, Italian 0x410, German 0x407). apps/shelldrive-host/CMakeLists.txt runs it, then mc.exe -u compiles the table into svc_events.h, svc_events.rc and one MSG*.bin per language. The same mc.exe serves x86-ia32, x64-modern and x64-xp (v141_xp), so nothing changes per toolset.
  • Build checks. An Event Log entry must exist in every locale even under --allow-incomplete, and a translation that reorders the %N placeholders of en is an error.
  • Tests. l10n.svc_catalogs_complete (the real svc catalog), l10n.event_placeholder_order_fails and l10n.event_missing_locale_fails_when_allowed (fixtures under tests/l10n/fixtures/event_*), and l10n.svc_event_mc_written. In unit.svc, tests/unit/sd_svc/test_evtmsg.c reads the generated svc_events.mc and checks six Language= blocks for every MessageId, then calls FormatMessageW on the built shelldrive-host.exe (loaded as a data file) for every id and every LCID and compares the result with the .mc text; a third test checks the severity bits of the generated header constants. Nothing writes the Event Log or registers a source.
  • Known gap. The table has an es-AR block only. Spanish users with another Spanish LCID (es-ES 0x0C0A, es-MX 0x080A) may get the English text from FormatMessage until more LCIDs are added. This is recorded in 03 10.3.
  • Not changed. The message ids and placeholders, the event sources and the registration. The agent still does not write to the Event Log.

Addendum: Event Log table per LANGID

The "known gap" above is closed. FormatMessage and the Event Viewer match the exact LANGID, so sdl10n --out-mc now writes each language's one text under every sublanguage LANGID that winnt.h defines for that primary language, plus the primary-neutral LANGID: 58 LanguageNames entries (English 17, Spanish 22, French 7, Portuguese 3, Italian 3, German 6). The mapping mirrors lang_from_langid in src/sd_l10n/l10n.c, which selects the text by primary language. The .bin files are named MSG by mc.exe and are not listed as build outputs. unit.svc checks that the table has every LANGID of the required list (including es-ES 0x0C0A, es-MX 0x080A, pt-PT 0x0816, fr-CA 0x0C0C, de-AT 0x0C07, it-CH 0x0810, en-GB 0x0809) and that each id resolves in each LANGID to the text of its block.

Part 14: threat-model review, the double-mount diagnosis, the service attach stack (2026-10-30)

This round closes three of the four items the M5 brief ranked before the live lab run: the threat-model review that 00-integration-review.md §4/§6 asks for, the undiagnosed heap corruption of Part 10, and the service half of the WebDAV attach path (02 §7.7). The live global Dokany mount still needs sd-win10-ltsc21-x64, which m3-lab holds.

1. Threat-model review (05 §12)

docs/design/05-threat-model.md gains section 12: per surface — named pipes, loopback WebDAV, the Dokany requestor check, update signatures, DPAPI, the Event Log, and the service's own inputs — the property the design claims, the code that carries it with file:line, and a verdict: carried, partial or absent. Nothing in it is normative; the gaps become eight "no code" findings and six proposed TM-R40-TM-R45 that the owning documents must accept.

The findings that matter most:

  • The updater has no trust roots in this build. apps/shelldrive-host/update_ipc.c:30-31 passes { NULL, 0, NULL, 0 }. The verifier in sd_update is complete (ed25519 over the exact manifest bytes, keyset, channel, expires, anti-rollback, host allow-list, size and digest), but with an empty root set no manifest can verify, so the product has no update signature property at all. Proposed TM-R40: compile the roots in and fail the build when a release configuration has none.
  • Crash dumps do not exist. No MiniDumpWriteDump and no sd_dump_mark_sensitive anywhere; agent.c:3643 says "come later". 03 §10.4, TM-R30 and TST-28 have nothing behind them.
  • Event 3100 has no code. 1200, 2300, 3101 and 3102 are written and localized; 3100 appears in no source file, header or catalog entry.
  • The WebDAV server cannot authorize a group. wd_server.c:466 (before this change) compared the authenticated SID with a single owner SID and :541 passed no token groups, so a service_access entry that names a group could never match. That was the blocking gap for the attach path and is fixed here (section 3).
  • Fast user switching/RDP sessions are logged only (service.c:3485-3486), the admin session list of 2.6 does not exist, --elevated-view has no implementation, settings.ini is never read by the service, and the machine known_hosts keeps its check-to-use window. These were already "Left" items; the review now records them as claims with no code behind them rather than as work in progress.

2. The double mount of Part 10 was a test-harness double free

Root cause: wait_state(c, id, want, timeout, &st) kept the status reply in a static and freed the previous one; tests that called it twice without dropping st in between (the announcement tests did) freed the same sd_json twice, and the debug CRT ended the process with 0xC0000374 before the second wait_state — exactly the "after the second announcement callback" signature Part 10 recorded. It was in the test process only; service.c and sd_mount were not involved, which is why the machine-store stub and the reject path made no difference.

e2c3df5 added json_drop(&st) (free and clear the pointer) and the regression test svc_one_profile_mounted_twice_keeps_both_announcements, which mounts the rotate profile twice, checks that both mount ids and both announcement ids differ, and unmounts both. Verified 2026-10-30: that test passes on its own and the whole sd-test-svc.exe suite passes in a Debug build (97 tests, 0 failed) — see section 4.

3. The service attach stack (02 §7.7, 03 §1.3, D11)

Implemented in the shape the spike chose: the service hosts the export, each user's agent maps it in its own logon session. system and link stay unbuilt and the compiled table still has no GO cell (svc_gw.c), so auto resolves to attach.

What was built

Path What
src/sd_webdav/sd_webdav.h, wd_server.c, wd_server.h, wd_auth.c, wd_client.c service_mode on the server: the connection-level owner check yields to the per-request sd_vfs check, and the authenticated connection carries the token's enabled, non-deny-only groups (wd_auth_step grows groups/n_groups, wd_groups_free); no_map on the mount (host the export, map nothing); sd_webdav_mount_remote for the export's UNC
src/sd_mount/sd_mount.h, mount.c, mount_real.c webdav_remote backend entry; sd_mount_attach.webdav_remote / .webdav_remote_xp; a global WebDAV mount is hosted with no_map and reports its export
apps/shelldrive-host/svc_access.c backend = webdav is a valid service profile again (the mechanism is chosen at mount time)
apps/shelldrive-host/service.c job_start uses the WebDAV backend for a profile that asks for it; svc_on_state records the export; mount.attach_info for a member of service_access; feature name
apps/shelldrive-host/agent.c mount.attach (asks the service, maps with svc_gw_attach_real_ops) and attach_global_webdav() at logon (lists the service's mounts, attaches each unc)
apps/shelldrive-host/CMakeLists.txt, tests/apps/CMakeLists.txt svc_gw_attach.c and mpr in the host and in the fake-host test
tests/unit/sd_svc/test_service.c, test_access.c, main.c; tests/unit/sd_mount/fake_backend.c two fixture profiles, two tests, the fake backend's webdav_remote, the profile count 18 → 20

Flow. At logon the agent lists the service's mounts (the reply already hides the ones the caller is not in service_access for), asks mount.attach_info for each, and maps the unc/xp_url it gets back. The service decides from svc_decide(use), so a non-member gets access_denied and no token leaves the service. The mapping is not persistent; it is cancelled with every other \\localhost@port mapping of the session at agent start and at stop (cleanup_webdav_mappings). The server binds loopback only, and every request is checked per export by sd_vfs against service_access/service_access_write with the caller's SID and groups (02 §6.7 rules, G7).

Three rules added after review (before the commit, on a second read of the first draft):

  • The mount-start cleanup would have cancelled the attach. sd_webdav_mount_start removes every \\localhost@port mapping of the session before it binds the agent's own server (TM-R17 d). A user who mounted a per-user WebDAV profile after logon would have lost the global drive. sd_webdav_preserve_port (backend entry webdav_preserve_port) now registers the service's port after a successful attach, and only that internal cleanup skips it; the agent's explicit start and stop cleanups still remove the mapping. An agent crash leaves the attach mapping in place, which is not the T-32 squat case: the port belongs to the running service, not to the dead agent. The next agent start removes it and attaches again.
  • Anonymous, Guest, LOCAL SERVICE, NETWORK SERVICE (02 §7.7 "rejected always ... unless listed"). In service mode wd_server.c refuses with 403 an anonymous token, a Guest account (RID 501) and any member of BUILTIN\Guests, before sd_vfs sees them. LOCAL SERVICE and NETWORK SERVICE keep their user SID but lose their groups, so a group entry (Everyone, Users) never admits them; only an explicit SID entry in service_access does.
  • The mechanism decision is wired. job_start asks svc_gw_decide (mode auto: the service does not read settings.ini) before a WebDAV global mount. Attach is used; a refusal (OS family unknown, WebClient missing or disabled) fails the mount with usage and the reason; a system or link verdict — possible only after a lab run flips a table cell — is refused as "not in this build" instead of being served as attach. svc_gw.c is now part of the shipping host.

G1-G7, what is covered without a second logon

# Criterion State
G1 Visibility in every session not testable here (needs a second logon); attach is per session by construction
G2 The server sees each user's own SID, no shared connection unit: mount.attach_info returns the export only to a member, and the server keeps one SSPI context per TCP connection (wd_auth); the two-user test is a lab item
G3 WebClient/service restart, sleep/resume no: lab
G4 No security-setting changes attach changes none; WebClient start is the existing path
G5 Function (1 GiB copy, Office locks) no: lab. The export is the same sd_webdav the per-user path uses
G6 Before logon not claimed for attach (D11: only Dokany is pre-logon)
G7 Negative access unit: a caller outside service_access gets access_denied from the service and 403 from the server; groups now reach sd_vfs. Membership-change timing (60 s) and the session-0 case: lab

Tests added (unit.svc, all in-process, no second session):

  • svc_webdav_mount_reports_its_attach_point: a backend = webdav global profile mounts, mount.attach_info returns backend = webdav, attach = true, the \\localhost@49321\DavWWWRoot\s-<26> UNC, the XP http:// form and the port; a Dokany global mount answers attach = false with no UNC.
  • svc_attach_info_refuses_a_caller_outside_service_access: a profile whose service_access names a SID this process does not carry mounts, and mount.attach_info answers access_denied with no UNC.

And in unit.webdav, against a real loopback server with real SSPI (the test user's own token):

  • webdav_service_server_admits_a_member: a global vfs whose service_access is the test user, a server owned by SYSTEM in service mode: the authenticated PROPFIND answers 207 (the per-user server answers 403 for the same owner, webdav_server_rejects_other_sid).
  • webdav_service_server_refuses_a_non_member: the same server with service_access naming LOCAL SERVICE: authentication succeeds and sd_vfs refuses, so no listing reaches a non-member.

Not done, and why

  • The service's own AcceptSecurityContext as LocalSystem, and the token groups of a real user token, are not exercised: the tests use the fake backend and no real SSPI session. This is the lab half of G2/G7.
  • system/link mechanisms, --elevated-view, and the per-request fallback of 02 §7.7 (switch to Connection: close on an OS where the redirector shares connections) are untouched.
  • The XP form (http://localhost:PORT/s-<token>, provider "Web Client Network") is compiled but unrun; attach on XP is a lab item.
  • sd_webdav and sd_mount are outside the paths the brief listed as this lane's; the two changes there are the minimum the 02 §7.7 design needs (the server authorization gap of 05 §12.2 and the hosted-not-mapped export). apps/shelldrive-ui, src/sd_update, apps/shelldrive-setup and packaging/ were not touched.

4. Verification

  • x64-modern Debug: full build, 0 errors, 0 warnings; unit.webdav 28/28 (26 existing, 2 new) after the service-mode change (the first run caught a double free of the user SID in the 403 branch, fixed).
  • sd-test-svc.exe (Debug): 97 tests, 0 failed, including both new tests and the double-mount regression test.
  • logpriv.source_check: no problems (one %lu in a new agent log line was changed to %u).
  • unit.webdav adds the two service-server tests above (real SSPI against a real loopback server).
  • Local gate, 2026-10-30, tools\ci-local.ps1 -Pipeline (Release and Debug, -LE "matrix|bench|repro"): x64-modern, x64-xp, x86-ia32, x86-sse2 and x64-analysis all pass, every test passes; the only skips are the expected dokany.mount ones under WOW64 on the two x86 flavours. repro.x64-modern (the label the gate excludes and CI runs) passes too.
  • Gate trap: the WSL sshd fixture is shared between checkouts. When it already runs, start.sh exits before it writes this checkout's tests/fixtures/wsl-sshd/state/, the interop tests skip, and ci-local.ps1 fails the preset on the skip. Copying env and the two client keys from the checkout that started the fixture (the folder is gitignored) fixes it without restarting a fixture other sessions use.

5. Left after this round

  • The live global Dokany mount on sd-win10-ltsc21-x64 ran on 2026-10-30, attempt 13, log D:\sdlab\logs\m5-20261030-233947.log (the procedure is the appendix of docs/dev/lab-results.md): PASS on install/start as SYSTEM (after 58d6b68), machine profile load and host key, the global mount (Event 1100), G1 batch and B1/B2 console logons (two live sessions), G5 (1 GiB write 74.6 s, read 17.6 s, SHA-256 match), G7 including the drop-member mutation, G3 stop/start and VM save/resume, and uninstall. Per-item results with the quoted log lines are in the 2026-10-30 section of docs/dev/lab-results.md. The run left four product gaps; all four are fixed on this branch and the fixes were checked by a second live run (2026-10-31, log D:\sdlab\logs\m5-20261031-025507.log):
    • Fixed (5780848): autostart = boot was not applied by the service (03 §3.4.1). The service now mounts those profiles after loading them (start, config reload, data-folder repair) through the same queue as a mount request. Live: both phase-B reboots log pre-logon-state OK … list=[Z: GlobalDokan mounted] and boot-autostart OK mounted by the service at boot, 33 s after boot (35 s on the second), so the pre-logon (G6) claim now holds for Dokany; a service stop unmounts Z: cleanly and the restart brings it back.
    • Fixed (b478b45): a standard user's shelldrive service list exited 8 "not running or not installed" from a batch session. 03 §2.2 grants the service pipe to interactive users only (O:SYD:P(D;;GA;;;NU)(A;;GA;;;SY)(A;;GA;;;BA)(A;;GRGW;;;IU)), so a batch logon is refused by design; the defect was the report. The CLI now says "Access to the ShellDrive service is denied." with exit 9, and exit 8 only when the service is really absent. Live: service_list_rc=9 from the batch session, list-after-uninstall rc=8.
    • Fixed (7f4538c): service mount|unmount|status <name> errors now name the profile ("There is no profile named nosuch.").
    • Fixed (7f4538c): scm_error tells a caller that is not elevated (exit 9, "Managing the ShellDrive service needs an elevated console") from an elevated console whose SCM call was refused (exit 1, with the Win32 code).
    • Found by the second run and fixed (9b26bfc): the first autostart mount after install fails until the machine host key is added, and its final failed record then made service mount answer already_mounted (exit 10). A new mount of the profile now replaces a final failed record (03 §1.11: failed is terminal); a live mount is still refused. Live: phase A service-mount brings Z: up after the key is added.
    • Note only: Get-Volume (MSFT_Volume) does not list the Dokany Z: ("No MSFT_Volume objects found with property 'DriveLetter' equal to 'Z'."); dir and Explorer work.
    • Not covered by the runs: RDP/FUS second interactive session (G2 proper), Server 2022 + Secure Boot (the Gen2 media problem of lab-results' 2026-10-29 night section).
  • Everything in 05 §12.8 that has no code: release roots, crash dumps, Event 3100, the FUS/RDP session list, --elevated-view, settings.ini checks, discovered-proxy detection.
  • The per-user identity test (two users, each mapping the other's UNC) and the rest of G1-G7.