Skip to content

Mouse Without Borders: create received files in the logged-on user's context#48769

Open
yeelam-gordon wants to merge 4 commits into
microsoft:mainfrom
yeelam-gordon:fix/114552
Open

Mouse Without Borders: create received files in the logged-on user's context#48769
yeelam-gordon wants to merge 4 commits into
microsoft:mainfrom
yeelam-gordon:fix/114552

Conversation

@yeelam-gordon

Copy link
Copy Markdown
Contributor

Summary

When Mouse Without Borders receives a file (clipboard / file transfer) while the
service is running elevated, the destination folder is created while impersonating
the logged-on user, but the file itself was created outside of that context. As a
result, the received file's ownership and permissions did not match the folder it
lives in.

This change creates the received file in the same context as its destination folder:

  • For per-user storage (the user's Desktop), the file is created while impersonating
    the logged-on user, so it is owned by that user and inherits the folder's
    permissions.
  • On the logon / screen-saver desktop the storage lives under Program Files, where
    there is no interactive user to impersonate, so the file continues to be created
    directly — existing behavior is preserved.

Scope

  • Single file: src/modules/MouseWithoutBorders/App/Core/Clipboard.cs.
  • Reuses the existing Launch.ImpersonateLoggedOnUserAndDoSomething helper; no new
    dependencies, no API / IPC / schema changes.
  • Folder-creation logic is unchanged. Only the context of the file creation changes,
    and only for the per-user storage path. The Program Files path keeps its current
    behavior.

Validation

  • Built MouseWithoutBorders.csproj (Release | x64) — succeeds (exit code 0).

…context

When the service runs elevated, the destination folder for an incoming clipboard/file transfer is created while impersonating the logged-on user, but the file itself was created outside that context. This makes the resulting file ownership/permissions inconsistent with the folder.

Create the file in the same impersonated context as its folder so it is owned by the logged-on user and inherits the folder's permissions. On the logon/screen-saver desktop the storage lives under Program Files where there is no interactive user to impersonate, so the file is still created directly to preserve existing behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Mouse Without Borders Refers to the Mouse Without Borders module label Jun 21, 2026
Comment thread src/modules/MouseWithoutBorders/App/Core/Clipboard.cs
Comment thread src/modules/MouseWithoutBorders/App/Core/Clipboard.cs
Comment thread src/modules/MouseWithoutBorders/App/Core/Clipboard.cs
@MuyuanMS MuyuanMS enabled auto-merge (squash) June 23, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Mouse Without Borders Refers to the Mouse Without Borders module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants