On 27.03.2016 20:07, Roman Bogorodskiy wrote:
* tools/nss/libvirt_nss.[ch]: add BSD-comptabile wrappers and
register via the nss_module_register() interface
* m4/virt-nss.m4: add checks if we're building NSS for FreeBSD
* tools/Makefile.am: handle target library name differences, as
Linux needs libnss_libvirt.so.2 and FreeBSD needs
nss_libvirt.so.1. Also, different syms files have to be used
as Linux needs to export all the methods while FreeBSD
only needs to have nss_module_register()
* tests/nsstest.c, tests/nssmock.c: s/__linux__/NSS/
* libvirt_nss_bsd.syms: FreeBSD syms file
---
m4/virt-nss.m4 | 18 +++++-
tests/nssmock.c | 6 +-
tests/nsstest.c | 2 +-
tools/Makefile.am | 16 ++++-
tools/nss/libvirt_nss.c | 139 +++++++++++++++++++++++++++++++++++++++--
tools/nss/libvirt_nss.h | 9 +++
tools/nss/libvirt_nss_bsd.syms | 9 +++
7 files changed, 189 insertions(+), 10 deletions(-)
create mode 100644 tools/nss/libvirt_nss_bsd.syms
diff --git a/m4/virt-nss.m4 b/m4/virt-nss.m4
index 3fa4ad3..3d6e8f4 100644
--- a/m4/virt-nss.m4
+++ b/m4/virt-nss.m4
@@ -23,6 +23,7 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
[enable Name Servie Switch plugin for resolving guest IP addresses])],
[], [with_nss_plugin=check])
+ bsd_nss=no
fail=0
if test "x$with_nss_plugin" != "xno" ; then
AC_CHECK_HEADERS([nss.h], [
@@ -39,11 +40,26 @@ AC_DEFUN([LIBVIRT_CHECK_NSS],[
if test "x$with_nss_plugin" = "xyes" ; then
AC_DEFINE_UNQUOTED([NSS], 1, [whether nss plugin is enabled])
+
+ AC_CHECK_TYPE([struct gaih_addrtuple],
+ [AC_DEFINE([HAVE_STRUCT_GAIH_ADDRTUPLE], [1],
+ [Defined if struct gaih_addrtuple exists in nss.h])],
+ [], [[#include <nss.h>
+ ]])
+
+ AC_CHECK_TYPES([ns_mtab, nss_module_unregister_fn],
+ [AC_DEFINE([HAVE_BSD_NSS],
+ [1],
+ [whether using BSD style NSS])
+ bsd_nss=yes
+ ],
+ [],
+ [#include <nsswitch.h>])
fi
fi
AM_CONDITIONAL(WITH_NSS, [test "x$with_nss_plugin" = "xyes"])
-
+ AM_CONDITIONAL(WITH_BSD_NSS, [test "x$bsd_nss" = "xyes"])
])
AC_DEFUN([LIBVIRT_RESULT_NSS],[
diff --git a/tests/nssmock.c b/tests/nssmock.c
index b4a4260..31b1177 100644
--- a/tests/nssmock.c
+++ b/tests/nssmock.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifdef __linux__
+#ifdef NSS
# include <stdio.h>
# include <stdlib.h>
# include <dlfcn.h>
@@ -107,7 +107,7 @@ open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, int);
Why this change? I mean, even in the context it can be seen that @mode
is type of mode_t.
Otherwise looking good. ACK
Michal