10 #define _RPMEVR_INTERNAL
47 if (*fdp && (fnp == NULL || *fnp == NULL)) {
54 if (*fdp == NULL && fnp != NULL && *fnp != NULL) {
55 fd =
Fopen(*fnp, ((flags & O_WRONLY) ?
"w" :
"r"));
56 if (fd == NULL ||
Ferror(fd)) {
66 if (*fdp == NULL && (fnp == NULL || *fnp == NULL)) {
74 *fdp =
fdLink(fd,
"manageFile return");
75 fd =
fdFree(fd,
"manageFile return");
81 if (*fdp != NULL && fnp != NULL && *fnp != NULL)
94 FD_t *tfdp,
const char **tfnp)
100 unsigned char buf[BUFSIZ];
106 if (
manageFile(tfdp, tfnp, O_WRONLY|O_CREAT|O_TRUNC, 0))
109 while ((count =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), *sfdp)) > 0)
111 if (
Fwrite(buf,
sizeof(buf[0]), count, *tfdp) != count) {
130 if (*sfdp) (void)
manageFile(sfdp, NULL, 0, rc);
131 if (*tfdp) (void)
manageFile(tfdp, NULL, 0, rc);
152 if (
headerGetEntry(sig, sigtag, &pkttyp, &pkt, &pktlen) && pkt != NULL) {
176 QVA_t qva,
const char ** argv)
184 struct rpmlead lead, *l = &lead;
186 const char *rpm, *trpm;
187 const char *sigtarget = NULL;
202 while ((rpm = *argv++) != NULL)
206 fprintf(stdout,
"%s:\n", rpm);
212 memset(l, 0,
sizeof(*l));
237 (msg && *msg ? msg :
"\n"));
252 if (
copyFile(&fd, &rpm, &ofd, &sigtarget))
309 unsigned char oldsignid[8], newsignid[8];
312 memset(oldsignid, 0,
sizeof(oldsignid));
335 memset(newsignid, 0,
sizeof(newsignid));
336 if (memcmp(oldsignid, newsignid,
sizeof(oldsignid))) {
342 if (!memcmp(oldsignid, newsignid,
sizeof(oldsignid))) {
345 _(
"%s: was already signed by key ID %s, skipping\n"),
346 rpm,
pgpHexStr(newsignid+4,
sizeof(newsignid)-4));
349 xx = unlink(sigtarget);
350 sigtarget =
_free(sigtarget);
364 strcat(tmprpm,
".XXXXXX");
366 (void) mktemp(tmprpm);
369 if (
manageFile(&ofd, &trpm, O_WRONLY|O_CREAT|O_TRUNC, 0))
388 if (
copyFile(&fd, &sigtarget, &ofd, &trpm))
395 xx = rename(trpm, rpm);
399 xx = unlink(sigtarget);
400 sigtarget =
_free(sigtarget);
408 if (ofd) (void)
manageFile(&ofd, NULL, 0, res);
413 xx = unlink(sigtarget);
414 sigtarget =
_free(sigtarget);
416 if (tmprpm[0] !=
'\0') {
426 static unsigned char zeros[] =
427 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
428 const char * afmt =
"%{pubkeys:armor}";
429 const char * group =
"Public Keys";
430 const char * license =
"pubkey";
431 const char * buildhost =
"localhost";
436 const char * d = NULL;
437 const char * enc = NULL;
438 const char * n = NULL;
439 const char * u = NULL;
440 const char * v = NULL;
441 const char * r = NULL;
442 const char * evr = NULL;
448 if (pkt == NULL || pktlen <= 0)
453 if ((enc = b64encode(pkt, pktlen)) == NULL)
463 || !memcmp(pubp->
time, zeros,
sizeof(pubp->
time))
474 n = t =
xmalloc(
sizeof(
"gpg()")+8);
482 evr = t =
xmalloc(
sizeof(
"4X:-")+strlen(v)+strlen(r));
576 const unsigned char * pkt = NULL;
583 if (argv == NULL)
return res;
587 while ((fn = *argv++) != NULL) {
595 if (fn[0] ==
'0' && fn[1] ==
'x') {
598 for (i = 0, s = fn+2; *s && isxdigit(*s); s++, i++)
600 if (i == 8 || i == 16) {
601 t =
rpmExpand(
"%{_hkp_keyserver_query}", fn+2, NULL);
637 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
647 unsigned char buf[4*BUFSIZ];
686 while ((count =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), fd)) > 0)
694 for (i = fd->
ndigests - 1; i >= 0; i--) {
699 assert(dig->
md5ctx == NULL);
705 #if HAVE_BEECRYPT_API_H
729 struct rpmlead lead, *l = &lead;
732 char missingKeys[7164], * m;
733 char untrustedKeys[7164], * u;
751 memset(l, 0,
sizeof(*l));
774 (msg && *msg ? msg :
"\n"));
791 if (sigtag == 0 && !nosignatures) {
801 if (sigtag == 0 && !nodigests) {
814 xx =
headerGetEntry(sigh, sigtag, &sigtype, (
void **)&sig, &siglen);
832 if (dig == NULL || sigp == NULL ||
readFile(fd, fn, dig)) {
839 m = missingKeys; *m =
'\0';
840 u = untrustedKeys; *u =
'\0';
841 sprintf(b,
"%s:%c", fn, (
rpmIsVerbose() ?
'\n' :
' ') );
846 (void)
rpmtsSetSig(ts, sigtag, sigtype, NULL, siglen))
852 (void)
rpmtsSetSig(ts, sigtag, sigtype, sig, siglen);
870 _(
"skipping package %s with unverifiable V%u signature\n"),
937 b =
stpcpy(b,
"(MD5) (PGP) ");
938 tempKey = strstr(result,
"ey ID");
939 if (tempKey == NULL) {
940 tempKey = strstr(result,
"keyid:");
946 m =
stpncpy(m, tempKey + offset, 8);
950 u =
stpncpy(u, tempKey + offset, 8);
956 b =
stpcpy(b,
"MD5 PGP ");
962 b =
stpcpy(b,
"(SHA1) DSA ");
971 tempKey = strstr(result,
"ey ID");
985 b =
stpcpy(b,
"?UnknownSignatureType? ");
1012 b =
stpcpy(b,
"(md5) pgp ");
1015 b =
stpcpy(b,
"(sha1) dsa ");
1038 (missingKeys[0] !=
'\0') ?
_(
" (MISSING KEYS:") :
"",
1040 (missingKeys[0] !=
'\0') ?
_(
") ") :
"",
1041 (untrustedKeys[0] !=
'\0') ?
_(
" (UNTRUSTED KEYS:") :
"",
1043 (untrustedKeys[0] !=
'\0') ?
_(
")") :
"");
1052 (missingKeys[0] !=
'\0') ?
_(
" (MISSING KEYS:") :
"",
1054 (missingKeys[0] !=
'\0') ?
_(
") ") :
"",
1055 (untrustedKeys[0] !=
'\0') ?
_(
" (UNTRUSTED KEYS:") :
"",
1057 (untrustedKeys[0] !=
'\0') ?
_(
")") :
"");
1075 if (argv == NULL)
return res;
1094 while ((arg = *argv++) != NULL) {
1097 if ((fd =
Fopen(arg,
"r")) == NULL
1102 if (fd != NULL) xx =
Fclose(fd);