13 #define _RPMEVR_INTERNAL
53 if (*fdp && (fnp == NULL || *fnp == NULL)) {
60 if (*fdp == NULL && fnp != NULL && *fnp != NULL) {
61 fd =
Fopen(*fnp, ((flags & O_WRONLY) ?
"w.fdio" :
"r.fdio"));
62 if (fd == NULL ||
Ferror(fd)) {
72 if (*fdp == NULL && (fnp == NULL || *fnp == NULL)) {
81 *fdp =
fdLink(fd,
"manageFile return");
82 fd =
fdFree(fd,
"manageFile return");
88 if (*fdp != NULL && fnp != NULL && *fnp != NULL)
99 FD_t *tfdp,
const char **tfnp)
105 unsigned char buf[BUFSIZ];
111 if (
manageFile(tfdp, tfnp, O_WRONLY|O_CREAT|O_TRUNC, 0))
114 while ((count =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), *sfdp)) > 0)
116 if (
Fwrite(buf,
sizeof(buf[0]), count, *tfdp) != (
size_t)count) {
135 if (*sfdp) (void)
manageFile(sfdp, NULL, 0, rc);
136 if (*tfdp) (void)
manageFile(tfdp, NULL, 0, rc);
151 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
157 if (xx && he->
p.
ptr != NULL) {
161 memcpy(signid, dig->signature.signid,
sizeof(dig->signature.signid));
179 QVA_t qva,
const char ** argv)
185 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
191 const char *sigtarget = NULL;
194 const char * msg = NULL;
220 fprintf(stdout,
"%s:\n", fn);
227 {
const char item[] =
"Lead";
238 {
const char item[] =
"Signature";
244 (msg && *msg ? msg :
""));
261 if (
copyFile(&fd, &fn, &ofd, &sigtarget))
271 HE_t ohe = memset(
alloca(
sizeof(*ohe)), 0,
sizeof(*ohe));
316 size_t nsigs =
sizeof(sigs) /
sizeof(sigs[0]);
317 for (i = 0; i < (int)nsigs; i++) {
331 size_t nsigs =
sizeof(sigs) /
sizeof(sigs[0]);
332 for (i = 0; i < (int)nsigs; i++) {
342 unsigned char oldsignid[8], newsignid[8];
345 memset(oldsignid, 0,
sizeof(oldsignid));
379 memset(newsignid, 0,
sizeof(newsignid));
380 if (memcmp(oldsignid, newsignid,
sizeof(oldsignid))) {
386 if (!memcmp(oldsignid, newsignid,
sizeof(oldsignid))) {
389 _(
"%s: was already signed by key ID %s, skipping\n"),
390 fn,
pgpHexStr(newsignid+4,
sizeof(newsignid)-4));
394 sigtarget =
_free(sigtarget);
410 #if defined(HAVE_MKSTEMP)
411 (void) close(mkstemp(tmprpm));
413 (void) mktemp(tmprpm);
417 if (
manageFile(&ofd, &tfn, O_WRONLY|O_CREAT|O_TRUNC, 0))
420 {
const char item[] =
"Lead";
428 {
const char item[] =
"Signature";
438 if (
copyFile(&fd, &sigtarget, &ofd, &tfn))
450 sigtarget =
_free(sigtarget);
459 if (ofd) (void)
manageFile(&ofd, NULL, 0, res);
469 sigtarget =
_free(sigtarget);
471 if (tmprpm[0] !=
'\0') {
481 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
482 static unsigned char zeros[] =
483 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
484 const char * afmt =
"%{pubkeys:armor}";
485 const char * group =
"Public Keys";
486 const char * license =
"pubkey";
487 const char * buildhost =
"localhost";
492 const char * d = NULL;
493 const char * enc = NULL;
494 const char * n = NULL;
495 const char * u = NULL;
496 const char * v = NULL;
497 const char * r = NULL;
498 const char * evr = NULL;
504 if (pkt == NULL || pktlen <= 0)
510 if ((enc = b64encode(pkt, pktlen)) == NULL)
520 if (!memcmp(pubp->signid, zeros,
sizeof(pubp->signid))
521 || !memcmp(pubp->time, zeros,
sizeof(pubp->time))
522 || pubp->userid == NULL)
531 n = t =
xmalloc(
sizeof(
"gpg()")+8);
535 u = t =
xmalloc(
sizeof(
"gpg()")+strlen(pubp->userid));
539 evr = t =
xmalloc(
sizeof(
"4X:-")+strlen(v)+strlen(r));
540 t =
stpcpy(t, (pubp->version == 4 ?
"4:" :
"3:"));
579 #if defined(SUPPORT_IMPLICIT_TAG_DATA_TYPES)
588 #if defined(SUPPORT_IMPLICIT_TAG_DATA_TYPES)
597 #if defined(SUPPORT_IMPLICIT_TAG_DATA_TYPES)
607 he->
p.
str =
"pubkey";
610 he->
p.
str =
"pubkey";
747 if (argv == NULL)
return res;
749 while ((fn = *argv++) != NULL) {
756 if (fn[0] ==
'0' && fn[1] ==
'x') {
759 for (i = 0, s = fn+2; *s && isxdigit(*s); s++, i++)
761 if (i == 8 || i == 16) {
762 t =
rpmExpand(
"%{_hkp_keyserver_query}", fn+2, NULL);
804 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
805 unsigned char buf[4*BUFSIZ];
814 const char item[] =
"Header";
815 const char * msg = NULL;
827 unsigned char * hmagic = NULL;
832 if (!xx || he->
p.
ptr == NULL) {
836 _(
"failed to retrieve original header\n"));
842 if (hmagic && nmagic > 0)
846 if (hmagic && nmagic > 0)
856 const char item[] =
"Payload";
859 _(
"XAR file not found (or no XAR support)"));
866 while ((count =
Fread(buf,
sizeof(buf[0]),
sizeof(buf), fd)) > 0)
867 dig->nbytes += count;
868 if (count < 0 ||
Ferror(fd)) {
885 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
886 HE_t she = memset(
alloca(
sizeof(*she)), 0,
sizeof(*she));
892 char missingKeys[7164], * m;
893 char untrustedKeys[7164], * u;
898 const char * msg = NULL;
907 {
const char item[] =
"Lead";
921 {
const char item[] =
"Signature";
929 (msg && *msg ? msg :
""));
947 if (she->
tag == 0 && !nosignatures) {
953 if (she->
tag == 0 && !nodigests) {
981 if (dig == NULL || sigp == NULL
991 m = missingKeys; *m =
'\0';
992 u = untrustedKeys; *u =
'\0';
993 sprintf(b,
"%s:%c", fn, (
rpmIsVerbose() ?
'\n' :
' ') );
1002 assert(she->
p.
ptr != NULL);
1019 if (sigp->version != 3 && sigp->version != 4) {
1021 _(
"skipping package %s with unverifiable V%u signature\n"),
1064 b =
stpcpy(b,
"(SHA1) DSA ");
1067 b =
stpcpy(b,
"?UnknownSignatureType? ");
1088 b =
stpcpy(b,
"(sha1) dsa ");
1110 (missingKeys[0] !=
'\0') ?
_(
" (MISSING KEYS:") :
"",
1112 (missingKeys[0] !=
'\0') ?
_(
") ") :
"",
1113 (untrustedKeys[0] !=
'\0') ?
_(
" (UNTRUSTED KEYS:") :
"",
1115 (untrustedKeys[0] !=
'\0') ?
_(
")") :
"");
1124 (missingKeys[0] !=
'\0') ?
_(
" (MISSING KEYS:") :
"",
1126 (missingKeys[0] !=
'\0') ?
_(
") ") :
"",
1127 (untrustedKeys[0] !=
'\0') ?
_(
" (UNTRUSTED KEYS:") :
"",
1129 (untrustedKeys[0] !=
'\0') ?
_(
")") :
"");
1148 if (argv == NULL)
return res;
1183 fd =
Fopen(fn,
"r.fdio");
1184 if (fd == NULL ||
Ferror(fd)) {