fix: SSH_ASKPASS can NOT use parameter

This commit is contained in:
leo 2024-07-10 10:47:43 +08:00
parent 7febac5843
commit ca461d1926
No known key found for this signature in database
3 changed files with 4 additions and 3 deletions

1
.gitignore vendored
View file

@ -604,3 +604,4 @@ build/*.zip
build/*.tar.gz
build/*.deb
build/*.rpm
build/*.AppImage

View file

@ -456,10 +456,10 @@ namespace SourceGit
private bool TryLaunchedAsAskpass(IClassicDesktopStyleApplicationLifetime desktop)
{
var args = desktop.Args;
if (args.Length <= 1 || !args[0].Equals("--askpass", StringComparison.Ordinal))
if (args.Length != 1 || !args[0].StartsWith("Enter passphrase", StringComparison.Ordinal))
return false;
desktop.MainWindow = new Views.Askpass(args[1]);
desktop.MainWindow = new Views.Askpass(args[0]);
return true;
}

View file

@ -53,7 +53,7 @@ namespace SourceGit.Commands
// Force using this app as SSH askpass program
var selfExecFile = Process.GetCurrentProcess().MainModule.FileName;
start.Environment.Add("DISPLAY", "required");
start.Environment.Add("SSH_ASKPASS", $"\"{selfExecFile}\" --askpass");
start.Environment.Add("SSH_ASKPASS", selfExecFile); // Can not use parameter here, because it invoked by SSH with `exec`
start.Environment.Add("SSH_ASKPASS_REQUIRE", "prefer");
// If an SSH private key was provided, sets the environment.