No mdns support in snaps (should core have a modified nsswitch.conf ?)

@ogra, thanks, and especially thanks as you have also corrected a bug with it, using $SNAPCRAFT_ARCH_TRIPLET as my version with x86_64-linux-gnu was naturally not working on non-amd64 systems.

I have updated my Snaps again now. The complete changes in snapcraft.yaml needed to add mDNS look-up of .local host names are now:

[...]
# Make resolution of ".local" host names (Zero-Conf/mDNS/DNS-SD)
# working: Mirror nsswitch.conf with added mDNS look-up support into
# /etc/nsswitch.conf
layout:
  /etc/nsswitch.conf:
    bind-file: $SNAP/etc/nsswitch.conf
[...]
parts:
  [...]
  mdns-lookup:
    # Make resolution of ".local" host names (Zero-Conf/mDNS/DNS-SD)
    # working: Take the original nsswitch.conf file from the base
    # Snap and add "mdns4_minimal [NOTFOUND=return]" to its "hosts:" line
    # Also install corresponding mdns4_minimal plug-in
    # See: https://forum.snapcraft.io/t/no-mdns-support-in-snaps-should-core-have-a-modified-nsswitch-conf/
    plugin: nil
    stage-packages:
      - libnss-mdns
    override-prime: |
      set -eux
      sed -Ee 's/^\s*hosts:(\s+)files/hosts:\1files mdns4_minimal \[NOTFOUND=return\]/' /snap/core20/current/etc/nsswitch.conf > $SNAPCRAFT_STAGE/etc/nsswitch.conf
      snapcraftctl prime
    prime:
      - lib/$SNAPCRAFT_ARCH_TRIPLET/libnss_mdns4_minimal*
      - etc/nsswitch.conf
  [...]
1 Like