From owner-p4-projects@FreeBSD.ORG Tue Jun 20 14:06:35 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CCCF516A47E; Tue, 20 Jun 2006 14:06:34 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8FBBF16A474 for ; Tue, 20 Jun 2006 14:06:34 +0000 (UTC) (envelope-from bushman@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D3A243D45 for ; Tue, 20 Jun 2006 14:06:34 +0000 (GMT) (envelope-from bushman@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5KE6YWf026175 for ; Tue, 20 Jun 2006 14:06:34 GMT (envelope-from bushman@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5KE6YE1026172 for perforce@freebsd.org; Tue, 20 Jun 2006 14:06:34 GMT (envelope-from bushman@freebsd.org) Date: Tue, 20 Jun 2006 14:06:34 GMT Message-Id: <200606201406.k5KE6YE1026172@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bushman@freebsd.org using -f From: Michael Bushkov To: Perforce Change Reviews Cc: Subject: PERFORCE change 99671 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2006 14:06:35 -0000 http://perforce.freebsd.org/chv.cgi?CH=99671 Change 99671 by bushman@bushman_nss_ldap_cached on 2006/06/20 14:06:17 Makefile's hierarchy changed so that modules are now built as the shared libraries + their sources are included to the libc sources so that statically linked programs would run normally. It would be better, though, to include nss-modules's source only for libc.a - and not for the libc.so. Affected files ... .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/Makefile#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/Makefile.inc#4 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/getprotoent.c#3 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/netdb_private.h#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/nss_backends.h#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/Makefile#4 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/Makefile#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/compat_passwd.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/nss_compat.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/Makefile#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/nss_dns.c#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/Makefile#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_passwd.c#3 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_proto.c#3 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/nss_files.c#7 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/Makefile#4 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/icmp_hosts_namadr.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/nss_icmp.c#2 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_nis/Makefile#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_nis/nss_nis.c#4 edit Differences ... ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/Makefile#2 (text+ko) ==== @@ -110,7 +110,29 @@ .if defined(KMSRCS) && !empty(KMSRCS) cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${MACHINE_ARCH} .endif - + +# Include nss-modules's sources so that statically linked apps can work +# normally +CFLAGS+= -I${.CURDIR}/../libnssutil +CFLAGS+= -I${.CURDIR/include -I${.CURDIR/net + +.PATH: ${.CURDIR}/../libnssutil +.include "${.CURDIR}/../libnssutil/Makefile.inc" + +.PATH: ${.CURDIR}/../nss_files +.include "${.CURDIR}/../nss_files/Makefile.inc" + +.PATH: ${.CURDIR}/../nss_dns +.include "${.CURDIR}/../nss_dns/Makefile.inc" + +.if ${MK_NIS} != "no" +.PATH: ${.CURDIR}/../nss_nis +.include "${.CURDIR}/../nss_nis/Makefile.inc" +.endif + +.PATH: ${.CURDIR}/../nss_compat +.include "${.CURDIR}/../nss_compat/Makefile.inc" + .include # Disable warnings in contributed sources. ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/Makefile.inc#4 (text+ko) ==== @@ -7,7 +7,7 @@ SRCS+= addr2ascii.c ascii2addr.c base64.c ether_addr.c eui64.c \ gai_strerror.c getaddrinfo.c gethostnamadr.c \ getifaddrs.c getifmaddrs.c getnameinfo.c \ - getnetnamadr.c getproto.c getprotoent.c getprotoname.c getservent.c \ + getnetnamadr.c getprotoent.c getservent.c \ if_indextoname.c if_nameindex.c if_nametoindex.c \ ip6opt.c linkaddr.c map_v4v6.c name6.c \ nsdispatch.c nslexer.c nsparser.c nss_compat.c \ ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/getprotoent.c#3 (text+ko) ==== @@ -278,6 +278,66 @@ #endif /* NS_CACHING */ int +getprotobyname_r(const char *name, struct protoent *pptr, char *buffer, + size_t buflen, struct protoent **result) +{ +#ifdef NS_CACHING + static const nss_cache_info cache_info = + NS_COMMON_CACHE_INFO_INITIALIZER( + protocols, (void *)nss_lt_name, + __proto_id_func, __proto_marshal_func, __proto_unmarshal_func); +#endif + static const ns_dtab dtab[] = { +#ifdef NS_CACHING + NS_CACHE_CB(&cache_info) +#endif + { NULL, NULL, NULL } + }; + int rv, ret_errno; + + ret_errno = 0; + *result = NULL; + rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotobyname_r", + defaultsrc, name, pptr, buffer, buflen, &ret_errno); + + if (rv == NS_SUCCESS) + return (0); + else + return (ret_errno); +} + +int +getprotobynumber_r(int proto, struct protoent *pptr, char *buffer, + size_t buflen, struct protoent **result) +{ +#ifdef NS_CACHING + static const nss_cache_info cache_info = + NS_COMMON_CACHE_INFO_INITIALIZER( + protocols, (void *)nss_lt_id, + __proto_id_func, __proto_marshal_func, __proto_unmarshal_func); +#endif + + static const ns_dtab dtab[] = { +#ifdef NS_CACHING + NS_CACHE_CB(&cache_info) +#endif + { NULL, NULL, NULL } + }; + int rv, ret_errno; + + ret_errno = 0; + *result = NULL; + rv = nsdispatch(result, dtab, NSDB_PROTOCOLS, "getprotobynumber_r", + defaultsrc, proto, pptr, buffer, buflen, &ret_errno); + + if (rv == NS_SUCCESS) + return (0); + else + return (ret_errno); +} + + +int getprotoent_r(struct protoent *pptr, char *buffer, size_t buflen, struct protoent **result) { @@ -345,6 +405,35 @@ } struct protoent * +getprotobyname(const char *name) +{ + struct protodata *pd; + struct protoent *rval; + + if ((pd = __protodata_init()) == NULL) + return (NULL); + if (getprotobyname_r(name, &pd->proto, pd->data, sizeof(pd->data), + &rval) != 0) + return (NULL); + return (rval); +} + + +struct protoent * +getprotobynumber(int proto) +{ + struct protodata *pd; + struct protoent *rval; + + if ((pd = __protodata_init()) == NULL) + return (NULL); + if (getprotobynumber_r(proto, &pd->proto, pd->data, sizeof(pd->data), + &rval) != 0) + return (NULL); + return (rval); +} + +struct protoent * getprotoent(void) { struct protodata *pd; ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/netdb_private.h#5 (text+ko) ==== @@ -48,7 +48,7 @@ (thr_keycreate(&name##_key, name##_free) == 0); \ } \ \ -struct name * \ +static struct name * \ __##name##_init(void) \ { \ struct name *he; \ ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libc/net/nss_backends.h#2 (text+ko) ==== @@ -35,9 +35,12 @@ * Eventually, the implementations of existing built-in NSS functions * may be moved into NSS modules and live here. */ -#if 0 +#if 1 NSS_BACKEND( files, _files_nss_module_register ) NSS_BACKEND( dns, _dns_nss_module_register ) +#ifdef YP NSS_BACKEND( nis, _nis_nss_module_register ) +#endif NSS_BACKEND( compat, _compat_nss_module_register ) +//NSS_BACKEND( icmp, _icmp_nss_module_register ) #endif ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/libnssutil/Makefile#4 (text+ko) ==== @@ -1,9 +1,10 @@ # $FreeBSD$ -LIB= nssutil -SRCS= copynetent.c copyhtent.c gr_scan.c pw_scan.c rpcunpack.c\ - servunpack.c +LIB= nssutil +#SRCS= copynetent.c copyhtent.c gr_scan.c pw_scan.c rpcunpack.c\ +# servunpack.c INTERNAL= NO_PIC= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/Makefile#2 (text+ko) ==== @@ -7,8 +7,7 @@ SHLIBDIR?= /lib # NOTE: dirty hack with nss_files's file_serv.c is used -SRCS= nss_compat.c compat_group.c compat_passwd.c compat_serv.c\ - ${.CURDIR}/../nss_files/files_serv.c +SRCS+= ${.CURDIR}/../nss_files/files_serv.c CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc/gen -I${.CURDIR}/../libc/include\ -I${.CURDIR}/../libc/net -I${.CURDIR}/../libnssutil CFLAGS+=-DINET6 @@ -26,4 +25,5 @@ INCS= MAN= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/compat_passwd.c#2 (text+ko) ==== @@ -72,6 +72,7 @@ static void compat_endstate(void *); NSS_TLS_HANDLING(compat); +static void pwd_init(struct passwd *pwd); static int pwdb_match_entry_v3(char *, size_t, enum nss_lookup_type, const char *, uid_t); static int pwdb_parse_entry_v3(char *, size_t, struct passwd *, int *); @@ -79,7 +80,7 @@ const char *, uid_t); static int pwdb_parse_entry_v4(char *, size_t, struct passwd *, int *); -struct { +static struct { int (*match)(char *, size_t, enum nss_lookup_type, const char *, uid_t); int (*parse)(char *, size_t, struct passwd *, int *); @@ -464,6 +465,22 @@ return (NS_SUCCESS); } +static void +pwd_init(struct passwd *pwd) +{ + static char nul[] = ""; + + memset(pwd, 0, sizeof(*pwd)); + pwd->pw_uid = (uid_t)-1; /* Considered least likely to lead to */ + pwd->pw_gid = (gid_t)-1; /* a security issue. */ + pwd->pw_name = nul; + pwd->pw_passwd = nul; + pwd->pw_class = nul; + pwd->pw_gecos = nul; + pwd->pw_dir = nul; + pwd->pw_shell = nul; +} + static DB * pwdbopen(int *version) { ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_compat/nss_compat.c#2 (text+ko) ==== @@ -65,7 +65,7 @@ }; ns_mtab * -nss_module_register(const char *source, unsigned int *mtabsize, +_compat_nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) { *mtabsize = sizeof(methods) / sizeof(methods[0]); @@ -74,8 +74,4 @@ return (methods); } -int -main(int argc, char **argv) -{ - return (0); -} +__weak_reference(_compat_nss_module_register, nss_module_register); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/Makefile#5 (text+ko) ==== @@ -2,12 +2,13 @@ .include +LIB= nss_dns SHLIB_MAJOR= 1 SHLIB_NAME= nss_dns.so.${SHLIB_MAJOR} SHLIBDIR?= /lib -SRCS= nss_dns.c dns_hosts_namadr.c dns_hosts_addrinfo.c dns_passwd.c\ - dns_group.c dns_net.c +#SRCS= nss_dns.c dns_hosts_namadr.c dns_hosts_addrinfo.c dns_passwd.c\ +# dns_group.c dns_net.c CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc/gen -I${.CURDIR}/../libc/include\ -I${.CURDIR}/../libc/net -I${.CURDIR}/../libnssutil CFLAGS+=-DINET6 @@ -25,4 +26,5 @@ INCS= MAN= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_dns/nss_dns.c#5 (text+ko) ==== @@ -84,7 +84,7 @@ }; ns_mtab * -nss_module_register(const char *source, unsigned int *mtabsize, +_dns_nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) { *mtabsize = sizeof(methods) / sizeof(methods[0]); @@ -93,8 +93,4 @@ return (methods); } -int -main(int argc, char **argv) -{ - return (0); -} +__weak_reference(_dns_nss_module_register, nss_module_register); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/Makefile#5 (text+ko) ==== @@ -2,13 +2,14 @@ .include +LIB= nss_files SHLIB_MAJOR= 1 SHLIB_NAME= nss_files.so.${SHLIB_MAJOR} SHLIBDIR?= /lib -SRCS= nss_files.c files_passwd.c files_group.c files_hosts_namadr.c\ - files_hosts_addrinfo.c files_serv.c files_proto.c\ - files_net.c files_rpc.c +#SRCS= nss_files.c files_passwd.c files_group.c files_hosts_namadr.c\ +# files_hosts_addrinfo.c files_serv.c files_proto.c\ +# files_net.c files_rpc.c CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc/gen -I${.CURDIR}/../libc/include\ -I${.CURDIR}/../libc/net -I${.CURDIR}/../libnssutil CFLAGS+=-DINET6 @@ -26,4 +27,5 @@ INCS= MAN= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_passwd.c#3 (text+ko) ==== @@ -71,7 +71,7 @@ static int pwdb_parse_entry_v4(char *, size_t, struct passwd *, int *); -struct { +static struct { int (*match)(char *, size_t, enum nss_lookup_type, const char *, uid_t); int (*parse)(char *, size_t, struct passwd *, int *); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/files_proto.c#3 (text+ko) ==== @@ -62,7 +62,7 @@ } static void -protoent_data_free(void *ptr) +files_protoent_data_free(void *ptr) { struct files_protoent_data *ped = ptr; ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_files/nss_files.c#7 (text+ko) ==== @@ -126,7 +126,7 @@ }; ns_mtab * -nss_module_register(const char *source, unsigned int *mtabsize, +_files_nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) { *mtabsize = sizeof(methods) / sizeof(methods[0]); @@ -135,8 +135,4 @@ return (methods); } -int -main(int argc, char **argv) -{ - return (0); -} +__weak_reference(_files_nss_module_register, nss_module_register); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/Makefile#4 (text+ko) ==== @@ -2,11 +2,11 @@ .include -SHLIB_MAJOR= 1 -LIB= nss_icmp.so.${SHLIB_MAJOR} -SHLIBDIR?= /lib +SHLIB_MAJOR= 1 +SHLIB_NAME= nss_icmp.so.${SHLIB_MAJOR} +SHLIBDIR?= /lib -SRCS= nss_icmp.c icmp_hosts_namadr.c +#SRCS= nss_icmp.c icmp_hosts_namadr.c CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc/gen -I${.CURDIR}/../libc/include\ -I${.CURDIR}/../libc/net -I${.CURDIR}/../libnssutil CFLAGS+=-DINET6 @@ -19,9 +19,10 @@ .endif LDADD+= -lnssutil -LDFLAGS+= -L${.OBJDIR/../libnssutil +LDFLAGS+= -L${.OBJDIR}/../libnssutil INCS= MAN= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/icmp_hosts_namadr.c#2 (text+ko) ==== @@ -119,6 +119,13 @@ #include "netdb_private.h" #include "nss_icmp.h" +#ifdef INET6 +#define ADDRLEN(af) ((af) == AF_INET6 ? sizeof(struct in6_addr) : \ + sizeof(struct in_addr)) +#else +#define ADDRLEN(af) sizeof(struct in_addr) +#endif + NETDB_THREAD_ALLOC(hostent) NETDB_THREAD_ALLOC(icmp_hostent_data) ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_icmp/nss_icmp.c#2 (text+ko) ==== @@ -44,7 +44,7 @@ }; ns_mtab * -nss_module_register(const char *source, unsigned int *mtabsize, +_icmp_nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) { *mtabsize = sizeof(methods) / sizeof(methods[0]); @@ -53,8 +53,4 @@ return (methods); } -int -main(int argc, char **argv) -{ - return (0); -} +__weak_reference(_icmp_nss_module_register, nss_module_register); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_nis/Makefile#5 (text+ko) ==== @@ -6,8 +6,8 @@ SHLIB_NAME= nss_nis.so.${SHLIB_MAJOR} SHLIBDIR?= /lib -SRCS= nss_nis.c nis_hosts_namadr.c nis_hosts_addrinfo.c nis_passwd.c\ - nis_group.c nis_net.c nis_rpc.c nis_serv.c +#SRCS= nss_nis.c nis_hosts_namadr.c nis_hosts_addrinfo.c nis_passwd.c\ +# nis_group.c nis_net.c nis_rpc.c nis_serv.c CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../libc/gen -I${.CURDIR}/../libc/include\ -I${.CURDIR}/../libc/net -I${.CURDIR}/../libnssutil CFLAGS+=-DINET6 @@ -25,4 +25,5 @@ INCS= MAN= +.include "Makefile.inc" .include ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_nis/nss_nis.c#4 (text+ko) ==== @@ -87,7 +87,7 @@ }; ns_mtab * -nss_module_register(const char *source, unsigned int *mtabsize, +_nis_nss_module_register(const char *source, unsigned int *mtabsize, nss_module_unregister_fn *unreg) { *mtabsize = sizeof(methods) / sizeof(methods[0]); @@ -96,8 +96,4 @@ return (methods); } -int -main(int argc, char **argv) -{ - return (0); -} +__weak_reference(_nis_nss_module_register, nss_module_register);