diff --git a/common/configdir.c b/common/configdir.c index 856411e6ac65..f08daabb6b77 100644 --- a/common/configdir.c +++ b/common/configdir.c @@ -26,14 +26,9 @@ char *opt_set_talstr(const char *arg, char **p) static char *opt_set_abspath(const char *arg, char **p) { - char* ret; tal_free(*p); - - ret = opt_set_charp(path_join(options_ctx, take(path_cwd(NULL)), arg),p); - if (strlen(*p) > OPT_SHOW_LEN) - errx(EXITCODE_INVALID_PATH, "absolute path of command line option exceeds %d chars: '%s'", - OPT_SHOW_LEN, *p); - return ret; + return opt_set_charp(path_join(options_ctx, take(path_cwd(NULL)), arg), + p); } /* Tal wrappers for opt. */ @@ -43,6 +38,17 @@ static void *opt_allocfn(size_t size) TAL_LABEL(opt_allocfn_notleak, "")); } +static void opt_show_longpath(char *buf, char *const *p) +{ + if (*p){ + size_t len = strlen(*p); + buf[0] = '"'; + strncpy(buf+1, *p, len); + buf[1+len] = '"'; + buf[2+len] = '\0'; + } +} + static void *tal_reallocfn(void *ptr, size_t size) { if (!ptr) @@ -315,7 +321,7 @@ void initial_config_opts(const tal_t *ctx, /* Cmdline can also set lightning-dir. */ *config_basedir = NULL; opt_register_early_arg("--lightning-dir=", - opt_set_abspath, NULL, + opt_set_abspath, opt_show_longpath, config_basedir, "Set base directory: network-specific subdirectory is under here"); @@ -336,7 +342,7 @@ void initial_config_opts(const tal_t *ctx, /* If they set --conf it can still set --lightning-dir */ if (!*config_filename) { opt_register_early_arg("--lightning-dir=", - opt_restricted_forceconf_only, opt_show_charp, + opt_restricted_forceconf_only, opt_show_longpath, config_basedir, "Set base directory: network-specific subdirectory is under here"); } else { diff --git a/lightningd/options.c b/lightningd/options.c index 968f0ae8220c..a87b21e0e632 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1522,7 +1522,8 @@ static void add_config(struct lightningd *ld, { char *name0 = tal_strndup(tmpctx, name, len); char *answer = NULL; - char buf[OPT_SHOW_LEN + sizeof("...")]; + // FIXME(vincenzopalazzo): accept arbitrary length + char buf[256]; #if DEVELOPER if (strstarts(name0, "dev-")) { @@ -1590,7 +1591,6 @@ static void add_config(struct lightningd *ld, /* Ignore hidden options (deprecated) */ } else if (opt->show) { opt->show(buf, opt->u.carg); - strcpy(buf + OPT_SHOW_LEN - 1, "..."); if (streq(buf, "true") || streq(buf, "false") || (!streq(buf, "") && strspn(buf, "0123456789.") == strlen(buf))) {