diff options
author | BlueBlock <danb@pobox.com> | 2019-07-20 14:40:01 +0300 |
---|---|---|
committer | BlueBlock <danb@pobox.com> | 2019-07-20 22:04:16 +0300 |
commit | a0e02e38f0910ba05c19fc66d17d86de253b1ef7 (patch) | |
tree | 7817cef96e396521c96d8b7362dd586caf675990 /BuildTools | |
parent | 4884fda0c69828cb5f1b4ff8e560323a45a58bf5 (diff) |
Use gpg library method to determine gpg exe path
Diffstat (limited to 'BuildTools')
-rw-r--r-- | BuildTools/GnupgSigningTool/Program.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/BuildTools/GnupgSigningTool/Program.cs b/BuildTools/GnupgSigningTool/Program.cs index e53422ead..7470001aa 100644 --- a/BuildTools/GnupgSigningTool/Program.cs +++ b/BuildTools/GnupgSigningTool/Program.cs @@ -21,6 +21,7 @@ namespace GnupgSigningTool { var armorOption = useArmor ? "--armor" : ""; + var gpgArgument = string.Format("--pinentry-mode loopback --passphrase-fd 0 --batch --yes {0} -u \"{1}\" --output \"{2}\" --detach-sig \"{3}\"", armorOption, gpgkeyid, @@ -36,6 +37,7 @@ namespace GnupgSigningTool }); proc.StandardInput.WriteLine(gpgkeypassphrase); + proc.WaitForExit(); } @@ -45,18 +47,20 @@ namespace GnupgSigningTool using (var ms = new System.IO.MemoryStream()) using (var fs = System.IO.File.OpenRead(gpgkeyfile)) { - try { enc.Decrypt(fs, ms); - } catch (System.Security.Cryptography.CryptographicException e) { + } + catch (System.Security.Cryptography.CryptographicException e) + { throw new ArgumentException("Failed to decrypt gpg secret credentials file: {0}\n", e.Message); } + ms.Position = 0; using (var sr = new System.IO.StreamReader(ms)) { - var lines = sr.ReadToEnd().Split(new [] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + var lines = sr.ReadToEnd().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); gpgkeyid = lines[0]; gpgkeypassphrase = lines[1]; } @@ -64,7 +68,7 @@ namespace GnupgSigningTool } - public static void Main(string [] _args) + public static void Main(string[] _args) { var args = new List<string>(_args); var opts = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args); @@ -95,7 +99,8 @@ namespace GnupgSigningTool throw new ArgumentException("Could not fetch gpg key id or gpg passphrase."); } - gpgpath = gpgpath ?? "gpg"; + gpgpath = gpgpath ?? Duplicati.Library.Encryption.GPGEncryption.GetGpgExePath(); + SpawnGPG(); } } |