daemon.ContainerExport(): do not panic

In case ContainerExport() is called for an unmounted container, it leads
to a daemon panic as container.BaseFS, which is dereferenced here, is
nil.

To fix, do not rely on container.BaseFS; use the one returned from
rwlayer.Mount().

Fixes: 7a7357dae1bccc ("LCOW: Implemented support for docker cp + build")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 81f6307eda44ab3a91de6e29304810a976161d74)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Kir Kolyshkin
2018-04-17 15:09:01 -07:00
committed by Sebastiaan van Stijn
parent ec3221ac7d
commit c9c8799088
+2 -2
View File
@@ -61,12 +61,12 @@ func (daemon *Daemon) containerExport(container *container.Container) (arch io.R
}
}()
_, err = rwlayer.Mount(container.GetMountLabel())
basefs, err := rwlayer.Mount(container.GetMountLabel())
if err != nil {
return nil, err
}
archive, err := archivePath(container.BaseFS, container.BaseFS.Path(), &archive.TarOptions{
archive, err := archivePath(basefs, basefs.Path(), &archive.TarOptions{
Compression: archive.Uncompressed,
UIDMaps: daemon.idMappings.UIDs(),
GIDMaps: daemon.idMappings.GIDs(),