diff options
author | Matt Johnston <matt@ucc.asn.au> | 2007-02-22 14:53:49 +0000 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2007-02-22 14:53:49 +0000 |
commit | b01a74a9d757ce2b83465214bde1fa07d3e2d3ea (patch) | |
tree | 092cac6797947f7b23fcdcc2c081b19c390c5bc4 /dropbearkey.c | |
parent | 66643fa5c723da2dc781c5eeae2e008c280a7b1c (diff) | |
parent | 7f12251fbb2acefac04e13a7c6a95ca4dd4b5578 (diff) |
merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee'
and 'c22be8b8f570b48e9662dac32c7b3e7148a42206'
--HG--
extra : convert_revision : 066f6aef2791d54b9ec6a0c3033fd28fa946251f
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); |