summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-08-03 20:45:04 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-08-03 20:45:04 +0800
commite0364bef5b0eed7322ed94581b3feb107b9027c7 (patch)
tree671243020ad97c4ee7d3fb515deb18b4f474e086
parent5174f6d8bc39e2d7025e16122b27c048eb55c675 (diff)
downloaddropbear-e0364bef5b0eed7322ed94581b3feb107b9027c7.tar.gz
change DROPBEAR_DEFAULT_CLI_AUTHKEY to just prepend homedir
rather than doing ~ expansion
-rw-r--r--cli-runopts.c2
-rw-r--r--dbutil.c11
-rw-r--r--dbutil.h2
-rw-r--r--options.h4
4 files changed, 10 insertions, 9 deletions
diff --git a/cli-runopts.c b/cli-runopts.c
index 5bd4c55..58b64ce 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -449,7 +449,7 @@ void cli_getopts(int argc, char ** argv) {
#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 --git a/dbutil.c b/dbutil.c
index 4669304..d87835b 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -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;
}
}
diff --git a/dbutil.h b/dbutil.h
index 83ba888..71f3bdc 100644
--- a/dbutil.h
+++ b/dbutil.h
@@ -97,6 +97,6 @@ int constant_time_memcmp(const void* a, const void *b, size_t n);
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 --git a/options.h b/options.h
index 41cc129..c61d4d9 100644
--- a/options.h
+++ b/options.h
@@ -222,8 +222,8 @@ If you test it please contact the Dropbear author */
#define ENABLE_CLI_INTERACT_AUTH
/* A default argument for dbclient -i <privatekey>.
- 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