Skip to content

Commit

Permalink
arguments: remove trailing slashes for the input lxcpath
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hqhq authored and hallyn committed Sep 24, 2013
1 parent 9d0cda4 commit e555005
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lxc/arguments.c
Expand Up @@ -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;
Expand Down

0 comments on commit e555005

Please sign in to comment.