summaryrefslogtreecommitdiffhomepage
path: root/dbutil.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-01-24 00:05:26 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-01-24 00:05:26 +0800
commit6165f53fcd6be9bb06fc3cd29e8640bb14d95111 (patch)
tree3319421458308184edfd0bdd945be7d62c299b87 /dbutil.c
parent4122cac66b139492d5b7fa6a1b8afcb1bfc529f7 (diff)
Default client key path ~/.ssh/id_dropbear
Diffstat (limited to 'dbutil.c')
-rw-r--r--dbutil.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/dbutil.c b/dbutil.c
index 2acc53b..ae73132 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -936,6 +936,23 @@ 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) {
+ struct passwd *pw = NULL;
+ if (inpath[0] == '~') {
+ pw = getpwuid(getuid());
+ if (pw && pw->pw_dir) {
+ int len = strlen(inpath) + strlen(pw->pw_dir) + 1;
+ char *buf = m_malloc(len);
+ snprintf(buf, len, "%s/%s", pw->pw_dir, &inpath[1]);
+ return buf;
+ }
+ }
+
+ /* Fallback */
+ return m_strdup(inpath);
+}
+
int constant_time_memcmp(const void* a, const void *b, size_t n)
{
const char *xa = a, *xb = b;