Hey Trent,

thank you for getting back at me! You know what's funny? Now I had to
dig a bit to recover my finding. :-)

OK, the main point you can see in diff-1.patch: here the command
substitutions are used in a wrong way because the shell expects to
execute what the command substitution returned. Example to illustrate
what I mean:

$ sh -c '$(echo "echo PID is $$")'
PID is 17168

diff-2.patch contains some changes that simplify, replace backticks
for the modern form of Command Substitution and get rid of a check of
$? vs. a direct check of exit status in the if condition.

I have also attached the base version against which patches were done.
This is from Xubuntu 18.04.

I filed the error as a bug against Ubuntu ahavi so it can be properly tracked:
https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/1870824

The other changes are merely suggestions for improvement. I would
probably do more, but then again we should never touch a running
system. :-)

Kind regards

robert

On Tue, Mar 31, 2020 at 11:15 AM Trent Lloyd <trent.ll...@canonical.com> wrote:
>
> Hi Robert,
>
> Sorry for the late reply. This script is specific to the Debian/Ubuntu 
> packages and is not upstream. And actually due to libnss-mdns improvements 
> this script is not required in Focal as libnss-mdns automatically determines 
> if a .local domain exists and directs the queries appropriately. The version 
> in 18.04 (Bionic) however does technically still require it.
>
> In terms of how to submit a patch it would be upstream to Debian and/or 
> Ubuntu directly by filing a bug in the relevant packaging systems.
>
>
> I am the maintainer of Avahi upstream but also active in the Ubuntu 
> development and happy to discuss your patches/thoughts/changes - feel free to 
> open a Launchpad bug and we can always curate it and then send it upstream to 
> Debian. The debian maintainers are also fairly responsive.
>
> Regards,
> Trent
>
> On Tue, 25 Feb 2020 at 02:47, Robert Klemme <shortcut...@googlemail.com> 
> wrote:
>>
>> Hi,
>>
>> I think I found something that could be improved in file
>> /usr/lib/avahi/avahi-daemon-check-dns.sh on my Xubuntu 18.04.4. But
>> somehow I cannot seem to find the right place to deliver a patch, pull
>> request or feedback. Via apt-file I found out the file belongs to
>> package avahi-daemon. When downloading the source via "apt source
>> avahi-daemon" it says
>>
>> $ apt source avahi-daemon
>> Reading package lists... Done
>> Picking 'avahi' as source package instead of 'avahi-daemon'
>> NOTICE: 'avahi' packaging is maintained in the 'Git' version control system 
>> at:
>> git://anonscm.debian.org/pkg-utopia/avahi.git
>> Please use:
>> git clone git://anonscm.debian.org/pkg-utopia/avahi.git
>> to retrieve the latest (possibly unreleased) updates to the package.
>> Need to get 1.373 kB of source archives.
>> Get:1 http://ubuntu.unitedcolo.de/ubuntu bionic-updates/main avahi
>> 0.7-3.1ubuntu1.2 (dsc) [4.186 B]
>> Get:2 http://ubuntu.unitedcolo.de/ubuntu bionic-updates/main avahi
>> 0.7-3.1ubuntu1.2 (tar) [1.333 kB]
>> Get:3 http://ubuntu.unitedcolo.de/ubuntu bionic-updates/main avahi
>> 0.7-3.1ubuntu1.2 (diff) [35,1 kB]
>> Fetched 1.373 kB in 1s (2.417 kB/s)
>> dpkg-source: info: extracting avahi in avahi-0.7
>> dpkg-source: info: unpacking avahi_0.7.orig.tar.gz
>> dpkg-source: info: unpacking avahi_0.7-3.1ubuntu1.2.debian.tar.xz
>> dpkg-source: info: applying fix-manpage-install-conditions.patch
>> dpkg-source: info: applying man-add-missing-bshell.1-symlink.patch
>> dpkg-source: info: applying
>> man-fix-reference-to-avahi-autoipd.action-8-in-avahi-auto.patch
>> dpkg-source: info: applying no-systemd-also.patch
>> dpkg-source: info: applying local-only-services-support.patch
>> dpkg-source: info: applying CVE-2017-6519-and-CVE-2018-1000845.patch
>>
>> I tried git clone git://anonscm.debian.org/pkg-utopia/avahi.git first but
>>
>> $ git clone git://anonscm.debian.org/pkg-utopia/avahi.git
>> Cloning into 'avahi'...
>> fatal: unable to connect to anonscm.debian.org:
>> anonscm.debian.org[0: 194.177.211.202]: errno=Connection refused
>> anonscm.debian.org[1: 2001:648:2ffc:deb::211:202]: errno=Network is 
>> unreachable
>>
>> The system seems up:
>>
>> $ ping -c 4 anonscm.debian.org
>> PING cgi-grnet-01.debian.org (194.177.211.202) 56(84) bytes of data.
>> 64 bytes from cgi-grnet-01.debian.org (194.177.211.202): icmp_seq=1
>> ttl=54 time=63.3 ms
>> 64 bytes from cgi-grnet-01.debian.org (194.177.211.202): icmp_seq=2
>> ttl=54 time=65.2 ms
>> 64 bytes from cgi-grnet-01.debian.org (194.177.211.202): icmp_seq=3
>> ttl=54 time=62.3 ms
>> 64 bytes from cgi-grnet-01.debian.org (194.177.211.202): icmp_seq=4
>> ttl=54 time=63.8 ms
>>
>> --- cgi-grnet-01.debian.org ping statistics ---
>> 4 packets transmitted, 4 received, 0% packet loss, time 3003ms
>> rtt min/avg/max/mdev = 62.336/63.689/65.293/1.067 ms
>>
>> When I checked the .dsc file and try to go to
>> http://anonscm.debian.org/gitweb/?p=pkg-utopia/avahi.git;a=summary I
>> get 404
>>
>> When I look at https://code.launchpad.net/avahi I get pointed to the
>> original repo https://github.com/lathiat/avahi (via
>> https://www.avahi.org/). But in that repo the file does not exist.
>>
>> Now I am confused. What am I missing?
>>
>> Kind regards
>>
>> robert
>>
>>
>> --
>> [guy, jim, charlie, sho].each {|him| remember.him do |as, often|
>> as.you_can - without end}
>> http://blog.rubybestpractices.com/
>>
>> --
>> Ubuntu-devel-discuss mailing list
>> Ubuntu-devel-discuss@lists.ubuntu.com
>> Modify settings or unsubscribe at: 
>> https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss



--
[guy, jim, charlie, sho].each {|him| remember.him do |as, often|
as.you_can - without end}
http://blog.rubybestpractices.com/

Attachment: avahi-daemon-check-dns.sh
Description: application/shellscript

--- /usr/lib/avahi/avahi-daemon-check-dns.sh	2019-01-30 16:32:00.000000000 +0100
+++ avahi-daemon-check-dns.sh	2020-04-04 19:35:30.481897499 +0200
@@ -37,15 +37,15 @@
   fi
 }
 
 dns_reachable() {
   # If there are no nameserver entries in resolv.conf there is no dns reachable
-  $(grep -q nameserver /etc/resolv.conf) || return 1;
+  grep -q nameserver /etc/resolv.conf || return 1;
 
   # If there is no local nameserver and no we have no global ip addresses
   # then we can't reach any nameservers
-  if ! $(egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf); then 
+  if ! egrep -q "nameserver 127.0.0.1|::1" /etc/resolv.conf; then 
     if [ -x "$(which ip)" ]; then
       ADDRS=$(ip addr show scope global | grep inet)
       ROUTES=$(ip route show 0.0.0.0/0)
     elif [ -x "$(which ifconfig)" -a -x "$(which route)" ]; then
       # Get addresses of all running interfaces
--- avahi-daemon-check-dns.sh	2020-04-04 19:35:30.481897499 +0200
+++ avahi-daemon-check-dns.sh-2	2020-04-04 19:44:24.831199418 +0200
@@ -64,20 +64,16 @@
 }
 
 dns_has_local() { 
   # Some magic to do tests 
   if [ -n "${FAKE_HOST_RETURN}" ] ; then
-    if [ "${FAKE_HOST_RETURN}" = "true" ]; then
-      return 0;
-    else
-      return 1;
-    fi
+    [ "${FAKE_HOST_RETURN}" = "true" ]
+    return
   fi
 
   # Use timeout when calling host as workaround for LP: #1752411
-  OUT=`LC_ALL=C timeout 5 host -t soa local. 2>&1`
-  if [ $? -eq 0 ] ; then
+  if OUT=$(LC_ALL=C timeout 5 host -t soa local. 2>&1); then
     if echo "$OUT" | egrep -vq 'has no|not found'; then
       return 0
     fi
   else 
     # Checking the dns servers failed. Assuming no .local unicast dns, but
-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss

Reply via email to