Skip to content
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

Point GVFS.Service to the correct executable when C:\Program exists #1806

Merged

Conversation

winstliu
Copy link
Member

@winstliu winstliu commented Mar 8, 2024

An issue was reported to our team where someone was unable to gvfs clone a repo. The error message they received was Could not execute 'C:\Program Files\GVFS\GVFS.Hooks.exe'. CreateProcess error (193).

After investigation, we discovered that GVFS.Service was stopped and could not be started with the same error. Eventually, we root-caused it to a rogue C:\Program file. When this file was deleted, GVFS.Service started up and the repo clone succeeded.

To properly resolve paths with spaces in them, quotes must be added. The installer already attempted to do this, but the quotes it added around the binPath would get stripped away during argument parsing.
Adding another set of quotes properly retains the quotes until it gets to sc.exe.

Without this change, the "path to executable" is not quoted:
path-to-executable-unquoted

With this change, the path is now quoted:
path-to-executable-quoted

This is consistent with other services that run out of paths with spaces in them, e.g. Logi Options+, Visual Studio Installer Elevation.

Validation

  1. Stop GVFS.Service.
  2. In an admin PowerShell window, New-Item -Path C:\Program -ItemType File.
  3. Attempt to start GVFS.Service. This should fail.
  4. Attempt to clone a GVFS repo. This should fail.
  5. Delete the file.
  6. Uninstall VFS for Git.
  7. Add back the file.
  8. Attempt to install a version that has the quotes fix. This should succeed.
  9. Attempt to clone a GVFS repo. This should succeed.

If the binPath isn't quoted, sc.exe will first look for a file at C:\Program.
Starting that will yield CreateProcess error 193 (aka invalid Win32 program).

By properly quoting the binPath, we guarantee that the correct file will be loaded.
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@dscho dscho merged commit f892a51 into microsoft:master Oct 24, 2024
5 checks passed
@winstliu winstliu deleted the user/winstonliu/fix-sc-create-arguments branch October 24, 2024 15:34
@dscho dscho added this to the M195 milestone Oct 24, 2024
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.

3 participants