Module Name:    src
Committed By:   agc
Date:           Wed Dec  1 22:01:41 UTC 2010

Modified Files:
        src/crypto/external/bsd/netpgp/dist/src/lib: netpgp.c

Log Message:
When generating a key, set the new key's userid (last 16 bytes of
fingerprint) as an internal netpgp variable.

This can then be queried using netpgp_getvar(netpgp, "userid") to find the
new key's id.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 \
    src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.85 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.86
--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.85	Mon Nov 29 04:20:12 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c	Wed Dec  1 22:01:41 2010
@@ -34,7 +34,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: netpgp.c,v 1.85 2010/11/29 04:20:12 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.86 2010/12/01 22:01:41 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1156,6 +1156,7 @@
 	int             	 attempts;
 	int             	 passc;
 	int             	 fd;
+	int             	 cc;
 
 	uid = NULL;
 	io = netpgp->io;
@@ -1178,7 +1179,8 @@
 	pgp_sprint_keydata(netpgp->io, NULL, key, &cp, "signature ", &key->key.seckey.pubkey, 0);
 	(void) fprintf(stdout, "%s", cp);
 	/* write public key */
-	(void) snprintf(dir, sizeof(dir), "%s/%.16s", netpgp_getvar(netpgp, "homedir"), &cp[ID_OFFSET]);
+	cc = snprintf(dir, sizeof(dir), "%s/%.16s", netpgp_getvar(netpgp, "homedir"), &cp[ID_OFFSET]);
+	netpgp_setvar(netpgp, "userid", &dir[cc - 16]);
 	if (mkdir(dir, 0700) < 0) {
 		(void) fprintf(io->errs, "can't mkdir '%s'\n", dir);
 		return 0;

Reply via email to