Panu Matilainen 4a8173
commit 31c5e0f9b7b09661611b50d84d26ba47ce97fffe
Panu Matilainen 4a8173
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 4a8173
Date:   Wed Nov 25 16:42:43 2009 +0200
Panu Matilainen 4a8173
Panu Matilainen 4a8173
    Fix signature password checking result on abnormal conditions (RhBug:496754)
Panu Matilainen 4a8173
    - Execve() failure wasn't returning an error code, causing rpm to
Panu Matilainen 4a8173
      think the password was ok when we couldn't even try verifying
Panu Matilainen 4a8173
    - Stricter return code checking from the password checking child:
Panu Matilainen 4a8173
      the password can only be ok if the child exits with WIFEXITED() *and*
Panu Matilainen 4a8173
      WIFEXITCODE() of 0. Also WIFEXITCODE() should only be called if
Panu Matilainen 4a8173
      WIFEXITED() returns true.
Panu Matilainen 4a8173
    (cherry picked from commit 2b41860984f0c4ebba5ebce93a18c9c0ca5e1065)
Panu Matilainen 4a8173
Panu Matilainen 4a8173
diff --git a/lib/signature.c b/lib/signature.c
Panu Matilainen 4a8173
index a501f3e..a2eaf9b 100644
Panu Matilainen 4a8173
--- a/lib/signature.c
Panu Matilainen 4a8173
+++ b/lib/signature.c
Panu Matilainen 4a8173
@@ -883,6 +883,7 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag)
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
 	    rpmlog(RPMLOG_ERR, _("Could not exec %s: %s\n"), "gpg",
Panu Matilainen 4a8173
 			strerror(errno));
Panu Matilainen 4a8173
+	    _exit(EXIT_FAILURE);
Panu Matilainen 4a8173
 	}   break;
Panu Matilainen 4a8173
 	case RPMSIGTAG_RSA:
Panu Matilainen 4a8173
 	case RPMSIGTAG_PGP5:	/* XXX legacy */
Panu Matilainen 4a8173
@@ -932,7 +933,7 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag)
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
     (void) waitpid(pid, &status, 0);
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
-    return ((!WIFEXITED(status) || WEXITSTATUS(status)) ? 1 : 0);
Panu Matilainen 4a8173
+    return ((WIFEXITED(status) && WEXITSTATUS(status) == 0)) ? 0 : 1;
Panu Matilainen 4a8173
 }
Panu Matilainen 4a8173
 
Panu Matilainen 4a8173
 char * rpmGetPassPhrase(const char * prompt, const rpmSigTag sigTag)