Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure when /etc/resolv.conf is a symlink #151

Open
tych0 opened this issue Mar 30, 2021 · 2 comments
Open

failure when /etc/resolv.conf is a symlink #151

tych0 opened this issue Mar 30, 2021 · 2 comments

Comments

@tych0
Copy link
Collaborator

tych0 commented Mar 30, 2021

Stacker bind mounts in /etc/resolv.conf so that the container can resolve things as the host would.

However, when /etc/resolv.conf is a symlink in the container, we get,

lxc build-c3-minbase 20210330225039.565 ERROR    utils - utils.c:open_without_symlink:1062 - Too many levels of symbolic links - resolv.conf in /home/tycho/c3/build/stacker/rootfsPivot/etc/resolv.conf was a symbolic link!

because the kernel doesn't like mounting over a symbolic link.

@tych0
Copy link
Collaborator Author

tych0 commented Mar 30, 2021

A few options here:

  1. we could write the file contents. but if e.g. it's a symbolic link to a file somewhere in /run that doesn't exist, that's not so great since we create that file for posterity. Additionally, we modify /etc even if there are no other changes to it, so we'd have to make some sort of exclusion for that sort of like we do for / and /stacker.

  2. we could add an additional "stacker" overlay layer, that includes "/stacker" and "/etc/resolv.conf" on top of whatever the rootfs is. This would make it totally invisible in the final image. However, this would be a fair amount of work to do in the btrfs backend. Perhaps we can delete the btrfs backend? :)

@raharper
Copy link
Contributor

I had also entertained the idea of also bind mounting the target of the
symlink

% mkdir -p /tmp/wark/rootfs/etc
% ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Mar 14  2020 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
% cp -a /etc/resolv.conf /tmp/wark/rootfs/etc/resolv.conf
# once we copy this to a different rootfs path, the link is relative and invalid
% test -f /tmp/wark/rootfs/etc/resolv.conf; echo $?
1
% sudo mount -t tmpfs tmpfs /tmp/wark/rootfs/run
% mountpoint /tmp/wark/rootfs/run
/tmp/wark/rootfs/run is a mountpoint
% mkdir -p /tmp/wark/rootfs/run/systemd/resolve
% sudo mount -o bind /run/systemd/resolve /tmp/wark/rootfs/run/systemd/resolve
ls -al /tmp/wark/rootfs/etc/
total 3
drwxrwxr-x 2 rharper rharper  3 Mar 30 18:37 .
drwxrwxr-x 4 rharper rharper  4 Mar 30 18:36 ..
lrwxrwxrwx 1 rharper rharper 39 Mar 14  2020 resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
# after bind mount it's valid
% test -f /tmp/wark/rootfs/etc/resolv.conf; echo $?
0

Vetting the source path and not masking that with the tmpfs mount might be
a bit of work (check if /run is empty) but I think for resolv.conf handling
it's typically file in /etc or symlink into /run/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants