result:
Error: open /var/lib/snapd/hostfs/home/{user}/a.txt: no such file or directory
This happens if the symbolic link points to an absolute path.
It is not a problem for some relative symlinks, like: ln -s a.txt b.txt; lxc file push b.txt …
Is this known? Fixable? A snapd issue or an LXD issue?
I ran into it while pushing my ~/.ssh/authorized_keys to the container. I forgot that I had ~/.ssh linked somewhere else, and I was baffled until I figured out that the link caused the problem.
But I can push /opt/a.txt just fine. The problem does not seem to be the location outside of the home directory, but the symbolic link from home to somewhere outside of home.
Indeed, if you use the non-snap LXD client (i.e. go get github.com/lxc/lxd/lxc and then use executable from ~/go/bin/), then it works.
The affected code should be at or around:
Since lxc file push /opt/myfile.txt ... works but not the symlink to that file, then it is likely that the client is reading the file in the first case, and in the second it sends the file path so that the server performs the copy (and cannot find the file due to mount namespaces).