Skip to content

resolved: create private stub resolve file for integration with resolvconf - #7014

Merged
poettering merged 1 commit into
systemd:masterfrom
xnox:stub-resolv-conf
Oct 24, 2017
Merged

poettering merged 1 commit into
systemd:masterfrom
xnox:stub-resolv-conf

Conversation

@xnox

@xnox xnox commented Oct 6, 2017

Copy link
Copy Markdown
Contributor

This creates a second private resolve.conf file which lists the stub resolver
and the resolved acquired search domains.

This file is then supplied to resolvconf, such that non-nss using software does
name resolution via stub resolver, with search domains information.

This runtime file may be used as a symlink target for /etc/resolv.conf such
that non-nss based applications can resolve search domains. It is used by
default on Ubuntu 17.10+

Fixes: #7009

@xnox

xnox commented Oct 6, 2017

Copy link
Copy Markdown
Contributor Author

Note this also has units for resolvconf integration, which may or may not be desired to be shipped in systemd. I think it would be best to ship those units upstream in resolvconf instead. But when this was written both systemd and resolvconf portions were Ubuntu distro patches.

@poettering poettering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it!

Also, the section about /etc/resolv.conf in the systemd-resolved.service.8 needs a brief addition about this. It currently lists three modes of handling /etc/resolv.conf, and we should list the fourth one (this new one) there, too, and suggest that it is the best option.

Comment thread src/resolve/resolved-resolv-conf.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think the old write_resolv_conf_contents() function should be renamed a bit to make clear what it actually contains now. Something like "write_uplink_resolv_conf_contents()" or so. That way we have the "stub" and the "uplink" version of resolv.conf, which I think should be pretty clear in their purposes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

Comment thread units/meson.build Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prefer if we wouldn't have this bit in systemd. It's a Debianism, and should really live downstream I think.

That said, I think for systems not using Debian's resolvconf tool, this new stub file should become the default. Can you update tmpfiles.d/etc.conf.m4 accordingly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolvconf stuff is dropped. tmpfiles updated.

@poettering poettering added resolve reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Oct 10, 2017
@xnox
xnox force-pushed the stub-resolv-conf branch 2 times, most recently from d7f297a to 01d6e9b Compare October 19, 2017 13:42
@xnox

xnox commented Oct 19, 2017

Copy link
Copy Markdown
Contributor Author

@poettering everything is updated, i guess this new re-review.

Also I've now spotted nspawn integration, which imho looks obsolete and/or needs a switch to stub-resolv.conf?

@poettering poettering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one trivial nitpick. lgtm otherwise

Comment thread man/systemd-resolved.service.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: 127.0.053 → 127.0.0.53

@poettering

Copy link
Copy Markdown
Member

Also I've now spotted nspawn integration, which imho looks obsolete and/or needs a switch to stub-resolv.conf?

yeah, we need to figure out something there. Currently nspawn's resolv.conf logic is fully static, and the status quo ante static resolv.conf file matches that nicely. Anything more dynamic becomes a lot more complex, as propagating changes from the host into the container is hard, as bind mounting a dynamic file from the host conflicts with the desired to do atomic updates on the file (as atomic file updates means create new and rename, which will break propagation of bind mounts on the old file).

I figure we should just accept that DNS server info is propagated into container payloads by nspawn, but search domains are not, but need to happen locally. i.e. something akin to the status quo ante...

@xnox
xnox force-pushed the stub-resolv-conf branch from 01d6e9b to d764d22 Compare October 20, 2017 10:32
@xnox

xnox commented Oct 20, 2017

Copy link
Copy Markdown
Contributor Author

Typo fixed.

I'm ok with containers not propagating dynamic search domains.

So should the private resolv.conf & stub-resolv.conf be removed on the service shutdown? imho they should not be.... but i might be overlooking something in the resolved lifecycle here. Hence I have this hunk of code:

diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index d6f916b..9ff8774 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -117,10 +117,6 @@ int main(int argc, char *argv[]) {
         sd_event_get_exit_code(m->event, &r);
 
 finish:
-        /* systemd-nspawn checks for private resolv.conf to decide whether
-           or not to mount it into the container. So just delete it. */
-        (void) unlink(PRIVATE_RESOLV_CONF);
-
         sd_notify(false,
                   "STOPPING=1\n"
                   "STATUS=Shutting down...");

@poettering

Copy link
Copy Markdown
Member

Looks good! thanks!

However, it's currently unmergable due to some other conflicting merge. Could you please rebase on current git and force push? thanks!

@poettering poettering added needs-rebase and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Oct 24, 2017
…ration

This creates a second private resolve.conf file which lists the stub resolver
and the resolved acquired search domains.

This runtime file should be used as a symlink target for /etc/resolv.conf such
that non-nss based applications can resolve search domains.

Fixes: systemd#7009
@xnox
xnox force-pushed the stub-resolv-conf branch from d764d22 to 624e303 Compare October 24, 2017 08:26
@xnox

xnox commented Oct 24, 2017

Copy link
Copy Markdown
Contributor Author

sigh i wish github would ping me via notifications or email when that happens.

@poettering Rebased & force pushed.

@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed needs-rebase labels Oct 24, 2017
@poettering

Copy link
Copy Markdown
Member

excellent! thanks!

Comment thread NEWS
dynamic file. It points at the systemd-resolved stub DNS 127.0.0.53
resolver and it includes dynamically acquired search domains. This
achieves a more correct DNS resolution by software that bypasses
local DNS APIs (e.g. NSS).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unclear what the last "e.g." refers to: is NSS an example of a software that bypasses local APIs or is it an example of those local APIs? (I know the answer, I'm just pointing out that this needs editing.)

Maybe also add a sentence like "See the section /ETC/RESOLVED.CONF in systemd-resolved.service(8) for more information.".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native english speaker, but I do not think anybody out of the target audience will be confused by this statement as is. And it appears to be grammatically correct to me.

@keszybz keszybz removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Oct 24, 2017
@poettering

Copy link
Copy Markdown
Member

Let's merge this for now, we can tweak the NEWS file when releasing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

resolved needs to write out a 127.0.0.53 /etc/resolv.conf file that lists all collected search domains

3 participants