diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2010-10-04 21:35:46 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2010-10-04 21:35:46 +0200 |
commit | b7c3c078c873b1596519b661fdc5b35d48794ace (patch) | |
tree | 820602961c5746e09ecae953daf804769358b8a1 | |
parent | 4db60137880169354d4596a598509600d125ccaf (diff) |
merge some of the changes for Solaris portability to ease merging, adding --with-pam-seclib-dir, --with-pam-ldap-soname and --with-nss-flavour options and having some auto-detection for SONAMEs and NSS flavour
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1239 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r-- | compat/nss_compat.h | 3 | ||||
-rw-r--r-- | configure.ac | 90 | ||||
-rw-r--r-- | nss/Makefile.am | 6 | ||||
-rw-r--r-- | nss/common.h | 1 | ||||
-rw-r--r-- | nss/hosts.c | 14 | ||||
-rw-r--r-- | nss/networks.c | 16 | ||||
-rw-r--r-- | nss/prototypes.h | 8 | ||||
-rw-r--r-- | pam/Makefile.am | 9 |
8 files changed, 119 insertions, 28 deletions
diff --git a/compat/nss_compat.h b/compat/nss_compat.h index f38463e..232519e 100644 --- a/compat/nss_compat.h +++ b/compat/nss_compat.h @@ -49,6 +49,9 @@ #ifdef HAVE_NSSWITCH_H #include <nsswitch.h> #endif /* HAVE_NSSWITCH_H */ +#ifdef HAVE_IRS_NSS_H +#include "irs-nss.h" +#endif /* HAVE_IRS_NSS_H */ #include "compat/ether.h" diff --git a/configure.ac b/configure.ac index f56d515..9b5c8e6 100644 --- a/configure.ac +++ b/configure.ac @@ -207,15 +207,50 @@ AC_ARG_WITH(nslcd-socket, AC_DEFINE_UNQUOTED(NSLCD_SOCKET,"$NSLCD_SOCKET",[The location of the socket used for communicating.]) AC_SUBST(NSLCD_SOCKET) +# the directory PAM librabries are expected to be placed into +AC_ARG_WITH(pam-seclib-dir, + AS_HELP_STRING([--with-pam-seclib-dir=PAM_SECLIB_DIR], + [path to PAM security library]), + [ PAM_SECLIB_DIR="$with_pam_seclib_dir" ], + [ PAM_SECLIB_DIR="/lib/security" ]) +AC_DEFINE_UNQUOTED(PAM_SECLIB_DIR,"$PAM_SECLIB_DIR",[path to PAM security library]) +AC_SUBST(PAM_SECLIB_DIR) + # the SONAME to use for the NSS module +AC_MSG_CHECKING([name of NSS module]) AC_ARG_WITH(nss-ldap-soname, AS_HELP_STRING([--with-nss-ldap-soname=SONAME], - [name of NSS module @<:@libnss_ldap.so.2@:>@]), + [name of NSS module @<:@auto@:>@]), [ NSS_LDAP_SONAME="$with_nss_ldap_soname" ], - [ NSS_LDAP_SONAME="libnss_ldap.so.2" ]) + [ NSS_LDAP_SONAME="auto" ]) +if test "x$NSS_LDAP_SONAME" = "xauto" +then + case "$target_os" in + solaris*) NSS_LDAP_SONAME="nss_ldap.so.1" ;; + *) NSS_LDAP_SONAME="libnss_ldap.so.2" ;; + esac +fi +AC_MSG_RESULT($NSS_LDAP_SONAME) AC_DEFINE_UNQUOTED(NSS_LDAP_SONAME,"$NSS_LDAP_SONAME",[The SONAME of the NSS library module.]) AC_SUBST(NSS_LDAP_SONAME) +# the SONAME to use for the PAM module +AC_MSG_CHECKING([name of PAM module]) +AC_ARG_WITH(pam-ldap-soname, + AS_HELP_STRING([--with-pam-ldap-soname=SONAME], + [name of PAM module @<:@auto@:>@]), + [ PAM_LDAP_SONAME="$with_pam_ldap_soname" ], + [ PAM_LDAP_SONAME="auto" ]) +if test "x$PAM_LDAP_SONAME" = "xauto" +then + case "$target_os" in + solaris*) PAM_LDAP_SONAME="pam_ldap.so.1" ;; + *) PAM_LDAP_SONAME="pam_ldap.so" ;; + esac +fi +AC_MSG_RESULT($PAM_LDAP_SONAME) +AC_SUBST(PAM_LDAP_SONAME) + # check which modules should be build AC_ARG_WITH(nss-ldap-maps, AS_HELP_STRING([--with-nss-ldap-maps=MAP LIST], @@ -326,15 +361,62 @@ then #include <rpc/rpcent.h> #endif]) - # check for a definition of enum nss_status - AC_CHECK_TYPES(enum nss_status,,,[ + # check for a definition of enum nss_status and nss_backend_t + AC_CHECK_TYPES([enum nss_status,nss_backend_t],,,[ #ifdef HAVE_NSS_H #include <nss.h> #endif #ifdef HAVE_NSS_COMMON_H #include <nss_common.h> + #endif + #ifdef HAVE_NSS_DBDEFS_H + #include <nss_dbdefs.h> + #endif + #ifdef HAVE_NSSWITCH_H + #include <nsswitch.h> + #endif + #ifdef HAVE_IRS_NSS_H + #include "irs-nss.h" #endif]) + # check if struct nss_XbyY_args has a returnlen attribute + AC_CHECK_MEMBER([struct nss_XbyY_args.returnlen],,,[[ + #ifdef HAVE_NSS_H + #include <nss.h> + #endif + #ifdef HAVE_NSS_COMMON_H + #include <nss_common.h> + #endif + #ifdef HAVE_NSS_DBDEFS_H + #include <nss_dbdefs.h> + #endif + #ifdef HAVE_NSSWITCH_H + #include <nsswitch.h> + #endif + #ifdef HAVE_IRS_NSS_H + #include "irs-nss.h" + #endif]]) + + # check which NSS flavour to build + AC_MSG_CHECKING([which NSS flavour to build]) + AC_ARG_WITH(nss-flavour, + AS_HELP_STRING([--with-nss-flavour=auto|glibc|solaris], + [the libc flavour to build our NSS module for @<:@auto@:>@]),, + with_nss_flavour=auto) + if test "x$with_nss_flavour" = "xauto" + then + # do the guessing game + case "$target_os" in + solaris*) with_nss_flavour=solaris ;; + *) with_nss_flavour=glibc ;; + esac + fi + AC_MSG_RESULT($with_nss_flavour) + case "$with_nss_flavour" in + glibc) AC_DEFINE(NSS_FLAVOUR_GLIBC,1,[Whether to use the Glibc NSS interface flavour.]) ;; + solaris) AC_DEFINE(NSS_FLAVOUR_SOLARIS,1,[Whether to use the Solaris NSS interface flavour.]) ;; + esac + # check which module source files to use AC_MSG_CHECKING([which NSS maps to build]) if test "x$with_nss_ldap_maps" = "xall" diff --git a/nss/Makefile.am b/nss/Makefile.am index 9420d6a..1efe77b 100644 --- a/nss/Makefile.am +++ b/nss/Makefile.am @@ -3,6 +3,7 @@ # Copyright (C) 2006 Luke Howard # Copyright (C) 2006 West Consulting # Copyright (C) 2006, 2007, 2009, 2010 Arthur de Jong +# Copyright (C) 2010 Symas Corporation # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -42,8 +43,9 @@ EXTRA_DIST = nss_ldap.map install-exec-local: install-nss_ldap_so uninstall-local: uninstall-nss_ldap_so -# install libnss_ldap.so.2 install-nss_ldap_so: nss_ldap.so - $(INSTALL_PROGRAM) -D nss_ldap.so $(DESTDIR)$(libdir)/$(NSS_LDAP_SONAME) + -rm -f $(DESTDIR)$(libdir)/$(NSS_LDAP_SONAME) + $(mkinstalldirs) $(DESTDIR)$(libdir) + $(INSTALL_PROGRAM) nss_ldap.so $(DESTDIR)$(libdir)/$(NSS_LDAP_SONAME) uninstall-nss_ldap_so: -rm -f $(DESTDIR)$(libdir)/$(NSS_LDAP_SONAME) diff --git a/nss/common.h b/nss/common.h index e7182de..f9f5fbe 100644 --- a/nss/common.h +++ b/nss/common.h @@ -24,6 +24,7 @@ #define NSS__COMMON_H 1 #include <stdio.h> +#include <stdlib.h> #include "nslcd.h" #include "common/nslcd-prot.h" diff --git a/nss/hosts.c b/nss/hosts.c index 6d5c406..5a48f6e 100644 --- a/nss/hosts.c +++ b/nss/hosts.c @@ -2,7 +2,7 @@ hosts.c - NSS lookup functions for hosts database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008 Arthur de Jong + Copyright (C) 2006, 2007, 2008, 2010 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 @@ -161,6 +161,12 @@ static nss_status_t read_hostent_nextonempty( return NSS_STATUS_SUCCESS; } +/* write an address value */ +#define WRITE_ADDRESS(fp,af,len,addr) \ + WRITE_INT32(fp,af); \ + WRITE_INT32(fp,len); \ + WRITE(fp,addr,len); + /* this function looks up a single host entry and returns all the addresses associated with the host in a single address familiy name - IN - hostname to lookup @@ -186,12 +192,6 @@ nss_status_t _nss_ldap_gethostbyname_r( return _nss_ldap_gethostbyname2_r(name,AF_INET,result,buffer,buflen,errnop,h_errnop); } -/* write an address value */ -#define WRITE_ADDRESS(fp,af,len,addr) \ - WRITE_INT32(fp,af); \ - WRITE_INT32(fp,len); \ - WRITE(fp,addr,len); - /* this function looks up a single host entry and returns all the addresses associated with the host in a single address familiy addr - IN - the address to look up diff --git a/nss/networks.c b/nss/networks.c index 8273f27..3c7d10f 100644 --- a/nss/networks.c +++ b/nss/networks.c @@ -2,7 +2,7 @@ networks.c - NSS lookup functions for networks database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008 Arthur de Jong + Copyright (C) 2006, 2007, 2008, 2010 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 @@ -99,13 +99,6 @@ static nss_status_t read_netent( return retv; } -nss_status_t _nss_ldap_getnetbyname_r(const char *name,struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop) -{ - NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME, - name, - read_netent(fp,result,buffer,buflen,errnop,h_errnop)); -} - /* write an address value */ /* version 2.10 of glibc changed the address from network to host order (changelog entry 2009-07-01) */ @@ -114,6 +107,13 @@ nss_status_t _nss_ldap_getnetbyname_r(const char *name,struct netent *result,cha WRITE_INT32(fp,4); \ WRITE_INT32(fp,htonl(addr)); +nss_status_t _nss_ldap_getnetbyname_r(const char *name,struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop) +{ + NSS_BYNAME(NSLCD_ACTION_NETWORK_BYNAME, + name, + read_netent(fp,result,buffer,buflen,errnop,h_errnop)); +} + /* Note: the af parameter is ignored and is assumed to be AF_INET */ /* TODO: implement handling of af parameter */ nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr,int UNUSED(af),struct netent *result,char *buffer,size_t buflen,int *errnop,int *h_errnop) diff --git a/nss/prototypes.h b/nss/prototypes.h index 862b04a..ffb0151 100644 --- a/nss/prototypes.h +++ b/nss/prototypes.h @@ -25,6 +25,10 @@ #include "compat/nss_compat.h" +/* flag to gloabally disable lookups (all _nss_ldap_*() functions will return + NSS_STATUS_UNAVAIL */ +extern int _nss_ldap_enablelookups; + /* These are prototypes for functions exported from the ldap NSS module. For more complete definitions of these functions check the GLIBC @@ -38,10 +42,6 @@ http://www.gnu.org/software/libc/manual/html_node/Name-Service-Switch.html */ -/* flag to gloabally disable lookups (all _nss_ldap_*() functions will return - NSS_STATUS_UNAVAIL */ -extern int _nss_ldap_enablelookups; - /* aliases - mail aliases */ nss_status_t _nss_ldap_getaliasbyname_r(const char *name,struct aliasent *result,char *buffer,size_t buflen,int *errnop); nss_status_t _nss_ldap_setaliasent(void); diff --git a/pam/Makefile.am b/pam/Makefile.am index 8bdd411..497440a 100644 --- a/pam/Makefile.am +++ b/pam/Makefile.am @@ -1,6 +1,7 @@ # Makefile.am - use automake to generate Makefile.in # # Copyright (C) 2009, 2010 Arthur de Jong +# Copyright (C) 2010 Symas Corporation # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -36,8 +37,10 @@ EXTRA_DIST = pam_ldap.map install-exec-local: install-pam_ldap_so uninstall-local: uninstall-pam_ldap_so -# install pam_ldap.so install-pam_ldap_so: pam_ldap.so - $(INSTALL_PROGRAM) -D pam_ldap.so $(DESTDIR)$(libdir)/security/pam_ldap.so + -rm -f $(DESTDIR)/$(PAM_SECLIB_DIR)/$(PAM_LDAP_SONAME) + $(mkinstalldirs) $(DESTDIR)/$(PAM_SECLIB_DIR) + $(INSTALL_PROGRAM) pam_ldap.so $(DESTDIR)$(libdir)/$(PAM_LDAP_SONAME) + uninstall-pam_ldap_so: - -rm -f $(DESTDIR)$(libdir)/security/pam_ldap.so + -rm -f $(DESTDIR)/$(PAM_SECLIB_DIR)/$(PAM_LDAP_SONAME) |