#2101 PR merged: quick hack to copy the real resolv.conf file on ubuntu18.x

Labels: enhancement, fixed / solved / done

gdha opened issue at 2019-03-27 17:26:

Signed-off-by: Gratien D'haese gratien.dhaese@gmail.com

Pull Request Details:
  • Type: Enhancement

  • Impact: *Normal

  • Reference to related issue (URL): #2015 and #2018

  • How was this pull request tested? via rea-automated-testing

  • Brief description of the changes in this pull request:
    https://github.com/gdha/rear-automated-testing/issues/75 - I did not like to current behaviour and agree with @OliverO2 that ReaR pretends to just work out of the box, which was not correct IMHO in this particular case. I agree with @schlomo too that we should adopt systemd more (not less), but this was a quick-win.
    For the next release we can have systemd-resolved incorporated (no rush as systemd is a moving duck anyhow)

jsmeix commented at 2019-03-28 09:58:

@gdha
could you - as a reference and as an example - post here
the whole content of a /run/systemd/resolve/resolv.conf file?

I do not have a system with that file and I would like to see
a real example what its actual content could be.

According to what I read at
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html

systemd-resolved maintains the /run/systemd/resolve/resolv.conf
file for compatibility with traditional Linux programs.
This file may be symlinked from /etc/resolv.conf and is always kept
up-to-date, containing information about all known DNS servers.

it seems /run/systemd/resolve/resolv.conf contains real directly
usable DNS servers (as a traditional /etc/resolv.conf does)
but it seems that contradicts what I read in
https://github.com/rear/rear/issues/2015#issuecomment-454349979

Ubuntu 16.04.x DNS clients actually run systemd-resolved.service
(with /etc/resolv.conf being a symlink to ../run/resolvconf/resolv.conf).

and my blind (I do not have such a system) assumption in
https://github.com/rear/rear/issues/2015#issuecomment-454829795

When /etc/resolv.conf is a symlink to a file that contains
real directly usable DNS servers then the current code in
usr/share/rear/build/GNU/Linux/630_verify_resolv_conf_file.sh

# Ensure /etc/resolv.conf in the recovery system contains actual content.
# Because of the issues
# https://github.com/rear/rear/issues/520
# https://github.com/rear/rear/issues/1200
# https://github.com/rear/rear/issues/2015
# where on Ubuntu /etc/resol.conf is linked to /run/resolvconf/resolv.conf
# and since Ubuntu 18.x /etc/resol.conf is linked to /lib/systemd/resolv.conf
# so that we need to remove the link and have the actual content in /etc/resolv.conf
if test -h $ROOTFS_DIR/etc/resolv.conf ; then
    rm -f $ROOTFS_DIR/etc/resolv.conf
    cp $v /etc/resolv.conf $ROOTFS_DIR/etc/resolv.conf
fi

would already copy the right content.

But now it seems here that a /etc/resolv.conf symlink target
does not contain real directly usable DNS servers
and instead /run/systemd/resolve/resolv.conf is the file
that contains real directly usable DNS servers
but this contradicts what
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
tells that /etc/resolv.conf symlinks to the right file
that contains real directly usable DNS servers.

As always this is again just one more funny example how
totally absurd and overcomplicated simple things become
as soon as systemd gets somehow involved.

DNS had worked o.k. since ages, now systemd comes into play,
and things fall apart.

I would like to leave systemd related issues to systemd enthusiasts
to implement in ReaR all what is needed in relation to systemd.

jsmeix commented at 2019-03-28 10:01:

@gdha
I do appreciate very much your efforts to deal with such things
and I welcome any dirty hacks that make ReaR work well
even under special circumstances.

gdha commented at 2019-03-28 10:19:

@jsmeix sure will paste the content tomorrow - I am at a customer today.

gdha commented at 2019-04-01 09:01:

root@client:/home/vagrant# cat /etc/resolv.conf 
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search lan

root@client:/home/vagrant# cat /lib/systemd/resolv.conf
# This file belongs to man:systemd-resolved(8). Do not edit.
#
# This is a static resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists no search
# domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0

root@client:/home/vagrant# cat /run/systemd/resolve/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 10.0.2.3
search lan

jsmeix commented at 2019-04-01 11:56:

Via https://github.com/rear/rear/commit/8c0c827fb0c68c9bd6d8c09a539e2be249b9c45d
I added https://github.com/rear/rear/pull/2101#issuecomment-478496081
to the comments and copying the file verbosely as in the else case.


[Export of Github issue for rear/rear.]