summaryrefslogtreecommitdiff
path: root/sign
diff options
context:
space:
mode:
authorPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-07 11:55:28 +0300
committerPanu Matilainen <Panu Matilainen pmatilai@redhat.com>2011-07-07 11:55:28 +0300
commit78c95448a16f0c766e1fdd34db861b8150335484 (patch)
tree27e7e5ab638b154839f89a4fe15fd1e862ce3fff /sign
parente156eac1c8d1703d311277d177ddc0ebba9b187a (diff)
downloadlibrpm-tizen-78c95448a16f0c766e1fdd34db861b8150335484.tar.gz
librpm-tizen-78c95448a16f0c766e1fdd34db861b8150335484.tar.bz2
librpm-tizen-78c95448a16f0c766e1fdd34db861b8150335484.zip
Further streamline & sanitize lead handling
- Never log anything from rpmLeadRead(), instead return an error message the callers can log if they see fit - Add a return value for the lead type (which is the only bit of info from the lead we sometimes resort to using) - Permit NULL pointers on all return values - Eliminate rpmLeadCheck() and rpmLeadType() from the internal API, these are now combined into rpmLeadRead(). - Fix up the callers: only (re)signing needs the actual lead, signature verification only cares if its valid or not and package reading only wants the type from the lead (annoying but...)
Diffstat (limited to 'sign')
-rw-r--r--sign/rpmgensig.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c
index 6b332541b..cd61b7af4 100644
--- a/sign/rpmgensig.c
+++ b/sign/rpmgensig.c
@@ -433,7 +433,7 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase)
rpmlead lead = NULL;
char *sigtarget = NULL, *trpm = NULL;
Header sigh = NULL;
- char * msg;
+ char * msg = NULL;
int res = -1; /* assume failure */
rpmRC rc;
struct rpmtd_s utd;
@@ -443,18 +443,12 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase)
if (manageFile(&fd, rpm, O_RDONLY))
goto exit;
- if ((rc = rpmLeadRead(fd, &lead)) == RPMRC_OK) {
- const char *lmsg = NULL;
- rc = rpmLeadCheck(lead, &lmsg);
- if (rc != RPMRC_OK)
- rpmlog(RPMLOG_ERR, "%s: %s\n", rpm, lmsg);
- }
-
- if (rc != RPMRC_OK) {
+ if ((rc = rpmLeadRead(fd, &lead, NULL, &msg)) != RPMRC_OK) {
+ rpmlog(RPMLOG_ERR, "%s: %s\n", rpm, msg);
+ free(msg);
goto exit;
}
- msg = NULL;
rc = rpmReadSignature(fd, &sigh, RPMSIGTYPE_HEADERSIG, &msg);
switch (rc) {
default: