From ee82d2f519cc97aa433cf050b6c96d3430aa5a61 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Mon, 19 Jan 2015 23:08:59 +0100 Subject: [PATCH] Allow configuration of NSS and PAM names This introduces the --with-module-name configure option to allow building of NSS and PAM modules with different namespaces than ldap. --- .gitignore | 3 ++ configure.ac | 40 ++++++++++----- nslcd/nslcd.c | 6 +-- nss/Makefile.am | 8 ++- nss/aliases.c | 10 ++-- nss/bsdnss.c | 56 ++++++++++----------- nss/common.c | 6 +-- nss/common.h | 4 +- nss/ethers.c | 14 +++--- nss/group.c | 16 +++--- nss/hosts.c | 18 +++---- nss/netgroup.c | 14 +++--- nss/networks.c | 14 +++--- nss/passwd.c | 14 +++--- nss/protocols.c | 14 +++--- nss/prototypes.h | 130 ++++++++++++++++++++++++------------------------ nss/rpc.c | 14 +++--- nss/services.c | 14 +++--- nss/shadow.c | 12 ++--- pam/pam.c | 6 +-- pynslcd/constants.py.in | 5 +- pynslcd/pynslcd.py | 7 +-- 22 files changed, 226 insertions(+), 199 deletions(-) diff --git a/.gitignore b/.gitignore index 6554d20..8380b28 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,9 @@ stamp-* # /nslcd/ /nslcd/nslcd +# /nss/ +/nss/exports.map + # /pynslcd/ /pynslcd/constants.py diff --git a/configure.ac b/configure.ac index 90cfb14..8492867 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # # Copyright (C) 2006 Luke Howard # Copyright (C) 2006 West Consulting -# Copyright (C) 2006-2014 Arthur de Jong +# Copyright (C) 2006-2015 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 @@ -23,7 +23,7 @@ AC_PREREQ(2.61) AC_COPYRIGHT( [Copyright (C) 2006 Luke Howard Copyright (C) 2006 West Consulting -Copyright (C) 2006-2014 Arthur de Jong +Copyright (C) 2006-2015 Arthur de Jong This configure script is derived from configure.ac which is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser @@ -283,8 +283,22 @@ AC_MSG_RESULT($PAM_SECLIB_DIR) AC_DEFINE_UNQUOTED(PAM_SECLIB_DIR, "$PAM_SECLIB_DIR", [path to PAM security library]) AC_SUBST(PAM_SECLIB_DIR) +# the name to use for the NSS module +AC_MSG_CHECKING([name of NSS and PAM modules]) +AC_ARG_WITH(module-name, + AS_HELP_STRING([--with-module-name=NAME], + [name of NSS and PAM modules @<:@ldap@:>@]), + [ MODULE_NAME="$with_module_name" ], + [ MODULE_NAME="ldap" ]) + # FIXME: this does not work +AC_MSG_RESULT($MODULE_NAME) +AC_DEFINE_UNQUOTED(MODULE_NAME, "$MODULE_NAME", [The name of the NSS and PAM modules.]) +AC_DEFINE_UNQUOTED(NSS_NAME(NAME), [_nss_${MODULE_NAME}_##NAME], [Expand to NSS symbol name.]) +AC_DEFINE_UNQUOTED(PAM_NAME(NAME), [_pam_${MODULE_NAME}_##NAME], [Expand to PAM symbol name.]) +AC_SUBST(MODULE_NAME) + # the SONAME to use for the NSS module -AC_MSG_CHECKING([name of NSS module]) +AC_MSG_CHECKING([soname of NSS module]) AC_ARG_WITH(nss-ldap-soname, AS_HELP_STRING([--with-nss-ldap-soname=SONAME], [name of NSS module @<:@auto@:>@]), @@ -293,9 +307,9 @@ AC_ARG_WITH(nss-ldap-soname, if test "x$NSS_LDAP_SONAME" = "xauto" then case "$target_os" in - solaris*) NSS_LDAP_SONAME="nss_ldap.so.1" ;; - freebsd*|dragonfly*) NSS_LDAP_SONAME="nss_ldap.so.1" ;; - *) NSS_LDAP_SONAME="libnss_ldap.so.2" ;; + solaris*) NSS_LDAP_SONAME="nss_$MODULE_NAME.so.1" ;; + freebsd*|dragonfly*) NSS_LDAP_SONAME="nss_$MODULE_NAME.so.1" ;; + *) NSS_LDAP_SONAME="libnss_$MODULE_NAME.so.2" ;; esac fi AC_MSG_RESULT($NSS_LDAP_SONAME) @@ -303,7 +317,7 @@ AC_DEFINE_UNQUOTED(NSS_LDAP_SONAME, "$NSS_LDAP_SONAME", [The SONAME of the NSS l AC_SUBST(NSS_LDAP_SONAME) # the SONAME to use for the PAM module -AC_MSG_CHECKING([name of PAM module]) +AC_MSG_CHECKING([soname of PAM module]) AC_ARG_WITH(pam-ldap-soname, AS_HELP_STRING([--with-pam-ldap-soname=SONAME], [name of PAM module @<:@auto@:>@]), @@ -312,8 +326,8 @@ AC_ARG_WITH(pam-ldap-soname, 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" ;; + solaris*) PAM_LDAP_SONAME="pam_$MODULE_NAME.so.1" ;; + *) PAM_LDAP_SONAME="pam_$MODULE_NAME.so" ;; esac fi AC_MSG_RESULT($PAM_LDAP_SONAME) @@ -515,6 +529,8 @@ then solaris) AC_DEFINE(NSS_FLAVOUR_SOLARIS, 1, [Whether to use the Solaris NSS interface flavour.]) ;; freebsd) AC_DEFINE(NSS_FLAVOUR_FREEBSD, 1, [Whether to use the FreeBSD NSS interface flavour.]) ;; esac + NSS_FLAVOUR="$with_nss_flavour" + AC_SUBST(NSS_FLAVOUR) # check which module source files to use AC_MSG_CHECKING([which NSS maps to build]) @@ -536,13 +552,13 @@ then solaris*) if test "x$GCC" = xyes then - nss_ldap_so_LINK="/usr/ccs/bin/ld -Bdirect -z nodelete -Bdynamic -M \$(srcdir)/exports.solaris -G -o \$@" + nss_ldap_so_LINK="/usr/ccs/bin/ld -Bdirect -z nodelete -Bdynamic -M exports.map -G -o \$@" else - nss_ldap_so_LDFLAGS="-Wl,-Bdirect -Wl,-z,nodelete -Wl,-Bdynamic -Wl,-M,\$(srcdir)/exports.solaris -Wl,-G" + nss_ldap_so_LDFLAGS="-Wl,-Bdirect -Wl,-z,nodelete -Wl,-Bdynamic -Wl,-M,exports.map -Wl,-G" fi ;; *) - nss_ldap_so_LDFLAGS="-shared -Wl,-h,\$(NSS_LDAP_SONAME) -Wl,--version-script,\$(srcdir)/exports.$with_nss_flavour" + nss_ldap_so_LDFLAGS="-shared -Wl,-h,\$(NSS_LDAP_SONAME) -Wl,--version-script,exports.map" ;; esac AC_SUBST(nss_ldap_so_LDFLAGS) diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index 2a12f68..3fb03ed 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -2,7 +2,7 @@ nslcd.c - ldap local connection daemon Copyright (C) 2006 West Consulting - Copyright (C) 2006-2014 Arthur de Jong + Copyright (C) 2006-2015 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 @@ -117,7 +117,7 @@ static void display_version(FILE *fp) { fprintf(fp, "%s\n", PACKAGE_STRING); fprintf(fp, "Written by Luke Howard and Arthur de Jong.\n\n"); - fprintf(fp, "Copyright (C) 1997-2014 Luke Howard, Arthur de Jong and West Consulting\n" + fprintf(fp, "Copyright (C) 1997-2015 Luke Howard, Arthur de Jong and West Consulting\n" "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); } @@ -617,7 +617,7 @@ static void disable_nss_ldap(void) /* clear any existing errors */ dlerror(); /* try to look up the flag */ - enable_flag = (int *)dlsym(handle, "_nss_ldap_enablelookups"); + enable_flag = (int *)dlsym(handle, "_nss_" MODULE_NAME "_enablelookups"); error = dlerror(); if ((enable_flag == NULL) || (error != NULL)) { diff --git a/nss/Makefile.am b/nss/Makefile.am index 6bb2b24..cfa05e0 100644 --- a/nss/Makefile.am +++ b/nss/Makefile.am @@ -2,7 +2,7 @@ # # Copyright (C) 2006 Luke Howard # Copyright (C) 2006 West Consulting -# Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong +# Copyright (C) 2006-2015 Arthur de Jong # Copyright (C) 2010 Symas Corporation # # This library is free software; you can redistribute it and/or @@ -39,9 +39,13 @@ if NSS_FLAVOUR_FREEBSD nss_ldap_so_LDADD += bsdnss.$(OBJEXT) endif nss_ldap_so_LDADD += ../common/libtio.a ../common/libprot.a -nss_ldap_so_DEPENDENCIES = $(nss_ldap_so_LDADD) +nss_ldap_so_DEPENDENCIES = $(nss_ldap_so_LDADD) exports.map EXTRA_DIST = exports.glibc exports.solaris exports.freebsd +CLEANFILES = exports.map + +exports.map: $(EXTRA_DIST) + sed 's/ldap/@MODULE_NAME@/' < $(srcdir)/exports.$(NSS_FLAVOUR) > exports.map install-exec-local: install-nss_ldap_so uninstall-local: uninstall-nss_ldap_so diff --git a/nss/aliases.c b/nss/aliases.c index 261c92d..d832aec 100644 --- a/nss/aliases.c +++ b/nss/aliases.c @@ -2,7 +2,7 @@ aliases.c - NSS lookup functions for aliases database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 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 @@ -48,7 +48,7 @@ static nss_status_t read_aliasent(TFILE *fp, struct aliasent *result, } /* get an alias entry by name */ -nss_status_t _nss_ldap_getaliasbyname_r(const char *name, +nss_status_t NSS_NAME(getaliasbyname_r)(const char *name, struct aliasent *result, char *buffer, size_t buflen, int *errnop) @@ -62,13 +62,13 @@ nss_status_t _nss_ldap_getaliasbyname_r(const char *name, static TLS TFILE *aliasentfp; /* start a request to read all aliases */ -nss_status_t _nss_ldap_setaliasent(void) +nss_status_t NSS_NAME(setaliasent)(void) { NSS_SETENT(aliasentfp); } /* read a single alias entry from the stream */ -nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result, +nss_status_t NSS_NAME(getaliasent_r)(struct aliasent *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(aliasentfp, NSLCD_ACTION_ALIAS_ALL, @@ -76,7 +76,7 @@ nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result, } /* close the stream opened with setaliasent() above */ -nss_status_t _nss_ldap_endaliasent(void) +nss_status_t NSS_NAME(endaliasent)(void) { NSS_ENDENT(aliasentfp); } diff --git a/nss/bsdnss.c b/nss/bsdnss.c index 85c62b8..04be5b4 100644 --- a/nss/bsdnss.c +++ b/nss/bsdnss.c @@ -6,7 +6,7 @@ Copyright (C) 2003 Jacques Vidrine Copyright (C) 2006 Artem Kazakov Copyright (C) 2009 Alexander V. Chernikov - Copyright (C) 2011, 2012, 2013 Arthur de Jong + Copyright (C) 2011-2015 Arthur de Jong Copyright (C) 2011 Tom Judge This library is free software; you can redistribute it and/or @@ -55,34 +55,34 @@ NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname2); NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyaddr); static ns_mtab methods[] = { - { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, _nss_ldap_getgrnam_r }, - { NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, _nss_ldap_getgrgid_r }, - { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, _nss_ldap_getgrent_r }, - { NSDB_GROUP, "setgrent", __nss_compat_setgrent, _nss_ldap_setgrent }, - { NSDB_GROUP, "endgrent", __nss_compat_endgrent, _nss_ldap_endgrent }, + { NSDB_GROUP, "getgrnam_r", __nss_compat_getgrnam_r, NSS_NAME(getgrnam_r) }, + { NSDB_GROUP, "getgrgid_r", __nss_compat_getgrgid_r, NSS_NAME(getgrgid_r) }, + { NSDB_GROUP, "getgrent_r", __nss_compat_getgrent_r, NSS_NAME(getgrent_r) }, + { NSDB_GROUP, "setgrent", __nss_compat_setgrent, NSS_NAME(setgrent) }, + { NSDB_GROUP, "endgrent", __nss_compat_endgrent, NSS_NAME(endgrent) }, { NSDB_GROUP, "getgroupmembership", __freebsd_getgroupmembership, NULL }, - { NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, _nss_ldap_getpwnam_r }, - { NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, _nss_ldap_getpwuid_r }, - { NSDB_PASSWD, "getpwent_r", __nss_compat_getpwent_r, _nss_ldap_getpwent_r }, - { NSDB_PASSWD, "setpwent", __nss_compat_setpwent, _nss_ldap_setpwent }, - { NSDB_PASSWD, "endpwent", __nss_compat_endpwent, _nss_ldap_endpwent }, - - { NSDB_HOSTS, "gethostbyname", __nss_compat_gethostbyname, _nss_ldap_gethostbyname_r }, - { NSDB_HOSTS, "gethostbyaddr", __nss_compat_gethostbyaddr, _nss_ldap_gethostbyaddr_r }, - { NSDB_HOSTS, "gethostbyname2", __nss_compat_gethostbyname2, _nss_ldap_gethostbyname2_r }, - - { NSDB_GROUP_COMPAT, "getgrnam_r", __nss_compat_getgrnam_r, _nss_ldap_getgrnam_r }, - { NSDB_GROUP_COMPAT, "getgrgid_r", __nss_compat_getgrgid_r, _nss_ldap_getgrgid_r }, - { NSDB_GROUP_COMPAT, "getgrent_r", __nss_compat_getgrent_r, _nss_ldap_getgrent_r }, - { NSDB_GROUP_COMPAT, "setgrent", __nss_compat_setgrent, _nss_ldap_setgrent }, - { NSDB_GROUP_COMPAT, "endgrent", __nss_compat_endgrent, _nss_ldap_endgrent }, - - { NSDB_PASSWD_COMPAT, "getpwnam_r", __nss_compat_getpwnam_r, _nss_ldap_getpwnam_r }, - { NSDB_PASSWD_COMPAT, "getpwuid_r", __nss_compat_getpwuid_r, _nss_ldap_getpwuid_r }, - { NSDB_PASSWD_COMPAT, "getpwent_r", __nss_compat_getpwent_r, _nss_ldap_getpwent_r }, - { NSDB_PASSWD_COMPAT, "setpwent", __nss_compat_setpwent, _nss_ldap_setpwent }, - { NSDB_PASSWD_COMPAT, "endpwent", __nss_compat_endpwent, _nss_ldap_endpwent }, + { NSDB_PASSWD, "getpwnam_r", __nss_compat_getpwnam_r, NSS_NAME(getpwnam_r) }, + { NSDB_PASSWD, "getpwuid_r", __nss_compat_getpwuid_r, NSS_NAME(getpwuid_r) }, + { NSDB_PASSWD, "getpwent_r", __nss_compat_getpwent_r, NSS_NAME(getpwent_r) }, + { NSDB_PASSWD, "setpwent", __nss_compat_setpwent, NSS_NAME(setpwent) }, + { NSDB_PASSWD, "endpwent", __nss_compat_endpwent, NSS_NAME(endpwent) }, + + { NSDB_HOSTS, "gethostbyname", __nss_compat_gethostbyname, NSS_NAME(gethostbyname_r) }, + { NSDB_HOSTS, "gethostbyaddr", __nss_compat_gethostbyaddr, NSS_NAME(gethostbyaddr_r) }, + { NSDB_HOSTS, "gethostbyname2", __nss_compat_gethostbyname2, NSS_NAME(gethostbyname2_r) }, + + { NSDB_GROUP_COMPAT, "getgrnam_r", __nss_compat_getgrnam_r, NSS_NAME(getgrnam_r) }, + { NSDB_GROUP_COMPAT, "getgrgid_r", __nss_compat_getgrgid_r, NSS_NAME(getgrgid_r) }, + { NSDB_GROUP_COMPAT, "getgrent_r", __nss_compat_getgrent_r, NSS_NAME(getgrent_r) }, + { NSDB_GROUP_COMPAT, "setgrent", __nss_compat_setgrent, NSS_NAME(setgrent) }, + { NSDB_GROUP_COMPAT, "endgrent", __nss_compat_endgrent, NSS_NAME(endgrent) }, + + { NSDB_PASSWD_COMPAT, "getpwnam_r", __nss_compat_getpwnam_r, NSS_NAME(getpwnam_r) }, + { NSDB_PASSWD_COMPAT, "getpwuid_r", __nss_compat_getpwuid_r, NSS_NAME(getpwuid_r) }, + { NSDB_PASSWD_COMPAT, "getpwent_r", __nss_compat_getpwent_r, NSS_NAME(getpwent_r) }, + { NSDB_PASSWD_COMPAT, "setpwent", __nss_compat_setpwent, NSS_NAME(setpwent) }, + { NSDB_PASSWD_COMPAT, "endpwent", __nss_compat_endpwent, NSS_NAME(endpwent) }, }; int __nss_compat_gethostbyname(void UNUSED(*retval), void *mdata, va_list ap) @@ -189,7 +189,7 @@ int __freebsd_getgroupmembership(void UNUSED(*retval), void UNUSED(*mdata_), __gr_addgid(group, groups, maxgrp, grpcnt); lstart = 0; lsize = maxgrp; - s = _nss_ldap_initgroups_dyn(user, group, &lstart, &lsize, &tmpgroups, 0, &err); + s = NSS_NAME(initgroups_dyn)(user, group, &lstart, &lsize, &tmpgroups, 0, &err); if (s == NSS_STATUS_SUCCESS) { for (i = 0; i < lstart; i++) diff --git a/nss/common.c b/nss/common.c index 1e00475..63ce992 100644 --- a/nss/common.c +++ b/nss/common.c @@ -1,7 +1,7 @@ /* common.c - common definitions - Copyright (C) 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2010-2015 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 @@ -23,7 +23,7 @@ #include -int _nss_ldap_enablelookups = 1; +int NSS_NAME(enablelookups) = 1; /* version information about the NSS module */ -char *_nss_ldap_version[3] = { PACKAGE, VERSION, NULL }; +char *NSS_NAME(version)[3] = { PACKAGE, VERSION, NULL }; diff --git a/nss/common.h b/nss/common.h index 254a5bb..0bc4440 100644 --- a/nss/common.h +++ b/nss/common.h @@ -2,7 +2,7 @@ common.h - common functions for NSS lookups Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 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 @@ -80,7 +80,7 @@ /* check to see if we should answer NSS requests */ #define NSS_AVAILCHECK \ - if (!_nss_ldap_enablelookups) \ + if (!NSS_NAME(enablelookups)) \ return NSS_STATUS_UNAVAIL; #ifdef NSS_FLAVOUR_GLIBC diff --git a/nss/ethers.c b/nss/ethers.c index b094a66..291c797 100644 --- a/nss/ethers.c +++ b/nss/ethers.c @@ -2,7 +2,7 @@ ethers.c - NSS lookup functions for ethers database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -45,7 +45,7 @@ static nss_status_t read_etherent(TFILE *fp, struct etherent *result, #ifdef NSS_FLAVOUR_GLIBC /* map a hostname to the corresponding ethernet address */ -nss_status_t _nss_ldap_gethostton_r(const char *name, +nss_status_t NSS_NAME(gethostton_r)(const char *name, struct etherent *result, char *buffer, size_t buflen, int *errnop) { @@ -55,7 +55,7 @@ nss_status_t _nss_ldap_gethostton_r(const char *name, } /* map an ethernet address to the corresponding hostname */ -nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr, +nss_status_t NSS_NAME(getntohost_r)(const struct ether_addr *addr, struct etherent *result, char *buffer, size_t buflen, int *errnop) { @@ -68,13 +68,13 @@ nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr, static TLS TFILE *etherentfp; /* open a connection to read all ether entries */ -nss_status_t _nss_ldap_setetherent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setetherent)(int UNUSED(stayopen)) { NSS_SETENT(etherentfp); } /* read a single ethernet entry from the stream */ -nss_status_t _nss_ldap_getetherent_r(struct etherent *result, +nss_status_t NSS_NAME(getetherent_r)(struct etherent *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(etherentfp, NSLCD_ACTION_ETHER_ALL, @@ -82,7 +82,7 @@ nss_status_t _nss_ldap_getetherent_r(struct etherent *result, } /* close the stream opened with setetherent() above */ -nss_status_t _nss_ldap_endetherent(void) +nss_status_t NSS_NAME(endetherent)(void) { NSS_ENDENT(etherentfp); } @@ -174,7 +174,7 @@ static nss_backend_op_t ethers_ops[] = { ethers_getntohost }; -nss_backend_t *_nss_ldap_ethers_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(ethers_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/group.c b/nss/group.c index 5945718..69aa1fc 100644 --- a/nss/group.c +++ b/nss/group.c @@ -2,7 +2,7 @@ group.c - NSS lookup functions for group database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -115,7 +115,7 @@ static nss_status_t read_gids(TFILE *fp, gid_t skipgroup, long int *start, #ifdef NSS_FLAVOUR_GLIBC /* get a group entry by name */ -nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result, +nss_status_t NSS_NAME(getgrnam_r)(const char *name, struct group *result, char *buffer, size_t buflen, int *errnop) { NSS_GETONE(NSLCD_ACTION_GROUP_BYNAME, @@ -124,7 +124,7 @@ nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result, } /* get a group entry by numeric gid */ -nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result, +nss_status_t NSS_NAME(getgrgid_r)(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop) { NSS_GETONE(NSLCD_ACTION_GROUP_BYGID, @@ -136,13 +136,13 @@ nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result, static TLS TFILE *grentfp; /* start a request to read all groups */ -nss_status_t _nss_ldap_setgrent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setgrent)(int UNUSED(stayopen)) { NSS_SETENT(grentfp); } /* read a single group from the stream */ -nss_status_t _nss_ldap_getgrent_r(struct group *result, +nss_status_t NSS_NAME(getgrent_r)(struct group *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(grentfp, NSLCD_ACTION_GROUP_ALL, @@ -150,7 +150,7 @@ nss_status_t _nss_ldap_getgrent_r(struct group *result, } /* close the stream opened with setgrent() above */ -nss_status_t _nss_ldap_endgrent(void) +nss_status_t NSS_NAME(endgrent)(void) { NSS_ENDENT(grentfp); } @@ -167,7 +167,7 @@ nss_status_t _nss_ldap_endgrent(void) limit IN - the maxium size of the array *errnop OUT - for returning errno */ -nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup, +nss_status_t NSS_NAME(initgroups_dyn)(const char *user, gid_t skipgroup, long int *start, long int *size, gid_t **groupsp, long int limit, int *errnop) @@ -267,7 +267,7 @@ static nss_backend_op_t group_ops[] = { group_getgroupsbymember }; -nss_backend_t *_nss_ldap_group_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(group_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/hosts.c b/nss/hosts.c index 539b74a..5f12bc7 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, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -151,7 +151,7 @@ static nss_status_t read_hostent(TFILE *fp, struct hostent *result, result - OUT - entry found buffer,buflen - OUT - buffer to store allocated stuff on errnop,h_errnop - OUT - for reporting errors */ -nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af, +nss_status_t NSS_NAME(gethostbyname2_r)(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) @@ -163,12 +163,12 @@ nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af, /* this function just calls the gethostbyname2() variant with the address familiy set */ -nss_status_t _nss_ldap_gethostbyname_r(const char *name, +nss_status_t NSS_NAME(gethostbyname_r)(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) { - return _nss_ldap_gethostbyname2_r(name, AF_INET, result, buffer, buflen, + return NSS_NAME(gethostbyname2_r)(name, AF_INET, result, buffer, buflen, errnop, h_errnop); } @@ -180,7 +180,7 @@ nss_status_t _nss_ldap_gethostbyname_r(const char *name, result - OUT - entry found buffer,buflen - OUT - buffer to store allocated stuff on errnop,h_errnop - OUT - for reporting errors */ -nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len, +nss_status_t NSS_NAME(gethostbyaddr_r)(const void *addr, socklen_t len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) @@ -193,13 +193,13 @@ nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len, /* thread-local file pointer to an ongoing request */ static TLS TFILE *hostentfp; -nss_status_t _nss_ldap_sethostent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(sethostent)(int UNUSED(stayopen)) { NSS_SETENT(hostentfp); } /* this function only returns addresses of the AF_INET address family */ -nss_status_t _nss_ldap_gethostent_r(struct hostent *result, +nss_status_t NSS_NAME(gethostent_r)(struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) { @@ -209,7 +209,7 @@ nss_status_t _nss_ldap_gethostent_r(struct hostent *result, } /* close the stream opened with sethostent() above */ -nss_status_t _nss_ldap_endhostent(void) +nss_status_t NSS_NAME(endhostent)(void) { NSS_ENDENT(hostentfp); } @@ -302,7 +302,7 @@ static nss_backend_op_t hosts_ops[] = { hosts_gethostbyaddr }; -nss_backend_t *_nss_ldap_hosts_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(hosts_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/netgroup.c b/nss/netgroup.c index 81eb33d..cd2e5b0 100644 --- a/nss/netgroup.c +++ b/nss/netgroup.c @@ -2,7 +2,7 @@ netgroup.c - NSS lookup functions for netgroup entries Copyright (C) 2006 West Consulting - Copyright (C) 2006-2014 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -82,7 +82,7 @@ static nss_status_t read_netgrent_line(TFILE *fp, struct __netgrent *result, return NSS_STATUS_SUCCESS; } else if (type == NSLCD_NETGROUP_TYPE_END) - /* make _nss_ldap_getnetgrent_r() indicate the end of the netgroup */ + /* make NSS_NAME(getnetgrent_r)() indicate the end of the netgroup */ return NSS_STATUS_RETURN; /* we got something unexpected */ ERROR_OUT_NOSUCCESS(fp); @@ -95,7 +95,7 @@ static nss_status_t read_netgrent_line(TFILE *fp, struct __netgrent *result, static TLS TFILE *netgrentfp; /* start a request to get a netgroup by name */ -nss_status_t _nss_ldap_setnetgrent(const char *group, +nss_status_t NSS_NAME(setnetgrent)(const char *group, struct __netgrent UNUSED(*result)) { /* we cannot use NSS_SETENT() here because we have a parameter that is only @@ -118,7 +118,7 @@ nss_status_t _nss_ldap_setnetgrent(const char *group, } /* get a single netgroup tuple from the stream */ -nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result, +nss_status_t NSS_NAME(getnetgrent_r)(struct __netgrent *result, char *buffer, size_t buflen, int *errnop) { nss_status_t retv; @@ -153,7 +153,7 @@ nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result, } /* close the stream opened with setnetgrent() above */ -nss_status_t _nss_ldap_endnetgrent(struct __netgrent UNUSED(*result)) +nss_status_t NSS_NAME(endnetgrent)(struct __netgrent UNUSED(*result)) { NSS_ENDENT(netgrentfp); } @@ -356,11 +356,11 @@ static nss_backend_op_t netgroup_ops[] = { NULL, NULL, NULL, - NULL, /* TODO:_nss_ldap_netgr_in */ + NULL, /* TODO:NSS_NAME(netgr_in) */ netgroup_setnetgrent_constructor }; -nss_backend_t *_nss_ldap_netgroup_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(netgroup_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/networks.c b/nss/networks.c index 3ffea52..e1cc84a 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, 2010, 2011, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -111,7 +111,7 @@ static nss_status_t read_netent(TFILE *fp, struct netent *result, #ifdef NSS_FLAVOUR_GLIBC /* get a network entry by name */ -nss_status_t _nss_ldap_getnetbyname_r(const char *name, +nss_status_t NSS_NAME(getnetbyname_r)(const char *name, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) @@ -123,7 +123,7 @@ nss_status_t _nss_ldap_getnetbyname_r(const char *name, /* 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), +nss_status_t NSS_NAME(getnetbyaddr_r)(uint32_t addr, int UNUSED(af), struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) @@ -137,13 +137,13 @@ nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int UNUSED(af), static TLS TFILE *netentfp; /* start a request to read all networks */ -nss_status_t _nss_ldap_setnetent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setnetent)(int UNUSED(stayopen)) { NSS_SETENT(netentfp); } /* get a single network entry from the stream */ -nss_status_t _nss_ldap_getnetent_r(struct netent *result, +nss_status_t NSS_NAME(getnetent_r)(struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop) { @@ -152,7 +152,7 @@ nss_status_t _nss_ldap_getnetent_r(struct netent *result, } /* close the stream opened by setnetent() above */ -nss_status_t _nss_ldap_endnetent(void) +nss_status_t NSS_NAME(endnetent)(void) { NSS_ENDENT(netentfp); } @@ -229,7 +229,7 @@ static nss_backend_op_t networks_ops[] = { networks_getnetbyaddr }; -nss_backend_t *_nss_ldap_networks_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(networks_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/passwd.c b/nss/passwd.c index c17d8cc..313f957 100644 --- a/nss/passwd.c +++ b/nss/passwd.c @@ -2,7 +2,7 @@ passwd.c - NSS lookup functions for passwd database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -54,7 +54,7 @@ static nss_status_t read_passwd(TFILE *fp, struct passwd *result, #ifdef NSS_FLAVOUR_GLIBC /* get a single passwd entry by name */ -nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, +nss_status_t NSS_NAME(getpwnam_r)(const char *name, struct passwd *result, char *buffer, size_t buflen, int *errnop) { NSS_GETONE(NSLCD_ACTION_PASSWD_BYNAME, @@ -63,7 +63,7 @@ nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, } /* get a single passwd entry by uid */ -nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, +nss_status_t NSS_NAME(getpwuid_r)(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop) { NSS_GETONE(NSLCD_ACTION_PASSWD_BYUID, @@ -75,13 +75,13 @@ nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, static TLS TFILE *pwentfp; /* open a connection to read all passwd entries */ -nss_status_t _nss_ldap_setpwent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setpwent)(int UNUSED(stayopen)) { NSS_SETENT(pwentfp); } /* read password data from an opened stream */ -nss_status_t _nss_ldap_getpwent_r(struct passwd *result, +nss_status_t NSS_NAME(getpwent_r)(struct passwd *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(pwentfp, NSLCD_ACTION_PASSWD_ALL, @@ -89,7 +89,7 @@ nss_status_t _nss_ldap_getpwent_r(struct passwd *result, } /* close the stream opened with setpwent() above */ -nss_status_t _nss_ldap_endpwent(void) +nss_status_t NSS_NAME(endpwent)(void) { NSS_ENDENT(pwentfp); } @@ -159,7 +159,7 @@ static nss_backend_op_t passwd_ops[] = { passwd_getpwuid }; -nss_backend_t *_nss_ldap_passwd_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(passwd_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/protocols.c b/nss/protocols.c index 4944dff..3732ae5 100644 --- a/nss/protocols.c +++ b/nss/protocols.c @@ -2,7 +2,7 @@ protocols.c - NSS lookup functions for protocol database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -46,7 +46,7 @@ static nss_status_t read_protoent(TFILE *fp, struct protoent *result, #ifdef NSS_FLAVOUR_GLIBC /* get a protocol entry by name */ -nss_status_t _nss_ldap_getprotobyname_r(const char *name, +nss_status_t NSS_NAME(getprotobyname_r)(const char *name, struct protoent *result, char *buffer, size_t buflen, int *errnop) @@ -57,7 +57,7 @@ nss_status_t _nss_ldap_getprotobyname_r(const char *name, } /* get a protocol entry by number */ -nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result, +nss_status_t NSS_NAME(getprotobynumber_r)(int number, struct protoent *result, char *buffer, size_t buflen, int *errnop) { @@ -70,13 +70,13 @@ nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result, static TLS TFILE *protoentfp; /* start a request to read all protocol entries */ -nss_status_t _nss_ldap_setprotoent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setprotoent)(int UNUSED(stayopen)) { NSS_SETENT(protoentfp); } /* get a single protocol entry */ -nss_status_t _nss_ldap_getprotoent_r(struct protoent *result, +nss_status_t NSS_NAME(getprotoent_r)(struct protoent *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(protoentfp, NSLCD_ACTION_PROTOCOL_ALL, @@ -84,7 +84,7 @@ nss_status_t _nss_ldap_getprotoent_r(struct protoent *result, } /* close the stream opened by setprotoent() above */ -nss_status_t _nss_ldap_endprotoent(void) +nss_status_t NSS_NAME(endprotoent)(void) { NSS_ENDENT(protoentfp); } @@ -156,7 +156,7 @@ static nss_backend_op_t protocols_ops[] = { protocols_getprotobynumber }; -nss_backend_t *_nss_ldap_protocols_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(protocols_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/prototypes.h b/nss/prototypes.h index 0f7a6a9..37a9824 100644 --- a/nss/prototypes.h +++ b/nss/prototypes.h @@ -2,7 +2,7 @@ prototypes.h - all functions exported by the NSS library Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2008, 2010, 2011, 2012 Arthur de Jong + Copyright (C) 2006-2015 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 @@ -27,7 +27,7 @@ /* flag to gloabally disable lookups (all _nss_ldap_*() functions will return NSS_STATUS_UNAVAIL */ -extern int _nss_ldap_enablelookups; +extern int NSS_NAME(enablelookups); #ifdef NSS_FLAVOUR_FREEBSD @@ -57,79 +57,79 @@ ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize, */ /* 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); -nss_status_t _nss_ldap_getaliasent_r(struct aliasent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endaliasent(void); +nss_status_t NSS_NAME(getaliasbyname_r)(const char *name, struct aliasent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setaliasent)(void); +nss_status_t NSS_NAME(getaliasent_r)(struct aliasent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endaliasent)(void); /* ethers - ethernet numbers */ -nss_status_t _nss_ldap_gethostton_r(const char *name, struct etherent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getntohost_r(const struct ether_addr *addr, struct etherent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setetherent(int stayopen); -nss_status_t _nss_ldap_getetherent_r(struct etherent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endetherent(void); +nss_status_t NSS_NAME(gethostton_r)(const char *name, struct etherent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getntohost_r)(const struct ether_addr *addr, struct etherent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setetherent)(int stayopen); +nss_status_t NSS_NAME(getetherent_r)(struct etherent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endetherent)(void); /* group - groups of users */ -nss_status_t _nss_ldap_getgrnam_r(const char *name, struct group *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getgrgid_r(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_initgroups_dyn(const char *user, gid_t skipgroup, long int *start, long int *size, gid_t **groupsp, long int limit, int *errnop); -nss_status_t _nss_ldap_setgrent(int stayopen); -nss_status_t _nss_ldap_getgrent_r(struct group *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endgrent(void); +nss_status_t NSS_NAME(getgrnam_r)(const char *name, struct group *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getgrgid_r)(gid_t gid, struct group *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(initgroups_dyn)(const char *user, gid_t skipgroup, long int *start, long int *size, gid_t **groupsp, long int limit, int *errnop); +nss_status_t NSS_NAME(setgrent)(int stayopen); +nss_status_t NSS_NAME(getgrent_r)(struct group *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endgrent)(void); /* hosts - host names and numbers */ -nss_status_t _nss_ldap_gethostbyname_r(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_gethostbyname2_r(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_gethostbyaddr_r(const void *addr, socklen_t len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_sethostent(int stayopen); -nss_status_t _nss_ldap_gethostent_r(struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_endhostent(void); +nss_status_t NSS_NAME(gethostbyname_r)(const char *name, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(gethostbyname2_r)(const char *name, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(gethostbyaddr_r)(const void *addr, socklen_t len, int af, struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(sethostent)(int stayopen); +nss_status_t NSS_NAME(gethostent_r)(struct hostent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(endhostent)(void); /* netgroup - list of host and users */ -nss_status_t _nss_ldap_setnetgrent(const char *group, struct __netgrent *result); -nss_status_t _nss_ldap_getnetgrent_r(struct __netgrent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endnetgrent(struct __netgrent *result); +nss_status_t NSS_NAME(setnetgrent)(const char *group, struct __netgrent *result); +nss_status_t NSS_NAME(getnetgrent_r)(struct __netgrent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endnetgrent)(struct __netgrent *result); /* networks - network names and numbers */ -nss_status_t _nss_ldap_getnetbyname_r(const char *name, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_getnetbyaddr_r(uint32_t addr, int af, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_setnetent(int stayopen); -nss_status_t _nss_ldap_getnetent_r(struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); -nss_status_t _nss_ldap_endnetent(void); +nss_status_t NSS_NAME(getnetbyname_r)(const char *name, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(getnetbyaddr_r)(uint32_t addr, int af, struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(setnetent)(int stayopen); +nss_status_t NSS_NAME(getnetent_r)(struct netent *result, char *buffer, size_t buflen, int *errnop, int *h_errnop); +nss_status_t NSS_NAME(endnetent)(void); /* passwd - user database and passwords */ -nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setpwent(int stayopen); -nss_status_t _nss_ldap_getpwent_r(struct passwd *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endpwent(void); +nss_status_t NSS_NAME(getpwnam_r)(const char *name, struct passwd *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getpwuid_r)(uid_t uid, struct passwd *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setpwent)(int stayopen); +nss_status_t NSS_NAME(getpwent_r)(struct passwd *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endpwent)(void); /* protocols - network protocols */ -nss_status_t _nss_ldap_getprotobyname_r(const char *name, struct protoent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getprotobynumber_r(int number, struct protoent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setprotoent(int stayopen); -nss_status_t _nss_ldap_getprotoent_r(struct protoent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endprotoent(void); +nss_status_t NSS_NAME(getprotobyname_r)(const char *name, struct protoent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getprotobynumber_r)(int number, struct protoent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setprotoent)(int stayopen); +nss_status_t NSS_NAME(getprotoent_r)(struct protoent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endprotoent)(void); /* rpc - remote procedure call names and numbers */ -nss_status_t _nss_ldap_getrpcbyname_r(const char *name, struct rpcent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setrpcent(int stayopen); -nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endrpcent(void); +nss_status_t NSS_NAME(getrpcbyname_r)(const char *name, struct rpcent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getrpcbynumber_r)(int number, struct rpcent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setrpcent)(int stayopen); +nss_status_t NSS_NAME(getrpcent_r)(struct rpcent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endrpcent)(void); /* services - network services */ -nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setservent(int stayopen); -nss_status_t _nss_ldap_getservent_r(struct servent *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endservent(void); +nss_status_t NSS_NAME(getservbyname_r)(const char *name, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(getservbyport_r)(int port, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setservent)(int stayopen); +nss_status_t NSS_NAME(getservent_r)(struct servent *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endservent)(void); /* shadow - extended user information */ -nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_setspent(int stayopen); -nss_status_t _nss_ldap_getspent_r(struct spwd *result, char *buffer, size_t buflen, int *errnop); -nss_status_t _nss_ldap_endspent(void); +nss_status_t NSS_NAME(getspnam_r)(const char *name, struct spwd *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(setspent)(int stayopen); +nss_status_t NSS_NAME(getspent_r)(struct spwd *result, char *buffer, size_t buflen, int *errnop); +nss_status_t NSS_NAME(endspent)(void); #endif /* NSS_FLAVOUR_GLIBC */ @@ -140,16 +140,16 @@ nss_status_t _nss_ldap_endspent(void); #define LDAP_BE(be) ((struct nss_ldap_backend*)(be)) /* these are the constructors we provide */ -nss_backend_t *_nss_ldap_ethers_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_group_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_hosts_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_netgroup_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_networks_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_passwd_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_protocols_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_rpc_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_services_constr(const char *db_name, const char *src_name, const char *cfg_args); -nss_backend_t *_nss_ldap_shadow_constr(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(ethers_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(group_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(hosts_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(netgroup_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(networks_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(passwd_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(protocols_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(rpc_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(services_constr)(const char *db_name, const char *src_name, const char *cfg_args); +nss_backend_t *NSS_NAME(shadow_constr)(const char *db_name, const char *src_name, const char *cfg_args); #endif /* NSS_FLAVOUR_SOLARIS */ diff --git a/nss/rpc.c b/nss/rpc.c index 6b0bcc8..547b86b 100644 --- a/nss/rpc.c +++ b/nss/rpc.c @@ -2,7 +2,7 @@ rpc.c - NSS lookup functions for rpc database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -46,7 +46,7 @@ static nss_status_t read_rpcent(TFILE *fp, struct rpcent *result, #ifdef NSS_FLAVOUR_GLIBC /* get a rpc entry by name */ -nss_status_t _nss_ldap_getrpcbyname_r(const char *name, +nss_status_t NSS_NAME(getrpcbyname_r)(const char *name, struct rpcent *result, char *buffer, size_t buflen, int *errnop) { @@ -56,7 +56,7 @@ nss_status_t _nss_ldap_getrpcbyname_r(const char *name, } /* get a rpc entry by number */ -nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result, +nss_status_t NSS_NAME(getrpcbynumber_r)(int number, struct rpcent *result, char *buffer, size_t buflen, int *errnop) { @@ -69,13 +69,13 @@ nss_status_t _nss_ldap_getrpcbynumber_r(int number, struct rpcent *result, static TLS TFILE *rpcentfp; /* request a stream to list all rpc entries */ -nss_status_t _nss_ldap_setrpcent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setrpcent)(int UNUSED(stayopen)) { NSS_SETENT(rpcentfp); } /* get an rpc entry from the list */ -nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result, +nss_status_t NSS_NAME(getrpcent_r)(struct rpcent *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(rpcentfp, NSLCD_ACTION_RPC_ALL, @@ -83,7 +83,7 @@ nss_status_t _nss_ldap_getrpcent_r(struct rpcent *result, } /* close the stream opened by setrpcent() above */ -nss_status_t _nss_ldap_endrpcent(void) +nss_status_t NSS_NAME(endrpcent)(void) { NSS_ENDENT(rpcentfp); } @@ -155,7 +155,7 @@ static nss_backend_op_t rpc_ops[] = { rpc_getrpcbynumber }; -nss_backend_t *_nss_ldap_rpc_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(rpc_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/services.c b/nss/services.c index aa2c5b7..260f828 100644 --- a/nss/services.c +++ b/nss/services.c @@ -2,7 +2,7 @@ service.c - NSS lookup functions for services database Copyright (C) 2006 West Consulting - Copyright (C) 2006-2014 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -50,7 +50,7 @@ static nss_status_t read_servent(TFILE *fp, struct servent *result, #ifdef NSS_FLAVOUR_GLIBC /* get a service entry by name and protocol */ -nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol, +nss_status_t NSS_NAME(getservbyname_r)(const char *name, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop) { @@ -61,7 +61,7 @@ nss_status_t _nss_ldap_getservbyname_r(const char *name, const char *protocol, } /* get a service entry by port and protocol */ -nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol, +nss_status_t NSS_NAME(getservbyport_r)(int port, const char *protocol, struct servent *result, char *buffer, size_t buflen, int *errnop) { @@ -77,13 +77,13 @@ nss_status_t _nss_ldap_getservbyport_r(int port, const char *protocol, static TLS TFILE *serventfp; /* open request to get all services */ -nss_status_t _nss_ldap_setservent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setservent)(int UNUSED(stayopen)) { NSS_SETENT(serventfp); } /* read a single returned service definition */ -nss_status_t _nss_ldap_getservent_r(struct servent *result, +nss_status_t NSS_NAME(getservent_r)(struct servent *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(serventfp, NSLCD_ACTION_SERVICE_ALL, @@ -91,7 +91,7 @@ nss_status_t _nss_ldap_getservent_r(struct servent *result, } /* close the stream opened by setservent() above */ -nss_status_t _nss_ldap_endservent(void) +nss_status_t NSS_NAME(endservent)(void) { NSS_ENDENT(serventfp); } @@ -166,7 +166,7 @@ static nss_backend_op_t services_ops[] = { services_getservbyport }; -nss_backend_t *_nss_ldap_services_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(services_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/nss/shadow.c b/nss/shadow.c index 29fc810..f1953d5 100644 --- a/nss/shadow.c +++ b/nss/shadow.c @@ -2,7 +2,7 @@ shadow.c - NSS lookup functions for shadow database Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong + Copyright (C) 2006-2015 Arthur de Jong Copyright (C) 2010 Symas Corporation This library is free software; you can redistribute it and/or @@ -52,7 +52,7 @@ static nss_status_t read_spwd(TFILE *fp, struct spwd *result, #ifdef NSS_FLAVOUR_GLIBC /* get a shadow entry by name */ -nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result, +nss_status_t NSS_NAME(getspnam_r)(const char *name, struct spwd *result, char *buffer, size_t buflen, int *errnop) { NSS_GETONE(NSLCD_ACTION_SHADOW_BYNAME, @@ -64,13 +64,13 @@ nss_status_t _nss_ldap_getspnam_r(const char *name, struct spwd *result, static TLS TFILE *spentfp; /* start listing all shadow users */ -nss_status_t _nss_ldap_setspent(int UNUSED(stayopen)) +nss_status_t NSS_NAME(setspent)(int UNUSED(stayopen)) { NSS_SETENT(spentfp); } /* return a single shadow entry read from the stream */ -nss_status_t _nss_ldap_getspent_r(struct spwd *result, +nss_status_t NSS_NAME(getspent_r)(struct spwd *result, char *buffer, size_t buflen, int *errnop) { NSS_GETENT(spentfp, NSLCD_ACTION_SHADOW_ALL, @@ -78,7 +78,7 @@ nss_status_t _nss_ldap_getspent_r(struct spwd *result, } /* close the stream opened by setspent() above */ -nss_status_t _nss_ldap_endspent(void) +nss_status_t NSS_NAME(endspent)(void) { NSS_ENDENT(spentfp); } @@ -154,7 +154,7 @@ static nss_backend_op_t shadow_ops[] = { shadow_getspnam }; -nss_backend_t *_nss_ldap_shadow_constr(const char UNUSED(*db_name), +nss_backend_t *NSS_NAME(shadow_constr)(const char UNUSED(*db_name), const char UNUSED(*src_name), const char UNUSED(*cfg_args)) { diff --git a/pam/pam.c b/pam/pam.c index 3068e2a..dcefa46 100644 --- a/pam/pam.c +++ b/pam/pam.c @@ -2,7 +2,7 @@ pam.c - pam module functions Copyright (C) 2009 Howard Chu - Copyright (C) 2009, 2010, 2011, 2012, 2013 Arthur de Jong + Copyright (C) 2009-2015 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 @@ -779,8 +779,8 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags, } #ifdef PAM_STATIC -struct pam_module _pam_ldap_modstruct = { - "pam_ldap", +struct pam_module PAM_NAME(modstruct) = { + "pam_" MODULE_NAME, pam_sm_authenticate, pam_sm_setcred, pam_sm_acct_mgmt, diff --git a/pynslcd/constants.py.in b/pynslcd/constants.py.in index 4f57e34..e5972f8 100644 --- a/pynslcd/constants.py.in +++ b/pynslcd/constants.py.in @@ -2,7 +2,7 @@ # constants.py - configured information and constants, this file is processed # and extended by the configure script # -# Copyright (C) 2012 Arthur de Jong +# Copyright (C) 2012-2015 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 @@ -49,3 +49,6 @@ NSLCD_SOCKET = '''@NSLCD_SOCKET@''' # The SONAME of the NSS library module. NSS_LDAP_SONAME = '''@NSS_LDAP_SONAME@''' + +# The name of the NSS and PAM modules. +MODULE_NAME = '''@MODULE_NAME@''' diff --git a/pynslcd/pynslcd.py b/pynslcd/pynslcd.py index 27b31d8..bf6b31f 100755 --- a/pynslcd/pynslcd.py +++ b/pynslcd/pynslcd.py @@ -2,7 +2,7 @@ # pynslcd.py - main daemon module # -# Copyright (C) 2010-2014 Arthur de Jong +# Copyright (C) 2010-2015 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 @@ -91,7 +91,7 @@ def display_version(fp): fp.write('%(PACKAGE_STRING)s\n' 'Written by Arthur de Jong.\n' '\n' - 'Copyright (C) 2010-2014 Arthur de Jong\n' + 'Copyright (C) 2010-2015 Arthur de Jong\n' 'This is free software; see the source for copying conditions. There is NO\n' 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n' % {'PACKAGE_STRING': constants.PACKAGE_STRING, }) @@ -242,7 +242,8 @@ def disable_nss_ldap(): except OSError: return # ignore errors in opening NSS module try: - ctypes.c_int.in_dll(lib, '_nss_ldap_enablelookups').value = 0 + ctypes.c_int.in_dll( + lib, '_nss_%s_enablelookups' % constants.MODULE_NAME).value = 0 except ValueError: logging.warn('probably older NSS module loaded', exc_info=True) try: -- 2.1.4