Date: Fri, 9 Jun 2006 13:31:52 GMT From: Michael Bushkov <bushman@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 98866 for review Message-ID: <200606091331.k59DVqYo077625@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=98866 Change 98866 by bushman@bushman_nss_ldap_cached on 2006/06/09 13:31:39 Draft versions of DNS and files nss-modules introduced. There are issues with common fucntionality, issues with getipnodeby* functions (which should be probably be implemented through gethostby* functions). Several changes to gethostnamadr.c were made to implement gethostent() in the more general way. Affected files ... .. //depot/projects/soc2006/nss_ldap_cached/src/include/nsswitch.h#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/Makefile#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/include/nss_tls.h#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/gethostnamadr.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/netdb_private.h#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/nsdispatch.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/Makefile#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/hosts_namadr.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/hosts_namadr.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/hosts_name6.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/hosts_name6.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/Makefile#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_addrinfo.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_addrinfo.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_namadr.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_namadr.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_name6.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/dns_hosts_name6.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/nss_dns.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/Makefile#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_group.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_group.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_addrinfo.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_addrinfo.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_namadr.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_namadr.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_name6.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_hosts_name6.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_net.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_net.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_passwd.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_passwd.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_proto.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_proto.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_rpc.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_rpc.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_serv.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_serv.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_shells.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_shells.h#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/nss_files.c#1 add .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/nss_files.h#1 add Differences ... ==== //depot/projects/soc2006/nss_ldap_cached/src/include/nsswitch.h#2 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/Makefile#2 (text+ko) ==== @@ -25,6 +25,7 @@ # Otherwise, the SUBDIR list should be in alphabetical order. SUBDIR= ${_csu} libbsm libcom_err libcrypt libkvm msun libmd libncurses \ + nss_files nss_dns\ libnetgraph libradius librpcsvc libsbuf libtacplus libutil \ ${_libypclnt} libalias libarchive ${_libatm} \ libbegemot ${_libbluetooth} libbsnmp libbz2 libc ${_libc_r} \ @@ -121,6 +122,7 @@ .if ${MK_NIS} != "no" _libypclnt= libypclnt +_nss_nis= nss_nis .endif .if ${MK_GPIB} != "no" ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/include/nss_tls.h#2 (text+ko) ==== @@ -61,7 +61,7 @@ rv = _pthread_once(&keyinit, name##_keyinit); \ if (rv != 0) \ return (rv); \ - *p = _pthread_getspecific(name##_state_key); \ + *p = (struct name##_state *)_pthread_getspecific(name##_state_key);\ if (*p != NULL) \ return (0); \ *p = calloc(1, sizeof(**p)); \ ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/gethostnamadr.c#2 (text+ko) ==== @@ -64,6 +64,14 @@ { NSSRC_DNS, NS_SUCCESS }, { 0 } }; + +/* Host lookupd order for gethostent() function - it can't be changed through + * nsswitch.conf */ +static const ns_src default_gethostent_src[] = { + { NSSRC_FILES, NS_SUCCESS }, + { 0 } +}; + #ifdef NS_CACHING static int host_id_func(char *, size_t *, va_list, void *); static int host_marshal_func(char *, size_t *, void *, va_list, void *); @@ -654,6 +662,35 @@ return ((rval == NS_SUCCESS) ? 0 : -1); } +int +gethostent_r(struct hostent *hptr, char *buffer, size_t buflen, + struct hostent **result, int *h_errnop) +{ + static const ns_dtab dtab[] = { + { 0 } + }; + + int rval, ret_errno; + res_state statp; + + statp = __res_state(); + if ((statp->options & RES_INIT) == 0 && res_ninit(statp) == -1) { + RES_SET_H_ERRNO(statp, NETDB_INTERNAL); + *h_errnop = statp->res_h_errno; + return (-1); + } + + /* NOTE: NSDB_HOSTS_INTERNAL is passed to the _nsdispatch() instead of + * NSDB_HOSTS, so that it won't use nsswitch.conf to determine + * the appropriate sources, but will use only the provided + * default_src */ + rval = _nsdispatch((void *)result, dtab, NSDB_HOSTS_INTERNAL, + "gethostent_r", default_gethostent_src, hp, buf, buflen, + &ret_errno, h_errnop); + + return ((rval == NS_SUCCESS) ? 0 : -1); +} + struct hostent * gethostbyname(const char *name) { @@ -699,24 +736,43 @@ return (rval); } +struct hostent * +gethostent() +{ + struct hostdata *hd; + struct hostent *rval; + int ret_h_errno; + + if ((hd = __hostdata_init()) == NULL) + return (NULL); + if (gethostent_r(&hd->host, hd->data, sizeof(hd->data), &rval, + &ret_h_errno) != 0) + return (NULL); + return (rval); +} + void sethostent(int stayopen) { - struct hostent_data *hed; + static const ns_dtab dtab[] = { + { 0 } + }; - if ((hed = __hostent_data_init()) == NULL) - return; - _sethosthtent(stayopen, hed); - _sethostdnsent(stayopen); + int rval; + rval = _nsdispatch(NULL, dtab, NSDB_HOSTS_INTERNAL, "sethostent", + default_src, stayopen); + /* TODO: should we omit the rval? */ } void endhostent(void) { - struct hostent_data *hed; - - if ((hed = __hostent_data_init()) == NULL) - return; - _endhosthtent(hed); - _endhostdnsent(); + static const ns_dtab dtab[] = { + { 0 } + }; + + int rval; + rval = _nsdispatch(NULL, dtab, NSDB_HOSTS_INTERNAL, "endhostent", + default_src); + /* TODO: should we omit the rval? */ } ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/netdb_private.h#2 (text+ko) ==== @@ -30,6 +30,9 @@ #include <stdio.h> /* XXX: for FILE */ +#define NSDB_HOSTS_INTERNAL "__hosts_internal" +#define NSDB_NETWORKS_INTERNAL "__networks_internal" + #define NETDB_THREAD_ALLOC(name) \ static struct name name; \ static thread_key_t name##_key; \ @@ -55,7 +58,7 @@ if (thr_once(&name##_init_once, name##_keycreate) != 0 || \ !name##_thr_keycreated) \ return (NULL); \ - if ((he = thr_getspecific(name##_key)) != NULL) \ + if ((he = (struct name *)thr_getspecific(name##_key)) != NULL) \ return (he); \ if ((he = calloc(1, sizeof(*he))) == NULL) \ return (NULL); \ @@ -120,26 +123,16 @@ struct hostent_data *__hostent_data_init(void); struct netdata *__netdata_init(void); struct netent_data *__netent_data_init(void); -struct protodata *__protodata_init(void); -struct protoent_data *__protoent_data_init(void); int __copy_hostent(struct hostent *, struct hostent *, char *, size_t); int __copy_netent(struct netent *, struct netent *, char *, size_t); -int __copy_protoent(struct protoent *, struct protoent *, char *, size_t); -void __endprotoent_p(struct protoent_data *); -int __getprotoent_p(struct protoent *, struct protoent_data *); -void __setprotoent_p(int, struct protoent_data *); void _endhostdnsent(void); -void _endhosthtent(struct hostent_data *); void _endnetdnsent(void); -void _endnethtent(struct netent_data *); struct hostent *_gethostbynisaddr(const void *, socklen_t, int); struct hostent *_gethostbynisname(const char *, int); void _map_v4v6_address(const char *, char *); void _map_v4v6_hostent(struct hostent *, char **, char *); void _sethostdnsent(int); -void _sethosthtent(int, struct hostent_data *); void _setnetdnsent(int); -void _setnethtent(int, struct netent_data *); #endif /* _NETDB_PRIVATE_H_ */ ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/nsdispatch.c#2 (text+ko) ====
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606091331.k59DVqYo077625>