[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
net/nss_ldap port update.
- To: ports_(_at_)_FreeBSD_(_dot_)_org
- Subject: net/nss_ldap port update.
- From: Artem Kazakov <kazakov_(_at_)_gmail_(_dot_)_com>
- Date: Wed, 03 May 2006 15:46:00 +0900
- Cc:
Hello all!
I extended net/nss_ldap port functionality a little.
Now it is possible to use ldap as source for hosts database.
Only gethosbyname, gethostbyname2, gethostbyaddr are implemented.
But it seems sufficient for most cases I think.
Patch file is attached.
Cheers,
Artem Kazakov.
PS. There are some "strange" lines in the original
nss_ldap/files/bsdnss.c
for example:
{ NSDB_PASSWD, "endpwent", __nss_compat_setpwent,
_nss_ldap_setpwent },
{ NSDB_PASSWD, "setpwent", __nss_compat_endpwent,
_nss_ldap_endpwent },
Shouldn't it be like that? :
{ NSDB_PASSWD, "setpwent", __nss_compat_setpwent,
_nss_ldap_setpwent },
{ NSDB_PASSWD, "endpwent", __nss_compat_endpwent,
_nss_ldap_endpwent },
I have not noticed any difference in behavior when I change this, so I
did not include that fix to my patch. But can anyone explain if it is a
mistake or not?
setgrent/endgrent are also mixed as in example.
diff -rcN /usr/ports/net/nss_ldap/files/bsdnss.c files/bsdnss.c
*** /usr/ports/net/nss_ldap/files/bsdnss.c Fri Apr 25 00:07:20 2003
--- files/bsdnss.c Wed May 3 06:29:46 2006
***************
*** 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,26 ****
--- 24,40 ----
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,38 ****
--- 47,56 ----
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 },
***************
*** 46,51 ****
--- 64,73 ----
{ NSDB_PASSWD, "endpwent", __nss_compat_setpwent, _nss_ldap_setpwent },
{ NSDB_PASSWD, "setpwent", __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 },
***************
*** 68,71 ****
--- 90,158 ----
*mtabsize = sizeof(methods)/sizeof(methods[0]);
*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 -rcN /usr/ports/net/nss_ldap/files/patch-Makefile.in files/patch-Makefile.in
*** /usr/ports/net/nss_ldap/files/patch-Makefile.in Fri Mar 24 22:52:30 2006
--- files/patch-Makefile.in Tue May 2 05:07:18 2006
***************
*** 12,23 ****
-
+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
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
DEFS = @DEFS@
--- 12,23 ----
-
+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 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 ldap-hosts.c
DEFS = @DEFS@
***************
*** 41,47 ****
+ 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)
nss_ldap_so_OBJECTS = $(am_nss_ldap_so_OBJECTS)
nss_ldap_so_LDADD = $(LDADD)
nss_ldap_so_DEPENDENCIES =
--- 41,47 ----
+ 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) ldap-hosts.$(OBJEXT)
nss_ldap_so_OBJECTS = $(am_nss_ldap_so_OBJECTS)
nss_ldap_so_LDADD = $(LDADD)
nss_ldap_so_DEPENDENCIES =
***************
*** 68,74 ****
@AMDEP_TRUE@ $(DEPDIR)/pagectrl.Po $(DEPDIR)/resolve.Po \
-_(_at_)_AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po
+_(_at_)_AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po \
! +_(_at_)_AMDEP_TRUE@ $(DEPDIR)/bsdnss.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
--- 68,74 ----
@AMDEP_TRUE@ $(DEPDIR)/pagectrl.Po $(DEPDIR)/resolve.Po \
-_(_at_)_AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po
+_(_at_)_AMDEP_TRUE@ $(DEPDIR)/snprintf.Po $(DEPDIR)/util.Po \
! +_(_at_)_AMDEP_TRUE@ $(DEPDIR)/bsdnss.Po $(DEPDIR)/ldap-hosts.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
***************
*** 108,114 ****
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
! @@ -248,22 +240,11 @@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/aix_authmeth_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/dnsconfig_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/irs-nss_(_dot_)_Po_(_at_)_am__quote@
--- 108,114 ----
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
! @@ -248,21 +240,11 @@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/aix_authmeth_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/dnsconfig_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/irs-nss_(_dot_)_Po_(_at_)_am__quote@
***************
*** 117,123 ****
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-bp_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-ethers_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-grp_(_dot_)_Po_(_at_)_am__quote@
! -_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-hosts_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-netgrp_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-network_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-nss_(_dot_)_Po_(_at_)_am__quote@
--- 117,123 ----
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-bp_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-ethers_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-grp_(_dot_)_Po_(_at_)_am__quote@
! @AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-hosts_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-netgrp_(_dot_)_Po_(_at_)_am__quote@
-_(_at_)_AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-network_(_dot_)_Po_(_at_)_am__quote@
@AMDEP_TRUE@@am__include@ @am__quote_(_at_)_$(DEPDIR)/ldap-nss_(_dot_)_Po_(_at_)_am__quote@
_______________________________________________
freebsd-ports_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org