Make gpg-pubkey buildtime reflect the public key create time
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Nov 2011 09:25:53 +0000 (11:25 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 24 Nov 2011 09:25:53 +0000 (11:25 +0200)
- Pubkey buildtime has until now been the time of import, which equals
  install time/tid. Which is of course the time when that header
  does get created, but it seems rather redundant to have the same
  thing recorded in three places. Having the key creation time
  easily (easier than un-hexifying the version string, duh)
  available seems like a potentially useful thing. Buildtime is
  "wrong" for this, but ... so is everything.
- With this change, the "meat" of the pubkey headers is now constant
  and repeatable regardless of where and when a key gets imported,
  so we could stomp a digest on it and it'd be unique for that
  particular key everywhere.

lib/rpmts.c

index 70caae5..afee2cd 100644 (file)
@@ -360,6 +360,7 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header h)
     const char * userid;
     rpmsenseFlags pflags = (RPMSENSE_KEYRING|RPMSENSE_EQUAL);
     uint32_t zero = 0;
+    uint32_t keytime = 0;
     pgpDig dig = NULL;
     pgpDigParams pubp = NULL;
     char * d = NULL;
@@ -382,6 +383,7 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header h)
     v = pgpHexStr(pubp->signid, sizeof(pubp->signid)); 
     r = pgpHexStr(pubp->time, sizeof(pubp->time));
     userid = pubp->userid ? pubp->userid : "none";
+    keytime = pgpGrab(pubp->time, sizeof(pubp->time));
 
     rasprintf(&n, "gpg(%s)", v+8);
     rasprintf(&u, "gpg(%s)", userid);
@@ -413,12 +415,12 @@ static int makePubkeyHeader(rpmts ts, rpmPubkey key, Header h)
 
     headerPutString(h, RPMTAG_RPMVERSION, RPMVERSION);
     headerPutString(h, RPMTAG_BUILDHOST, buildhost);
+    headerPutUint32(h, RPMTAG_BUILDTIME, &keytime, 1);
     headerPutString(h, RPMTAG_SOURCERPM, "(none)");
 
     {   rpm_tid_t tid = rpmtsGetTid(ts);
        headerPutUint32(h, RPMTAG_INSTALLTIME, &tid, 1);
        headerPutUint32(h, RPMTAG_INSTALLTID, &tid, 1);
-       headerPutUint32(h, RPMTAG_BUILDTIME, &tid, 1);
     }
     rc = 0;