]> git.proxmox.com Git - mirror_lxc.git/commitdiff
remove pivotdir only if it was created by us
authorFerenc Wagner <wferi@niif.hu>
Wed, 12 May 2010 21:47:55 +0000 (23:47 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Wed, 12 May 2010 21:47:55 +0000 (23:47 +0200)
The removal does not account for possible leading path components that
were also created during creation of pivotdir.

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/conf.c

index 57b8c1a3ca2fb19c1fd19939c9559bf2bd802499..39aa982024f39c55a6c3ceb27f3defe80bfaf3e2 100644 (file)
@@ -464,6 +464,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
        void *cbparm[2];
        struct lxc_list mountlist, *iterator;
        int ok, still_mounted, last_still_mounted;
+       int remove_pivotdir = 0;
 
        /* change into new root fs */
        if (chdir(rootfs)) {
@@ -484,6 +485,7 @@ static int setup_rootfs_pivot_root(const char *rootfs, const char *pivotdir)
                        return -1;
                }
 
+               remove_pivotdir = 1;
                DEBUG("created '%s' directory", path);
        }
 
@@ -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
         * as fatal */
-       if (rmdir(pivotdir))
-               WARN("can't remove mountpoint: %m");
+       if (remove_pivotdir && rmdir(pivotdir))
+               WARN("can't remove mountpoint '%s': %m", pivotdir);
 
        INFO("pivoted to '%s'", rootfs);
        return 0;