8 #if defined(HAVE_MACHINE_TYPES_H)
9 # include <machine/types.h>
12 #include <netinet/in.h>
14 #define _RPMIOB_INTERNAL
20 #define _RPMHKP_INTERNAL
24 #define _RPMTAG_INTERNAL
30 #define _RPMTS_INTERNAL
63 #define timedRead (ufdio->read)
79 const void * uh = NULL;
85 fprintf(stderr,
"--> rpmWriteHeader(%p, %p, %p)\n", fd, h, msg);
89 *msg =
xstrdup(
_(
"write of NULL header"));
96 *msg =
xstrdup(
_(
"headerUnload failed"));
100 {
unsigned char * hmagic = NULL;
104 nb =
Fwrite(hmagic,
sizeof(hmagic[0]), nmagic, fd);
105 if (nb != nmagic ||
Ferror(fd)) {
108 ?
xstrdup(
_(
"short write of header magic"))
115 nb =
Fwrite(uh,
sizeof(
char), length, fd);
117 if (nb != length ||
Ferror(fd)) {
120 ?
xstrdup(
_(
"short write of header"))
137 if (ts != NULL && (
int)opx >= 0 && (
int)opx <
RPMTS_OP_MAX)
164 static const char * _dbpath = NULL;
170 const char * pubkeysource = NULL;
179 fprintf(stderr,
"--> %s(%p,%p)\n", __FUNCTION__, ts, _dig);
182 assert(sigp != NULL);
183 assert(pubp != NULL);
194 fprintf(stderr,
"==> find sig id %08x %08x ts pubkey id %08x %08x\n",
200 if (memcmp(sigp->signid, hkp->signid,
sizeof(hkp->signid))) {
203 fprintf(stderr,
"*** free pkt %p[%d] id %08x %08x\n", hkp->pkt, hkp->pktlen,
pgpGrab(hkp->signid, 4),
pgpGrab(hkp->signid+4, 4));
205 hkp->pkt =
_free(hkp->pkt);
207 memset(hkp->signid, 0,
sizeof(hkp->signid));
211 if (hkp->pkt == NULL && awol != NULL
212 &&
rpmbfChk(awol, sigp->signid,
sizeof(sigp->signid)))
216 if (hkp->pkt == NULL) {
228 memcpy(
xmalloc(iob->blen), iob->b, iob->blen);
229 hkp->pktlen = iob->blen;
230 pubkeysource =
xstrdup(
"keyutils");
235 fprintf(stderr,
"\t%s: rpmku %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
241 if (hkp->pkt == NULL && *_dbpath !=
'\0') {
242 unsigned hx = 0xffffffff;
243 unsigned ix = 0xffffffff;
248 if (ts->rdb == NULL) {
249 xx =
rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, (mode_t)0644);
252 _(
"cannot open Packages database in %s\n"), _dbpath);
270 if (b64decode(he->
p.
argv[ix], (
void **)&hkp->pkt, &hkp->pktlen))
279 if (ix < 0xffffffff) {
281 sprintf(hnum,
"h#%u[%u]", hx, ix);
285 hkp->pkt =
_free(hkp->pkt);
289 fprintf(stderr,
"\t%s: rpmdb %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
293 if (hkp->pkt == NULL && dig->pub && dig->publen > 0) {
297 if (!memcmp(sigp->signid, keyid,
sizeof(keyid))) {
298 hkp->pkt = (uint8_t *) dig->pub; dig->pub = NULL;
299 hkp->pktlen = dig->publen; dig->publen = 0;
300 pubkeysource =
xstrdup(
"package");
303 fprintf(stderr,
"\t%s: auto %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
308 if (hkp->pkt == NULL) {
309 const char * fn =
rpmExpand(
"%{_hkp_keyserver_query}",
"0x",
310 pgpHexStr(sigp->signid,
sizeof(sigp->signid)), NULL);
312 xx = (fn && *fn !=
'%')
317 hkp->pkt =
_free(hkp->pkt);
321 pubkeysource =
xstrdup(
"keyserver");
325 fprintf(stderr,
"\t%s: rpmhkp %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
330 if (hkp->pkt == NULL) {
331 const char * fn =
rpmExpand(
"%{_gpg_pubkey}", NULL);
334 if (fn && *fn !=
'%')
338 hkp->pkt =
_free(hkp->pkt);
341 pubkeysource =
xstrdup(
"macro");
347 if (hkp->pkt == NULL || hkp->pktlen == 0)
350 fprintf(stderr,
"\t%s: match %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
353 hkp->pkts =
_free(hkp->pkts);
355 xx =
pgpGrabPkts(hkp->pkt, hkp->pktlen, &hkp->pkts, &hkp->npkts);
359 memcpy(pubp->signid, hkp->keyid,
sizeof(pubp->signid));
377 fprintf(stderr,
"*** rpmhkpValidate: validate %d rc %d\n", validate, rc);
384 xx =
rpmhkpFindKey(hkp, dig, sigp->signid, sigp->pubkey_algo);
392 if (sigp->pubkey_algo == pubp->pubkey_algo
393 && !memcmp(sigp->signid, pubp->signid,
sizeof(sigp->signid)) )
400 iob->b = (
rpmuint8_t *)memcpy(iob->b, hkp->pkt, iob->blen);
404 fprintf(stderr,
"\t%s: rpmku %p[%u]\n", __FUNCTION__, hkp->pkt, (
unsigned) hkp->pktlen);
408 memcpy(hkp->signid, pubp->signid,
sizeof(hkp->signid));
421 pubkeysource =
_free(pubkeysource);
423 hkp->pkt =
_free(hkp->pkt);
426 xx =
rpmbfAdd(awol, sigp->signid,
sizeof(sigp->signid));
434 fprintf(stderr,
"<-- %s(%p,%p) res %d\n", __FUNCTION__, ts, _dig, res);
444 if (ts->dig == NULL) {
495 0xed, 0xab, 0xee, 0xdb, 0x00, 0x00, 0x00, 0x00
515 fprintf(stderr,
"--> wrLead(%p, %p, %p)\n", fd, ptr, msg);
517 memcpy(&l, ptr,
sizeof(l));
520 if ((
int)l.
major == 0)
521 l.
major = (
unsigned char) 3;
525 (void) strncpy(l.
name, *msg,
sizeof(l.
name));
527 memcpy(&l.
magic, lead_magic,
sizeof(l.
magic));
528 l.
type = (
unsigned short) htons(l.
type);
533 if (
Fwrite(&l, 1,
sizeof(l), fd) !=
sizeof(l))
559 fprintf(stderr,
"--> rdLead(%p, %p, %p)\n", fd, ptr, msg);
562 if (leadp != NULL) *leadp = NULL;
565 if ((xx = (
int)
timedRead(fd, (
char *)l,
sizeof(*l))) != (
int)
sizeof(*l)) {
568 _(
"lead size(%u): BAD, read(%d), %s(%d)"),
573 _(
"lead size(%u): BAD, read(%d), %s(%d)"),
574 (unsigned)
sizeof(*l), xx, strerror(
errno),
errno);
582 unsigned char * bh = (
unsigned char *)l;
583 if (bh[0] ==
'x' && bh[1] ==
'a' && bh[2] ==
'r' && bh[3] ==
'!') {
595 unsigned char *
b = NULL;
597 const char item[] =
"Lead";
600 _(
"XAR file not found (or no XAR support)"));
605 if (nb !=
sizeof(*l)) {
607 _(
"lead size(%u): BAD, xar read(%u)"),
608 (unsigned)
sizeof(*l), (unsigned)nb);
617 l->
type = (
unsigned short) ntohs(l->
type);
622 if (memcmp(l->
magic, lead_magic,
sizeof(l->
magic))) {
633 _(
"lead version(%u): UNSUPPORTED"), (unsigned) l->
major);
652 if (rc ==
RPMRC_OK && leadp != NULL)
657 if (msg != NULL && buf[0] !=
'\0') {
658 buf[
sizeof(buf)-1] =
'\0';
679 static unsigned char zero[8]
680 = {
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0',
'\0' };
686 fprintf(stderr,
"--> wrSignature(%p, %p, %p)\n", fd, ptr, msg);
693 pad = (8 - (sigSize % 8)) % 8;
695 if (
Fwrite(zero,
sizeof(zero[0]), pad, fd) != pad)
714 struct stat sb, * st = &sb;
721 if (fdno == 123456789) {
724 st->st_size -= nl + siglen + pad + datalen;
728 if (
Fstat(fd, st) < 0)
731 expected = nl + siglen + pad + datalen;
733 D_(
"Expected size: %12lu = lead(%u)+sigs(%u)+pad(%u)+data(%lu)\n"),
734 (
unsigned long)expected,
735 (
unsigned)nl, (
unsigned) siglen, (
unsigned) pad,
736 (
unsigned long)datalen);
738 D_(
" Actual size: %12lu\n"), (
unsigned long)st->st_size);
768 memset(
alloca(
sizeof(*entry)), 0,
sizeof(*entry));
770 memset(
alloca(
sizeof(*info)), 0,
sizeof(*info));
771 unsigned char * dataStart;
772 unsigned char * dataEnd = NULL;
780 fprintf(stderr,
"--> rdSignature(%p, %p, %p)\n", fd, ptr, msg);
786 memset(block, 0,
sizeof(block));
788 const char item[] =
"Signature";
791 _(
"XAR file not found (or no XAR support)"));
797 if ((xx = (
int)
timedRead(fd, (
char *)block,
sizeof(block))) != (int)
sizeof(block)) {
799 _(
"sigh size(%d): BAD, read returned %d"), (int)
sizeof(block), xx);
803 {
unsigned char * hmagic = NULL;
808 if (memcmp(block, hmagic, nmagic)) {
809 unsigned char * x = (
unsigned char *)block;
811 (void)
snprintf(buf,
sizeof(buf),
_(
"sigh magic: BAD, read %02x%02x%02x%02x%02x%02x%02x%02x"), x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]);
819 _(
"sigh tags: BAD, no. of tags(%u) out of range"), (unsigned) il);
825 _(
"sigh data: BAD, no. of bytes(%u) out of range"), (unsigned) dl);
833 size_t pvlen = (
sizeof(il) +
sizeof(dl) + nb);
834 static const int prot = PROT_READ | PROT_WRITE;
835 static const int flags = MAP_PRIVATE| MAP_ANONYMOUS;
836 static const int fdno = -1;
837 static const off_t off = 0;
839 ei = (
rpmuint32_t *) mmap(NULL, pvlen, prot, flags, fdno, off);
840 assert(ei != NULL && ei != (
void *)-1);
841 if (ei == NULL || ei == (
void *)-1)
843 "==> mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n",
844 NULL, (
unsigned)pvlen, prot, flags, fdno, (
unsigned)off,
847 size_t pvlen = (
sizeof(il) +
sizeof(dl) + nb);
851 if ((xx = (
int)
timedRead(fd, (
char *)&ei[2], nb)) != (
int) nb) {
853 _(
"sigh blob(%u): BAD, read returned %d"), (unsigned) nb, xx);
860 size_t pvlen = (
sizeof(il) +
sizeof(dl) + nb);
861 if (mprotect(ei, pvlen, PROT_READ) != 0)
862 fprintf(stderr,
"==> mprotect(%p[%u],0x%x) error(%d): %s\n",
863 ei, (
unsigned)pvlen, PROT_READ,
864 errno, strerror(errno));
868 dataStart = (
unsigned char *) (pe + il);
874 _(
"tag[%d]: BAD, tag %u type %u offset %d count %u"),
889 _(
"region tag: BAD, tag %u type %u offset %d count %u"),
903 _(
"region offset: BAD, tag %u type %u offset %d count %u"),
917 memcpy(dataEnd, &stag,
sizeof(stag));
928 _(
"region trailer: BAD, tag %u type %u offset %d count %u"),
934 memset(info, 0,
sizeof(*info));
938 if ((entry->
info.
offset %
sizeof(*pe)) || ril > il) {
940 _(
"region size: BAD, ril(%u) > il(%u)"), (unsigned) ril, (
unsigned) il);
946 memset(info, 0,
sizeof(*info));
947 for (i = 1; i < (unsigned) il; i++) {
951 _(
"sigh tag[%u]: BAD, tag %u type %u offset %d count %u"),
961 (void)
snprintf(buf,
sizeof(buf),
_(
"sigh load: BAD"));
972 size_t pad = (8 - (sigSize % 8)) % 8;
975 if (pad && (xx = (
int)
timedRead(fd, (
char *)block, pad)) != (
int) pad)
978 _(
"sigh pad(%u): BAD, read %d bytes"), (unsigned) pad, xx);
987 size_t datasize = he->
p.
ui32p[0];
988 rc =
printSize(fd, sigSize, pad, datasize);
991 _(
"sigh sigSize(%u): BAD, Fstat(2) failed"), (unsigned) sigSize);
999 if (sighp && sigh && rc ==
RPMRC_OK)
1005 buf[
sizeof(buf)-1] =
'\0';
1021 const unsigned char * dataStart = (
const unsigned char *) (pe + il);
1023 unsigned char *
b = NULL;
1043 b = (
unsigned char *) ildl;
1048 b = (
unsigned char *) pe;
1049 nb = (size_t) (htonl(ildl[0]) *
sizeof(*pe));
1053 b = (
unsigned char *) dataStart;
1054 nb = (size_t) htonl(ildl[1]);
1085 size_t pvlen =
sizeof(ildl) + (il *
sizeof(*pe)) + dl;
1086 const unsigned char * dataStart = (
const unsigned char *) (pe + il);
1088 memset(
alloca(
sizeof(*entry)), 0,
sizeof(*entry));
1090 memset(
alloca(
sizeof(*info)), 0,
sizeof(*info));
1091 const void * sig = NULL;
1096 const unsigned char * regionEnd = NULL;
1104 fprintf(stderr,
"--> headerCheck(%p, %p[%u], %p)\n", dig, uh, (
unsigned) uc, msg);
1109 if (uc > 0 && pvlen != uc) {
1111 _(
"blob size(%d): BAD, 8 + 16 * il(%u) + dl(%u)"),
1112 (int)uc, (
unsigned)il, (unsigned)dl);
1120 _(
"tag[%d]: BAD, tag %u type %u offset %d count %u"),
1138 _(
"region tag: BAD, tag %u type %u offset %d count %u"),
1148 _(
"region offset: BAD, tag %u type %u offset %d count %u"),
1167 _(
"region trailer: BAD, tag %u type %u offset %d count %u"),
1173 memset(info, 0,
sizeof(*info));
1177 if ((entry->
info.
offset %
sizeof(*pe)) || ril > il) {
1179 _(
"region size: BAD, ril(%u) > il(%u)"), (unsigned) ril, (
unsigned)il);
1184 for (i = ril; i < (unsigned) il; i++) {
1188 _(
"tag[%u]: BAD, tag %u type %u offset %d count %u"),
1189 (unsigned) i, (
unsigned) entry->
info.
tag, (unsigned) entry->
info.
type,
1196 {
const unsigned char *
b;
1200 for (b = dataStart + entry->
info.
offset; *b !=
'\0'; b++) {
1201 if (strchr(
"0123456789abcdefABCDEF", *b) == NULL)
1207 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr SHA1: BAD, not hex"));
1210 if (info->
tag == 0) {
1211 *info = entry->
info;
1219 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr RSA: BAD, not binary"));
1222 *info = entry->
info;
1223 siglen = info->
count;
1229 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr DSA: BAD, not binary"));
1232 *info = entry->
info;
1233 siglen = info->
count;
1239 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr ECDSA: BAD, not binary"));
1242 *info = entry->
info;
1243 siglen = info->
count;
1254 buf[
sizeof(buf)-1] =
'\0';
1257 fprintf(stderr,
"<-- headerCheck #1: rc %d \"%s\"\n", rc, (msg ? *msg:
""));
1262 if (info->
tag == 0) {
1266 _(
"tag[%d]: BAD, tag %u type %u offset %d count %u"),
1271 (void)
snprintf(buf,
sizeof(buf),
"Header sanity check: OK");
1274 buf[
sizeof(buf)-1] =
'\0';
1277 fprintf(stderr,
"<-- headerCheck #2: rc %d \"%s\"\n", rc, (msg ? *msg:
""));
1282 assert(dig != NULL);
1285 sig = memcpy(
xmalloc(siglen), dataStart + info->
offset, siglen);
1295 switch (info->
tag) {
1298 pleft = info->
count;
1305 _(
"skipping header with unverifiable V%u signature\n"),
1306 (
unsigned) dig->signature.version);
1311 xx =
hBlobDigest(uh, dig, dig->signature.hash_algo,
1312 regionEnd, ril, &dig->hrsa);
1317 pleft = info->
count;
1324 _(
"skipping header with unverifiable V%u signature\n"),
1325 (
unsigned) dig->signature.version);
1330 xx =
hBlobDigest(uh, dig, dig->signature.hash_algo,
1331 regionEnd, ril, &dig->hdsa);
1336 pleft = info->
count;
1343 _(
"skipping header with unverifiable V%u signature\n"),
1344 (
unsigned) dig->signature.version);
1349 xx =
hBlobDigest(uh, dig, dig->signature.hash_algo,
1350 regionEnd, ril, &dig->hecdsa);
1357 regionEnd, ril, &dig->hdsa);
1368 buf[
sizeof(buf)-1] =
'\0';
1372 fprintf(stderr,
"<-- headerCheck #3: rc %d \"%s\"\n", rc, (msg ? *msg:
""));
1385 assert(ptr != NULL);
1386 memcpy(p, ptr,
sizeof(p));
1387 return (8 + 8 + 16 * ntohl(p[2]) + ntohl(p[3]));
1439 const char * origin = NULL;
1445 fprintf(stderr,
"--> rpmReadHeader(%p, %p, %p)\n", fd, hdrp, msg);
1458 memset(block, 0,
sizeof(block));
1460 const char item[] =
"Header";
1463 _(
"XAR file not found (or no XAR support)"));
1470 if ((xx = (
int)
timedRead(fd, (
char *)block,
sizeof(block))) != (int)
sizeof(block)) {
1476 _(
"hdr size(%u): BAD, read returned %d"), (
unsigned)
sizeof(block), xx);
1483 if (memcmp(block, b, nb)) {
1484 unsigned char * x = (
unsigned char *) block;
1486 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr magic: BAD, read %02x%02x%02x%02x%02x%02x%02x%02x"), x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7]);
1494 _(
"hdr tags: BAD, no. of tags(%u) out of range"), (unsigned) il);
1501 _(
"hdr data: BAD, no. of bytes(%u) out of range\n"), (unsigned) dl);
1508 uc =
sizeof(il) +
sizeof(dl) + nb;
1510 static const int prot = PROT_READ | PROT_WRITE;
1511 static const int flags = MAP_PRIVATE| MAP_ANONYMOUS;
1512 static const int fdno = -1;
1513 static const off_t off = 0;
1515 ei = (
rpmuint32_t *) mmap(NULL, uc, prot, flags, fdno, off);
1516 assert(ei != NULL && ei != (
void *)-1);
1517 if (ei == NULL || ei == (
void *)-1)
1519 "==> mmap(%p[%u], 0x%x, 0x%x, %d, 0x%x) error(%d): %s\n",
1520 NULL, (
unsigned)uc, prot, flags, fdno, (
unsigned)off,
1526 if ((xx = (
int)
timedRead(fd, (
char *)&ei[2], nb)) != (int) nb) {
1528 _(
"hdr blob(%u): BAD, read returned %d"), (unsigned)nb, xx);
1535 if (mprotect(ei, uc, PROT_READ) != 0)
1536 fprintf(stderr,
"==> mprotect(%p[%u],0x%x) error(%d): %s\n",
1537 ei, (
unsigned)uc, PROT_READ,
1538 errno, strerror(errno));
1549 (void)
snprintf(buf,
sizeof(buf),
_(
"hdr load: BAD\n"));
1562 if (origin != NULL) {
1563 const char * lpath = NULL;
1564 int ut =
urlPath(origin, &lpath);
1566 if (lpath && *lpath !=
'/') {
1567 char * rpath =
Realpath(origin, NULL);
1569 rpath =
_free(rpath);
1576 (void)
Fstat(fd, st);
1586 if (ei != NULL && uc > 0) {
1588 if (munmap(ei, uc) != 0)
1589 fprintf(stderr,
"==> munmap(%p[%u]) error(%d): %s\n",
1599 if (msg != NULL && *msg == NULL && buf[0] !=
'\0') {
1600 buf[
sizeof(buf)-1] =
'\0';
1605 fprintf(stderr,
"<-- rpmReadHeader: rc %d \"%s\"\n", rc, (msg ? *msg:
""));
1650 if (!strcmp(fn,
"Lead"))
1653 if (!strcmp(fn,
"Signature")) {
1655 len += ((8 - (len % 8)) % 8);
1657 if (!strcmp(fn,
"Header"))
1669 if (!strcmp(fn,
"Header"))
1681 if (!strcmp(fn,
"Lead"))
1682 rc =
rdLead(fd, ptr, msg);
1684 if (!strcmp(fn,
"Signature"))
1687 if (!strcmp(fn,
"Header"))
1699 if (!strcmp(fn,
"Lead"))
1700 rc =
wrLead(fd, ptr, msg);
1702 if (!strcmp(fn,
"Signature"))
1705 if (!strcmp(fn,
"Header"))
Structure(s)and methods for a XAR archive wrapper format.
void _rpmhkpDumpDig(const char *msg, pgpDig dig, FILE *fp)
pgpDigParams pgpGetPubkey(pgpDig dig)
Return OpenPGP pubkey parameters.
rpmtime_t rpmswExit(rpmop op, ssize_t rc)
Exit timed operation.
int pgpSetFindPubkey(pgpDig dig, int(*findPubkey)(void *ts, void *dig), void *_ts)
Set find pubkey vector.
int rpmhkpFindKey(rpmhkp hkp, pgpDig dig, const rpmuint8_t *signid, rpmuint8_t pubkey_algo)
rpmRC rpmhkpValidate(rpmhkp hkp, const char *keyname)
Retrieve/Validate binding and certification signatures on a pubkey.
pgpDig pgpDigFree(pgpDig dig)
Destroy a container for parsed OpenPGP packates.
const char const char size_t len
const char bson_timestamp_t * ts
static rpmRC wrHeader(FD_t fd, void *ptr, const char **msg)
Write metadata header.
int pgpPktLen(const rpmuint8_t *pkt, size_t pleft, pgpPkt pp)
static size_t szHeader(const void *ptr)
Return size of Header.
static rpmRC rdSignature(FD_t fd, void *ptr, const char **msg)
Read (and verify header+payload size) signature header.
rpmRC rpmpkgWrite(const char *fn, FD_t fd, void *ptr, const char **msg)
Write item onto file descriptor.
const void * pgpGetSig(pgpDig dig)
Get signature tag data, i.e.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd)
fwrite(3) clone.
char * xstrdup(const char *str)
struct pgpDigParams_s * pgpDigParams
DIGEST_CTX rpmDigestInit(pgpHashAlgo hashalgo, rpmDigestFlags flags)
Initialize digest context.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
static const char * fdGetOPath(FD_t fd)
struct headerToken_s * Header
static unsigned int pgpGrab(const rpmuint8_t *s, size_t nbytes)
Return (native-endian) integer from big-endian representation.
enum pgpHashAlgo_e pgpHashAlgo
9.4.
rpmhkp rpmhkpNew(const rpmuint8_t *keyid, uint32_t flags)
Create a new hkp handle.
static pgpDig fdGetDig(FD_t fd)
int rpmxarNext(rpmxar xar)
Iterate a xar archive instance.
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
static rpmVSFlags vsflags
rpmRC headerCheck(pgpDig dig, const void *uh, size_t uc, const char **msg)
Check header consistency, performing headerGet() the hard way.
int pgpSetSig(pgpDig dig, rpmuint32_t sigtag, rpmuint32_t sigtype, const void *sig, rpmuint32_t siglen)
Set signature tag info, i.e.
enum rpmtsOpX_e rpmtsOpX
Indices for timestamps.
pgpDig pgpDigLink(pgpDig dig)
Reference a signature parameters instance.
static void rpmlog(int code, const char *fmt,...)
rpmhkp rpmhkpFree(rpmhkp hkp)
Destroy a hkp handle.
rpmRC rpmpkgCheck(const char *fn, FD_t fd, const void *ptr, const char **msg)
Verify item integrity.
pgpDigParams rpmtsPubkey(const rpmts ts)
Return OpenPGP pubkey constants.
rpmmi rpmmiInit(rpmdb db, rpmTag tag, const void *keyp, size_t keylen)
Return database iterator.
int Fstat(FD_t fd, struct stat *st)
fstat(2) clone.
static rpmRC rpmWriteHeader(FD_t fd, Header h, const char **msg)
Write (with unload) header to file handle.
pgpArmor pgpReadPkts(const char *fn, rpmuint8_t **pkt, size_t *pktlen)
Parse armored OpenPGP packets from a file.
pgpVSFlags pgpDigVSFlags
Disabler bits(s) for signature/digest checking.
const char * Fstrerror(FD_t fd)
strerror(3) clone.
void * xcalloc(size_t nmemb, size_t size)
int rpmDigestUpdate(DIGEST_CTX ctx, const void *data, size_t len)
Update context with next plain text buffer.
rpmbf rpmbfFree(rpmbf bf)
Destroy a Bloom filter.
static const char * _pgpPubkeyAlgo2Name(uint32_t algo)
static void fdSetDig(FD_t fd, pgpDig dig)
int rpmxarPull(rpmxar xar, const char *fn)
rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
Retrieve operation timestamp from a transaction set.
void rpmtsCleanDig(rpmts ts)
Free signature verification data.
static rpmRC wrLead(FD_t fd, const void *ptr, const char **msg)
Write lead to file handle.
size_t rpmpkgSizeof(const char *fn, const void *ptr)
Return size of item in bytes.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
static rpmRC rdHeader(FD_t fd, void *ptr, const char **msg)
Read metadata header.
static rpmRC rpmReadHeader(FD_t fd, Header *hdrp, const char **msg)
Return checked and loaded header.
pgpDigParams pgpGetSignature(pgpDig dig)
Return OpenPGP signature parameters.
static int hBlobDigest(const void *uh, pgpDig dig, pgpHashAlgo hash_algo, const unsigned char *regionEnd, rpmuint32_t ril, DIGEST_CTX *ctxp)
int rpmdbOpen(const char *prefix, rpmdb *dbp, int mode, mode_t perms)
Open rpm database.
static void fdSetXAR(FD_t fd, rpmxar xar)
unsigned short signature_type
The FD_t File Handle data structure.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
Generate and verify rpm package signatures.
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Header headerFree(Header h)
Dereference a header instance.
rpmRC rpmVerifySignature(void *_dig, char *result)
Verify a signature from a package.
int rpmswEnter(rpmop op, ssize_t rc)
Enter timed operation.
const char const bson const bson * op
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static rpmRC ckHeader(FD_t fd, const void *ptr, const char **msg)
Check metadata header.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
Cumulative statistics for an operation.
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
const char const bson int mongo_write_concern int flags
Header headerLink(Header h)
Reference a header instance.
int pgpGrabPkts(const rpmuint8_t *pkts, size_t pktlen, rpmuint8_t ***pppkts, int *pnpkts)
Return array of packet pointers.
enum pgpPubkeyAlgo_e pgpPubkeyAlgo
9.1.
rpmdb rpmtsGetRdb(rpmts ts)
Get transaction set database handle.
enum rpmRC_e rpmRC
RPM return codes.
pgpDig pgpDigNew(pgpVSFlags vsflags, pgpPubkeyAlgo pubkey_algo)
Create a container for parsed OpenPGP packates.
rpmhkp rpmhkpLink(rpmhkp hkp)
Reference a hkp handle instance.
int Ferror(FD_t fd)
ferror(3) clone.
rpmRC rpmkuFindPubkey(pgpDigParams sigp, rpmiob *iobp)
Lookup pubkey in keyutils keyring.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
static unsigned char lead_magic[]
static int snprintf(char *buf, int nb, const char *fmt,...)
Methods to handle package elements.
int pgpPubkeyFingerprint(const rpmuint8_t *pkt, size_t pktlen, rpmuint8_t *keyid)
Print/parse an OpenPGP subtype packet.
int rpmxarSwapBuf(rpmxar xar, unsigned char *b, size_t bsize, unsigned char **obp, size_t *obsizep)
struct rpmts_s * rpmts
The RPM Transaction Set.
pgpDig rpmtsDig(rpmts ts)
Get OpenPGP packet parameters, i.e.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Structures and prototypes used for an "rpmts" transaction set.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
static rpmxar fdGetXAR(FD_t fd)
rpmRC rpmtsFindPubkey(rpmts ts, void *_dig)
Retrieve pubkey from rpm database.
static rpmRC wrSignature(FD_t fd, void *ptr, const char **msg)
Write signature header.
int rpmbfAdd(rpmbf bf, const void *_s, size_t ns)
Add item to a Bloom filter.
rpmbf rpmbfLink(rpmbf bf)
Reference a Bloom filter instance.
int Fileno(FD_t fd)
fileno(3) clone.
rpmxar rpmxarFree(rpmxar xar, const char *msg)
Destroy a xar archive instance.
rpmRC rpmpkgRead(const char *fn, FD_t fd, void *ptr, const char **msg)
Read item from file descriptor.
Access RPM indices using Berkeley DB interface(s).
static char * pgpHexStr(const rpmuint8_t *p, size_t plen)
Return hex formatted representation of bytes.
static rpmRC printSize(FD_t fd, size_t siglen, size_t pad, size_t datalen)
Print package size.
static rpmRC rdLead(FD_t fd, void *ptr, const char **msg)
Read lead from file handle.
void * pgpStatsAccumulator(pgpDig dig, int opx)
Return pgpDig container accumulator structure.
rpmxar rpmxarNew(const char *fn, const char *fmode)
Create a xar archive instance.
char * Realpath(const char *path, char *resolved_path)
realpath(3) clone.
rpmRC rpmkuStorePubkey(pgpDigParams sigp, rpmiob iob)
Store pubkey in keyutils keyring.
int rpmhkpLoadSignature(rpmhkp hkp, pgpDig dig, pgpPkt pp)
int rpmbfChk(rpmbf bf, const void *_s, size_t ns)
Check for item in a Bloom filter.