Commit a91d897a by Ferenc Wagner Committed by Daniel Lezcano

remove pivotdir only if it was created by us

The removal does not account for possible leading path components that were also created during creation of pivotdir. Signed-off-by: 's avatarFerenc Wagner <wferi@niif.hu> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent b1789442
...@@ -464,6 +464,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir) ...@@ -464,6 +464,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
void *cbparm[2]; void *cbparm[2];
struct lxc_list mountlist, *iterator; struct lxc_list mountlist, *iterator;
int ok, still_mounted, last_still_mounted; int ok, still_mounted, last_still_mounted;
int remove_pivotdir = 0;
/* change into new root fs */ /* change into new root fs */
if (chdir(rootfs)) { if (chdir(rootfs)) {
...@@ -484,6 +485,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir) ...@@ -484,6 +485,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
return -1; return -1;
} }
remove_pivotdir = 1;
DEBUG("created '%s' directory", path); DEBUG("created '%s' directory", path);
} }
...@@ -573,8 +575,8 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir) ...@@ -573,8 +575,8 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
/* remove temporary mount point, we don't consider the removing /* remove temporary mount point, we don't consider the removing
* as fatal */ * as fatal */
if (rmdir(pivotdir)) if (remove_pivotdir && rmdir(pivotdir))
WARN("can't remove mountpoint: %m"); WARN("can't remove mountpoint '%s': %m", pivotdir);
INFO("pivoted to '%s'", rootfs); INFO("pivoted to '%s'", rootfs);
return 0; return 0;
......
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