comparison 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
comparison
equal deleted inserted replaced
1128:a9e074b78cd5 1134:36557295418e
611 *val = l; 611 *val = l;
612 return DROPBEAR_SUCCESS; 612 return DROPBEAR_SUCCESS;
613 } 613 }
614 } 614 }
615 615
616 /* Returns malloced path. Only expands ~ in first character */ 616 /* Returns malloced path. inpath beginning with '/' is returned as-is,
617 char * expand_tilde(const char *inpath) { 617 otherwise home directory is prepended */
618 char * expand_homedir_path(const char *inpath) {
618 struct passwd *pw = NULL; 619 struct passwd *pw = NULL;
619 if (inpath[0] == '~') { 620 if (inpath[0] != '/') {
620 pw = getpwuid(getuid()); 621 pw = getpwuid(getuid());
621 if (pw && pw->pw_dir) { 622 if (pw && pw->pw_dir) {
622 int len = strlen(inpath) + strlen(pw->pw_dir) + 1; 623 int len = strlen(inpath) + strlen(pw->pw_dir) + 2;
623 char *buf = m_malloc(len); 624 char *buf = m_malloc(len);
624 snprintf(buf, len, "%s/%s", pw->pw_dir, &inpath[1]); 625 snprintf(buf, len, "%s/%s", pw->pw_dir, inpath);
625 return buf; 626 return buf;
626 } 627 }
627 } 628 }
628 629
629 /* Fallback */ 630 /* Fallback */