diff options
author | Matt Johnston <matt@ucc.asn.au> | 2015-08-03 20:45:04 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2015-08-03 20:45:04 +0800 |
commit | e0364bef5b0eed7322ed94581b3feb107b9027c7 (patch) | |
tree | 671243020ad97c4ee7d3fb515deb18b4f474e086 /dbutil.c | |
parent | 5174f6d8bc39e2d7025e16122b27c048eb55c675 (diff) | |
download | dropbear-e0364bef5b0eed7322ed94581b3feb107b9027c7.tar.gz |
change DROPBEAR_DEFAULT_CLI_AUTHKEY to just prepend homedir
rather than doing ~ expansion
Diffstat (limited to 'dbutil.c')
-rw-r--r-- | dbutil.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -613,15 +613,16 @@ int m_str_to_uint(const char* str, unsigned int *val) { } } -/* 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; } } |