lib/io_streams/pgp/reader.rb in iostreams-0.12.1 vs lib/io_streams/pgp/reader.rb in iostreams-0.13.0
- old
+ new
@@ -18,11 +18,15 @@
raise(ArgumentError, 'Missing both passphrase and IOStreams::Pgp::Reader.default_passphrase') unless passphrase
if IOStreams.reader_stream?(file_name_or_io)
raise(NotImplementedError, 'Can only PGP Decrypt directly from a file name. Input streams are not yet supported.')
else
+ loopback = IOStreams::Pgp.pgp_version.to_f >= 2.1 ? '--pinentry-mode loopback' : ''
+ command = "#{IOStreams::Pgp.executable} #{loopback} --batch --no-tty --yes --decrypt --passphrase-fd 0 #{file_name_or_io}"
+ IOStreams::Pgp.logger.debug { "IOStreams::Pgp::Reader.open: #{command}" } if IOStreams::Pgp.logger
+
# Read decrypted contents from stdout
- Open3.popen3("gpg --batch --no-tty --yes --decrypt --passphrase-fd 0 #{file_name_or_io}") do |stdin, stdout, stderr, waith_thr|
+ Open3.popen3(command) do |stdin, stdout, stderr, waith_thr|
stdin.puts(passphrase) if passphrase
stdin.close
result =
begin
stdout.binmode if binary