From: Stéphane Graber Date: Mon, 20 Jan 2014 20:57:16 +0000 (-0500) Subject: utils: Drop trailing / in lxcpath X-Git-Tag: lxc-1.0.0.beta3~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f407c5e4c142e870f01a7f0a52b58a7a30b6c865;p=thirdparty%2Flxc.git utils: Drop trailing / in lxcpath This fixes command line tools and functions which use lxc_global_config_value o get lxcpath but don't strip the trailing / leading to mismatching command path (as lxc_container_new does strip the path). As lxcpath is typically a const and so can't easily be changed by the caller, add the trick directly into lxc_global_config_value (having to juggle a bit in there too to avoid trying to alter a const). Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 3746adb9f..2f9e08b86 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -332,14 +332,25 @@ const char *lxc_global_config_value(const char *option_name) while (*p && (*p == ' ' || *p == '\t')) p++; if (!*p) continue; - values[i] = copy_global_config_value(p); + free(user_default_config_path); + + if (strcmp(option_name, "lxc.lxcpath") == 0) { + free(user_lxc_path); + user_lxc_path = copy_global_config_value(p); + remove_trailing_slashes(user_lxc_path); + values[i] = user_lxc_path; + goto out; + } + + values[i] = copy_global_config_value(p); free(user_lxc_path); goto out; } } /* could not find value, use default */ if (strcmp(option_name, "lxc.lxcpath") == 0) { + remove_trailing_slashes(user_lxc_path); values[i] = user_lxc_path; free(user_default_config_path); }