]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
arguments: remove trailing slashes for the input lxcpath
authorQiang Huang <h.huangqiang@huawei.com>
Tue, 24 Sep 2013 07:27:55 +0000 (15:27 +0800)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 24 Sep 2013 14:37:09 +0000 (09:37 -0500)
In lxc_cmd(), we use
snprintf(path, len, "%s/%s/command", lxcpath ? lxcpath : inpath, name);
to fill sock name, this assume lxcpath have no trailing slashes, so
if we use
lxc-info -n test -P /usr/local/var/lib/lxc_anon/
to get a running container's state, we will get state: STOPPED which
is wrong, because we combine a wrong sock name.

To fix this, just remove trailing slashes when parsing arguments.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/arguments.c

index c35dfd89675b50c96c7985b2b03195cdf0f600db..adcf8fede75f7f6444b3d4499299e014b97f964f 100644 (file)
@@ -197,6 +197,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
                case 'l':       args->log_priority = optarg; break;
                case 'q':       args->quiet = 1; break;
                case 'P':
+                       remove_trailing_slashes(optarg);
                        ret = lxc_arguments_lxcpath_add(args, optarg);
                        if (ret < 0)
                                return ret;