aboutsummaryrefslogtreecommitdiffstats
path: root/net/nss_ldap
diff options
context:
space:
mode:
authoranray <anray@FreeBSD.org>2006-05-24 18:48:59 +0800
committeranray <anray@FreeBSD.org>2006-05-24 18:48:59 +0800
commit2241894f999f2526b38cd890f921282eee617d12 (patch)
tree2cafa3cd10e0695255bf86ea7de2833c989e22e2 /net/nss_ldap
parent08cd3dd146b9ff0675230659fa240f8cf0b66bd9 (diff)
downloadfreebsd-ports-gnome-2241894f999f2526b38cd890f921282eee617d12.tar.gz
freebsd-ports-gnome-2241894f999f2526b38cd890f921282eee617d12.tar.zst
freebsd-ports-gnome-2241894f999f2526b38cd890f921282eee617d12.zip
- Now it is possible to use ldap as source for hosts database.
Only gethosbyname, gethostbyname2, gethostbyaddr are implemented. Behavior of getpwXXX functions is made traditional for BSD. When uid=0 they return user password, otherwise returned password is "x". Also, in previous version of the port functions setpwent/endpwent and setgrent/endgrent were mixed. Now they are not. - Assign maintainership to submitter. Submitted by: Artem Kazakov <kazakov@gmail.com>
Diffstat (limited to 'net/nss_ldap')
-rw-r--r--net/nss_ldap/Makefile9
-rw-r--r--net/nss_ldap/files/bsdnss.c103
-rw-r--r--net/nss_ldap/files/patch-Makefile.in12
-rw-r--r--net/nss_ldap/files/patch-ldap-pwd.c29
4 files changed, 133 insertions, 20 deletions
diff --git a/net/nss_ldap/Makefile b/net/nss_ldap/Makefile
index 748b5a803e30..595099ef1028 100644
--- a/net/nss_ldap/Makefile
+++ b/net/nss_ldap/Makefile
@@ -7,13 +7,14 @@
PORTNAME= nss_ldap
PORTVERSION= 1.${NSS_LDAP_VERSION}
+PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= http://www.padl.com/download/ \
${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR= sem
DISTNAME= ${PORTNAME}-${NSS_LDAP_VERSION}
-MAINTAINER= ports@FreeBSD.org
+MAINTAINER= kazakov@gmail.com
COMMENT= RFC 2307 NSS module
USE_OPENLDAP= yes
@@ -23,7 +24,6 @@ NSS_LDAP_VERSION=249
GNU_CONFIGURE= yes
USE_GMAKE= yes
INSTALLS_SHLIB= yes
-PKGMESSAGE= ${WRKDIR}/pkg-message
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib -Wl,-rpath,${LOCALBASE}/lib"
@@ -37,13 +37,10 @@ CONFIGURE_ARGS= --with-ldap-conf-file=${PREFIX}/etc/nss_ldap.conf \
post-extract:
${CP} ${FILESDIR}/bsdnss.c ${WRKSRC}
-post-build:
- ${SED} -e "s,%%PREFIX%%,${PREFIX},g" ${PKGDIR}/pkg-message > ${PKGMESSAGE}
-
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/nss_ldap.so ${PREFIX}/lib/nss_ldap.so.1
${INSTALL_DATA} ${WRKSRC}/ldap.conf ${PREFIX}/etc/nss_ldap.conf.sample
- ${CAT} ${PKGMESSAGE}
+ ${SED} -e "s,%%PREFIX%%,${PREFIX},g" ${PKGMESSAGE}
.include <bsd.port.pre.mk>
diff --git a/net/nss_ldap/files/bsdnss.c b/net/nss_ldap/files/bsdnss.c
index 62095ba959ee..f1ccde3a03d8 100644
--- a/net/nss_ldap/files/bsdnss.c
+++ b/net/nss_ldap/files/bsdnss.c
@@ -1,7 +1,10 @@
+#include <errno.h>
#include <sys/param.h>
+#include <netinet/in.h>
#include <pwd.h>
#include <grp.h>
#include <nss.h>
+#include <netdb.h>
extern enum nss_status _nss_ldap_getgrent_r(struct group *, char *, size_t,
int *);
@@ -21,6 +24,17 @@ extern enum nss_status _nss_ldap_getpwuid_r(gid_t gid, struct passwd *, char *,
extern enum nss_status _nss_ldap_setpwent(void);
extern enum nss_status _nss_ldap_endpwent(void);
+extern enum nss_status _nss_ldap_gethostbyname_r (const char *name, struct hostent * result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop);
+
+extern enum nss_status _nss_ldap_gethostbyname2_r (const char *name, int af, struct hostent * result,
+ char *buffer, size_t buflen, int *errnop,
+ int *h_errnop);
+extern enum nss_status _nss_ldap_gethostbyaddr_r (struct in_addr * addr, int len, int type,
+ struct hostent * result, char *buffer,
+ size_t buflen, int *errnop, int *h_errnop);
+
NSS_METHOD_PROTOTYPE(__nss_compat_getgrnam_r);
NSS_METHOD_PROTOTYPE(__nss_compat_getgrgid_r);
NSS_METHOD_PROTOTYPE(__nss_compat_getgrent_r);
@@ -33,30 +47,38 @@ 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, "endgrent", __nss_compat_setgrent, _nss_ldap_setgrent },
-{ NSDB_GROUP, "setgrent", __nss_compat_endgrent, _nss_ldap_endgrent },
+{ 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, "endpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
-{ NSDB_PASSWD, "setpwent", __nss_compat_endpwent, _nss_ldap_endpwent },
+{ 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, "endgrent", __nss_compat_setgrent, _nss_ldap_setgrent },
-{ NSDB_GROUP_COMPAT, "setgrent", __nss_compat_endgrent, _nss_ldap_endgrent },
+{ 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, "endpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
-{ NSDB_PASSWD_COMPAT, "setpwent", __nss_compat_endpwent, _nss_ldap_endpwent },
+{ NSDB_PASSWD_COMPAT, "setpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
+{ NSDB_PASSWD_COMPAT, "endpwent", __nss_compat_endpwent, _nss_ldap_endpwent },
};
@@ -69,3 +91,68 @@ nss_module_register(const char *source, unsigned int *mtabsize,
*unreg = NULL;
return (methods);
}
+
+int __nss_compat_gethostbyname(void *retval, void *mdata, va_list ap)
+{
+ enum nss_status (*fn)(const char *, struct hostent *, char *, size_t, int *, int *);
+ const char *name;
+ struct hostent *result;
+ char buffer[1024];
+ size_t buflen = 1024;
+ int errnop;
+ int h_errnop;
+ int af;
+ enum nss_status 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, buflen, &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)
+{
+ enum nss_status (*fn)(const char *, struct hostent *, char *, size_t, int *, int *);
+ const char *name;
+ struct hostent *result;
+ char buffer[1024];
+ size_t buflen = 1024;
+ int errnop;
+ int h_errnop;
+ int af;
+ enum nss_status 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, buflen, &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[1024];
+ size_t buflen = 1024;
+ int errnop;
+ int h_errnop;
+ enum nss_status (*fn)(struct in_addr *, int, int, struct hostent *, char *, size_t, int *, int *);
+ enum nss_status 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, buflen, &errnop, &h_errnop);
+ status = __nss_compat_result(status,errnop);
+ h_errno = h_errnop;
+ return (status);
+}
diff --git a/net/nss_ldap/files/patch-Makefile.in b/net/nss_ldap/files/patch-Makefile.in
index d48ae9f117b5..5e495bcf9fd9 100644
--- a/net/nss_ldap/files/patch-Makefile.in
+++ b/net/nss_ldap/files/patch-Makefile.in
@@ -12,12 +12,12 @@
-
+nss_ldap_so_SOURCES = ldap-nss.c ldap-pwd.c ldap-grp.c \
+ ldap-schema.c utils.c ltf.c snprintf.c resolve.c \
-+ dnsconfig.c irs-nss.c pagectrl.c bsdnss.c
++ dnsconfig.c irs-nss.c pagectrl.c bsdnss.c ldap-hosts.c
NSS_LDAP_SOURCES = ldap-nss.c ldap-grp.c ldap-pwd.c ldap-netgrp.c ldap-schema.c \
util.c ltf.c snprintf.c resolve.c dnsconfig.c \
- irs-nss.c pagectrl.c aix_authmeth.c
-+ irs-nss.c pagectrl.c aix_authmeth.c bsdnss.c
++ irs-nss.c pagectrl.c aix_authmeth.c bsdnss.c ldap-hosts.c
DEFS = @DEFS@
@@ -41,7 +41,7 @@
+ util.$(OBJEXT) ltf.$(OBJEXT) \
snprintf.$(OBJEXT) resolve.$(OBJEXT) dnsconfig.$(OBJEXT) \
- irs-nss.$(OBJEXT) pagectrl.$(OBJEXT) ldap-sldap.$(OBJEXT)
-+ irs-nss.$(OBJEXT) pagectrl.$(OBJEXT) bsdnss.$(OBJEXT)
++ irs-nss.$(OBJEXT) pagectrl.$(OBJEXT) bsdnss.$(OBJEXT) ldap-hosts.$(OBJEXT)
nss_ldap_so_OBJECTS = $(am_nss_ldap_so_OBJECTS)
nss_ldap_so_LDADD = $(LDADD)
nss_ldap_so_DEPENDENCIES =
@@ -68,7 +68,7 @@
@AMDEP_TRUE@ $(DEPDIR)/pagectrl.Po $(DEPDIR)/resolve.Po \
-@AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po
+@AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po \
-+@AMDEP_TRUE@ $(DEPDIR)/bsdnss.Po
++@AMDEP_TRUE@ $(DEPDIR)/bsdnss.Po $(DEPDIR)/ldap-hosts.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
@@ -108,7 +108,7 @@
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
-@@ -248,22 +240,11 @@
+@@ -248,21 +240,11 @@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/aix_authmeth.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dnsconfig.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/irs-nss.Po@am__quote@
@@ -117,7 +117,7 @@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-bp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-ethers.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-grp.Po@am__quote@
--@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-hosts.Po@am__quote@
+ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-hosts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-netgrp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-network.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ldap-nss.Po@am__quote@
diff --git a/net/nss_ldap/files/patch-ldap-pwd.c b/net/nss_ldap/files/patch-ldap-pwd.c
new file mode 100644
index 000000000000..e6eb878b4988
--- /dev/null
+++ b/net/nss_ldap/files/patch-ldap-pwd.c
@@ -0,0 +1,29 @@
+--- ldap-pwd.c.orig Fri Feb 24 11:02:50 2006
++++ ldap-pwd.c Thu May 11 14:52:42 2006
+@@ -21,7 +21,10 @@
+ static char rcsId[] =
+ "$Id: ldap-pwd.c,v 2.46 2006/01/11 18:03:49 lukeh Exp $";
+
++#include <sys/types.h>
++#include <unistd.h>
+ #include "config.h"
++
+
+ #ifdef HAVE_PORT_BEFORE_H
+ #include <port_before.h>
+@@ -90,9 +93,13 @@
+ size_t tmplen;
+ char *tmp;
+
+- if (_nss_ldap_oc_check (e, "shadowAccount") == NSS_SUCCESS)
+- {
++/* if (_nss_ldap_oc_check (e, "shadowAccount") == NSS_SUCCESS)
++ * {
++ */
+ /* don't include password for shadowAccount */
++ if (getuid() != 0)
++ {
++ /* don't include password for non-root users */
+ if (buflen < 3)
+ return NSS_TRYAGAIN;
+