lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1365 - in nss-pam-ldapd: . debian nss

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd commit: r1365 - in nss-pam-ldapd: . debian nss



Author: arthur
Date: Wed Jan  5 20:39:08 2011
New Revision: 1365
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1365

Log:
add FreeBSD support, partially imported from the FreeBSD port (thanks to 
Jacques Vidrine, Artem Kazakov and Alexander V. Chernikov)

Added:
   nss-pam-ldapd/nss/bsdnss.c
   nss-pam-ldapd/nss/exports.freebsd
Modified:
   nss-pam-ldapd/AUTHORS
   nss-pam-ldapd/HACKING
   nss-pam-ldapd/configure.ac
   nss-pam-ldapd/debian/copyright
   nss-pam-ldapd/nss/Makefile.am
   nss-pam-ldapd/nss/prototypes.h

Modified: nss-pam-ldapd/AUTHORS
==============================================================================
--- nss-pam-ldapd/AUTHORS       Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/AUTHORS       Wed Jan  5 20:39:08 2011        (r1365)
@@ -81,3 +81,6 @@
 Nalin Dahyabhai <nalin@redhat.com>
 Daniel Dehennin <daniel.dehennin@baby-gnu.org>
 Ted C. Cheng <tedcheng@symas.com>
+Jacques Vidrine <nectar@freebsd.org>
+Artem Kazakov <kazakov@gmail.com>
+Alexander V. Chernikov <melifaro@ipfw.ru>

Modified: nss-pam-ldapd/HACKING
==============================================================================
--- nss-pam-ldapd/HACKING       Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/HACKING       Wed Jan  5 20:39:08 2011        (r1365)
@@ -144,6 +144,18 @@
 http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/nss_common.h
 http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/head/nss_dbdefs.h
 
+FreeBSD C Libarary notes
+------------------------
+
+The FreeBSD C library seems to have support for exposing GNU C Library NSS
+module functions through a wrapper function. This makes it very easy to
+implement NSS support on FreeBSD.
+
+Pointers for more documentation on this is welcome. Some information is
+available here:
+http://nixdoc.net/man-pages/FreeBSD/man3/nsdispatch.3.html
+ftp://ftp8.tw.freebsd.org/pub/branches/-current/src/include/nss.h
+
 
 PAM MODULE
 ==========

Modified: nss-pam-ldapd/configure.ac
==============================================================================
--- nss-pam-ldapd/configure.ac  Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/configure.ac  Wed Jan  5 20:39:08 2011        (r1365)
@@ -412,7 +412,7 @@
   # 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],
+              AS_HELP_STRING([--with-nss-flavour=auto|glibc|solaris|freebsd],
                              [the libc flavour to build our NSS module for 
@<:@auto@:>@]),,
               with_nss_flavour=auto)
   if test "x$with_nss_flavour" = "xauto"
@@ -420,6 +420,7 @@
     # do the guessing game
     case "$target_os" in
       solaris*) with_nss_flavour=solaris ;;
+      freebsd*) with_nss_flavour=freebsd ;;
       *)        with_nss_flavour=glibc ;;
     esac
   fi
@@ -427,6 +428,7 @@
   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.]) ;;
+    freebsd) AC_DEFINE(NSS_FLAVOUR_FREEBSD,1,[Whether to use the FreeBSD NSS 
interface flavour.]) ;;
   esac
 
   # check which module source files to use
@@ -436,6 +438,7 @@
     case "$with_nss_flavour" in
       glibc)   
with_nss_maps="aliases,ethers,group,hosts,netgroup,networks,passwd,protocols,rpc,services,shadow"
 ;;
       solaris) 
with_nss_maps="ethers,group,hosts,netgroup,networks,passwd,protocols,rpc,services,shadow"
 ;;
+      freebsd) with_nss_maps="group,hosts,passwd" ;;
     esac
   fi
   AC_MSG_RESULT($with_nss_maps)
@@ -729,6 +732,7 @@
 
 AM_CONDITIONAL([NSS_FLAVOUR_GLIBC], [test "x${with_nss_flavour}" = xglibc])
 AM_CONDITIONAL([NSS_FLAVOUR_SOLARIS], [test "x${with_nss_flavour}" = xsolaris])
+AM_CONDITIONAL([NSS_FLAVOUR_FREEBSD], [test "x${with_nss_flavour}" = xfreebsd])
 
 # generate files
 AC_CONFIG_FILES([Makefile compat/Makefile common/Makefile nss/Makefile

Modified: nss-pam-ldapd/debian/copyright
==============================================================================
--- nss-pam-ldapd/debian/copyright      Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/debian/copyright      Wed Jan  5 20:39:08 2011        (r1365)
@@ -23,7 +23,7 @@
 
   Copyright (C) 1997-2006 Luke Howard
   Copyright (C) 2006-2007 West Consulting
-  Copyright (C) 2006-2010 Arthur de Jong
+  Copyright (C) 2006-2011 Arthur de Jong
   Copyright (C) 2009 Howard Chu
   Copyright (C) 2010 Symas Corporation
 
@@ -54,6 +54,9 @@
 debian/po/fi.po:   Copyright (C) 2009 Esko Arajärvi
 debian/po/fr.po:   Copyright (C) 2007, 2009, 2010 Debian French l10n team
 debian/po/vi.po:   Copyright (C) 2010 Free Software Foundation, Inc.
+nss/bsdnss.c:      Copyright (C) 2003 Jacques Vidrine
+nss/bsdnss.c:      Copyright (C) 2006 Artem Kazakov
+nss/bsdnss.c:      Copyright (C) 2009 Alexander V. Chernikov
 
 The distribution includes code from the Autoconf and Automake suites. This
 code is either licensed under the GNU General Public License with the extra

Modified: nss-pam-ldapd/nss/Makefile.am
==============================================================================
--- nss-pam-ldapd/nss/Makefile.am       Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/nss/Makefile.am       Wed Jan  5 20:39:08 2011        (r1365)
@@ -30,15 +30,18 @@
                       ../compat/attrs.h
 EXTRA_nss_ldap_so_SOURCES = aliases.c ethers.c group.c hosts.c netgroup.c \
                             networks.c passwd.c protocols.c rpc.c services.c \
-                            shadow.c solnss.c
+                            shadow.c solnss.c bsdnss.c
 nss_ldap_so_LDADD = $(NSS_MODULE_OBJS)
 if NSS_FLAVOUR_SOLARIS
 nss_ldap_so_LDADD += solnss.$(OBJEXT) ../common/libdict.a
 endif
+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)
 
-EXTRA_DIST = exports.glibc exports.solaris
+EXTRA_DIST = exports.glibc exports.solaris exports.freebsd
 
 install-exec-local: install-nss_ldap_so
 uninstall-local: uninstall-nss_ldap_so

Added: nss-pam-ldapd/nss/bsdnss.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nss-pam-ldapd/nss/bsdnss.c  Wed Jan  5 20:39:08 2011        (r1365)
@@ -0,0 +1,155 @@
+/*
+   bsdnss.c - BSD NSS functions
+   This file was part of the nss-pam-ldapd FreeBSD port and part of the
+   nss_ldap FreeBSD port before that.
+
+   Copyright (C) 2003 Jacques Vidrine
+   Copyright (C) 2006 Artem Kazakov
+   Copyright (C) 2009 Alexander V. Chernikov
+   Copyright (C) 2011 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
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA
+*/
+
+#include "config.h"
+
+#include <errno.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+#include <pwd.h>
+#include <grp.h>
+#include <nss.h>
+#include <netdb.h>
+
+#include "prototypes.h"
+
+#define BUFFER_SIZE 1024
+
+NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_getgrgid_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_getgrent_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_setgrent);
+NSS_METHOD_PROTOTYPE(__nss_compat_endgrent);
+
+NSS_METHOD_PROTOTYPE(__nss_compat_getpwnam_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_getpwuid_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_getpwent_r);
+NSS_METHOD_PROTOTYPE(__nss_compat_setpwent);
+NSS_METHOD_PROTOTYPE(__nss_compat_endpwent);
+
+NSS_METHOD_PROTOTYPE(__nss_compat_gethostbyname);
+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_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 },
+};
+
+int __nss_compat_gethostbyname(void *retval,void *mdata,va_list ap)
+{
+  nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+  const char *name;
+  struct hostent *result;
+  char buffer[BUFFER_SIZE];
+  int errnop;
+  int h_errnop;
+  int af;
+  nss_status_t status;
+  fn=mdata;
+  name=va_arg(ap,const char*);
+  af=va_arg(ap,int);
+  result=va_arg(ap,struct hostent *);
+  status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
+  status=__nss_compat_result(status,errnop);
+  h_errno=h_errnop;
+  return (status);
+}
+
+int __nss_compat_gethostbyname2(void *retval,void *mdata,va_list ap)
+{
+  nss_status_t (*fn)(const char *,struct hostent *,char *,size_t,int *,int *);
+  const char *name;
+  struct hostent *result;
+  char buffer[BUFFER_SIZE];
+  int errnop;
+  int h_errnop;
+  int af;
+  nss_status_t status;
+  fn=mdata;
+  name=va_arg(ap,const char*);
+  af=va_arg(ap,int);
+  result=va_arg(ap,struct hostent *);
+  status=fn(name,result,buffer,sizeof(buffer),&errnop,&h_errnop);
+  status=__nss_compat_result(status,errnop);
+  h_errno=h_errnop;
+  return (status);
+}
+
+int __nss_compat_gethostbyaddr(void *retval,void *mdata,va_list ap)
+{
+  struct in_addr *addr;
+  int len;
+  int type;
+  struct hostent *result;
+  char buffer[BUFFER_SIZE];
+  int errnop;
+  int h_errnop;
+  nss_status_t (*fn)(struct in_addr *,int,int,struct hostent *,char 
*,size_t,int *,int *);
+  nss_status_t status;
+  fn=mdata;
+  addr=va_arg(ap,struct in_addr*);
+  len=va_arg(ap,int);
+  type=va_arg(ap,int);
+  result=va_arg(ap,struct hostent*);
+  status=fn(addr,len,type,result,buffer,sizeof(buffer),&errnop,&h_errnop);
+  status=__nss_compat_result(status,errnop);
+  h_errno=h_errnop;
+  return (status);
+}
+
+ns_mtab *nss_module_register(const char *source,unsigned int *mtabsize,
+    nss_module_unregister_fn *unreg)
+{
+  *mtabsize=sizeof(methods)/sizeof(methods[0]);
+  *unreg=NULL;
+  return (methods);
+}

Added: nss-pam-ldapd/nss/exports.freebsd
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nss-pam-ldapd/nss/exports.freebsd   Wed Jan  5 20:39:08 2011        (r1365)
@@ -0,0 +1,16 @@
+EXPORTED {
+
+  # published NSS service functions
+  global:
+
+    # flag to enable or disable lookups
+    _nss_ldap_enablelookups;
+
+    # module init
+    nss_module_register;
+
+  # everything else should not be exported
+  local:
+    *;
+
+};

Modified: nss-pam-ldapd/nss/prototypes.h
==============================================================================
--- nss-pam-ldapd/nss/prototypes.h      Sat Jan  1 15:46:18 2011        (r1364)
+++ nss-pam-ldapd/nss/prototypes.h      Wed Jan  5 20:39:08 2011        (r1365)
@@ -29,6 +29,18 @@
    NSS_STATUS_UNAVAIL */
 extern int _nss_ldap_enablelookups;
 
+#ifdef NSS_FLAVOUR_FREEBSD
+
+/* for FreeBSD we want the GlibC prototypes and functions to be built
+   (we provide some wrappers in bsdnss.c) */
+#define NSS_FLAVOUR_GLIBC 1
+
+/* FreeBSD specific register function */
+ns_mtab *nss_module_register(const char *source, unsigned int *mtabsize,
+                             nss_module_unregister_fn *unreg);
+
+#endif /* NSS_FLAVOUR_FREEBSD */
+
 #ifdef NSS_FLAVOUR_GLIBC
 
 /*
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits