]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: Drop trailing / in lxcpath
authorStéphane Graber <stgraber@ubuntu.com>
Mon, 20 Jan 2014 20:57:16 +0000 (15:57 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 21 Jan 2014 04:11:54 +0000 (23:11 -0500)
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@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/utils.c

index 3746adb9f8774e8a5093eb17df0a3b0be459bf31..2f9e08b864fd150d585b32a281531bb69dedc322 100644 (file)
@@ -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);
        }