Unverified Commit 436253a7 by Paul Romlow Committed by Christian Brauner

proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c

Signed-off-by: 's avatarPaul Romlow <paul@romlow.com>
parent 925bcb12
......@@ -1298,12 +1298,13 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
return bdev;
}
static char *lxcbasename(char *path)
/* Strip path and return name of file for argv[0] passed to execvp */
static char *lxctemplatefilename(char *tpath)
{
char *p;
p = path + strlen(path) - 1;
while (*p != '/' && p > path)
p = tpath + strlen(tpath) - 1;
while ( (p-1) >= tpath && *(p-1) != '/')
p--;
return p;
......@@ -1429,7 +1430,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath,
newargv = malloc(nargs * sizeof(*newargv));
if (!newargv)
_exit(EXIT_FAILURE);
newargv[0] = lxcbasename(tpath);
newargv[0] = lxctemplatefilename(tpath);
/* --path */
len = strlen(c->config_path) + strlen(c->name) + strlen("--path=") + 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment