Repository navigation
resolvconf(8) compat interface - #8296
Conversation
There was a problem hiding this comment.
Would be nice to include a line number here.
There was a problem hiding this comment.
I think this should be a separate file... Let's try not to grow another systemctl.c. Even even this doesn't happen now, the interface should be accessible so that we can write unittests for parsing.
There was a problem hiding this comment.
Frankly, I think there's no choice but to provide a brief summary what these options do. Referring to a "competing" program, especially one that has many semi-compatible implementations, is just too vague for the users. Note that this is only for "supported" options, "ignored" and "unsupported" options below do not have to be explained.
There was a problem hiding this comment.
I think this also needs an entry in the synopsis.
362e044 to
c78bea0
Compare
|
OK, force pushed a new version. PTAL. All issues adressed, and one trivial (though unrelated) commit added on top. |
c78bea0 to
505c51c
Compare
505c51c to
1c359de
Compare
|
Thank you for adding the comment about telinit. |
There was a problem hiding this comment.
Would you consider supporting -l [interface]? The information and logic to support it is easily available, and so it wouldn't be cumbersome to support. This is used by wg-quick(8) to (optionally) save the active runtime configuration when deleting the interface.
There was a problem hiding this comment.
I think providing the API for 3rd party tools to hook into is priority, and I figure that's mostly -a and -d. OTOH -l is mostly user-facing, and we do have "systemd-resolve --status" covering that already (and without the skewedness because resolved's and resolvconf's concept don't match 100%).
That said, I think we can totally add support for that later on, if people want that (and apparently they do, as you have just shown). But I think it's just the cherry on top, and not not necessary to make the basic functionality work.
Or to say this differently: a PR adding support for that on top of this once it's merged would be very welcome!
There was a problem hiding this comment.
Indeed the other program supports many things too, but the point of having resolvconf in the first place is to maintain compatibility with scripts, just like shutdown and the rest. wg-quick(8) won't be growing support for a cornucopia of different DNS management invocations, preferring instead to use a single API (resolvconf). It's just a shell script after all.
You can see its usage of -l here: https://git.zx2c4.com/WireGuard/tree/src/tools/wg-quick.bash#n194
But I think it's just the cherry on top, and not necessary to make the basic functionality work.
It's certainly required to make wg-quick(8) work, rather than being a mere cherry.
There was a problem hiding this comment.
note that "-l" is only supported by openresolv, btw, it's not available in the original Debian implementation.
There was a problem hiding this comment.
Hmm, that script uses -m 0 -x btw, which isn't in the debian implementation. It appears the script only works with openresolv.
What confuses me a bit is this line in that script:
resolvconf -a "tun.$INTERFACE" -m 0 -x
The interface argument is reversed: According to the manpages you are supposed to specified the interface first, and the protocol second. i.e. it should be $INTERFACE.tun and not tun.$INTERFACE. (Oh, and I think it would be more expressive if you'd use "wguard or so instead of "tun" as protocol ID).
There was a problem hiding this comment.
FreeBSD uses openresolv, by the way.
I think it's based on it, yes, but it deviates, has new options and the file locations are all different.
There was a problem hiding this comment.
I think it's based on it, yes,
That man page you linked explicitly mentions openresolv, anyhow.
There was a problem hiding this comment.
are they? i just checked out the resolvconf upstream git repo, and if i run the command there
I'm reading this source: https://anonscm.debian.org/cgit/resolvconf/resolvconf.git/tree/bin/resolvconf
The key is to make -x the second argument, not the first. Then you avoid the error message and have future compatibility with openresolv.
There was a problem hiding this comment.
The compat implementation of this PR also expects that the interface name is valid. It will generate an error if it isn't.
Ahh, okay, that could be problematic, then, unless what you're saying about IF_EXCLUSIVE is actually true in current versions, in which case, I wouldn't need the tun. prefix hack. I can't find that, though:
zx2c4@thinkpad /tmp $ git clone https://anonscm.debian.org/cgit/resolvconf/resolvconf.git
Cloning into 'resolvconf'...
remote: Counting objects: 3635, done.
remote: Compressing objects: 100% (1474/1474), done.
remote: Total 3635 (delta 2510), reused 3044 (delta 2125)
Receiving objects: 100% (3635/3635), 598.85 KiB | 3.09 MiB/s, done.
Resolving deltas: 100% (2510/2510), done.
zx2c4@thinkpad /tmp/resolvconf $ grep -ri IF_EXCLUSIVE
zx2c4@thinkpad /tmp/resolvconf $
That seems to be, rather, an openresolv option, not a Debian one.
Anyway, I've just committed this: https://git.zx2c4.com/WireGuard/commit/?id=92320b60b6d85dc13a1932079366465569683b1e So hopefully the strict naming requirements of systemd should now be satisfied.
There was a problem hiding this comment.
note that "-l" is only supported by openresolv, btw, it's not available in the original Debian implementation.
So, it might be a good idea for systemd to support the modern interface for this instead of the old Debian cruft.
There was a problem hiding this comment.
Not really important, but I'm interested why you went with malloc_multiply as the name instead of the better known mallocarray (from OpenBSD etc)?
There was a problem hiding this comment.
reallocarray() was added recently to glibc, mallocarray() still isn't available there. C namespacing is a mess, but so far we tried to stay away from names that libcs currently don't provide but might very likely support later, though possibly in a slightly different way than the other platforms which inspired it. We do that mostly as a safety measure so that things don't start breaking when these things are added, and our implementation clashes with the libc one.
As soon as something gets added to glibc we however then rework our stuff to make use of it, which just happened in the case of reallocarray(), see #8279.
Or to say this differently: as soon as glibc made its mind up, and added the call we'll rework our stuff and use the exact same prototype as compat kludge for older distributions.
There was a problem hiding this comment.
Oh, that's a really good idea.
keszybz
left a comment
There was a problem hiding this comment.
I think it's OK to start with an implementation that is incomplete matches some version of the software. It's funny how this was supposed to be a unifying interface. It should be fairly easy to add support for other options once the basic thing is in place.
There was a problem hiding this comment.
That doesn't make much sense to cross from rootsbindir to bindir. resolvconf is in /sbin on Ubuntu/Debian, sp the second argument has to use rootsbindir. We can either say "who cares" and live with the fact that we'll have a dangling symlink until /usr is mounted, or move systemd-resolve to /bin. I don't care either way, maybe people who use split-usr can chime in?
@mbiebl, @martinpitt, does /sbin/resolvconf need to be usable before /usr is mounted?
There was a problem hiding this comment.
@keszybz on the systems that boot with systemd, our initramfs insures that /usr is mounted. So no. But there are things that use resolvconf state in the initramfs and hope that it will be transfered into the root filesystem, post initramfs. I have not yet checked, but it would be extra nice if there is e.g. path&service unit combos that process /run/resolvconf/interface/$IFACE files on boot. I didn't read all of the pull request, to check if this is done or not.
There was a problem hiding this comment.
no, we only provide command line compat with openresolv and debian's resolvconf, nothing else.
that said, if you run resolved in the initrd (which should be safe now) it should pass on its data 1:1 without isses to the main system
There was a problem hiding this comment.
It'd be nice to keep this line in the same order as the cases below… That makes it easier to verify that they match.
There was a problem hiding this comment.
We'll probably need to make this optional, since people install systemd into their root file system and might not want to overwrite their installed resolvconf. But this can be done later.
There was a problem hiding this comment.
Maybe I'm dumb, but I don't think I'd understand what is going on based on this comment.
What you wrote in #8305 is much clearer:
On SysV "telinit" was the official command to communicate with PID 1, but "init" would redirect itself to "telinit" if called with PID != 1. We follow the same logic here still, though we add one level of indirection, as we implement "telinit" in "systemctl". Hence, for us if you invoke "init" you get "systemd", but it will execve() "systemctl" immediately with argv[] unmodified if PID is != 1. If you invoke "telinit" you directly get "systemctl". In both cases we shall do the same thing, which is why we do strstr(p_i_s_n, "init") here, as a quick way to match both.
Also see redirect_telinit() in src/core/main.c.
This turns resolve-tool into a multi-call binary. When invoked as
"resolvconf" it provides minimal compatibility with the resolvconf(8)
tool of various distributions (and FreeBSD as it appears).
This new interface understands to varying degrees features of the two
major implementations of resolvconf(8): Debian's original one and
"openresolv". Specifically:
Fully supported:
-a -d (supported by all implementations)
-f (introduced by openresolv)
Somewhat supported:
-x (introduced by openresolv, mapped to a '~.' domain entry)
Unsupported and ignored:
-m -p (introduced by openresolv, not really necessary for us)
Unsupported and resulting in failure:
-u (supported by all other implementations)
-I -i -l -R -r -v -V
(all introduced by openresolv)
--enable-updates --disable-updates --updates-are-enabled
(specific to Debian's implementation)
Of course, resolvconf(8) is a tool with multiple backends, in our
implementation systemd-resolved is the only backend.
Fixes: systemd#7202
|
I force pushed a new version now. It drops all patches that were already merged in the meantime, thus only leaving resolvconf(8)-related patches in place. I already reordered the getopt() string, as requested. No other changes, in particular none regarding the location of systemd-resolve and its symlink, as the situation is not clear yet. So, my thinking regarding the precise location of the symlink was purely focussed on using the same path that upstream openresolv/debian's resolvconf use, nothing else. We are explicitly not supporting boots with /usr split off and not mounted in the initrd anyway, hence I don't think linking from /sbin to /usr/bin is a problem. People who still care about that are not using systemd anyway |
No description provided.