# HG changeset patch # User Matt Johnston # Date 1438605904 -28800 # Node ID 36557295418ef66a66622b2f64f7041442da6ab5 # Parent a9e074b78cd5caab6b41c2d6de22f859a0da7193 change DROPBEAR_DEFAULT_CLI_AUTHKEY to just prepend homedir rather than doing ~ expansion diff -r a9e074b78cd5 -r 36557295418e cli-runopts.c --- a/cli-runopts.c Tue Jun 23 21:48:13 2015 +0800 +++ b/cli-runopts.c Mon Aug 03 20:45:04 2015 +0800 @@ -449,7 +449,7 @@ #if defined(DROPBEAR_DEFAULT_CLI_AUTHKEY) && defined(ENABLE_CLI_PUBKEY_AUTH) { - char *expand_path = expand_tilde(DROPBEAR_DEFAULT_CLI_AUTHKEY); + char *expand_path = expand_homedir_path(DROPBEAR_DEFAULT_CLI_AUTHKEY); loadidentityfile(expand_path, 0); m_free(expand_path); } diff -r a9e074b78cd5 -r 36557295418e dbutil.c --- a/dbutil.c Tue Jun 23 21:48:13 2015 +0800 +++ b/dbutil.c Mon Aug 03 20:45:04 2015 +0800 @@ -613,15 +613,16 @@ } } -/* Returns malloced path. Only expands ~ in first character */ -char * expand_tilde(const char *inpath) { +/* Returns malloced path. inpath beginning with '/' is returned as-is, +otherwise home directory is prepended */ +char * expand_homedir_path(const char *inpath) { struct passwd *pw = NULL; - if (inpath[0] == '~') { + if (inpath[0] != '/') { pw = getpwuid(getuid()); if (pw && pw->pw_dir) { - int len = strlen(inpath) + strlen(pw->pw_dir) + 1; + int len = strlen(inpath) + strlen(pw->pw_dir) + 2; char *buf = m_malloc(len); - snprintf(buf, len, "%s/%s", pw->pw_dir, &inpath[1]); + snprintf(buf, len, "%s/%s", pw->pw_dir, inpath); return buf; } } diff -r a9e074b78cd5 -r 36557295418e dbutil.h --- a/dbutil.h Tue Jun 23 21:48:13 2015 +0800 +++ b/dbutil.h Mon Aug 03 20:45:04 2015 +0800 @@ -97,6 +97,6 @@ a real-world clock */ time_t monotonic_now(); -char * expand_tilde(const char *inpath); +char * expand_homedir_path(const char *inpath); #endif /* DROPBEAR_DBUTIL_H_ */ diff -r a9e074b78cd5 -r 36557295418e options.h --- a/options.h Tue Jun 23 21:48:13 2015 +0800 +++ b/options.h Mon Aug 03 20:45:04 2015 +0800 @@ -222,8 +222,8 @@ #define ENABLE_CLI_INTERACT_AUTH /* A default argument for dbclient -i . - leading "~" is expanded */ -#define DROPBEAR_DEFAULT_CLI_AUTHKEY "~/.ssh/id_dropbear" +Homedir is prepended unless path begins with / */ +#define DROPBEAR_DEFAULT_CLI_AUTHKEY ".ssh/id_dropbear" /* This variable can be used to set a password for client * authentication on the commandline. Beware of platforms