Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nss-mdns: install all libraries, correct avahi socket path #2303

Merged
merged 1 commit into from
Dec 9, 2017
Merged

nss-mdns: install all libraries, correct avahi socket path #2303

merged 1 commit into from
Dec 9, 2017

Conversation

MilhouseVH
Copy link
Contributor

Avahi isn't loading libnss_mdns_minimal.so.

Also, nss-mdns is using /var/run/avahi-daemon/socket as the path for the Avahi socket - it should be /run/avahi-daemon/socket. In the end I had to resort to a patch, as setting build variables got me nowhere.

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 8, 2017

Without a patch:

pre_configure_target() {
  export CFLAGS="$CFLAGS -UAVAHI_SOCKET -DAVAHI_SOCKET=\\\"/run/avahi-daemon/socket\\\""
}

I'm just not sure about those backslashes. But in library I see path set correctly.

@MilhouseVH
Copy link
Contributor Author

MilhouseVH commented Dec 8, 2017

I'm in the middle of a clean build with the current solution but will try your suggestion afterwards - thanks. Assuming it works then what I missed in my attempts is the -UAVAHI_SOCKET.

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 8, 2017

One other option would be using --localstatedir=/. which makes a path /./run/avahi-daemon/socket. It doesn't look nice but the path is correct :)

@MilhouseVH
Copy link
Contributor Author

One other option would be using --localstatedir=/.

Yes I considered that but thought it was too ugly! :)

@MilhouseVH
Copy link
Contributor Author

MilhouseVH commented Dec 8, 2017

@vpeter4 I had an old build directory available that allowed me to test rebuilding nss-mdns, and with your first solution:

pre_configure_target() {
  export CFLAGS="$CFLAGS -UAVAHI_SOCKET -DAVAHI_SOCKET=\\\"/run/avahi-daemon/socket\\\""
}

I get the same build failure that I saw when I tried setting -DAVAHI_SOCKET (without -UAVAHI_SOCKET): http://sprunge.us/afEM

Edit: Actually, I used a variation with -DAVAHI_SOCKET=\"/run/avahi-daemon/socket\" - let's try again with \\\ and see if that makes any difference...

@MilhouseVH
Copy link
Contributor Author

Aha... success with triple \\\. OK I'll drop the patch and update the package.mk - many thanks!

@MilhouseVH
Copy link
Contributor Author

The -UAVAHI_SOCKET doesn't appear to be necessary, just getting the slashes right is enough!

@MilhouseVH
Copy link
Contributor Author

Updated - thanks!

@MilhouseVH
Copy link
Contributor Author

By the way, each of the libraries is about 10KB in size (there are 6 in total) so not a big increase when including them all.

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 8, 2017

-UAVAHI_SOCKET is just to get rid of warnings about macro redeclaration.
And \\ is used because AVAHI_SOCKET is used as string parameter in function.

@MilhouseVH
Copy link
Contributor Author

-UAVAHI_SOCKET is just to get rid of warnings about macro redeclaration.

Yes you are correct, that does silence the redefined messages:

<command-line>:0:0: warning: "AVAHI_SOCKET" redefined

I've added back the -UAVAHI_SOCKET.

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 9, 2017

@MilhouseVH: doesn't avahi still using /var/run/avahi-daemon/socket? Should fix be applied there too? Or they have to be different?

@MilhouseVH
Copy link
Contributor Author

No, avahi uses /run/avahi-daemon/socket:

LibreELEC (community): devel-20171208232721-#1208-g712987f (RPi2.arm)
rpi22:~ # ls -la /run/avahi-daemon/socket
srwxrwxrwx    1 avahi    avahi            0 Oct  6 09:18 /run/avahi-daemon/socket

Changing avahi to use the same path that nss-mdns assumes (ie. /var/run/avahi-daemon/socket) would have been the other option, of course, but damned if you do, damned if you don't - changing avahi might have broken some other package (I've no idea what packages are using avahi).

I figured changing nss-mdns is the least worst option as we know it's wrong, while we don't know what else is using (but working correctly with) avahi.

If you think changing avahi is the better option then I'll take a patch - I've spent too long on this already and I'm not even sure if it gets us any further forward as the way people expect mDNS to work always seems to conflict with how it should work.

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 9, 2017

Ok then. I was grepping avahi build folder for this path and I have /var/run/avahi-daemon/socket inside them.

@MilhouseVH
Copy link
Contributor Author

MilhouseVH commented Dec 9, 2017

Unpacked source-code:

neil@nm-linux:~/projects/.unpack/avahi-0.7$ grep -r avahi_runtime_dir
configure.ac:avahi_runtime_dir="/run"
configure.ac:avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket"
configure.ac:AC_SUBST(avahi_runtime_dir)
avahi-daemon/Makefile.am:       -DAVAHI_DAEMON_RUNTIME_DIR=\"$(avahi_runtime_dir)/avahi-daemon/\" \
avahi-daemon/Makefile.am:               -e 's,@avahi_runtime_dir\@,$(avahi_runtime_dir),g' $< > $@
avahi-daemon/Makefile.am:       test -z "$(avahi_runtime_dir)" || $(MKDIR_P) "$(DESTDIR)$(avahi_runtime_dir)"
avahi-daemon/avahi-daemon.socket.in:ListenStream=@avahi_runtime_dir@/avahi-daemon/socket
avahi-autoipd/Makefile.am:      -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \
avahi-dnsconfd/Makefile.am:     -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \

No mention of /var. I'm looking in my avahi build directory (Generic) and see only /run/..., no mention of /var/run/.... Do you have something setting -DAVAHI_RUNTIME_DIR or -DAVAHI_DAEMON_RUNTIME_DIR by any chance?

@vpeter4
Copy link
Contributor

vpeter4 commented Dec 9, 2017

Maybe I see differently because I'm not on latest master. I assume it is all good then :)

@MilhouseVH
Copy link
Contributor Author

Ta-da!

neil@nm-linux:~/projects/.unpack/avahi-0.6.32$ grep -r avahi_runtime_dir
configure.ac:avahi_runtime_dir="${localstatedir}/run"
configure.ac:avahi_socket="${avahi_runtime_dir}/avahi-daemon/socket"
configure.ac:AC_SUBST(avahi_runtime_dir)
avahi-daemon/Makefile.am:       -DAVAHI_DAEMON_RUNTIME_DIR=\"$(avahi_runtime_dir)/avahi-daemon/\" \
avahi-daemon/Makefile.am:               -e 's,@avahi_runtime_dir\@,$(avahi_runtime_dir),g' $< > $@
avahi-daemon/avahi-daemon.socket.in:ListenStream=@avahi_runtime_dir@/avahi-daemon/socket
avahi-autoipd/Makefile.am:      -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \
avahi-dnsconfd/Makefile.am:     -DAVAHI_RUNTIME_DIR=\"$(avahi_runtime_dir)/\" \

So ${localstatedir} (default: /var) is dropped in avahi 0.7.

This is the relevant avahi PR: avahi/avahi#46

@MilhouseVH
Copy link
Contributor Author

It wasn't a popular change however, see avahi/avahi#150.

Modern, systemd based systems symlink /var/run to /run so there was no problems with the way it was.

We don't, but it might be an idea if it's common practice...

@MilhouseVH
Copy link
Contributor Author

Keep this open until we decide whether to symlink /var/run to /run, or not. I think a symlink might be a better solution (Ubuntu does it, for instance).

@@ -29,9 +29,8 @@ PKG_SHORTDESC="nss-mdns is a plugin for nss to allow name resolution via Multica
PKG_LONGDESC="nss-mdns is a plugin for the GNU Name Service Switch (NSS) functionality of the GNU C Library (glibc) providing host name resolution via Multicast DNS"
PKG_TOOLCHAIN="autotools"

makeinstall_target() {
mkdir -p $SYSROOT_PREFIX/usr/lib
cp -P $PKG_BUILD/.$TARGET_NAME/src/.libs/libnss_mdns_minimal.so.2 $SYSROOT_PREFIX/usr/lib
Copy link
Contributor

Choose a reason for hiding this comment

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

Avahi isn't loading libnss_mdns_minimal.so.

The bug in the old code is copying the lib to $SYSROOT_PREFIX only omitting $INSTALL.

But I agree with you the few kB don't harm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes absolutely! However even if the minimal library had been installed avahi wouldn't have loaded it.

@MilhouseVH
Copy link
Contributor Author

MilhouseVH commented Dec 9, 2017

The problem with the missing /var/run symlink is being caused by tz-data.service which is creating /var/run as a directory and preventing the symlink to /run from being created. See #2308.

I've now dropped the /var/run fix, as it is no longer necessary once #2308 merges.

@chewitt chewitt merged commit 9000ad5 into LibreELEC:master Dec 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants