Skip to content

installer: test any custom editor on a _writable_ file #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

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 <johannes.schindelin@gmx.de>
@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] <gitforwindowshelper-bot@users.noreply.github.com>
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