[libvirt] [PATCH] nss: use more strict check for automatic enabling

Currently nss plugin is automatically enabled if nss.h header exists and --without-nss-plugin is not specified. However, presence of the nss.h header does not guarantee a compatible interface, so check for struct gaih_addrtuple to make sure it's enabled only on platforms where it could be built. --- m4/virt-nss.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4 index 3fa4ad3..bc054db 100644 --- a/m4/virt-nss.m4 +++ b/m4/virt-nss.m4 @@ -25,12 +25,14 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[ fail=0 if test "x$with_nss_plugin" != "xno" ; then - AC_CHECK_HEADERS([nss.h], [ + AC_CHECK_TYPE([struct gaih_addrtuple], [ with_nss_plugin=yes ],[ if test "x$with_nss_plugin" = "xyes" ; then fail = 1 fi + ],[ + #include <nss.h> ]) if test $fail = 1 ; then -- 2.4.6

On 21.03.2016 06:21, Roman Bogorodskiy wrote:
Currently nss plugin is automatically enabled if nss.h header exists and --without-nss-plugin is not specified. However, presence of the nss.h header does not guarantee a compatible interface, so check for struct gaih_addrtuple to make sure it's enabled only on platforms where it could be built. --- m4/virt-nss.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4 index 3fa4ad3..bc054db 100644 --- a/m4/virt-nss.m4 +++ b/m4/virt-nss.m4 @@ -25,12 +25,14 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
fail=0 if test "x$with_nss_plugin" != "xno" ; then - AC_CHECK_HEADERS([nss.h], [ + AC_CHECK_TYPE([struct gaih_addrtuple], [ with_nss_plugin=yes ],[ if test "x$with_nss_plugin" = "xyes" ; then fail = 1 fi + ],[ + #include <nss.h> ])
if test $fail = 1 ; then
While this would fix the build, it would disable the whole feature on freebsd. The problem is with the structure that is needed just for _nss_libvirt_gethostbyname4_r(). Should we change the code in that way that the function is built conditionally when the structure is present? That way we still could have _gethostbyname3_r() on systems providing the header file but not having the structure. Michal

Michal Privoznik wrote:
On 21.03.2016 06:21, Roman Bogorodskiy wrote:
Currently nss plugin is automatically enabled if nss.h header exists and --without-nss-plugin is not specified. However, presence of the nss.h header does not guarantee a compatible interface, so check for struct gaih_addrtuple to make sure it's enabled only on platforms where it could be built. --- m4/virt-nss.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4 index 3fa4ad3..bc054db 100644 --- a/m4/virt-nss.m4 +++ b/m4/virt-nss.m4 @@ -25,12 +25,14 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
fail=0 if test "x$with_nss_plugin" != "xno" ; then - AC_CHECK_HEADERS([nss.h], [ + AC_CHECK_TYPE([struct gaih_addrtuple], [ with_nss_plugin=yes ],[ if test "x$with_nss_plugin" = "xyes" ; then fail = 1 fi + ],[ + #include <nss.h> ])
if test $fail = 1 ; then
While this would fix the build, it would disable the whole feature on freebsd. The problem is with the structure that is needed just for _nss_libvirt_gethostbyname4_r(). Should we change the code in that way that the function is built conditionally when the structure is present? That way we still could have _gethostbyname3_r() on systems providing the header file but not having the structure.
To tell the truth, I didn't look close at the nss implementation and wasn't sure if interfaces are compatible on Linux and FreeBSD for such type of things. I'll take a look if I can use this plugin on FreeBSD if I just disable _nss_libvirt_gethostbyname4_r() related stuff. Roman Bogorodskiy

Roman Bogorodskiy wrote:
Michal Privoznik wrote:
On 21.03.2016 06:21, Roman Bogorodskiy wrote: While this would fix the build, it would disable the whole feature on freebsd. The problem is with the structure that is needed just for _nss_libvirt_gethostbyname4_r(). Should we change the code in that way that the function is built conditionally when the structure is present? That way we still could have _gethostbyname3_r() on systems providing the header file but not having the structure.
To tell the truth, I didn't look close at the nss implementation and wasn't sure if interfaces are compatible on Linux and FreeBSD for such type of things.
I'll take a look if I can use this plugin on FreeBSD if I just disable _nss_libvirt_gethostbyname4_r() related stuff.
Quick follow up on this: I tried the patch you posted on IRC (http://fpaste.org/343763/58660075/). As ALIGN is defined by system headers on FreeBSD, I just renamed it to LIBVIRT_ALIGN and got it compiled. However, trying to use it spawned an error like this: NSSWITCH(nss_load_module): libvirt, Undefined symbol "nss_module_register" Apparently, FreeBSD's nss layout requires some additional steps: defining an array of the methods provided and registering it with nss_module_register (at least that's what I understood after playing with that briefly). I hope I can bring this together before the next release. Roman Bogorodskiy
participants (2)
-
Michal Privoznik
-
Roman Bogorodskiy