[lxc-devel] [PATCH] utils: Drop trailing / in lxcpath
Stéphane Graber
stgraber at ubuntu.com
Mon Jan 20 21:30:25 UTC 2014
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 <stgraber at ubuntu.com>
---
src/lxc/utils.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index 3746adb..2f9e08b 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);
}
--
1.8.5.3
More information about the lxc-devel
mailing list