Mercurial > dropbear
diff dbutil.c @ 1134:36557295418e
change DROPBEAR_DEFAULT_CLI_AUTHKEY to just prepend homedir
rather than doing ~ expansion
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 03 Aug 2015 20:45:04 +0800 |
parents | 01eea88963f3 |
children | 6ecc133fb2ee |
line wrap: on
line diff
--- 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; } }