diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-04-21 10:47:31 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-04-21 10:48:42 +0300 |
commit | c798aed743b4df9569475520ad0821d555b35c82 (patch) | |
tree | 44e5860851ad0c877a7fdcc86a560d68e4d5e5ab /sign | |
parent | 96c4f818a5676cb87c930fb15ad0a243ea3cbd80 (diff) | |
download | librpm-tizen-c798aed743b4df9569475520ad0821d555b35c82.tar.gz librpm-tizen-c798aed743b4df9569475520ad0821d555b35c82.tar.bz2 librpm-tizen-c798aed743b4df9569475520ad0821d555b35c82.zip |
Remove redundant indentation block from rpmSign()
- No code changes, just formatting sanity/prettiness
Diffstat (limited to 'sign')
-rw-r--r-- | sign/rpmgensig.c | 253 |
1 files changed, 125 insertions, 128 deletions
diff --git a/sign/rpmgensig.c b/sign/rpmgensig.c index 832c48659..6efe618d2 100644 --- a/sign/rpmgensig.c +++ b/sign/rpmgensig.c @@ -436,155 +436,152 @@ static int rpmSign(const char *rpm, int deleting, const char *passPhrase) char * msg; int res = -1; /* assume failure */ int xx; - - { - rpmRC rc; - struct rpmtd_s utd; + rpmRC rc; + struct rpmtd_s utd; - fprintf(stdout, "%s:\n", rpm); + fprintf(stdout, "%s:\n", rpm); - if (manageFile(&fd, rpm, O_RDONLY)) - goto exit; + if (manageFile(&fd, rpm, O_RDONLY)) + goto exit; - lead = rpmLeadNew(); + lead = rpmLeadNew(); - 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 = 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) { - lead = rpmLeadFree(lead); - goto exit; - } + if (rc != RPMRC_OK) { + lead = rpmLeadFree(lead); + goto exit; + } - msg = NULL; - rc = rpmReadSignature(fd, &sigh, RPMSIGTYPE_HEADERSIG, &msg); - switch (rc) { - default: - rpmlog(RPMLOG_ERR, _("%s: rpmReadSignature failed: %s"), rpm, - (msg && *msg ? msg : "\n")); - msg = _free(msg); - goto exit; - break; - case RPMRC_OK: - if (sigh == NULL) { - rpmlog(RPMLOG_ERR, _("%s: No signature available\n"), rpm); - goto exit; - } - break; - } + msg = NULL; + rc = rpmReadSignature(fd, &sigh, RPMSIGTYPE_HEADERSIG, &msg); + switch (rc) { + default: + rpmlog(RPMLOG_ERR, _("%s: rpmReadSignature failed: %s"), rpm, + (msg && *msg ? msg : "\n")); msg = _free(msg); - - /* ASSERT: ofd == NULL && sigtarget == NULL */ - ofd = rpmMkTempFile(NULL, &sigtarget); - if (ofd == NULL || Ferror(ofd)) { - rpmlog(RPMLOG_ERR, _("rpmMkTemp failed\n")); + goto exit; + break; + case RPMRC_OK: + if (sigh == NULL) { + rpmlog(RPMLOG_ERR, _("%s: No signature available\n"), rpm); goto exit; } - /* Write the header and archive to a temp file */ - if (copyFile(&fd, rpm, &ofd, sigtarget)) - goto exit; - /* Both fd and ofd are now closed. sigtarget contains tempfile name. */ - /* ASSERT: fd == NULL && ofd == NULL */ - - /* Dump the immutable region (if present). */ - if (headerGet(sigh, RPMTAG_HEADERSIGNATURES, &utd, HEADERGET_DEFAULT)) { - struct rpmtd_s copytd; - Header nh = headerNew(); - Header oh = headerCopyLoad(utd.data); - HeaderIterator hi = headerInitIterator(oh); - while (headerNext(hi, ©td)) { - if (copytd.data) - xx = headerPut(nh, ©td, HEADERPUT_DEFAULT); - rpmtdFreeData(©td); - } - hi = headerFreeIterator(hi); - oh = headerFree(oh); + break; + } + msg = _free(msg); - sigh = headerFree(sigh); - sigh = headerLink(nh); - nh = headerFree(nh); + /* ASSERT: ofd == NULL && sigtarget == NULL */ + ofd = rpmMkTempFile(NULL, &sigtarget); + if (ofd == NULL || Ferror(ofd)) { + rpmlog(RPMLOG_ERR, _("rpmMkTemp failed\n")); + goto exit; + } + /* Write the header and archive to a temp file */ + if (copyFile(&fd, rpm, &ofd, sigtarget)) + goto exit; + /* Both fd and ofd are now closed. sigtarget contains tempfile name. */ + /* ASSERT: fd == NULL && ofd == NULL */ + + /* Dump the immutable region (if present). */ + if (headerGet(sigh, RPMTAG_HEADERSIGNATURES, &utd, HEADERGET_DEFAULT)) { + struct rpmtd_s copytd; + Header nh = headerNew(); + Header oh = headerCopyLoad(utd.data); + HeaderIterator hi = headerInitIterator(oh); + while (headerNext(hi, ©td)) { + if (copytd.data) + xx = headerPut(nh, ©td, HEADERPUT_DEFAULT); + rpmtdFreeData(©td); } + hi = headerFreeIterator(hi); + oh = headerFree(oh); - /* Eliminate broken digest values. */ - xx = headerDel(sigh, RPMSIGTAG_BADSHA1_1); - xx = headerDel(sigh, RPMSIGTAG_BADSHA1_2); - - /* Toss and recalculate header+payload size and digests. */ - { - rpmTagVal const sigs[] = { RPMSIGTAG_SIZE, - RPMSIGTAG_MD5, - RPMSIGTAG_SHA1, - }; - int nsigs = sizeof(sigs) / sizeof(rpmTagVal); - for (int i = 0; i < nsigs; i++) { - (void) headerDel(sigh, sigs[i]); - if (rpmGenDigest(sigh, sigtarget, sigs[i])) - goto exit; - } - } + sigh = headerFree(sigh); + sigh = headerLink(nh); + nh = headerFree(nh); + } - if (deleting) { /* Nuke all the signature tags. */ - deleteSigs(sigh); - } else { - res = replaceSignature(sigh, sigtarget, passPhrase); - if (res != 0) { - if (res == 1) { - rpmlog(RPMLOG_WARNING, - _("%s already contains identical signature, skipping\n"), - rpm); - /* Identical signature is not an error */ - res = 0; - } + /* Eliminate broken digest values. */ + xx = headerDel(sigh, RPMSIGTAG_BADSHA1_1); + xx = headerDel(sigh, RPMSIGTAG_BADSHA1_2); + + /* Toss and recalculate header+payload size and digests. */ + { + rpmTagVal const sigs[] = { RPMSIGTAG_SIZE, + RPMSIGTAG_MD5, + RPMSIGTAG_SHA1, + }; + int nsigs = sizeof(sigs) / sizeof(rpmTagVal); + for (int i = 0; i < nsigs; i++) { + (void) headerDel(sigh, sigs[i]); + if (rpmGenDigest(sigh, sigtarget, sigs[i])) goto exit; - } } + } - /* Reallocate the signature into one contiguous region. */ - sigh = headerReload(sigh, RPMTAG_HEADERSIGNATURES); - if (sigh == NULL) /* XXX can't happen */ - goto exit; - - rasprintf(&trpm, "%s.XXXXXX", rpm); - ofd = rpmMkTemp(trpm); - if (ofd == NULL || Ferror(ofd)) { - rpmlog(RPMLOG_ERR, _("rpmMkTemp failed\n")); + if (deleting) { /* Nuke all the signature tags. */ + deleteSigs(sigh); + } else { + res = replaceSignature(sigh, sigtarget, passPhrase); + if (res != 0) { + if (res == 1) { + rpmlog(RPMLOG_WARNING, + _("%s already contains identical signature, skipping\n"), + rpm); + /* Identical signature is not an error */ + res = 0; + } goto exit; } + } - /* Write the lead/signature of the output rpm */ - rc = rpmLeadWrite(ofd, lead); - lead = rpmLeadFree(lead); - if (rc != RPMRC_OK) { - rpmlog(RPMLOG_ERR, _("%s: writeLead failed: %s\n"), trpm, - Fstrerror(ofd)); - goto exit; - } + /* Reallocate the signature into one contiguous region. */ + sigh = headerReload(sigh, RPMTAG_HEADERSIGNATURES); + if (sigh == NULL) /* XXX can't happen */ + goto exit; - if (rpmWriteSignature(ofd, sigh)) { - rpmlog(RPMLOG_ERR, _("%s: rpmWriteSignature failed: %s\n"), trpm, - Fstrerror(ofd)); - goto exit; - } + rasprintf(&trpm, "%s.XXXXXX", rpm); + ofd = rpmMkTemp(trpm); + if (ofd == NULL || Ferror(ofd)) { + rpmlog(RPMLOG_ERR, _("rpmMkTemp failed\n")); + goto exit; + } - /* Append the header and archive from the temp file */ - /* ASSERT: fd == NULL && ofd != NULL */ - if (copyFile(&fd, sigtarget, &ofd, trpm)) - goto exit; - /* Both fd and ofd are now closed. */ - /* ASSERT: fd == NULL && ofd == NULL */ - - /* Move final target into place, restore file permissions. */ - { - struct stat st; - xx = stat(rpm, &st); - xx = unlink(rpm); - xx = rename(trpm, rpm); - xx = chmod(rpm, st.st_mode); - } + /* Write the lead/signature of the output rpm */ + rc = rpmLeadWrite(ofd, lead); + lead = rpmLeadFree(lead); + if (rc != RPMRC_OK) { + rpmlog(RPMLOG_ERR, _("%s: writeLead failed: %s\n"), trpm, + Fstrerror(ofd)); + goto exit; + } + + if (rpmWriteSignature(ofd, sigh)) { + rpmlog(RPMLOG_ERR, _("%s: rpmWriteSignature failed: %s\n"), trpm, + Fstrerror(ofd)); + goto exit; + } + + /* Append the header and archive from the temp file */ + /* ASSERT: fd == NULL && ofd != NULL */ + if (copyFile(&fd, sigtarget, &ofd, trpm)) + goto exit; + /* Both fd and ofd are now closed. */ + /* ASSERT: fd == NULL && ofd == NULL */ + + /* Move final target into place, restore file permissions. */ + { + struct stat st; + xx = stat(rpm, &st); + xx = unlink(rpm); + xx = rename(trpm, rpm); + xx = chmod(rpm, st.st_mode); } res = 0; |