# HG changeset patch # User Matt Johnston # Date 1149687679 0 # Node ID 84aa4e60bd3c9476a13171c98dc3184d25c8b86d # Parent fa9c45d097273502f4c6ad8f497da6d4d94a4b7f Look at HOME before /etc/passwd when looking for ~/.ssh/known_hosts file, so people can workaround broken /etc/passwds. Print the full path in error messages. diff -r fa9c45d09727 -r 84aa4e60bd3c cli-kex.c --- a/cli-kex.c Wed Jun 07 13:37:03 2006 +0000 +++ b/cli-kex.c Wed Jun 07 13:41:19 2006 +0000 @@ -152,15 +152,14 @@ buffer * line = NULL; int ret; - pw = getpwuid(getuid()); + homedir = getenv("HOME"); - if (pw) - homedir = pw->pw_dir; - } - pw = NULL; - - if (!homedir) - homedir = getenv("HOME"); + if (!homedir) { + pw = getpwuid(getuid()); + if (pw) { + homedir = pw->pw_dir; + } + pw = NULL; } if (homedir) { @@ -172,8 +171,8 @@ /* Check that ~/.ssh exists - easiest way is just to mkdir */ if (mkdir(filename, S_IRWXU) != 0) { if (errno != EEXIST) { - dropbear_log(LOG_INFO, "Warning: failed creating ~/.ssh: %s", - strerror(errno)); + dropbear_log(LOG_INFO, "Warning: failed creating %s/.ssh: %s", + homedir, strerror(errno)); TRACE(("mkdir didn't work: %s", strerror(errno))) ask_to_confirm(keyblob, keybloblen); goto out; /* only get here on success */ @@ -197,7 +196,8 @@ if (hostsfile == NULL) { TRACE(("hostsfile didn't open: %s", strerror(errno))) - dropbear_log(LOG_WARNING, "Failed to open ~/.ssh/known_hosts"); + dropbear_log(LOG_WARNING, "Failed to open %s/.ssh/known_hosts", + homedir); ask_to_confirm(keyblob, keybloblen); goto out; /* We only get here on success */ }