From 962b20ea7e5d202c013c0467d71fc1a12fd44ac7 Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Fri, 14 Jun 2019 18:22:09 -0700 Subject: [PATCH 1/2] Update the rpm package signing to work with newer rpm version Newer versions of rpmsign (rpm 4.13+), no longer prompt for the pass phrase, but instead provide gpg with access to stdin/out to request it. Because this process is deferred, you will also often end up with warning output from rpmbuild before the prompt, so we can no longer assume the prompt will be the first output. This issue was discovered while trying to build rpm packages for OpenSUSE 15 which has the newer rpm. Signed-off-by: DJ Mountney --- resources/rpm/signing.erb | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/resources/rpm/signing.erb b/resources/rpm/signing.erb index 59a984852..6af2acb6d 100755 --- a/resources/rpm/signing.erb +++ b/resources/rpm/signing.erb @@ -11,25 +11,14 @@ require 'pty' puts rpm_cmd PTY.spawn(rpm_cmd) do |r, w, pid| - prompt = r.read(19) - - # match the expected prompt exactly, since that's the only way we know if - # something went wrong. - unless prompt == 'Enter pass phrase: ' - STDERR.puts "unexpected output from `#{rpm_cmd}`: '#{prompt}'" - Process.kill(:KILL, pid) - exit 1 - end - - STDOUT.puts prompt - w.write("#{password}\n") - # Keep printing output unti the command exits loop do begin line = r.gets puts line - if (line =~ /failed/) && !(line =~ /warning:/) + if line =~ /Enter pass phrase:/ || line =~ /Please enter the passphrase to unlock the OpenPGP secret key:/ + w.write("#{password}\n") + elsif (line =~ /failed/) && !(line =~ /warning:/) STDERR.puts 'RPM signing failure' exit 1 end From e15bdc5b0bda706c58510c8ab5dea4b6afd36abb Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Fri, 14 Jun 2019 21:52:35 -0700 Subject: [PATCH 2/2] Restore some of the previous behaviour that read the old rpmsign prompt Signed-off-by: DJ Mountney --- resources/rpm/signing.erb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/rpm/signing.erb b/resources/rpm/signing.erb index 6af2acb6d..7ba782f81 100755 --- a/resources/rpm/signing.erb +++ b/resources/rpm/signing.erb @@ -11,12 +11,20 @@ require 'pty' puts rpm_cmd PTY.spawn(rpm_cmd) do |r, w, pid| + # Older versions of rpmsign will prompt right away for the passphrase + prompt = r.read(19) + + if prompt == 'Enter pass phrase: ' + STDOUT.puts prompt + w.write("#{password}\n") + end + # Keep printing output unti the command exits loop do begin line = r.gets puts line - if line =~ /Enter pass phrase:/ || line =~ /Please enter the passphrase to unlock the OpenPGP secret key:/ + if line =~ /Please enter the passphrase to unlock the OpenPGP secret key:/ w.write("#{password}\n") elsif (line =~ /failed/) && !(line =~ /warning:/) STDERR.puts 'RPM signing failure'