Include user@host in the pubkey line, since it's sometimes very useful

--HG--
extra : convert_revision : c3d6444f31a3b583e6405e1b99e666d020e89eac
This commit is contained in:
Matt Johnston 2006-06-07 14:48:35 +00:00
parent 4aafeb0da2
commit 1428c01a5f

View File

@ -297,6 +297,9 @@ static void printpubkey(sign_key * key, int keytype) {
const char * typestring = NULL; const char * typestring = NULL;
char *fp = NULL; char *fp = NULL;
int len; int len;
struct passwd * pw = NULL;
char * username = NULL;
char hostname[100];
buf = buf_new(MAX_PUBKEY_SIZE); buf = buf_new(MAX_PUBKEY_SIZE);
buf_put_pub_key(buf, key, keytype); buf_put_pub_key(buf, key, keytype);
@ -315,8 +318,19 @@ static void printpubkey(sign_key * key, int keytype) {
fp = sign_key_fingerprint(buf_getptr(buf, len), len); fp = sign_key_fingerprint(buf_getptr(buf, len), len);
printf("Public key portion is:\n%s %s\nFingerprint: %s\n", /* a user@host comment is informative */
typestring, base64key, fp); username = "";
pw = getpwuid(getuid());
if (pw)
{
username = pw->pw_name;
}
gethostname(hostname, sizeof(hostname));
hostname[sizeof(hostname)-1] = '\0';
printf("Public key portion is:\n%s %s %s@%s\nFingerprint: %s\n",
typestring, base64key, username, hostname, fp);
m_free(fp); m_free(fp);
buf_free(buf); buf_free(buf);