diff --git a/dropbear/options.h b/dropbear/options.h index 6259413..a3b25d9 100644 --- a/dropbear/options.h +++ b/dropbear/options.h @@ -19,15 +19,17 @@ #define DROPBEAR_DEFADDRESS "" #endif +extern const char *conf_path_file(const char *fn); /* in jni/interface.c */ + /* Default hostkey paths - these can be specified on the command line */ #ifndef DSS_PRIV_FILENAME -#define DSS_PRIV_FILENAME "/etc/dropbear/dropbear_dss_host_key" +#define DSS_PRIV_FILENAME conf_path_file("dropbear_dss_host_key") #endif #ifndef RSA_PRIV_FILENAME -#define RSA_PRIV_FILENAME "/etc/dropbear/dropbear_rsa_host_key" +#define RSA_PRIV_FILENAME conf_path_file("dropbear_rsa_host_key") #endif #ifndef ECDSA_PRIV_FILENAME -#define ECDSA_PRIV_FILENAME "/etc/dropbear/dropbear_ecdsa_host_key" +#define ECDSA_PRIV_FILENAME conf_path_file("dropbear_ecdsa_host_key") #endif /* Set NON_INETD_MODE if you require daemon functionality (ie Dropbear listens diff --git a/jni/interface.c b/jni/interface.c index d6b5c1e..48b26e0 100644 --- a/jni/interface.c +++ b/jni/interface.c @@ -8,7 +8,16 @@ #include #include -const char *conf_path, *conf_shell, *conf_home; +const char *conf_path = "", *conf_shell = "", *conf_home = ""; + +/* NB - this will leak memory like crazy if called often.... */ +const char * +conf_path_file(const char *fn) +{ + char *ret = malloc(strlen(conf_path)+strlen(fn)+20); + sprintf(ret, "%s/%s", conf_path, fn); + return ret; +} /* XXX - do i need a function to generate host keys? DROPBEAR_DELAY_HOSTKEY */ /* XXX - a C-callable interface to get property strings from the java side (paths, etc) */ @@ -76,12 +85,11 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_, if (pid == 0) { char *argv[10] = { "sshd", NULL }; int argc = 1; - char *logfn; + const char *logfn; int logfd; int retval; - logfn = malloc(strlen(conf_path)+20); - sprintf(logfn, "%s/dropbear.err", conf_path); + logfn = conf_path_file("dropbear.err"); unlink(logfn); logfd = open(logfn, O_CREAT|O_WRONLY, 0666); if (logfd != -1) {