diff options
author | Matt Johnston <matt@ucc.asn.au> | 2006-12-06 13:11:41 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2006-12-06 13:11:41 +0000 |
commit | d5897b9a5d461c91cd525e5b2212125cf53ad268 (patch) | |
tree | cec78b43140a2610175f8e918ae22bfff0bbdf1f /dropbearkey.c | |
parent | 7b780efb42e3d9b369b4f00421fba1fc21ec2a22 (diff) | |
parent | 35bcc463e5ffe2f630c71962ca12d69a84952568 (diff) |
merge of '182c2d8dbd5321ef4d1df8758936f4dc7127015f'
and '31dcd7a22983ef19d6c63248e415e71d292dd0ec'
--HG--
extra : convert_revision : e84f66826c7ee6ebe99ef92cc0f6c22ecf638d01
Diffstat (limited to 'dropbearkey.c')
-rw-r--r-- | dropbearkey.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/dropbearkey.c b/dropbearkey.c index 8ceefdc..2433381 100644 --- a/dropbearkey.c +++ b/dropbearkey.c @@ -283,8 +283,10 @@ out: buf_burn(buf); buf_free(buf); buf = NULL; - sign_key_free(key); - key = NULL; + if (key) { + sign_key_free(key); + key = NULL; + } exit(err); } @@ -297,6 +299,9 @@ static void printpubkey(sign_key * key, int keytype) { const char * typestring = NULL; char *fp = NULL; int len; + struct passwd * pw = NULL; + char * username = NULL; + char hostname[100]; buf = buf_new(MAX_PUBKEY_SIZE); buf_put_pub_key(buf, key, keytype); @@ -315,8 +320,18 @@ static void printpubkey(sign_key * key, int keytype) { fp = sign_key_fingerprint(buf_getptr(buf, len), len); - printf("Public key portion is:\n%s %s\nFingerprint: %s\n", - typestring, base64key, fp); + /* a user@host comment is informative */ + 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); buf_free(buf); |