Create /etc/resolv.conf symlink if nothing is present yet

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-12-18 16:50:52 +01:00
parent 184bb74091
commit 7f4e198603

View File

@ -397,6 +397,8 @@ devices.
%package resolved %package resolved
Summary: Network Name Resolution manager Summary: Network Name Resolution manager
Requires(post): %{name}
Requires(post): grep
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes: %{name} < 249~~ Obsoletes: %{name} < 249~~
Requires: libidn2.so.0%{?elf_suffix} Requires: libidn2.so.0%{?elf_suffix}
@ -916,13 +918,13 @@ if [ $1 -eq 0 ] ; then
systemctl disable --quiet \ systemctl disable --quiet \
systemd-resolved.service \ systemd-resolved.service \
>/dev/null || : >/dev/null || :
if [ -L %{_sysconfdir}/resolv.conf ] && \ if [ -L /etc/resolv.conf ] && \
realpath %{_sysconfdir}/resolv.conf | grep ^/run/systemd/resolve/; then realpath /etc/resolv.conf | grep ^/run/systemd/resolve/; then
rm -f %{_sysconfdir}/resolv.conf # no longer useful rm -f /etc/resolv.conf # no longer useful
# if network manager is enabled, move to it instead # if network manager is enabled, move to it instead
[ -f /run/NetworkManager/resolv.conf ] && \ [ -f /run/NetworkManager/resolv.conf ] && \
systemctl -q is-enabled NetworkManager.service &>/dev/null && \ systemctl -q is-enabled NetworkManager.service &>/dev/null && \
ln -fsv ../run/NetworkManager/resolv.conf %{_sysconfdir}/resolv.conf ln -fsv ../run/NetworkManager/resolv.conf /etc/resolv.conf
fi fi
fi fi
@ -943,18 +945,26 @@ fi
# does not do this, because it's marked with ! and we don't specify --boot.) # does not do this, because it's marked with ! and we don't specify --boot.)
# https://bugzilla.redhat.com/show_bug.cgi?id=1873856 # https://bugzilla.redhat.com/show_bug.cgi?id=1873856
# #
# If systemd is not running, don't overwrite the symlink because that # *Create* the symlink if nothing is present yet.
# will immediately break DNS resolution, since systemd-resolved is # (https://bugzilla.redhat.com/show_bug.cgi?id=2032085)
# also not running (https://bugzilla.redhat.com/show_bug.cgi?id=1891847). #
# *Override* the symlink if systemd is running. Don't do it if systemd
# is not running, because that will immediately break DNS resolution,
# since systemd-resolved is also not running
# (https://bugzilla.redhat.com/show_bug.cgi?id=1891847).
# #
# Also don't create the symlink to the stub when the stub is disabled (#1891847 again). # Also don't create the symlink to the stub when the stub is disabled (#1891847 again).
if test -d /run/systemd/system/ && if systemctl -q is-enabled systemd-resolved.service &>/dev/null &&
systemctl -q is-enabled systemd-resolved.service &>/dev/null && ! systemd-analyze cat-config systemd/resolved.conf 2>/dev/null |
! mountpoint /etc/resolv.conf &>/dev/null && grep -iqE '^DNSStubListener\s*=\s*(no?|false|0|off)\s*$'; then
! systemd-analyze cat-config systemd/resolved.conf 2>/dev/null | \
grep -qE '^DNSStubListener\s*=\s*([nN][oO]?|[fF]|[fF][aA][lL][sS][eE]|0|[oO][fF][fF])$'; then if ! test -e /etc/resolv.conf; then
ln -sv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
elif test -d /run/systemd/system/ &&
! mountpoint /etc/resolv.conf &>/dev/null; then
ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
fi fi
fi
%global _docdir_fmt %{name} %global _docdir_fmt %{name}
@ -1013,6 +1023,7 @@ fi
- Move systemd-boot-update.service to -udev subpackage - Move systemd-boot-update.service to -udev subpackage
and add it the the installation scriptlets (#2031400) and add it the the installation scriptlets (#2031400)
- Move libcryptsetup-token-systemd plugins to -udev (#2031873) - Move libcryptsetup-token-systemd plugins to -udev (#2031873)
- Create /etc/resolv.conf symlink if nothing is present yet (#2032085)
* Fri Dec 10 2021 Pavel Březina <pbrezina@redhat.com> - 250~rc1-3 * Fri Dec 10 2021 Pavel Březina <pbrezina@redhat.com> - 250~rc1-3
- Remove nsswitch.conf scriptlets (#2023743) - Remove nsswitch.conf scriptlets (#2023743)