]> code.ossystems Code Review - openembedded-core.git/commitdiff
rpm: check _gpg_passphrase before ask for input
authorRobert Yang <liezhi.yang@windriver.com>
Mon, 21 Mar 2016 09:25:49 +0000 (02:25 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Mar 2016 14:24:25 +0000 (14:24 +0000)
rpm always asked for pass phrasae when add signature, which made it
can't work non-interactively, this patch fix the problem. It will work
non-interactively if _gpg_passphrase is defined, and work as before if
not.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/rpm/rpm/rpmqv.c-check-_gpg_passphrase-before-ask-for-input.patch [new file with mode: 0644]
meta/recipes-devtools/rpm/rpm_5.4.16.bb

diff --git a/meta/recipes-devtools/rpm/rpm/rpmqv.c-check-_gpg_passphrase-before-ask-for-input.patch b/meta/recipes-devtools/rpm/rpm/rpmqv.c-check-_gpg_passphrase-before-ask-for-input.patch
new file mode 100644 (file)
index 0000000..c68681c
--- /dev/null
@@ -0,0 +1,70 @@
+From bb48dbc88a58bc05a43d71a3375fb05358119ec5 Mon Sep 17 00:00:00 2001
+From: Robert Yang <liezhi.yang@windriver.com>
+Date: Sun, 20 Mar 2016 20:20:16 -0700
+Subject: [PATCH] rpmqv.c: check _gpg_passphrase before ask for input
+
+rpm always asked for pass phrasae when add signature, which made it
+can't work non-interactively, this patch fix the problem. It will work
+non-interactively if _gpg_passphrase is defined, and work as before if
+not.
+
+Upstream-Status: Pending
+
+Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
+---
+ macros/macros.in |    7 +++++--
+ rpmqv.c          |   17 ++++++++++-------
+ 2 files changed, 15 insertions(+), 9 deletions(-)
+
+diff --git a/macros/macros.in b/macros/macros.in
+index 2e5b07d..01b3aad 100644
+--- a/macros/macros.in
++++ b/macros/macros.in
+@@ -520,15 +520,18 @@ $_arbitrary_tags_tests   Foo:Bar
+ #     Macro(s) to hold the arguments passed to GPG/PGP for package
+ #     signing and verification.
+ #
++
++%_gpg_passphrase_way %{?_gpg_passphrase:--passphrase "%{_gpg_passphrase}"}%{!?_gpg_passphrase:--passphrase-fd 3}
++
+ %__gpg_check_password_cmd     %{__gpg} \
+-      gpg --batch --no-verbose --passphrase-fd 3 -u "%{_gpg_name}" -so -
++      gpg --batch --no-verbose %{_gpg_passphrase_way} -u "%{_gpg_name}" -so -
+ #%__pgp_check_password_cmd    %{__pgp} \
+ #     pgp +batchmode=on +verbose=0 "%{_pgp_name}" -sf
+ #%__pgp5_check_password_cmd   %{__pgp} \
+ #     pgps +batchmode=on +verbose=0 +armor=off "%{_pgp_name}" -f
+ %__gpg_sign_cmd                       %{__gpg} \
+-      gpg --batch --no-verbose --no-armor --passphrase-fd 3 --no-secmem-warning \
++      gpg --batch --no-verbose --no-armor %{_gpg_passphrase_way}  --no-secmem-warning \
+       -u "%{_gpg_name}" -sbo %{__signature_filename} %{__plaintext_filename}
+ #%__pgp_sign_cmd                      %{__pgp} \
+ #     pgp +batchmode=on +verbose=0 +armor=off \
+diff --git a/rpmqv.c b/rpmqv.c
+index b306486..7604396 100644
+--- a/rpmqv.c
++++ b/rpmqv.c
+@@ -831,13 +831,16 @@ int main(int argc, const char ** argv)
+ #endif
+           )
+           {
+-              passPhrase = Getpass(_("Enter pass phrase: "));
+-              if (rpmCheckPassPhrase(passPhrase)) {
+-                  fprintf(stderr, _("Pass phrase check failed\n"));
+-                  ec = EXIT_FAILURE;
+-                  goto exit;
++              passPhrase = rpmExpand("%{?_gpg_passphrase}", NULL);
++              if (passPhrase == NULL || passPhrase[0] == '\0') {
++                      passPhrase = Getpass(_("Enter pass phrase: "));
++                      if (rpmCheckPassPhrase(passPhrase)) {
++                          fprintf(stderr, _("Pass phrase check failed\n"));
++                          ec = EXIT_FAILURE;
++                          goto exit;
++                      }
++                      fprintf(stderr, _("Pass phrase is good.\n"));
+               }
+-              fprintf(stderr, _("Pass phrase is good.\n"));
+               /* XXX Getpass() should realloc instead. */
+               passPhrase = xstrdup(passPhrase);
+           }
index eba043e3af0d222411f768db8dde5943d8b3eb0c..7621f8ffaab2944587f901cb5de6cab982339e3d 100644 (file)
@@ -114,6 +114,7 @@ SRC_URI += " \
           file://rpm-python-AddErase.patch \
           file://rpm-rpmpgp-popt.patch \
           file://rpm-fix-lua-tests-compilation-failure.patch \
+          file://rpmqv.c-check-_gpg_passphrase-before-ask-for-input.patch \
 "
 
 # OE specific changes