Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 64851c6622aff64787a9fcea26cccde183b7c743 Mon Sep 17 00:00:00 2001 |
| 2 | From: "Roy.Li" <rongqing.li@windriver.com> |
| 3 | Date: Tue, 11 Nov 2014 16:28:22 +0800 |
| 4 | Subject: [PATCH] using poptParseArgvString to parse the |
| 5 | _gpg_check_password_cmd |
| 6 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 7 | Upstream-Status: Submitted [RPM5 maintainer] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | |
| 9 | Both __gpg_check_password_cmd and __gpg_sign_cmd include "%{_gpg_name}", but |
| 10 | strace shows that gpg_name has a quote when run _gpg_check_password, |
| 11 | but not when run __gpg_sign_cmd; for example, if gpg_name is "tester" |
| 12 | |
| 13 | execve("/usr/bin/gpg", ["gpg", "--batch", "--no-verbose", |
| 14 | "--passphrase-fd", "3", "-u", "\"tester\"", "-so", "-"], [/* 20 vars */]) = 0 |
| 15 | |
| 16 | execve("/usr/bin/gpg", ["gpg", "--batch", "--no-verbose", "--no-armor", |
| 17 | "--passphrase-fd", "3", "--no-secmem-warning", "-u", "tester", "-sbo"..,) = 0 |
| 18 | |
| 19 | it can be fixed by removing the quote around %{gpg_name} when define |
| 20 | __gpg_check_password_cmd in macros/macros, like below, but if gpg_name includes |
| 21 | space, it will not work. |
| 22 | |
| 23 | %__gpg_check_password_cmd %{__gpg} \ |
| 24 | gpg --batch --no-verbose --passphrase-fd 3 -u %{_gpg_name} -so - |
| 25 | |
| 26 | The poptParseArgvString function is used to parse _gpg_sign_cmd, so using |
| 27 | poptParseArgvString to parse __gpg_check_password_cmd to fix this issue. |
| 28 | |
| 29 | Signed-off-by: Roy.Li <rongqing.li@windriver.com> |
| 30 | --- |
| 31 | rpmdb/signature.c | 2 +- |
| 32 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 33 | |
| 34 | diff --git a/rpmdb/signature.c b/rpmdb/signature.c |
| 35 | index c35e0ab..016e8d1 100644 |
| 36 | --- a/rpmdb/signature.c |
| 37 | +++ b/rpmdb/signature.c |
| 38 | @@ -529,7 +529,7 @@ int rpmCheckPassPhrase(const char * passPhrase) |
| 39 | (void) setenv("GNUPGHOME", gpg_path, 1); |
| 40 | |
| 41 | cmd = rpmExpand("%{?__gpg_check_password_cmd}", NULL); |
| 42 | - rc = argvSplit(&av, cmd, NULL); |
| 43 | + rc = poptParseArgvString(cmd, NULL, (const char ***)&av); |
| 44 | if (!rc) |
| 45 | rc = execve(av[0], (char *const *)av+1, environ); |
| 46 | |
| 47 | -- |
| 48 | 1.9.1 |
| 49 | |