diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-05-08 19:46:34 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-05-08 19:46:34 +0200 |
commit | 2fac0dd5a7a62b67a869cd4c71c9d09159aaa31d (patch) | |
tree | 3749636ed93b8ed2d83be2e7b7e7997abafbf492 /methods/gpgv.cc | |
parent | 39c724b4848ef8d85c8c425f982dda85f0df1277 (diff) |
gpgv: show always webportal error on NODATA
gpg doesn't give use a UID on NODATA, which we were "expecting" (but not
using for anything), but just an error number. Instead of collecting
these as badsigners which will trigger a "invald signature" error with
remarks like "NODATA 1" we instead adapt a message similar to the NODATA
error of a clearsigned file (which is actually not reached anymore as we
split them up, which fails with a NOSPLIT error, which uses the same
general error message).
In other words: Not a security relevant change, just a user experience
improvement as we now point them to the most likely cause of the
problem instead of saying "invalid signature" which would point them in
the direction of the archive being broken (for everyone) instead.
Closes: 823746
Diffstat (limited to 'methods/gpgv.cc')
-rw-r--r-- | methods/gpgv.cc | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/methods/gpgv.cc b/methods/gpgv.cc index b9fb09a8f..dd395d659 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -173,6 +173,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, std::vector<std::string> ErrSigners; size_t buffersize = 0; char *buffer = NULL; + bool gotNODATA = false; while (1) { if (getline(&buffer, &buffersize, pipein) == -1) @@ -194,8 +195,8 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, ErrSigners.erase(std::remove_if(ErrSigners.begin(), ErrSigners.end(), [&](std::string const &errsig) { return errsig.compare(strlen("ERRSIG "), 16, buffer, sizeof(GNUPGNOPUBKEY), 16) == 0; }), ErrSigners.end()); } - else if (strncmp(buffer, GNUPGNODATA, sizeof(GNUPGBADSIG)-1) == 0) - PushEntryWithUID(BadSigners, buffer, Debug); + else if (strncmp(buffer, GNUPGNODATA, sizeof(GNUPGNODATA)-1) == 0) + gotNODATA = true; else if (strncmp(buffer, GNUPGEXPKEYSIG, sizeof(GNUPGEXPKEYSIG)-1) == 0) PushEntryWithUID(WorthlessSigners, buffer, Debug); else if (strncmp(buffer, GNUPGEXPSIG, sizeof(GNUPGEXPSIG)-1) == 0) @@ -293,10 +294,26 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, std::for_each(SoonWorthlessSigners.begin(), SoonWorthlessSigners.end(), [](Signer const &sig) { std::cerr << sig.key << ", "; }); std::cerr << std::endl << " NoPubKey: "; std::copy(NoPubKeySigners.begin(), NoPubKeySigners.end(), std::ostream_iterator<std::string>(std::cerr, ", ")); - std::cerr << std::endl; + std::cerr << std::endl << " NODATA: " << (gotNODATA ? "yes" : "no") << std::endl; } - if (WEXITSTATUS(status) == 0) + if (WEXITSTATUS(status) == 112) + { + // acquire system checks for "NODATA" to generate GPG errors (the others are only warnings) + std::string errmsg; + //TRANSLATORS: %s is a single techy word like 'NODATA' + strprintf(errmsg, _("Clearsigned file isn't valid, got '%s' (does the network require authentication?)"), "NODATA"); + return errmsg; + } + else if (gotNODATA) + { + // acquire system checks for "NODATA" to generate GPG errors (the others are only warnings) + std::string errmsg; + //TRANSLATORS: %s is a single techy word like 'NODATA' + strprintf(errmsg, _("Signed file isn't valid, got '%s' (does the network require authentication?)"), "NODATA"); + return errmsg; + } + else if (WEXITSTATUS(status) == 0) { if (keyIsID) { @@ -316,14 +333,6 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, return _("At least one invalid signature was encountered."); else if (WEXITSTATUS(status) == 111) return _("Could not execute 'apt-key' to verify signature (is gnupg installed?)"); - else if (WEXITSTATUS(status) == 112) - { - // acquire system checks for "NODATA" to generate GPG errors (the others are only warnings) - std::string errmsg; - //TRANSLATORS: %s is a single techy word like 'NODATA' - strprintf(errmsg, _("Clearsigned file isn't valid, got '%s' (does the network require authentication?)"), "NODATA"); - return errmsg; - } else return _("Unknown error executing apt-key"); } |