Bug 2020852 - systemd: /etc/resolv.conf is initialized to systemd-resolved symlink even when it is not installed
Summary: systemd: /etc/resolv.conf is initialized to systemd-resolved symlink even whe...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 35
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1313085
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-11-06 12:53 UTC by Petr Menšík
Modified: 2022-08-24 08:51 UTC (History)
12 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2022-08-24 08:51:25 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github systemd systemd issues 5395 0 None closed /etc/resolv.conf is a broken symlink on systems with systemd-resolved disabled 2021-11-06 12:53:02 UTC
Github systemd systemd pull 21257 0 None open Configure no-stub fallback on resolved shutdown 2021-11-06 18:07:03 UTC
Github systemd systemd pull 21317 0 None open Initialize resolv.conf only if systemd-resolved enabled 2021-11-14 12:06:25 UTC
Github systemd systemd pull 21393 0 None Merged tmpfiles: split out config for systemd-resolve 2022-08-24 08:51:25 UTC

Description Petr Menšík 2021-11-06 12:53:02 UTC
Description of problem:
I tried it on lxc f35 container, but I guess it is present on any system.

Version-Release number of selected component (if applicable):
systemd-249.4-2.fc35.x86_64

How reproducible:
reliable

Steps to Reproduce:
1. dnf install dhcpcd
2. dnf remove systemd-networkd systemd-resolved
3. systemctl enable dhcpcd
4. rm /etc/resolv.conf
5. reboot

Actual results:
# ls -l /etc/resolv.conf
lrwxrwxrwx. 1 root root 39 lis  6 12:24 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf


Expected results:
# rm /etc/resolv.conf
# systemctl restart dhcpcd
# ls -l /etc/resolv.conf
-rw-r--r--. 1 root root 160 lis  6 12:41 /etc/resolv.conf


Additional info:
systemd contains line, which IMHO should not be part of this package, but somewhere in systemd-resolved subpackage. I think it should be activated only when systemd-resolved service is enabled+started.

# /usr/lib/tmpfiles.d/etc.conf
L! /etc/resolv.conf - - - - ../run/systemd/resolve/stub-resolv.conf

Comment 1 Petr Menšík 2021-11-06 18:07:04 UTC
Created PR 21257 [1] on systemd upstream. Avoid creation of such link if user intention is unknown. Ensure it is always present when systemd-resolved.service enabled, but leave its status to any different service otherwise.
It seems such solution is more appropriate.

1. https://github.com/systemd/systemd/pull/21257

Comment 3 Petr Menšík 2021-11-09 00:16:30 UTC
Tried with podman fedora:rawhide container. Because it prepares /etc/resolv.conf as simple file, which even cannot be removed from the container. Podman works. But it does not allow on any systemd-init enabled container to have /etc/resolv.conf missing. If network is configured in a static way outside the container, I guess resolv.conf should be prepared by any such tooling. Be it cloud-init or anything similar.

Even with missing /etc/resolv.conf, container can have working name resolution. It is only required to forward its ports 127.0.0.1:53 and [::1]:53 to the host, which might run common cache for all containers. I guess such configuration is not possible without tmpfiles.d/etc.conf override.


Note You need to log in before you can comment on or make changes to this bug.