openresolv-discuss

Re: openresolv enabled status

Roy Marples

Fri Feb 05 17:38:35 2021

On 05/02/2021 14:44, Petr Menšík wrote:
Thanks for quick reply.

Unfortunately such test would not work on Fedora, because resolvconf is
always present. It is linked to systemd by default. >
lrwxrwxrwx. 1 root root 17 Dec 16 12:26 /usr/sbin/resolvconf ->
../bin/resolvectl

/sbin/resolvconf is always present on NetBSD and FreeBSD as well.


Because systemd-resolved does not have its own package, but is part of
systemd package, uninstallation is far from simple. It is usually just
disabled by command "systemctl disable systemd-resolved".

I used alternatives system as a workaround, resulting in:
$ ls -l /usr/sbin/resolvconf /etc/alternatives/resolvconf
lrwxrwxrwx. 1 root root 31 Feb  1 17:39 /etc/alternatives/resolvconf ->
/usr/sbin/resolvconf.openresolv
lrwxrwxrwx. 1 root root 28 Feb  1 17:39 /usr/sbin/resolvconf ->
/etc/alternatives/resolvconf

But that would mean, some resolvconf is always there. But not always
would be active.

Shame that the implementation is poor.
Disabled just means it writes directly to resolv.conf for you.
Actually that's not entirely true.
You can set resolvconf=NO in /etc/etc/resolvconf.conf.
This just stops the subscribers from running, including libc - so /etc/resolv.conf is never updated. Howver, the input is still accepted so that if the user turns the flag resolvconf back on they can then run `resolvconf -u` and it will apply the latest configuration.
So maybe semi disabled?

Anyway, the original design was so the calling application didn't have to think too hard, keeping it simple.

What I would do is have /sbin/resolvconf as a shell application

#/sbin/sh
# Has user installed openresolv?
# YES - pipe stdin to openresolv and pass args
# NO  - pipe stdin to systemd resovlconf and pass args
# return result

You could then make this flexable and just this like so

if [ -x /sbin/resolvconf ] && [ -e /etc/resolvconf.enabled ]; then
	echo "$resolv" | resolvconf -a interface.foo
else
	echo "$resolv" > /etc/resolv.conf
fi

You could then make the enabled test whatever you like if that's what you need.

Saying that, this patch also adds the Debian option if you prefer

diff --git a/resolvconf.in b/resolvconf.in
index 198096b..f70b27f 100644
--- a/resolvconf.in
+++ b/resolvconf.in
@@ -708,6 +708,15 @@ make_vars()
        echo "DOMAINS='$newdomains'"
 }

+# getopts doesn't support long options and some application expect
+# to check this Debian resolvconf option.
+if [ "$1" = "--updates-are-enabled" ]; then
+       case "${resolvconf:-YES}" in
+       [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) exit 0;;
+       *) exit 1;;
+       esac
+fi
+
 force=false
 VFLAG=
 while getopts a:C:c:Dd:fhIilm:pRruvVx OPT; do

Roy

References:
openresolv enabled statusPetr Menšík
Re: openresolv enabled statusRoy Marples
Re: openresolv enabled statusPetr Menšík
Archive administrator: postmaster@marples.name