diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-01-14 21:24:23 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-01-14 21:24:23 +0000 |
commit | b5b6c48ff54edcbe6e43e3dbe412f9faf911ab3f (patch) | |
tree | c85d7c5165b6ee4c62ff4dc74e4b49608ea3c719 | |
parent | 0a5ac8b614588f26e930c1337f1b24a00bba86f4 (diff) |
check whether setnetgrent() returns int or void (for FreeBSD)
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1914 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | configure.ac | 18 | ||||
-rw-r--r-- | tests/lookup_netgroup.c | 6 |
2 files changed, 23 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index cb166d9..d1440f4 100644 --- a/configure.ac +++ b/configure.ac @@ -341,6 +341,24 @@ AC_CHECK_TYPE(socklen_t,, #include <sys/types.h> #include <sys/socket.h>]) +# check the return type of setnetgrent() +AC_CACHE_CHECK( + [return type of setnetgrent], + nss_pam_ldapd_cv_setnetgrent_type, + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include <netdb.h> + ]], [[ + return setnetgrent(0); + ]])], + [nss_pam_ldapd_cv_setnetgrent_type=int], + [nss_pam_ldapd_cv_setnetgrent_type=void]) ]) +if test "x$nss_pam_ldapd_cv_setnetgrent_type" = "xvoid" +then + AC_DEFINE(SETNETGRENT_RETURNS_VOID, 1, + [Define to 1 if setnetgrent() returns void.]) +fi + # NSS module-specific tests if test "x$enable_nss" = "xyes" then diff --git a/tests/lookup_netgroup.c b/tests/lookup_netgroup.c index 024de56..07fbfbb 100644 --- a/tests/lookup_netgroup.c +++ b/tests/lookup_netgroup.c @@ -1,7 +1,7 @@ /* lookup_netgroup.c - simple lookup code for netgroups - Copyright (C) 2012 Arthur de Jong + Copyright (C) 2012, 2013 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -38,11 +38,15 @@ int main(int argc,char *argv[]) exit(EXIT_FAILURE); } /* start lookup */ +#ifdef SETNETGRENT_RETURNS_VOID + setnetgrent(argv[1]); +#else /* not SETNETGRENT_RETURNS_VOID */ if (setnetgrent(argv[1]) != 0) { /* output nothing */ exit(EXIT_FAILURE); } +#endif /* not SETNETGRENT_RETURNS_VOID */ fprintf(stdout, "%-20s", argv[1]); while (getnetgrent(&host, &user, &domain) != 0) { |