Up to commit 45c2f3ffa6 we were still
using the lead to confirm source vs binary package, but now we dont
need even that. Means the zombie data structure that's supposedly been
dead for the last 20+ years is truly gone now. We still dutifully
read/write and validate it, but no actual data from it is used.
Fix sneaky regression from commit 83a8640b47,
the lead used to be calloc()'ed so it was guaranteed all zeros, now its not.
Bulldoze to zero with memset() instead.
Since rpmLeadWrite() takes a header there's no more need for
rpmLeadFromHeader() to be "public" and since nothing returns
leads there's no need to free them either, make static + adjust
to eliminate the need for ever allocating a lead so the free func
can go too. Whee. the remaining rpmlead.h is something we could
actually consider making public.
The only "user" of the lead data structure is the signing code
which just wants to copy it over to the signed package. We can
just as well regenerate it from the header. Even if it doesn't
end up identical (which it should), it doesn't make a damnest
difference because nothing that matters looks at the lead anyway.
Header signatures were the new hot almost exactly twenty years ago, we
haven't supported anything else in a very, very, very, very very long time.
Drop the useless argument to rpmReadSignature() and bury the last remaining
related constant into rpmlead.c which is the only place that "needs" it.
No functional changes.
- There are no guarantees Fread() will return all of the requested size:
it can return partial data eg on signals and pipe descriptors. Introduce
a helper function to handle this centrally for all package read IO,
effectively reintroducing timedRead() but without the caveats:
timedRead() did not work on compressed streams, did not handle
eg EINTR correctly and while really being an internal helper,
was exported in the API.
- 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...)
- Requiring callers to allocate a lead "buffer" for reading into
is just DUMB (greetings to self back in 2008, sigh). This avoids
having to deal with freeing the lead in case the read failed, and
allows getting rid of rpmLeadNew() completely.
- rpmLeadNew() should not populate the struct, only allocate it
- The only case where we're creating new lead data is
rpmLeadFromHeader(), move all initialization there, and add a comment
for RhBug:717898. Also eliminate the stupid assert, we can
easily handle NULL header here.
- allows silent checking of lead and differentiating between
non-rpm files and incompatible rpms, avoiding bogus "not an rpm package"
message on manifests
- put some consistency into include ordering
- everything (apart from bits missed ;) is now ordered like this
1. "system.h"
2. other system includes
3. rpm public headers
4. rpm private headers
5. "debug.h"
- rename methods to rpmLead*() for easy grepping
- populate lead from header where necessary
- add rpmLeadCheck() method for minimal compatibility checking to get
rid of duplicate code in several places
- conditionalize lead version on dirtokens