From 7d7120d56610db980b82dbf2703bc9c677224346 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sep 30 2020 21:12:12 +0000 Subject: Only create resolv.conf symlink if sd-resolved.service is enabled This way, if one wants to opt-out of resolved, installing a preset that disables the service is enough. Previously that would only disable the service, but a dangling symlink would be created. --- diff --git a/systemd.spec b/systemd.spec index a885798..96f6a82 100644 --- a/systemd.spec +++ b/systemd.spec @@ -650,13 +650,6 @@ setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/ &>/de [ $1 -eq 1 ] || exit 0 -# Create /etc/resolv.conf symlink. -# We would also create it using tmpfiles, but let's do this here unconditionally -# too before NetworkManager gets a chance. (systemd-tmpfiles invocation above -# does not do this, because it's marked with ! and we don't specify --boot.) -# https://bugzilla.redhat.com/show_bug.cgi?id=1873856 -ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - # We reset the enablement of all services upon initial installation # https://bugzilla.redhat.com/show_bug.cgi?id=1118740#c23 # This will fix up enablement of any preset services that got installed @@ -667,6 +660,15 @@ ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf systemctl preset-all &>/dev/null || : systemctl --global preset-all &>/dev/null || : +# Create /etc/resolv.conf symlink. +# We would also create it using tmpfiles, but let's do this here +# too before NetworkManager gets a chance. (systemd-tmpfiles invocation above +# does not do this, because it's marked with ! and we don't specify --boot.) +# https://bugzilla.redhat.com/show_bug.cgi?id=1873856 +if systemctl -q is-enabled systemd-resolved.service &>/dev/null; then + ln -fsv ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf +fi + %preun if [ $1 -eq 0 ] ; then systemctl disable --quiet \