Skip to content

Conversation

dscho
Copy link
Member

@dscho dscho commented May 22, 2025

When choosing a custom editor, there is the convenient "Test Custom Editor" button. When clicking it, a file is written and the specified editor is invoked to edit that file. The file is then deleted.

The contents of that file specifically encourage the user to make changes and write the file.

Unfortunately, due to security concerns InnoSetup nowadays restricts the permissions of its temporary directory, which means that the file (which is written by the elevated installer process) is not writable by the (non-elevated) custom editor.

Let's just write the file next to that temporary directory, which is the user's TEMP directory and therefore writable.

This fixes git-for-windows/git#5618.

When choosing a custom editor, there is the convenient "Test Custom
Editor" button. When clicking it, a file is written and the specified
editor is invoked to edit that file. The file is then deleted.

The contents of that file specifically encourage the user to make
changes and write the file.

Unfortunately, due to security concerns InnoSetup nowadays restricts the
permissions of its temporary directory, which means that the file (which
is written by the elevated installer process) is not writable by the
(non-elevated) custom editor.

Let's just write the file _next_ to that temporary directory, which is
the user's TEMP directory and therefore writable.

This fixes git-for-windows/git#5618.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member Author

dscho commented May 22, 2025

For shiggles, I'll ask Copilot to review.

@dscho dscho requested a review from Copilot May 22, 2025 08:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a security issue where the custom editor was attempting to write to a restricted temporary directory by instead creating the file next to it in a writable location.

  • Modified the path for TmpFile to use '{tmp}-editor-test.txt' for enhanced writability.
  • Added DeleteFile calls in error-handling branches to ensure cleanup of the temporary file.

@dscho dscho merged commit 560bb6d into main May 22, 2025
7 checks passed
@dscho dscho deleted the test-custom-editor-on-writable-file branch May 22, 2025 11:04
github-actions bot pushed a commit that referenced this pull request May 22, 2025
Git for Windows' installer [used a non-writable
file](git-for-windows/git#5618) for testing
custom editors, which [was
fixed](#618).

Signed-off-by: gitforwindowshelper[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test custom editor opens a readonly file

2 participants