From 2b41860984f0c4ebba5ebce93a18c9c0ca5e1065 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 25 Nov 2009 16:42:43 +0200 Subject: Fix signature password checking result on abnormal conditions (RhBug:496754) - Execve() failure wasn't returning an error code, causing rpm to think the password was ok when we couldn't even try verifying - Stricter return code checking from the password checking child: the password can only be ok if the child exits with WIFEXITED() *and* WIFEXITCODE() of 0. Also WIFEXITCODE() should only be called if WIFEXITED() returns true. --- lib/signature.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/signature.c b/lib/signature.c index cd95e1304..7d50db7a5 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -653,6 +653,7 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag) rpmlog(RPMLOG_ERR, _("Could not exec %s: %s\n"), "gpg", strerror(errno)); + _exit(EXIT_FAILURE); } break; default: /* This case should have been screened out long ago. */ rpmlog(RPMLOG_ERR, _("Invalid %%_signature spec in macro file\n")); @@ -668,7 +669,7 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag) (void) waitpid(pid, &status, 0); - return ((!WIFEXITED(status) || WEXITSTATUS(status)) ? 1 : 0); + return ((WIFEXITED(status) && WEXITSTATUS(status) == 0)) ? 0 : 1; } char * rpmGetPassPhrase(const char * prompt, const rpmSigTag sigTag) -- cgit v1.2.3