Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lxc: Check the dereferencedAlias really exists on the remote before e…
…xporting it When doing a `lxc image export ..`, dereferencing the provided image name either returns a fingerprint or a human readable alias. Both forms can be fine. However, since this `dereferenceAlias` operation is not really checking if the image associated with this alias exists on the remote, we were creating a local target based on the same string that a user entered. Most of the time, this `targetMeta` string was resolved to a fingerprint (e.g, `/var/lib/snapd/hostfs/home/gab/d2a43fade9d0055e454a091b2e9bd819f7eb715a3d4d46667644a5784d40172`) and this was fine because there is only the fingerprint file created and no intermediate directories. Anyway, I think it is safer to systematically check for the image existence prior to creating any file resources. This way we avoid changing the filesystem write logic that could annoy exsting users and break their export image pipeline: ``` target := "." targetMeta := fingerprint if len(args) > 1 { target = args[1] if shared.IsDir(shared.HostPathFollow(args[1])) { targetMeta = filepath.Join(args[1], targetMeta) } else { targetMeta = args[1] } } targetMeta = shared.HostPathFollow(targetMeta) ``` Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
- Loading branch information