Package: symlinks
Version: 1.4-3+b1

Hello Debian community,
the symlinks command does not work as expected, if executed from a docker 
container containing overlay2 filesystem.
No absolute symlinks are converted to relative ones, when executing symlinks -o 
-r -c -v dir1

How to reproduce:
1) Install docker and configure usage of overlay2 filesystem storage driver in 
container (which should be the default in Debian stretch, docker info | grep 
"Storage Driver" )
2) Pull latest Debian container image
3) Execute in container:
        a. $ sudo -E apt install -y symlinks
        b. $ mkdir -p $HOME/dir1/dir2
        c. $ touch dir1/file
        d. $ ln -s $HOME/dir1/file $HOME/dir1/dir2/symlink
        e. $ symlinks -o -r -c -v dir1

Expected result:
symlink converted from absolute path to relative path:
        absolute: /home/bob/dir1/dir2/symlink -> /home/bob/dir1/file
        changed:  /home/bob/dir1/dir2/symlink -> ../file
        $ ls -alh dir1/dir2
        lrwxrwxrwx 1 bob bob   19 Jan  4 09:37 symlink -> ../file

Actual result: 
no conversion, no output fom symlink command at all
        $ ls -alh dir1/dir2
        lrwxrwxrwx 1 bob bob   19 Jan  4 09:37 symlink -> /home/bob/dir1/file

Impact:
As more and more build environments for source packages use the container 
technology to build binaries in clean environments, it should be possible to 
use this nice and handy tool also inside of container with overlayFS.
One example here is the package tzdata, which uses the symlinks command in the 
Makefile to convert absolute symlinks in a tmp directory to relative ones for 
all the available timezones before packaging.

If I take a look in the source code of version 1.4-3, it seems that an else 
case is missing in line 289 of the function dirwalk. The else should handle the 
case if the device numbers are not identical. In my opinion this is the root 
cause of the error, because in an overlayFS these device numbers are not 
identical.

Thanks and regards,
Dirk Mayer

Reply via email to