diff options
author | Matt Johnston <matt@ucc.asn.au> | 2022-03-30 14:08:15 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2022-03-30 14:08:15 +0800 |
commit | 040b19b2cb059e18b1541d9deb39fe945f67c44b (patch) | |
tree | f97692742c509b1ac3a532b6a9d420e05aac5fcf | |
parent | 3725b42fe95ef0b47b69d658dc875e980070b62d (diff) | |
download | dropbear-040b19b2cb059e18b1541d9deb39fe945f67c44b.tar.gz |
Fix tilde expansion of paths
(Part was missed from previous series of commits)
-rw-r--r-- | dbutil.c | 10 | ||||
-rw-r--r-- | default_options.h | 8 |
2 files changed, 9 insertions, 9 deletions
@@ -633,11 +633,11 @@ int m_str_to_uint(const char* str, unsigned int *val) { } } -/* Returns malloced path. inpath beginning with '/' is returned as-is, -otherwise home directory is prepended */ +/* Returns malloced path. inpath beginning with '~/' expanded, + otherwise returned as-is */ char * expand_homedir_path(const char *inpath) { struct passwd *pw = NULL; - if (inpath[0] != '/') { + if (strncmp(inpath, "~/", 2) == 0) { char *homedir = getenv("HOME"); if (!homedir) { @@ -648,9 +648,9 @@ char * expand_homedir_path(const char *inpath) { } if (homedir) { - int len = strlen(inpath) + strlen(homedir) + 2; + int len = strlen(inpath)-2 + strlen(homedir) + 2; char *buf = m_malloc(len); - snprintf(buf, len, "%s/%s", homedir, inpath); + snprintf(buf, len, "%s/%s", homedir, inpath+2); return buf; } } diff --git a/default_options.h b/default_options.h index c577d57..8d04506 100644 --- a/default_options.h +++ b/default_options.h @@ -19,7 +19,7 @@ IMPORTANT: Some options will require "make clean" after changes */ #define DROPBEAR_DEFADDRESS "" /* Default hostkey paths - these can be specified on the command line. - * Homedir is prepended if path begins with ~ + * Homedir is prepended if path begins with ~/ */ #define DSS_PRIV_FILENAME "/etc/dropbear/dropbear_dss_host_key" #define RSA_PRIV_FILENAME "/etc/dropbear/dropbear_rsa_host_key" @@ -238,7 +238,7 @@ group1 in Dropbear server too */ #define DROPBEAR_CLI_PUBKEY_AUTH 1 /* A default argument for dbclient -i <privatekey>. - * Homedir is prepended if path begins with ~ + * Homedir is prepended if path begins with ~/ */ #define DROPBEAR_DEFAULT_CLI_AUTHKEY "~/.ssh/id_dropbear" @@ -283,7 +283,7 @@ group1 in Dropbear server too */ /* The default file to store the daemon's process ID, for shutdown * scripts etc. This can be overridden with the -P flag. - * Homedir is prepended if path begins with ~ + * Homedir is prepended if path begins with ~/ */ #define DROPBEAR_PIDFILE "/var/run/dropbear.pid" @@ -295,7 +295,7 @@ group1 in Dropbear server too */ /* If you want to enable running an sftp server (such as the one included with * OpenSSH), set the path below and set DROPBEAR_SFTPSERVER. * The sftp-server program is not provided by Dropbear itself. - * Homedir is prepended if path begins with ~ + * Homedir is prepended if path begins with ~/ */ #define DROPBEAR_SFTPSERVER 1 #define SFTPSERVER_PATH "/usr/libexec/sftp-server" |