From ccd4a120fd72e1cd2071458320f7a1914ef55421 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 24 Oct 2003 22:37:25 +0000 Subject: [PATCH] Libinfo-173.tar.gz --- dns.subproj/Makefile | 4 +- dns.subproj/Makefile.preamble | 2 +- dns.subproj/PB.project | 4 +- dns.subproj/gethnamaddr.c | 48 +- dns.subproj/getnetbyaddr.c | 23 +- dns.subproj/getnetbyname.c | 23 +- dns.subproj/getnetent.c | 29 +- dns.subproj/getnetnamadr.c | 95 +- dns.subproj/herror.c | 27 +- dns.subproj/inet.h | 53 +- dns.subproj/{nameser.h => nameser8_compat.h} | 25 +- dns.subproj/options.h | 23 +- dns.subproj/portability.h | 23 +- dns.subproj/res_comp.c | 29 +- dns.subproj/res_data.c | 28 +- dns.subproj/res_debug.c | 29 +- dns.subproj/res_init.c | 31 +- dns.subproj/res_mkquery.c | 29 +- dns.subproj/res_query.c | 29 +- dns.subproj/res_send.c | 58 +- dns.subproj/{resolv.h => resolv8_compat.h} | 25 +- dns.subproj/sethostent.c | 29 +- gen.subproj/Makefile | 12 +- gen.subproj/Makefile.postamble | 8 +- gen.subproj/PB.project | 10 +- gen.subproj/aliasdb.c | 23 +- gen.subproj/ether_addr.3 | 1 + gen.subproj/ether_addr.c | 25 +- gen.subproj/fstab.c | 37 +- gen.subproj/getaddrinfo.c | 1676 ---------------------- gen.subproj/getgrent.c | 23 +- gen.subproj/gethostbyname.3 | 15 +- gen.subproj/getifaddrs.c | 4 + gen.subproj/getipnodebyname.3 | 2 - gen.subproj/getnameinfo.c | 384 ----- gen.subproj/getproto.c | 23 +- gen.subproj/getprotoent.c | 23 +- gen.subproj/getprotoname.c | 23 +- gen.subproj/getpwent.c | 27 +- gen.subproj/getservbyname.c | 23 +- gen.subproj/getservbyport.c | 23 +- gen.subproj/getservent.c | 23 +- gen.subproj/inet_ntop.c | 249 ++-- gen.subproj/inet_pton.c | 45 +- gen.subproj/initgroups.c | 23 +- gen.subproj/linkaddr.3 | 140 -- gen.subproj/map_v4v6.c | 4 +- gen.subproj/printerdb.c | 23 +- lookup.subproj/Makefile | 15 +- lookup.subproj/Makefile.postamble | 13 +- lookup.subproj/Makefile.preamble | 1 + lookup.subproj/PB.project | 14 +- lookup.subproj/_lu_types.x | 23 +- lookup.subproj/aliasdb.h | 23 +- lookup.subproj/bootparams.h | 23 +- {gen.subproj => lookup.subproj}/getaddrinfo.3 | 2 +- lookup.subproj/getaddrinfo.c | 1579 ++++++++++++++++++++ {gen.subproj => lookup.subproj}/getnameinfo.3 | 0 lookup.subproj/lookup.defs | 23 +- lookup.subproj/lookup_types.h | 23 +- lookup.subproj/lu_alias.c | 23 +- lookup.subproj/lu_bootp.c | 24 +- lookup.subproj/lu_bootparam.c | 23 +- lookup.subproj/lu_fstab.c | 23 +- lookup.subproj/lu_group.c | 290 +++- lookup.subproj/lu_host.c | 327 ++++- lookup.subproj/lu_host.h | 24 +- lookup.subproj/lu_host_async.c | 945 ++++++------ lookup.subproj/lu_netgroup.c | 23 +- lookup.subproj/lu_network.c | 23 +- lookup.subproj/lu_overrides.h | 23 +- lookup.subproj/lu_printer.c | 23 +- lookup.subproj/lu_protocol.c | 25 +- lookup.subproj/lu_rpc.c | 23 +- lookup.subproj/lu_service.c | 207 ++- lookup.subproj/lu_user.c | 223 ++- lookup.subproj/lu_utils.c | 366 ++++- lookup.subproj/lu_utils.h | 23 +- lookup.subproj/netdb.h | 263 ++++ lookup.subproj/netdb_async.h | 557 +++---- lookup.subproj/netgr.h | 23 +- lookup.subproj/printerdb.h | 23 +- mdns.subproj/DNSServiceDiscovery.c | 33 +- mdns.subproj/DNSServiceDiscovery.h | 29 +- mdns.subproj/DNSServiceDiscoveryDefines.h | 31 +- mdns.subproj/DNSServiceDiscoveryReply.defs | 29 +- mdns.subproj/DNSServiceDiscoveryRequest.defs | 29 +- mdns.subproj/Makefile | 7 +- mdns.subproj/Makefile.postamble | 8 +- mdns.subproj/Makefile.preamble | 17 +- mdns.subproj/PB.project | 6 +- mdns.subproj/dns_sd.h | 1013 +++++++++++++ mdns.subproj/dnssd_clientstub.c | 992 +++++++++++++ mdns.subproj/dnssd_ipc.c | 133 ++ mdns.subproj/dnssd_ipc.h | 159 ++ netinfo.subproj/Makefile | 2 +- netinfo.subproj/Makefile.preamble | 4 +- netinfo.subproj/PB.project | 2 +- netinfo.subproj/clib.h | 23 +- netinfo.subproj/mm.h | 23 +- netinfo.subproj/multi_call.c | 25 +- netinfo.subproj/ni.h | 34 +- netinfo.subproj/ni_error.c | 23 +- netinfo.subproj/ni_glue.c | 180 +-- netinfo.subproj/ni_prot.x | 23 +- netinfo.subproj/ni_pwdomain.c | 23 +- netinfo.subproj/ni_useful.c | 23 +- netinfo.subproj/ni_util.c | 23 +- netinfo.subproj/ni_util.h | 34 +- netinfo.subproj/nibind_prot.x | 23 +- netinfo.subproj/sys_interfaces.c | 23 +- netinfo.subproj/sys_interfaces.h | 23 +- nis.subproj/Makefile | 2 +- {util.subproj => nis.subproj}/Makefile.postamble | 30 +- nis.subproj/PB.project | 4 +- nis.subproj/getdomainname.c | 27 +- nis.subproj/getnetgrent.c | 23 +- nis.subproj/innetgr.c | 23 +- nis.subproj/setdomainname.c | 23 +- nis.subproj/xdr_domainname.c | 23 +- nis.subproj/xdr_keydat.c | 23 +- nis.subproj/xdr_mapname.c | 23 +- nis.subproj/xdr_peername.c | 23 +- nis.subproj/xdr_valdat.c | 23 +- nis.subproj/xdr_ypbind_binding.c | 23 +- nis.subproj/xdr_ypbind_resp.c | 23 +- nis.subproj/xdr_ypbind_resptype.c | 23 +- nis.subproj/xdr_ypbind_setdom.c | 23 +- nis.subproj/xdr_ypmaplist.c | 23 +- nis.subproj/xdr_ypreq_key.c | 23 +- nis.subproj/xdr_ypreq_nokey.c | 23 +- nis.subproj/xdr_ypresp_all.c | 23 +- nis.subproj/xdr_ypresp_key_val.c | 23 +- nis.subproj/xdr_ypresp_maplist.c | 23 +- nis.subproj/xdr_ypresp_master.c | 23 +- nis.subproj/xdr_ypresp_order.c | 23 +- nis.subproj/xdr_ypresp_val.c | 23 +- nis.subproj/xdr_ypstat.c | 23 +- nis.subproj/yp_all.c | 23 +- nis.subproj/yp_bind.c | 23 +- nis.subproj/yp_first.c | 23 +- nis.subproj/yp_get_default_domain.c | 23 +- nis.subproj/yp_maplist.c | 23 +- nis.subproj/yp_master.c | 23 +- nis.subproj/yp_order.c | 23 +- nis.subproj/yp_prot.h | 23 +- nis.subproj/ypclnt.h | 23 +- nis.subproj/yperr_string.c | 23 +- nis.subproj/ypinternal.h | 25 +- nis.subproj/ypmatch_cache.c | 23 +- nis.subproj/yppasswdd_xdr.c | 23 +- nis.subproj/ypprot_err.c | 23 +- nis.subproj/ypserv.acl.5 | 177 --- rpc.subproj/auth.h | 23 +- rpc.subproj/auth_none.c | 23 +- rpc.subproj/auth_unix.c | 23 +- rpc.subproj/auth_unix.h | 23 +- rpc.subproj/authunix_prot.c | 23 +- rpc.subproj/bindresvport.c | 45 +- rpc.subproj/clnt.h | 48 +- rpc.subproj/clnt_generic.c | 23 +- rpc.subproj/clnt_perror.c | 26 +- rpc.subproj/clnt_raw.c | 23 +- rpc.subproj/clnt_simple.c | 23 +- rpc.subproj/clnt_tcp.c | 23 +- rpc.subproj/clnt_udp.c | 23 +- rpc.subproj/get_myaddress.c | 23 +- rpc.subproj/getrpcent.c | 23 +- rpc.subproj/getrpcport.c | 23 +- rpc.subproj/pmap_clnt.c | 23 +- rpc.subproj/pmap_clnt.h | 23 +- rpc.subproj/pmap_getmaps.c | 23 +- rpc.subproj/pmap_getport.c | 23 +- rpc.subproj/pmap_prot.c | 23 +- rpc.subproj/pmap_prot.h | 23 +- rpc.subproj/pmap_prot2.c | 23 +- rpc.subproj/pmap_rmt.c | 32 +- rpc.subproj/pmap_rmt.h | 23 +- rpc.subproj/rpc.h | 23 +- rpc.subproj/rpc_callmsg.c | 35 +- rpc.subproj/rpc_commondata.c | 23 +- rpc.subproj/rpc_dtablesize.c | 23 +- rpc.subproj/rpc_msg.h | 23 +- rpc.subproj/rpc_prot.c | 29 +- rpc.subproj/svc.c | 23 +- rpc.subproj/svc.h | 23 +- rpc.subproj/svc_auth.c | 23 +- rpc.subproj/svc_auth.h | 23 +- rpc.subproj/svc_auth_unix.c | 27 +- rpc.subproj/svc_raw.c | 23 +- rpc.subproj/svc_run.c | 23 +- rpc.subproj/svc_simple.c | 23 +- rpc.subproj/svc_tcp.c | 65 +- rpc.subproj/svc_udp.c | 23 +- rpc.subproj/types.h | 23 +- rpc.subproj/xdr.c | 26 +- rpc.subproj/xdr.h | 51 +- rpc.subproj/xdr_array.c | 31 +- rpc.subproj/xdr_float.c | 23 +- rpc.subproj/xdr_mem.c | 33 +- rpc.subproj/xdr_rec.c | 27 +- rpc.subproj/xdr_reference.c | 26 +- rpc.subproj/xdr_stdio.c | 23 +- util.subproj/Makefile | 4 +- util.subproj/Makefile.postamble | 2 + util.subproj/Makefile.preamble | 2 +- util.subproj/PB.project | 4 +- util.subproj/getgrouplist.c | 111 -- util.subproj/glob.c | 29 +- util.subproj/hosts.equiv.5 | 180 +++ util.subproj/hton.c | 23 +- util.subproj/putpwpasswd.c | 23 +- util.subproj/pwcache.c | 24 +- util.subproj/rcmd.c | 159 +- util.subproj/rcmdsh.c | 23 +- 215 files changed, 9068 insertions(+), 5690 deletions(-) rename dns.subproj/{nameser.h => nameser8_compat.h} (94%) rename dns.subproj/{resolv.h => resolv8_compat.h} (92%) create mode 100644 gen.subproj/ether_addr.3 delete mode 100644 gen.subproj/getaddrinfo.c delete mode 100644 gen.subproj/getnameinfo.c rewrite gen.subproj/inet_ntop.c (75%) delete mode 100644 gen.subproj/linkaddr.3 rename {gen.subproj => lookup.subproj}/getaddrinfo.3 (99%) create mode 100644 lookup.subproj/getaddrinfo.c rename {gen.subproj => lookup.subproj}/getnameinfo.3 (100%) create mode 100644 lookup.subproj/netdb.h rewrite lookup.subproj/netdb_async.h (91%) create mode 100644 mdns.subproj/dns_sd.h create mode 100644 mdns.subproj/dnssd_clientstub.c create mode 100644 mdns.subproj/dnssd_ipc.c create mode 100644 mdns.subproj/dnssd_ipc.h copy {util.subproj => nis.subproj}/Makefile.postamble (81%) delete mode 100644 nis.subproj/ypserv.acl.5 delete mode 100644 util.subproj/getgrouplist.c create mode 100755 util.subproj/hosts.equiv.5 diff --git a/dns.subproj/Makefile b/dns.subproj/Makefile index 7097677..3192331 100644 --- a/dns.subproj/Makefile +++ b/dns.subproj/Makefile @@ -12,7 +12,7 @@ NAME = dns PROJECTVERSION = 2.8 PROJECT_TYPE = Component -HFILES = inet.h nameser.h options.h portability.h resolv.h +HFILES = inet.h nameser8_compat.h options.h portability.h resolv8_compat.h CFILES = gethnamaddr.c getnetbyaddr.c getnetbyname.c getnetent.c\ getnetnamadr.c herror.c res_comp.c res_data.c res_debug.c\ @@ -31,7 +31,7 @@ PROF_LIBS = $(LIBS) NEXTSTEP_PB_CFLAGS = -DUSE_OPTIONS_H -PUBLIC_HEADERS = resolv.h nameser.h +PUBLIC_HEADERS = resolv8_compat.h nameser8_compat.h diff --git a/dns.subproj/Makefile.preamble b/dns.subproj/Makefile.preamble index 89f0837..4b5a0be 100644 --- a/dns.subproj/Makefile.preamble +++ b/dns.subproj/Makefile.preamble @@ -20,5 +20,5 @@ OTHER_CFLAGS = \ PUBLIC_HEADER_DIR_SUFFIX = ARPA_HEADER_DIR_SUFFIX = /arpa ARPA_HEADERS = inet.h -ARPA_SYMLINKED_HEADERS = nameser.h +ARPA_SYMLINKED_HEADERS = nameser8_compat.h AFTER_INSTALLHDRS += arpa_headers diff --git a/dns.subproj/PB.project b/dns.subproj/PB.project index 32107f8..48b050e 100644 --- a/dns.subproj/PB.project +++ b/dns.subproj/PB.project @@ -1,7 +1,7 @@ { DYNAMIC_CODE_GEN = YES; FILESTABLE = { - H_FILES = (inet.h, nameser.h, options.h, portability.h, resolv.h); + H_FILES = (inet.h, nameser8_compat.h, options.h, portability.h, resolv8_compat.h); OTHER_LINKED = ( gethnamaddr.c, getnetbyaddr.c, @@ -19,7 +19,7 @@ sethostent.c ); OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble); - PUBLIC_HEADERS = (resolv.h, nameser.h); + PUBLIC_HEADERS = (resolv8_compat.h, nameser8_compat.h); }; LANGUAGE = English; MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; diff --git a/dns.subproj/gethnamaddr.c b/dns.subproj/gethnamaddr.c index 250a3c4..6d5a0e7 100644 --- a/dns.subproj/gethnamaddr.c +++ b/dns.subproj/gethnamaddr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,19 +79,19 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: gethnamaddr.c,v 1.6 2002/06/13 01:04:37 majka Exp $"; +static char rcsid[] = "$Id: gethnamaddr.c,v 1.8 2003/07/03 21:56:17 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include -#include +#include #include #include #include -#include +#include #include #include #include @@ -442,25 +443,6 @@ gethostbyname(name) return (gethostbyname2(name, AF_INET)); } -struct hostent * -gethostbyname2(name, af) - const char *name; - int af; -{ - if (_lu_running()) - { - return getipnodebyname(name, af, 0, &h_errno); - } - else - { - if (af == AF_INET) return gethostbyname_ipv4(name); - - errno = EAFNOSUPPORT; - h_errno = NETDB_INTERNAL; - return NULL; - } -} - static struct hostent * gethostbyname_ipv4(name) const char *name; diff --git a/dns.subproj/getnetbyaddr.c b/dns.subproj/getnetbyaddr.c index 9406809..d1586b1 100644 --- a/dns.subproj/getnetbyaddr.c +++ b/dns.subproj/getnetbyaddr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dns.subproj/getnetbyname.c b/dns.subproj/getnetbyname.c index 24cf4a6..5cf9290 100644 --- a/dns.subproj/getnetbyname.c +++ b/dns.subproj/getnetbyname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dns.subproj/getnetent.c b/dns.subproj/getnetent.c index 9240a1b..7a777c8 100644 --- a/dns.subproj/getnetent.c +++ b/dns.subproj/getnetent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -66,18 +67,18 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: getnetent.c,v 1.3 2002/06/12 17:40:29 epeyton Exp $"; +static char rcsid[] = "$Id: getnetent.c,v 1.4 2003/02/18 17:29:23 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include -#include +#include #include #include -#include +#include #include #include diff --git a/dns.subproj/getnetnamadr.c b/dns.subproj/getnetnamadr.c index 7676e4f..9f35cd6 100644 --- a/dns.subproj/getnetnamadr.c +++ b/dns.subproj/getnetnamadr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -64,19 +65,19 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93"; static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; -static char rcsid[] = "$Id: getnetnamadr.c,v 1.3.44.1 2002/11/19 01:20:51 bbraun Exp $"; +static char rcsid[] = "$Id: getnetnamadr.c,v 1.4 2003/02/18 17:29:23 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include #include -#include +#include #include #include #include -#include +#include #include #include #include @@ -122,11 +123,10 @@ getnetanswer(answer, anslen, net_i) register int n; u_char *eom; int type, class, buflen, ancount, qdcount, haveanswer, i, nchar; - char aux1[30], aux2[30], *in, *st, *pauxt, *bp, **ap, + char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap, *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0; - static struct netent net_entry; - static char *net_aliases[MAXALIASES], *netbuf = NULL; - static char ans[MAXDNAME]; +static struct netent net_entry; +static char *net_aliases[MAXALIASES], *netbuf = NULL; if (netbuf == NULL) { netbuf = malloc(BUFSIZ+1); @@ -162,14 +162,8 @@ getnetanswer(answer, anslen, net_i) h_errno = TRY_AGAIN; return (NULL); } - while (qdcount-- > 0) { - n = __dn_skipname(cp, eom); - if (n < 0 || (cp + n + QFIXEDSZ) > eom) { - h_errno = NO_RECOVERY; - return(NULL); - } - cp += n + QFIXEDSZ; - } + while (qdcount-- > 0) + cp += __dn_skipname(cp, eom) + QFIXEDSZ; ap = net_aliases; *ap = NULL; net_entry.n_aliases = net_aliases; @@ -180,7 +174,7 @@ getnetanswer(answer, anslen, net_i) break; cp += n; ans[0] = '\0'; - (void)strcpy(ans, bp); + (void)strcpy(&ans[0], bp); GETSHORT(type, cp); GETSHORT(class, cp); cp += INT32SZ; /* TTL */ @@ -192,13 +186,11 @@ getnetanswer(answer, anslen, net_i) return (NULL); } cp += n; - if ((ap + 2) < &net_aliases[MAXALIASES]) { - *ap++ = bp; - bp += strlen(bp) + 1; - net_entry.n_addrtype = - (class == C_IN) ? AF_INET : AF_UNSPEC; - haveanswer++; - } + *ap++ = bp; + bp += strlen(bp) + 1; + net_entry.n_addrtype = + (class == C_IN) ? AF_INET : AF_UNSPEC; + haveanswer++; } } if (haveanswer) { @@ -209,35 +201,26 @@ getnetanswer(answer, anslen, net_i) net_entry.n_net = 0L; break; case BYNAME: - ap = net_entry.n_aliases; - next_alias: - in = *ap++; - if (in == NULL) { - h_errno = HOST_NOT_FOUND; - return (NULL); - } - net_entry.n_name = ans; + in = *net_entry.n_aliases; + net_entry.n_name = &ans[0]; aux2[0] = '\0'; for (i = 0; i < 4; i++) { for (st = in, nchar = 0; - isdigit((unsigned char)*st); + *st != '.'; st++, nchar++) ; - - if (*st != '.' || nchar == 0 || nchar > 3) - goto next_alias; - if (i != 0) - nchar++; - (void)strncpy(paux1, in, nchar); - paux1[nchar] = '\0'; - pauxt = paux2; - paux2 = strcat(paux1, paux2); - paux1 = pauxt; + if (nchar != 1 || *in != '0' || flag) { + flag = 1; + (void)strncpy(paux1, + (i==0) ? in : in-1, + (i==0) ?nchar : nchar+1); + paux1[(i==0) ? nchar : nchar+1] = '\0'; + pauxt = paux2; + paux2 = strcat(paux1, paux2); + paux1 = pauxt; + } in = ++st; } - - if (strcasecmp(in, "IN-ADDR.ARPA") != 0) - goto next_alias; net_entry.n_net = inet_network(paux2); break; } diff --git a/dns.subproj/herror.c b/dns.subproj/herror.c index 580f847..3aa9ebb 100644 --- a/dns.subproj/herror.c +++ b/dns.subproj/herror.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: herror.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $"; +static char rcsid[] = "$Id: herror.c,v 1.4 2003/04/10 20:21:16 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -133,7 +134,7 @@ herror(s) writev(STDERR_FILENO, iov, (v - iov) + 1); } -char * +const char * hstrerror(err) int err; { diff --git a/dns.subproj/inet.h b/dns.subproj/inet.h index c07ca4f..01eea0c 100644 --- a/dns.subproj/inet.h +++ b/dns.subproj/inet.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ /* * @(#)inet.h 8.1 (Berkeley) 6/2/93 - * $Id: inet.h,v 1.3 2002/04/19 20:38:01 majka Exp $ + * $Id: inet.h,v 1.4 2003/05/20 23:00:27 majka Exp $ */ #ifndef _INET_H_ @@ -95,19 +96,23 @@ #include __BEGIN_DECLS -unsigned long inet_addr __P((const char *)); -int inet_aton __P((const char *, struct in_addr *)); -unsigned long inet_lnaof __P((struct in_addr)); -struct in_addr inet_makeaddr __P((u_long , u_long)); -unsigned long inet_netof __P((struct in_addr)); -unsigned long inet_network __P((const char *)); -char *inet_ntoa __P((struct in_addr)); -int inet_pton __P((int, const char *, void *)); -const char *inet_ntop __P((int, const void *, char *, size_t)); - -u_int inet_nsap_addr __P((const char *, u_char *, int maxlen)); -char *inet_nsap_ntoa __P((int, const u_char *, char *ascii)); +int ascii2addr(int, const char *, void *); +char *addr2ascii(int, const void *, int, char *); +in_addr_t inet_addr(const char *); +int inet_aton(const char *, struct in_addr *); +in_addr_t inet_lnaof(struct in_addr); +struct in_addr inet_makeaddr(in_addr_t, in_addr_t); +in_addr_t inet_netof(struct in_addr); +in_addr_t inet_network(const char *); +char *inet_ntoa(struct in_addr); +int inet_pton(int, const char *, void *); +const char *inet_ntop(int, const void *, char *, size_t); +char *inet_net_ntop(int, const void *, int, char *, size_t); +int inet_net_pton(int, const char *, void *, size_t); +char *inet_neta(in_addr_t, char *, size_t); +u_int inet_nsap_addr(const char *, u_char *, int maxlen); +char *inet_nsap_ntoa(int, const u_char *, char *ascii); __END_DECLS diff --git a/dns.subproj/nameser.h b/dns.subproj/nameser8_compat.h similarity index 94% rename from dns.subproj/nameser.h rename to dns.subproj/nameser8_compat.h index b3874e4..9dd03e5 100644 --- a/dns.subproj/nameser.h +++ b/dns.subproj/nameser8_compat.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ /* * @(#)nameser.h 8.1 (Berkeley) 6/2/93 - * $Id: nameser.h,v 1.2 1999/10/14 21:56:45 wsanchez Exp $ + * $Id: nameser8_compat.h,v 1.2 2003/02/18 17:29:24 majka Exp $ */ #ifndef _NAMESER_H_ diff --git a/dns.subproj/options.h b/dns.subproj/options.h index 6a79326..063464a 100644 --- a/dns.subproj/options.h +++ b/dns.subproj/options.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dns.subproj/portability.h b/dns.subproj/portability.h index 55ed578..4d7d13f 100644 --- a/dns.subproj/portability.h +++ b/dns.subproj/portability.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/dns.subproj/res_comp.c b/dns.subproj/res_comp.c index 805630d..a2e905c 100644 --- a/dns.subproj/res_comp.c +++ b/dns.subproj/res_comp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,15 +79,15 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_comp.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $"; +static char rcsid[] = "$Id: res_comp.c,v 1.4 2003/02/18 17:29:24 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include -#include +#include #include -#include +#include #include #if defined(BSD) && (BSD >= 199103) diff --git a/dns.subproj/res_data.c b/dns.subproj/res_data.c index 41def8c..ab741a4 100644 --- a/dns.subproj/res_data.c +++ b/dns.subproj/res_data.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -32,13 +33,12 @@ #include #include #include -#include -#include +#include +#include /* From res_init.c */ struct __res_state _res = {0}; -__private_extern__ struct __res_state _res_shadow = {0}; /* From getnetent.c */ diff --git a/dns.subproj/res_debug.c b/dns.subproj/res_debug.c index 656797d..e1703ab 100644 --- a/dns.subproj/res_debug.c +++ b/dns.subproj/res_debug.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,17 +79,17 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_debug.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $"; +static char rcsid[] = "$Id: res_debug.c,v 1.4 2003/02/18 17:29:24 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include -#include +#include #include #include -#include +#include #if defined(BSD) && (BSD >= 199103) # include #else diff --git a/dns.subproj/res_init.c b/dns.subproj/res_init.c index 94fb0f8..d3e4f1f 100644 --- a/dns.subproj/res_init.c +++ b/dns.subproj/res_init.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93"; -static char rcsid[] = "$Id: res_init.c,v 1.5.88.1 2002/11/06 17:30:17 majka Exp $"; +static char rcsid[] = "$Id: res_init.c,v 1.8 2003/02/18 17:29:24 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -86,11 +87,11 @@ static char rcsid[] = "$Id: res_init.c,v 1.5.88.1 2002/11/06 17:30:17 majka Exp #include #include #include -#include +#include #include #include -#include +#include #if defined(BSD) && (BSD >= 199103) # include # include @@ -152,7 +153,6 @@ static u_int32_t net_mask __P((struct in_addr)); extern #endif /* NeXT */ struct __res_state _res; -extern struct __res_state _res_shadow; /* * Set up default settings. If the configuration file exist, the values @@ -447,7 +447,6 @@ res_init() if ((cp = getenv("RES_OPTIONS")) != NULL) res_setoptions(cp, "env"); _res.options |= RES_INIT; - _res_shadow = _res; return (0); } diff --git a/dns.subproj/res_mkquery.c b/dns.subproj/res_mkquery.c index deda02f..0bdffe7 100644 --- a/dns.subproj/res_mkquery.c +++ b/dns.subproj/res_mkquery.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,16 +79,16 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_mkquery.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $"; +static char rcsid[] = "$Id: res_mkquery.c,v 1.3 2003/02/18 17:29:24 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include -#include +#include #include #include -#include +#include #if defined(BSD) && (BSD >= 199103) # include #else diff --git a/dns.subproj/res_query.c b/dns.subproj/res_query.c index 85b705a..18af5c5 100644 --- a/dns.subproj/res_query.c +++ b/dns.subproj/res_query.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,17 +79,17 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_query.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $"; +static char rcsid[] = "$Id: res_query.c,v 1.3 2003/02/18 17:29:24 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include #include -#include +#include #include #include -#include +#include #include #include #if defined(BSD) && (BSD >= 199306) diff --git a/dns.subproj/res_send.c b/dns.subproj/res_send.c index 7be2204..d9ffd55 100644 --- a/dns.subproj/res_send.c +++ b/dns.subproj/res_send.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: res_send.c,v 1.2.202.1 2002/11/06 17:30:17 majka Exp $"; +static char rcsid[] = "$Id: res_send.c,v 1.6 2003/02/18 17:29:25 majka Exp $"; #endif /* LIBC_SCCS and not lint */ /* change this to "0" @@ -97,7 +98,7 @@ static char rcsid[] = "$Id: res_send.c,v 1.2.202.1 2002/11/06 17:30:17 majka Exp #include #include #include -#include +#include #include #include #include @@ -105,7 +106,7 @@ static char rcsid[] = "$Id: res_send.c,v 1.2.202.1 2002/11/06 17:30:17 majka Exp #include #include #include -#include +#include #if defined(BSD) && (BSD >= 199306) # include # include @@ -186,8 +187,6 @@ static int vc = 0; /* is the socket a virtual ciruit? */ } #endif -extern struct __res_state _res_shadow; - static res_send_qhook Qhook = NULL; static res_send_rhook Rhook = NULL; @@ -313,26 +312,6 @@ res_queriesmatch(buf1, eom1, buf2, eom2) return (1); } -static int res_using_defaults() -{ - int i; - - if (_res.nscount != _res_shadow.nscount) - return 0; - - for (i = 0; i < _res.nscount; i++) { - /* Check that the address and port have not changed */ - if ((_res.nsaddr_list[i].sin_addr.s_addr != - _res_shadow.nsaddr_list[i].sin_addr.s_addr) || - (_res.nsaddr_list[i].sin_port != - _res_shadow.nsaddr_list[i].sin_port)) { - return 0; - } - } - - return 1; -} - /* Returns whether a dns encoded name should be sent to multicast or not */ static int dns_is_local_name(const u_int8_t *name) { @@ -340,7 +319,9 @@ static int dns_is_local_name(const u_int8_t *name) const u_int8_t *d1 = NULL; // Second-Level Domain const u_int8_t *d2 = NULL; // etc. const u_int8_t *d3 = NULL; - + + if (name == NULL) return 0; + while (*name) { d3 = d2; @@ -418,8 +399,7 @@ res_send(buf, buflen, ans, anssiz) terrno = ETIMEDOUT; badns = 0; - if (res_using_defaults() && - dns_is_local_name((u_int8_t*)(buf + DNS_HEADER_SIZE))) { + if (dns_is_local_name((u_int8_t*)(buf + DNS_HEADER_SIZE))) { multicast = 1; v_circuit = 0; } else { diff --git a/dns.subproj/resolv.h b/dns.subproj/resolv8_compat.h similarity index 92% rename from dns.subproj/resolv.h rename to dns.subproj/resolv8_compat.h index 12302ac..61e46ab 100644 --- a/dns.subproj/resolv.h +++ b/dns.subproj/resolv8_compat.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -78,7 +79,7 @@ /* * @(#)resolv.h 8.1 (Berkeley) 6/2/93 - * $Id: resolv.h,v 1.2 1999/10/14 21:56:45 wsanchez Exp $ + * $Id: resolv8_compat.h,v 1.2 2003/02/18 17:29:25 majka Exp $ */ #ifndef _RESOLV_H_ diff --git a/dns.subproj/sethostent.c b/dns.subproj/sethostent.c index 3070283..4719c36 100644 --- a/dns.subproj/sethostent.c +++ b/dns.subproj/sethostent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -56,14 +57,14 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "$Id: sethostent.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $"; +static char rcsid[] = "$Id: sethostent.c,v 1.3 2003/02/18 17:29:25 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include -#include +#include #include -#include +#include void _res_close __P((void)); diff --git a/gen.subproj/Makefile b/gen.subproj/Makefile index e05996d..0c859d6 100644 --- a/gen.subproj/Makefile +++ b/gen.subproj/Makefile @@ -14,17 +14,17 @@ PROJECT_TYPE = Component HFILES = ifaddrs.h -CFILES = aliasdb.c ether_addr.c fstab.c getaddrinfo.c getgrent.c\ - getifaddrs.c getnameinfo.c getproto.c getprotoent.c\ +CFILES = aliasdb.c ether_addr.c fstab.c getgrent.c\ + getifaddrs.c getproto.c getprotoent.c\ getprotoname.c getpwent.c getservbyname.c getservbyport.c\ getservent.c if_indextoname.c if_nameindex.c if_nametoindex.c\ inet_ntop.c inet_pton.c initgroups.c printerdb.c\ map_v4v6.c ip6opt.c rthdr.c vars.c -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble getaddrinfo.3\ - getifaddrs.3 if_indextoname.3 inet6_rthdr_space.3\ - gethostbyname.3 getnameinfo.3 inet6_option_space.3\ - linkaddr.3 getprotoent.3 gethostbyname.3 getipnodebyname.3\ +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ + ether_addr.3 getifaddrs.3 if_indextoname.3 inet6_rthdr_space.3\ + gethostbyname.3 inet6_option_space.3\ + getprotoent.3 gethostbyname.3 getipnodebyname.3\ getnetent.3 getservent.3 inet6_option_space.3 diff --git a/gen.subproj/Makefile.postamble b/gen.subproj/Makefile.postamble index cc40951..0db6698 100644 --- a/gen.subproj/Makefile.postamble +++ b/gen.subproj/Makefile.postamble @@ -110,10 +110,6 @@ # install-man-page: mkdir -p "$(DSTROOT)/usr/share/man/man3" - install -c -m 644 getaddrinfo.3 "$(DSTROOT)/usr/share/man/man3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/freeaddrinfo.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/gai_strerror.3" - install -c -m 644 getnameinfo.3 "$(DSTROOT)/usr/share/man/man3" install -c -m 644 gethostbyname.3 "$(DSTROOT)/usr/share/man/man3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/endhostent.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/gethostbyaddr.3" @@ -122,6 +118,7 @@ install-man-page: $(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/herror.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/hstrerror.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/sethostent.3" + install -c -m 644 ether_addr.3 "$(DSTROOT)/usr/share/man/man3" install -c -m 644 getifaddrs.3 "$(DSTROOT)/usr/share/man/man3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/getifaddrs.3" "$(DSTROOT)/usr/share/man/man3/freeifaddrs.3" install -c -m 644 getipnodebyname.3 "$(DSTROOT)/usr/share/man/man3" @@ -160,6 +157,3 @@ install-man-page: $(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_lasthop.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_reverse.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_segments.3" - install -c -m 644 linkaddr.3 "$(DSTROOT)/usr/share/man/man3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/linkaddr.3" "$(DSTROOT)/usr/share/man/man3/link_addr.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/linkaddr.3" "$(DSTROOT)/usr/share/man/man3/link_ntoa.3" diff --git a/gen.subproj/PB.project b/gen.subproj/PB.project index 19a7616..387e3a5 100644 --- a/gen.subproj/PB.project +++ b/gen.subproj/PB.project @@ -6,10 +6,8 @@ aliasdb.c, ether_addr.c, fstab.c, - getaddrinfo.c, getgrent.c, getifaddrs.c, - getnameinfo.c, getproto.c, getprotoent.c, getprotoname.c, @@ -33,21 +31,19 @@ Makefile.preamble, Makefile, Makefile.postamble, - getaddrinfo.3, + ether_addr.3, getifaddrs.3, if_indextoname.3, inet6_rthdr_space.3, gethostbyname.3, - getnameinfo.3, inet6_option_space.3, getprotoent.3, gethostbyname.3, getipnodebyname.3, getnetent.3, getservent.3, - inet6_option_space.3, - linkaddr.3 - ); + inet6_option_space.3 + ); PUBLIC_HEADERS = (ifaddrs.h); }; LANGUAGE = English; diff --git a/gen.subproj/aliasdb.c b/gen.subproj/aliasdb.c index ad0bd4f..6d1db73 100644 --- a/gen.subproj/aliasdb.c +++ b/gen.subproj/aliasdb.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/ether_addr.3 b/gen.subproj/ether_addr.3 new file mode 100644 index 0000000..4c50e4d --- /dev/null +++ b/gen.subproj/ether_addr.3 @@ -0,0 +1 @@ +.so man3/ethers.3 diff --git a/gen.subproj/ether_addr.c b/gen.subproj/ether_addr.c index d3d1aea..372201d 100644 --- a/gen.subproj/ether_addr.c +++ b/gen.subproj/ether_addr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -77,7 +78,7 @@ int ether_line(s, e, hostname) #define EI(i) (unsigned int)(e->ether_addr_octet[(i)]) char * ether_ntoa(e) - struct ether_addr *e; + const struct ether_addr *e; { static char *s; diff --git a/gen.subproj/fstab.c b/gen.subproj/fstab.c index 5d8d78c..33164ee 100644 --- a/gen.subproj/fstab.c +++ b/gen.subproj/fstab.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -46,7 +47,7 @@ #include #include -static FILE *_fs_fp; +static FILE *_fs_fp = NULL; static struct fstab _fs_fstab; static struct fstab _root_fstab; static char _root_fstype[MFSNAMELEN]; @@ -181,7 +182,7 @@ static int fstabscan() } for (;;) { - if (!(cp = fgets(line, sizeof(line), _fs_fp))) + if (!(cp = fgets(line, MAXLINELENGTH, _fs_fp))) return(0); /* OLD_STYLE_FSTAB */ if (!strpbrk(cp, " \t")) { @@ -191,11 +192,11 @@ static int fstabscan() continue; #endif _fs_fstab.fs_file = strtok((char *)NULL, ":\n"); - /* Only list the root filesystem once */ - if (!(strcmp(_fs_fstab.fs_file, "/"))) { - continue; - } - _fs_fstab.fs_type = strtok((char *)NULL, ":\n"); + /* Only list the root filesystem once */ + if (!_fs_fstab.fs_file || !(strcmp(_fs_fstab.fs_file, "/"))) { + continue; + } + _fs_fstab.fs_type = strtok((char *)NULL, ":\n"); if (_fs_fstab.fs_type) { if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) continue; diff --git a/gen.subproj/getaddrinfo.c b/gen.subproj/getaddrinfo.c deleted file mode 100644 index ab0fa14..0000000 --- a/gen.subproj/getaddrinfo.c +++ /dev/null @@ -1,1676 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SOCK_UNSPEC 0 -#define IPPROTO_UNSPEC 0 - -#define WANT_A4_ONLY 1 -#define WANT_A6_ONLY 2 -#define WANT_A6_PLUS_MAPPED_A4 3 -#define WANT_A6_OR_MAPPED4_IF_NO_A6 4 - -#define LONG_STRING_LENGTH 8192 -#define _LU_MAXLUSTRLEN 256 - -extern int _lu_running(void); -extern mach_port_t _lookupd_port(); -extern int _lookup_link(); -extern int _lookup_one(); -extern int _lookup_all(); - -struct lu_dict -{ - int count; - char *type; - char *name; - char *cname; - char *mx; - char *ipv4; - char *ipv6; - char *service; - char *port; - char *protocol; - char *target; - char *priority; - char *weight; - struct lu_dict *lu_next; -}; - -#define LU_NAME 1 -#define LU_CNAME 2 -#define LU_MX 3 -#define LU_IPV4 4 -#define LU_IPV6 5 -#define LU_PORT 6 -#define LU_TARGET 7 -#define LU_PRIORITY 8 -#define LU_WEIGHT 9 - -static int supported_family[] = -{ - PF_UNSPEC, - PF_INET, - PF_INET6 -}; -static int supported_family_count = 3; - -static int supported_socket[] = -{ - SOCK_RAW, - SOCK_UNSPEC, - SOCK_DGRAM, - SOCK_STREAM -}; -static int supported_socket_count = 4; - -static int supported_protocol[] = -{ - IPPROTO_UNSPEC, - IPPROTO_ICMPV6, - IPPROTO_UDP, - IPPROTO_TCP -}; -static int supported_protocol_count = 4; - -static int supported_socket_protocol_pair[] = -{ - SOCK_RAW, IPPROTO_UNSPEC, - SOCK_RAW, IPPROTO_UDP, - SOCK_RAW, IPPROTO_TCP, - SOCK_RAW, IPPROTO_ICMPV6, - SOCK_UNSPEC, IPPROTO_UNSPEC, - SOCK_UNSPEC, IPPROTO_UDP, - SOCK_UNSPEC, IPPROTO_TCP, - SOCK_UNSPEC, IPPROTO_ICMPV6, - SOCK_DGRAM, IPPROTO_UNSPEC, - SOCK_DGRAM, IPPROTO_UDP, - SOCK_STREAM, IPPROTO_UNSPEC, - SOCK_STREAM, IPPROTO_TCP -}; -static int supported_socket_protocol_pair_count = 12; - -static int -gai_family_type_check(int f) -{ - int i; - - for (i = 0; i < supported_family_count; i++) - { - if (f == supported_family[i]) return 0; - } - - return 1; -} - -static int -gai_socket_type_check(int s) -{ - int i; - - for (i = 0; i < supported_socket_count; i++) - { - if (s == supported_socket[i]) return 0; - } - - return 1; -} - -static int -gai_protocol_type_check(int p) -{ - int i; - - for (i = 0; i < supported_protocol_count; i++) - { - if (p == supported_protocol[i]) return 0; - } - - return 1; -} - -static int -gai_socket_protocol_type_check(int s, int p) -{ - int i, j, ss, sp; - - for (i = 0, j = 0; i < supported_socket_protocol_pair_count; i++, j+=2) - { - ss = supported_socket_protocol_pair[j]; - sp = supported_socket_protocol_pair[j+1]; - if ((s == ss) && (p == sp)) return 0; - } - - return 1; -} - -static int -gai_inet_pton(const char *s, struct in6_addr *a6) -{ - if (s == NULL) return 0; - if (a6 == NULL) return 0; - return inet_pton(AF_INET6, s, (void *)&a6->__u6_addr.__u6_addr32[0]); -} - -char * -gai_strerror(int err) -{ - switch (err) - { - case EAI_ADDRFAMILY: return "Address family for nodename not supported"; - case EAI_AGAIN: return "Temporary failure in name resolution"; - case EAI_BADFLAGS: return "Invalid value for ai_flags"; - case EAI_FAIL: return "Non-recoverable failure in name resolution"; - case EAI_FAMILY: return "ai_family not supported"; - case EAI_MEMORY: return "Memory allocation failure"; - case EAI_NODATA: return "No address associated with nodename"; - case EAI_NONAME: return "nodename nor servname provided, or not known"; - case EAI_SERVICE: return "servname not supported for ai_socktype"; - case EAI_SOCKTYPE: return "ai_socktype not supported"; - case EAI_SYSTEM: return "System error"; - case EAI_BADHINTS: return "Bad hints"; - case EAI_PROTOCOL: return "ai_protocol not supported"; - } - - return "Unknown error"; -} - -static int -is_ipv4_address(const char *s) -{ - struct in_addr a; - - if (s == NULL) return 0; - return inet_aton(s, &a); -} - -static int -is_ipv6_address(const char *s) -{ - struct in6_addr a; - - if (s == NULL) return 0; - return gai_inet_pton(s, &a); -} - -static void -append_addrinfo(struct addrinfo **l, struct addrinfo *a) -{ - struct addrinfo *x; - - if (l == NULL) return; - if (a == NULL) return; - - if (*l == NULL) - { - *l = a; - return; - } - - x = *l; - - if (a->ai_family == PF_INET6) - { - if (x->ai_family == PF_INET) - { - *l = a; - a->ai_next = x; - return; - } - - while ((x->ai_next != NULL) && (x->ai_next->ai_family != PF_INET)) x = x->ai_next; - a->ai_next = x->ai_next; - x->ai_next = a; - } - else - { - while (x->ai_next != NULL) x = x->ai_next; - a->ai_next = NULL; - x->ai_next = a; - } -} - -static void -free_lu_dict(struct lu_dict *d) -{ - struct lu_dict *next; - - while (d != NULL) - { - next = d->lu_next; - if (d->type != NULL) free(d->type); - if (d->name != NULL) free(d->name); - if (d->cname != NULL) free(d->cname); - if (d->mx != NULL) free(d->mx); - if (d->ipv4 != NULL) free(d->ipv4); - if (d->ipv6 != NULL) free(d->ipv6); - if (d->service != NULL) free(d->service); - if (d->port != NULL) free(d->port); - if (d->protocol != NULL) free(d->protocol); - if (d->target != NULL) free(d->target); - if (d->priority != NULL) free(d->priority); - if (d->weight != NULL) free(d->weight); - free(d); - d = next; - } -} - -static int -_lu_str_equal(char *a, char *b) -{ - if (a == NULL) - { - if (b == NULL) return 1; - return 0; - } - - if (b == NULL) return 0; - - if (!strcmp(a, b)) return 1; - return 0; -} - -static int -lu_dict_equal(struct lu_dict *a, struct lu_dict *b) -{ - if (a == NULL) return 0; - if (b == NULL) return 0; - - if (_lu_str_equal(a->type, b->type) == 0) return 0; - if (_lu_str_equal(a->name, b->name) == 0) return 0; - if (_lu_str_equal(a->cname, b->cname) == 0) return 0; - if (_lu_str_equal(a->mx, b->mx) == 0) return 0; - if (_lu_str_equal(a->ipv4, b->ipv4) == 0) return 0; - if (_lu_str_equal(a->ipv6, b->ipv6) == 0) return 0; - if (_lu_str_equal(a->service, b->service) == 0) return 0; - if (_lu_str_equal(a->port, b->port) == 0) return 0; - if (_lu_str_equal(a->protocol, b->protocol) == 0) return 0; - if (_lu_str_equal(a->target, b->target) == 0) return 0; - if (_lu_str_equal(a->priority, b->priority) == 0) return 0; - if (_lu_str_equal(a->weight, b->weight) == 0) return 0; - return 1; -} - -/* - * Append a single dictionary to a list if it is unique. - * Free it if it is not appended. - */ -static void -merge_lu_dict(struct lu_dict **l, struct lu_dict *d) -{ - struct lu_dict *x, *e; - - if (l == NULL) return; - if (d == NULL) return; - - if (*l == NULL) - { - *l = d; - return; - } - - e = *l; - for (x = *l; x != NULL; x = x->lu_next) - { - e = x; - if (lu_dict_equal(x, d)) - { - free_lu_dict(d); - return; - } - } - - e->lu_next = d; -} - -static void -append_lu_dict(struct lu_dict **l, struct lu_dict *d) -{ - struct lu_dict *x, *next; - - if (l == NULL) return; - if (d == NULL) return; - - if (*l == NULL) - { - *l = d; - return; - } - - x = d; - - while (x != NULL) - { - next = x->lu_next; - x->lu_next = NULL; - merge_lu_dict(l, x); - x = next; - } -} - -/* - * We collect values for the following keys: - * - * name - * cname - * port - * ip_address - * ipv6_address - * target - * mail_exchanger - * priority - * preference - * weight - */ -static void -lookupd_process_dictionary(XDR *inxdr, struct lu_dict **l) -{ - int i, nkeys, j, nvals; - int addme; - char *key, *val; - struct lu_dict *d; - - if (!xdr_int(inxdr, &nkeys)) return; - - d = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(d, 0, sizeof(struct lu_dict)); - - for (i = 0; i < nkeys; i++) - { - key = NULL; - - if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH)) - { - free_lu_dict(d); - return; - } - - addme = 0; - if (!strcmp(key, "name")) addme = LU_NAME; - else if (!strcmp(key, "cname")) addme = LU_CNAME; - else if (!strcmp(key, "mail_exchanger")) addme = LU_MX; - else if (!strcmp(key, "ip_address")) addme = LU_IPV4; - else if (!strcmp(key, "ipv6_address")) addme = LU_IPV6; - else if (!strcmp(key, "port")) addme = LU_PORT; - else if (!strcmp(key, "target")) addme = LU_TARGET; - else if (!strcmp(key, "priority")) addme = LU_PRIORITY; - else if (!strcmp(key, "preference")) addme = LU_PRIORITY; - else if (!strcmp(key, "weight")) addme = LU_WEIGHT; - free(key); - - if (!xdr_int(inxdr, &nvals)) - { - free_lu_dict(d); - return; - } - - for (j = 0; j < nvals; j++) - { - val = NULL; - if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH)) - { - free_lu_dict(d); - return; - } - - if (addme == 0) free(val); - else if (addme == LU_NAME) d->name = val; - else if (addme == LU_CNAME) d->cname = val; - else if (addme == LU_MX) d->mx = val; - else if (addme == LU_IPV4) d->ipv4 = val; - else if (addme == LU_IPV6) d->ipv6 = val; - else if (addme == LU_PORT) d->port = val; - else if (addme == LU_TARGET) d->target = val; - else if (addme == LU_PRIORITY) d->priority = val; - else if (addme == LU_WEIGHT) d->weight = val; - - if (addme != 0) d->count++; - addme = 0; - } - } - - merge_lu_dict(l, d); -} - -static int -encode_kv(XDR *x, char *k, char *v) -{ - int n = 1; - - if (!xdr_string(x, &k, _LU_MAXLUSTRLEN)) return 1; - if (!xdr_int(x, &n)) return 1; - if (!xdr_string(x, &v, _LU_MAXLUSTRLEN)) return 1; - - return 0; -} - -static int -gai_files(struct lu_dict *q, struct lu_dict **list) -{ - int port, i; - struct servent *s; - struct hostent *h; - struct lu_dict *d; - char str[64], portstr[64]; - struct in_addr a4; - - if (!strcmp(q->type, "service")) - { - s = NULL; - if (q->name != NULL) - { - s = getservbyname(q->name, q->protocol); - } - else if (q->port != NULL) - { - port = atoi(q->port); - s = getservbyport(port, q->protocol); - } - if (s == NULL) return 0; - - d = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(d, 0, sizeof(struct lu_dict)); - - if (s->s_name != NULL) d->name = strdup(s->s_name); - sprintf(str, "%u", ntohl(s->s_port)); - d->port = strdup(str); - if (s->s_proto != NULL) d->protocol = strdup(s->s_proto); - - merge_lu_dict(list, d); - return 1; - } - - if (!strcmp(q->type, "host")) - { - s = NULL; - if (q->service != NULL) - { - s = getservbyname(q->service, q->protocol); - } - else if (q->port != NULL) - { - port = atoi(q->port); - s = getservbyport(port, q->protocol); - } - - sprintf(portstr, "0"); - if (s != NULL) sprintf(portstr, "%u", ntohl(s->s_port)); - - h = NULL; - if (q->name != NULL) - { - h = gethostbyname(q->name); - } - else if (q->ipv4 != NULL) - { - if (inet_aton(q->ipv4, &a4) == 0) return -1; - h = gethostbyaddr((char *)&a4, sizeof(struct in_addr), PF_INET); - } - else - { - /* gethostbyaddr for IPV6? */ - return 0; - } - - if (h == NULL) return 0; - - for (i = 0; h->h_addr_list[i] != 0; i++) - { - d = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(d, 0, sizeof(struct lu_dict)); - - if (h->h_name != NULL) - { - d->name = strdup(h->h_name); - d->target = strdup(h->h_name); - } - memmove((void *)&a4.s_addr, h->h_addr_list[i], h->h_length); - - sprintf(str, "%s", inet_ntoa(a4)); - d->ipv4 = strdup(str); - - if (s != NULL) - { - if (s->s_name != NULL) d->service = strdup(s->s_name); - d->port = strdup(portstr); - } - - merge_lu_dict(list, d); - } - return i; - } - - return 0; -} - -static int -gai_lookupd(struct lu_dict *q, struct lu_dict **list) -{ - unsigned datalen; - XDR outxdr; - XDR inxdr; - int proc; - char *listbuf; - char databuf[_LU_MAXLUSTRLEN * BYTES_PER_XDR_UNIT]; - int n, i, na; - kern_return_t status; - mach_port_t server_port; - - if (q == NULL) return 0; - if (q->count == 0) return 0; - if (q->type == NULL) return 0; - - if (list == NULL) return -1; - - server_port = MACH_PORT_NULL; - if (_lu_running()) server_port = _lookupd_port(0); - - if (server_port == MACH_PORT_NULL) return gai_files(q, list); - - status = _lookup_link(server_port, "query", &proc); - if (status != KERN_SUCCESS) return gai_files(q, list); - - xdrmem_create(&outxdr, databuf, sizeof(databuf), XDR_ENCODE); - - /* Encode attribute count */ - na = q->count; - if (!xdr_int(&outxdr, &na)) - { - xdr_destroy(&outxdr); - return -1; - } - - if (encode_kv(&outxdr, "_lookup_category", q->type) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - - if (q->name != NULL) - { - if (encode_kv(&outxdr, "name", q->name) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - if (q->ipv4 != NULL) - { - if (encode_kv(&outxdr, "ip_address", q->ipv4) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - if (q->ipv6 != NULL) - { - if (encode_kv(&outxdr, "ipv6_address", q->ipv6) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - if (q->service != NULL) - { - if (encode_kv(&outxdr, "service", q->service) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - if (q->port != NULL) - { - if (encode_kv(&outxdr, "port", q->port) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - if (q->protocol != NULL) - { - if (encode_kv(&outxdr, "protocol", q->protocol) != 0) - { - xdr_destroy(&outxdr); - return -1; - } - } - - listbuf = NULL; - datalen = 0; - - n = xdr_getpos(&outxdr) / BYTES_PER_XDR_UNIT; - status = _lookup_all(server_port, proc, databuf, n, &listbuf, &datalen); - if (status != KERN_SUCCESS) - { - xdr_destroy(&outxdr); - return -1; - } - - xdr_destroy(&outxdr); - - datalen *= BYTES_PER_XDR_UNIT; - - xdrmem_create(&inxdr, listbuf, datalen, XDR_DECODE); - - if (!xdr_int(&inxdr, &n)) - { - xdr_destroy(&inxdr); - return -1; - } - - for (i = 0; i < n; i++) - { - lookupd_process_dictionary(&inxdr, list); - } - - xdr_destroy(&inxdr); - - vm_deallocate(mach_task_self(), (vm_address_t)listbuf, datalen); - - return n; -} - -void -freeaddrinfo(struct addrinfo *a) -{ - struct addrinfo *next; - - while (a != NULL) - { - next = a->ai_next; - if (a->ai_addr != NULL) free(a->ai_addr); - if (a->ai_canonname != NULL) free(a->ai_canonname); - free(a); - a = next; - } -} - -static struct addrinfo * -new_addrinfo_v4(int flags, int sock, int proto, unsigned short port, struct in_addr addr, char *cname) -{ - struct addrinfo *a; - struct sockaddr_in *sa; - int len; - - a = (struct addrinfo *)malloc(sizeof(struct addrinfo)); - memset(a, 0, sizeof(struct addrinfo)); - a->ai_next = NULL; - - a->ai_flags = flags; - a->ai_family = PF_INET; - a->ai_socktype = sock; - a->ai_protocol = proto; - - a->ai_addrlen = sizeof(struct sockaddr_in); - sa = (struct sockaddr_in *)malloc(a->ai_addrlen); - memset(sa, 0, a->ai_addrlen); - sa->sin_len = a->ai_addrlen; - sa->sin_family = PF_INET; - sa->sin_port = port; - sa->sin_addr = addr; - a->ai_addr = (struct sockaddr *)sa; - - if (cname != NULL) - { - len = strlen(cname) + 1; - a->ai_canonname = malloc(len); - memmove(a->ai_canonname, cname, len); - } - - return a; -} - -static struct addrinfo * -new_addrinfo_v6(int flags, int sock, int proto, unsigned short port, struct in6_addr addr, char *cname) -{ - struct addrinfo *a; - struct sockaddr_in6 *sa; - int len; - - a = (struct addrinfo *)malloc(sizeof(struct addrinfo)); - memset(a, 0, sizeof(struct addrinfo)); - a->ai_next = NULL; - - a->ai_flags = flags; - a->ai_family = PF_INET6; - a->ai_socktype = sock; - a->ai_protocol = proto; - - a->ai_addrlen = sizeof(struct sockaddr_in6); - sa = (struct sockaddr_in6 *)malloc(a->ai_addrlen); - memset(sa, 0, a->ai_addrlen); - sa->sin6_len = a->ai_addrlen; - sa->sin6_family = PF_INET6; - sa->sin6_port = port; - sa->sin6_addr = addr; - a->ai_addr = (struct sockaddr *)sa; - - if (cname != NULL) - { - len = strlen(cname) + 1; - a->ai_canonname = malloc(len); - memmove(a->ai_canonname, cname, len); - } - - return a; -} - -static void -grok_nodename(const char *nodename, int family, struct lu_dict *q) -{ - if (nodename == NULL) return; - if (q == NULL) return; - - if (((family == PF_UNSPEC) || (family == PF_INET)) && is_ipv4_address(nodename)) - { - q->ipv4 = (char *)nodename; - } - else if (((family == PF_UNSPEC) || (family == PF_INET6)) && is_ipv6_address(nodename)) - { - q->ipv6 = (char *)nodename; - } - else - { - q->name = (char *)nodename; - } -} - -static void -grok_service(const char *servname, struct lu_dict *q) -{ - int port; - char *p; - - if (servname == NULL) return; - if (q == NULL) return; - - port = 0; - for (p = (char *)servname; (port == 0) && (*p != '\0'); p++) - { - if (!isdigit(*p)) port = -1; - } - - if (port == 0) q->port = (char *)servname; - else q->service = (char *)servname; -} - -static int -gai_numerichost(struct lu_dict *h, struct lu_dict **list) -{ - struct lu_dict *a; - int n; - - if (h == NULL) return 0; - if (list == NULL) return -1; - - n = 0; - - if (h->ipv4 != NULL) - { - a = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(a, 0, sizeof(struct lu_dict)); - a->ipv4 = strdup(h->ipv4); - merge_lu_dict(list, a); - n++; - } - - if (h->ipv6 != NULL) - { - a = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(a, 0, sizeof(struct lu_dict)); - a->ipv6 = strdup(h->ipv6); - merge_lu_dict(list, a); - n++; - } - - return n; -} - -static int -gai_numericserv(struct lu_dict *s, struct lu_dict **list) -{ - struct lu_dict *a; - - if (s == NULL) return 0; - if (s->port == NULL) return 0; - if (list == NULL) return -1; - - a = (struct lu_dict *)malloc(sizeof(struct lu_dict)); - memset(a, 0, sizeof(struct lu_dict)); - a->port = strdup(s->port); - merge_lu_dict(list, a); - return 1; -} - -static void -merge_addr4(struct in_addr a, struct sockaddr_in ***l, int *n) -{ - int i; - struct sockaddr_in *sa4; - - for (i = 0; i < *n; i++) - { - if (((*l)[i]->sin_family == PF_INET) && (a.s_addr == (*l)[i]->sin_addr.s_addr)) return; - } - - sa4 = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in)); - memset(sa4, 0, sizeof(struct sockaddr_in)); - - sa4->sin_family = PF_INET; - sa4->sin_addr = a; - - if (*n == 0) *l = (struct sockaddr_in **)malloc(sizeof(struct sockaddr_in *)); - else *l = (struct sockaddr_in **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in *)); - - (*l)[*n] = sa4; - (*n)++; -} - -static void -merge_addr6(struct in6_addr a, struct sockaddr_in6 ***l, int *n) -{ - int i; - struct sockaddr_in6 *sa6; - - for (i = 0; i < *n; i++) - { - if (((*l)[i]->sin6_family == PF_INET6) - && (a.__u6_addr.__u6_addr32[0] == (*l)[i]->sin6_addr.__u6_addr.__u6_addr32[0])) return; - } - - sa6 = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6)); - memset(sa6, 0, sizeof(struct sockaddr_in6)); - - sa6->sin6_family = PF_INET6; - sa6->sin6_addr = a; - - if (*n == 0) *l = (struct sockaddr_in6 **)malloc(sizeof(struct sockaddr_in6 *)); - else *l = (struct sockaddr_in6 **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in6 *)); - - (*l)[*n] = sa6; - (*n)++; -} - -/* - * N.B. We use sim_family to store protocol in the sockaddr. - * sockaddr is just used here as a data structure to keep - * (port, protocol) pairs. - */ -static void -merge_plist(unsigned short port, unsigned short proto, struct sockaddr_in ***l, int *n) -{ - int i; - struct sockaddr_in *sa4; - - for (i = 0; i < *n; i++) - { - if ((port == (*l)[i]->sin_port) && (proto == (*l)[i]->sin_family)) return; - } - - sa4 = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in)); - memset(sa4, 0, sizeof(struct sockaddr_in)); - - sa4->sin_port = port; - sa4->sin_family = proto; - - if (*n == 0) *l = (struct sockaddr_in **)malloc(sizeof(struct sockaddr_in *)); - else *l = (struct sockaddr_in **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in *)); - - (*l)[*n] = (struct sockaddr_in *)sa4; - (*n)++; -} - -/* - * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1). - * From "Random number generators: good ones are hard to find", - * Park and Miller, Communications of the ACM, vol. 31, no. 10, - * October 1988, p. 1195. - */ -static int -gai_random() -{ - static int did_init = 0; - static unsigned int randseed = 1; - int x, hi, lo, t; - struct timeval tv; - - if (did_init++ == 0) - { - gettimeofday(&tv, NULL); - randseed = tv.tv_usec; - if(randseed == 0) randseed = 1; - } - - x = randseed; - hi = x / 127773; - lo = x % 127773; - t = 16807 * lo - 2836 * hi; - if (t <= 0) t += 0x7fffffff; - randseed = t; - return t; -} - -/* - * Sort by priority and weight. - */ -void -lu_prioity_sort(struct lu_dict **l) -{ - struct lu_dict *d, **nodes; - unsigned int x, count, i, j, bottom, *pri, *wgt, swap, t; - - if (*l == NULL) return; - - count = 0; - for (d = *l; d != NULL; d = d->lu_next) count++; - nodes = (struct lu_dict **)malloc(count * sizeof(struct lu_dict *)); - pri = (unsigned int *)malloc(count * sizeof(unsigned int)); - wgt = (unsigned int *)malloc(count * sizeof(unsigned int)); - - for (i = 0, d = *l; d != NULL; d = d->lu_next, i++) - { - nodes[i] = d; - - x = (unsigned int)-1; - if (d->priority != NULL) x = atoi(d->priority); - pri[i] = x; - - x = 0; - if (d->weight != NULL) x = atoi(d->weight); - wgt[i] = (gai_random() % 10000) * x; - } - - /* bubble sort by priority */ - swap = 1; - bottom = count - 1; - - while (swap == 1) - { - swap = 0; - for (i = 0, j = 1; i < bottom; i++, j++) - { - if (pri[i] < pri[j]) continue; - if ((pri[i] == pri[j]) && (wgt[i] < wgt[j])) continue; - swap = 1; - - t = pri[i]; - pri[i] = pri[j]; - pri[j] = t; - - t = wgt[i]; - wgt[i] = wgt[j]; - wgt[j] = t; - - d = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = d; - } - - bottom--; - } - - *l = nodes[0]; - bottom = count - 1; - for (i = 0, j = 1; i < bottom; i++, j++) nodes[i]->lu_next = nodes[j]; - nodes[bottom]->lu_next = NULL; - - free(pri); - free(wgt); - free(nodes); -} - -/* - * Get service records from lookupd - */ -static void -gai_serv_lookupd(const char *servname, int proto, int numericserv, struct lu_dict **list) -{ - struct lu_dict q, *sub; - - memset(&q, 0, sizeof(struct lu_dict)); - q.count = 3; - q.type = "service"; - - grok_service(servname, &q); - if (q.service != NULL) - { - q.name = q.service; - q.service = NULL; - } - - if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP)) - { - sub = NULL; - q.protocol = "udp"; - if (numericserv == 1) gai_numericserv(&q, &sub); - else gai_lookupd(&q, &sub); - append_lu_dict(list, sub); - for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("udp"); - } - - if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP)) - { - sub = NULL; - q.protocol = "tcp"; - if (numericserv == 1) gai_numericserv(&q, &sub); - else gai_lookupd(&q, &sub); - append_lu_dict(list, sub); - for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("tcp"); - } -} - -/* - * Find a service. - */ -static int -gai_serv(const char *servname, const struct addrinfo *hints, struct addrinfo **res) -{ - struct lu_dict *list, *d; - int proto, family, socktype, setcname, wantv4, wantv6; - unsigned short port; - char *loopv4, *loopv6; - struct addrinfo *a; - struct in_addr a4; - struct in6_addr a6; - - loopv4 = "127.0.0.1"; - loopv6 = "0:0:0:0:0:0:0:1"; - - family = PF_UNSPEC; - proto = IPPROTO_UNSPEC; - setcname = 0; - - if (hints != NULL) - { - proto = hints->ai_protocol; - if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP; - if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP; - - if (hints->ai_flags & AI_CANONNAME) setcname = 1; - - if ((hints->ai_flags & AI_PASSIVE) == 1) - { - loopv4 = "0.0.0.0"; - loopv6 = "0:0:0:0:0:0:0:0"; - } - - family = hints->ai_family; - } - - wantv4 = 1; - wantv6 = 1; - if (family == PF_INET6) wantv4 = 0; - if (family == PF_INET) wantv6 = 0; - - list = NULL; - gai_serv_lookupd(servname, proto, 0, &list); - if (list == NULL) gai_serv_lookupd(servname, proto, 1, &list); - - for (d = list; d != NULL; d = d->lu_next) - { - /* We only want records with port and protocol specified */ - if ((d->port == NULL) || (d->protocol == NULL)) continue; - - port = htons(atoi(d->port)); - proto = IPPROTO_UDP; - socktype = SOCK_DGRAM; - if (!strcasecmp(d->protocol, "tcp")) - { - proto = IPPROTO_TCP; - socktype = SOCK_STREAM; - } - - if (wantv4 == 1) - { - inet_aton(loopv4, &a4); - a = new_addrinfo_v4(0, socktype, proto, port, a4, NULL); - append_addrinfo(res, a); - } - - if (wantv6 == 1) - { - gai_inet_pton(loopv6, &a6); - a = new_addrinfo_v6(0, socktype, proto, port, a6, NULL); - append_addrinfo(res, a); - } - } - - free_lu_dict(list); - - /* Set cname in first result */ - if ((setcname == 1) && (*res != NULL)) - { - if (res[0]->ai_canonname == NULL) res[0]->ai_canonname = strdup("localhost"); - } - - return 0; -} - -/* - * Find a node. - */ -static void -gai_node_lookupd(const char *nodename, int family, int numerichost, struct lu_dict **list) -{ - struct lu_dict q; - - memset(&q, 0, sizeof(struct lu_dict)); - q.count = 2; - q.type = "host"; - - grok_nodename(nodename, family, &q); - if (numerichost) gai_numerichost(&q, list); - else gai_lookupd(&q, list); -} - -/* - * Find a node. - */ -static int -gai_node(const char *nodename, const struct addrinfo *hints, struct addrinfo **res) -{ - int i, family, numerichost, setcname, a_list_count, wantv4, wantv6; - struct lu_dict *list, *d, *t; - char *cname; - struct in_addr a4; - struct in6_addr a6; - struct addrinfo *a; - struct sockaddr **a_list; - struct sockaddr_in *sa4; - struct sockaddr_in6 *sa6; - - a_list_count = 0; - a_list = NULL; - - numerichost = 0; - family = PF_UNSPEC; - setcname = 0; - cname = NULL; - - if (hints != NULL) - { - family = hints->ai_family; - if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1; - if (hints->ai_flags & AI_CANONNAME) setcname = 1; - } - - wantv4 = 1; - wantv6 = 1; - if (family == PF_INET6) wantv4 = 0; - if (family == PF_INET) wantv6 = 0; - - t = NULL; - gai_node_lookupd(nodename, family, numerichost, &t); - if ((t == NULL) && (numerichost == 0)) - { - gai_node_lookupd(nodename, family, 1, &t); - } - - /* If the nodename is an alias, look up the real name */ - list = NULL; - for (d = t; d != NULL; d = d->lu_next) - { - if (d->cname != NULL) - { - if (cname == NULL) cname = strdup(d->cname); - gai_node_lookupd(d->cname, family, 0, &t); - } - } - - append_lu_dict(&list, t); - - for (d = list; d != NULL; d = d->lu_next) - { - /* Check for cname */ - if ((cname == NULL) && (d->name != NULL) && (strchr(d->name, '.') != NULL)) - { - cname = strdup(d->name); - } - - /* Check for ipv4 address */ - if ((d->ipv4 != NULL) && (wantv4 == 1)) - { - inet_aton(d->ipv4, &a4); - merge_addr4(a4, (struct sockaddr_in ***)&a_list, &a_list_count); - } - - /* Check for ipv6 address */ - if ((d->ipv6 != NULL) && (wantv6 == 1)) - { - gai_inet_pton(d->ipv6, &a6); - merge_addr6(a6, (struct sockaddr_in6 ***)&a_list, &a_list_count); - } - } - - /* Last chance for a name */ - for (d = list; (cname == NULL) && (d != NULL); d = d->lu_next) - { - if (d->name != NULL) cname = strdup(d->name); - } - - free_lu_dict(list); - - for (i = 0; i < a_list_count; i++) - { - if (a_list[i]->sa_family == PF_INET) - { - sa4 = (struct sockaddr_in *)a_list[i]; - a = new_addrinfo_v4(0, 0, 0, 0, sa4->sin_addr, NULL); - append_addrinfo(res, a); - } - else if (a_list[i]->sa_family == PF_INET6) - { - sa6 = (struct sockaddr_in6 *)a_list[i]; - a = new_addrinfo_v6(0, 0, 0, 0, sa6->sin6_addr, NULL); - append_addrinfo(res, a); - } - - free(a_list[i]); - } - - if (a_list_count > 0) free(a_list); - - /* Set cname in first result */ - if ((setcname == 1) && (*res != NULL)) - { - if (res[0]->ai_canonname == NULL) - { - res[0]->ai_canonname = cname; - cname = NULL; - } - } - - if (cname != NULL) free(cname); - - return 0; -} - -/* - * Find a service+node. - */ -static void -gai_nodeserv_lookupd(const char *nodename, const char *servname, const struct addrinfo *hints, struct lu_dict **list) -{ - struct lu_dict q, *sub; - int proto, family; - - family = PF_UNSPEC; - proto = IPPROTO_UNSPEC; - - if (hints != NULL) - { - if (hints->ai_flags & AI_NUMERICHOST) return; - family = hints->ai_family; - - proto = hints->ai_protocol; - if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP; - if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP; - } - - memset(&q, 0, sizeof(struct lu_dict)); - q.count = 4; - q.type = "host"; - - grok_nodename(nodename, family, &q); - grok_service(servname, &q); - - if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP)) - { - sub = NULL; - q.protocol = "udp"; - gai_lookupd(&q, &sub); - append_lu_dict(list, sub); - for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("udp"); - } - - if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP)) - { - sub = NULL; - q.protocol = "tcp"; - gai_lookupd(&q, &sub); - append_lu_dict(list, sub); - for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("tcp"); - } -} - -static void -gai_node_pp(const char *nodename, unsigned short port, int proto, int family, int setcname, struct addrinfo **res) -{ - struct lu_dict *list, *d; - int i, wantv4, wantv6, a_list_count, socktype; - char *cname; - struct sockaddr **a_list; - struct in_addr a4; - struct in6_addr a6; - struct sockaddr_in *sa4; - struct sockaddr_in6 *sa6; - struct addrinfo *a; - - socktype = SOCK_UNSPEC; - if (proto == IPPROTO_UDP) socktype = SOCK_DGRAM; - if (proto == IPPROTO_TCP) socktype = SOCK_STREAM; - - cname = NULL; - - wantv4 = 1; - wantv6 = 1; - if (family == PF_INET6) wantv4 = 0; - if (family == PF_INET) wantv6 = 0; - - /* Resolve node name */ - list = NULL; - gai_node_lookupd(nodename, family, 0, &list); - if (list == NULL) - { - gai_node_lookupd(nodename, family, 1, &list); - } - - /* Resolve aliases */ - for (d = list; d != NULL; d = d->lu_next) - { - if (d->cname != NULL) - { - if (cname == NULL) cname = strdup(d->cname); - gai_node_lookupd(d->cname, family, 0, &list); - } - } - - a_list_count = 0; - - for (d = list; d != NULL; d = d->lu_next) - { - /* Check for cname */ - if ((cname == NULL) && (d->name != NULL) && (strchr(d->name, '.') != NULL)) - { - cname = strdup(d->name); - } - - /* Check for ipv4 address */ - if ((d->ipv4 != NULL) && (wantv4 == 1)) - { - inet_aton(d->ipv4, &a4); - merge_addr4(a4, (struct sockaddr_in ***)&a_list, &a_list_count); - } - - /* Check for ipv6 address */ - if ((d->ipv6 != NULL) && (wantv6 == 1)) - { - gai_inet_pton(d->ipv6, &a6); - merge_addr6(a6, (struct sockaddr_in6 ***)&a_list, &a_list_count); - } - } - - free_lu_dict(list); - - for (i = 0; i < a_list_count; i++) - { - if (a_list[i]->sa_family == PF_INET) - { - sa4 = (struct sockaddr_in *)a_list[i]; - a = new_addrinfo_v4(0, socktype, proto, port, sa4->sin_addr, NULL); - append_addrinfo(res, a); - } - else if (a_list[i]->sa_family == PF_INET6) - { - sa6 = (struct sockaddr_in6 *)a_list[i]; - a = new_addrinfo_v6(0, socktype, proto, port, sa6->sin6_addr, NULL); - append_addrinfo(res, a); - } - - free(a_list[i]); - } - - if (a_list_count > 0) free(a_list); - - /* Set cname in first result */ - if ((setcname == 1) && (*res != NULL)) - { - if (res[0]->ai_canonname == NULL) - { - res[0]->ai_canonname = cname; - cname = NULL; - } - } - - if (cname != NULL) free(cname); -} - -static int -gai_nodeserv(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) -{ - struct lu_dict *srv_list, *node_list, *s, *n; - int numerichost, family, proto, setcname; - int wantv4, wantv6, i, j, gotmx, p_list_count; - unsigned short port; - char *cname; - struct sockaddr **p_list; - struct sockaddr_in *sa4; - - numerichost = 0; - family = PF_UNSPEC; - proto = IPPROTO_UNSPEC; - setcname = 0; - cname = NULL; - wantv4 = 1; - wantv6 = 1; - - if (hints != NULL) - { - family = hints->ai_family; - if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1; - if (hints->ai_flags & AI_CANONNAME) setcname = 1; - - proto = hints->ai_protocol; - if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP; - if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP; - } - - if (family == PF_INET6) wantv4 = 0; - if (family == PF_INET) wantv6 = 0; - - /* First check for this particular host / service (e.g. DNS_SRV) */ - - srv_list = NULL; - gai_nodeserv_lookupd(nodename, servname, hints, &srv_list); - lu_prioity_sort(&srv_list); - - if (srv_list != NULL) - { - for (s = srv_list; s != NULL; s = s->lu_next) - { - if (s->port == NULL) continue; - if (s->protocol == NULL) continue; - - i = htons(atoi(s->port)); - j = IPPROTO_UDP; - if (!strcmp(s->protocol, "tcp")) j = IPPROTO_TCP; - gai_node_pp(s->target, i, j, family, setcname, res); - } - - free_lu_dict(srv_list); - return 0; - } - - /* - * Special case for smtp: collect mail_exchangers. - */ - gotmx = 0; - node_list = NULL; - - if (!strcmp(servname, "smtp")) - { - gai_node_lookupd(nodename, family, numerichost, &node_list); - if ((node_list == NULL) && (numerichost == 0)) - { - gai_node_lookupd(nodename, family, 1, &node_list); - } - - lu_prioity_sort(&node_list); - - for (n = node_list; (n != NULL) && (gotmx == 0); n = n->lu_next) - { - if (n->mx != NULL) gotmx = 1; - } - - if ((gotmx == 0) && (node_list != NULL)) - { - free_lu_dict(node_list); - node_list = NULL; - } - } - - /* - * Look up service, look up node, and combine port/proto with node addresses. - */ - srv_list = NULL; - gai_serv_lookupd(servname, proto, 0, &srv_list); - if (srv_list == NULL) gai_serv_lookupd(servname, proto, 1, &srv_list); - if (srv_list == NULL) return 0; - - p_list_count = 0; - for (s = srv_list; s != NULL; s = s->lu_next) - { - if (s->port == NULL) continue; - if (s->protocol == NULL) continue; - - i = htons(atoi(s->port)); - j = IPPROTO_UDP; - if (!strcmp(s->protocol, "tcp")) j = IPPROTO_TCP; - - merge_plist(i, j, (struct sockaddr_in ***)&p_list, &p_list_count); - } - - free_lu_dict(srv_list); - - for (i = 0; i < p_list_count; i++) - { - sa4 = (struct sockaddr_in *)p_list[i]; - port = sa4->sin_port; - /* N.B. sin_family is overloaded */ - proto = sa4->sin_family; - - if (gotmx == 1) - { - for (n = node_list; n != NULL; n = n->lu_next) - { - if (n->mx != NULL) gai_node_pp(n->mx, port, proto, family, setcname, res); - } - } - else - { - gai_node_pp(nodename, port, proto, family, setcname, res); - } - - free(p_list[i]); - } - - if (node_list != NULL) free_lu_dict(node_list); - - if (p_list_count > 0) free(p_list); - return 0; -} - -int -getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) -{ - int status; - struct lu_dict *list; - - if (res == NULL) return 0; - *res = NULL; - list = NULL; - - /* Check input */ - if ((nodename == NULL) && (servname == NULL)) return EAI_NONAME; - - /* Check hints */ - if (hints != NULL) - { - if (hints->ai_addrlen != 0) return EAI_BADHINTS; - if (hints->ai_canonname != NULL) return EAI_BADHINTS; - if (hints->ai_addr != NULL) return EAI_BADHINTS; - if (hints->ai_next != NULL) return EAI_BADHINTS; - - /* Check for supported protocol family */ - if (gai_family_type_check(hints->ai_family) != 0) return EAI_FAMILY; - - /* Check for supported socket */ - if (gai_socket_type_check(hints->ai_socktype) != 0) return EAI_BADHINTS; - - /* Check for supported protocol */ - if (gai_protocol_type_check(hints->ai_protocol) != 0) return EAI_BADHINTS; - - /* Check that socket type is compatible with protocol */ - if (gai_socket_protocol_type_check(hints->ai_socktype, hints->ai_protocol) != 0) return EAI_BADHINTS; - } - - status = 0; - - if (nodename == NULL) - { - /* If node is NULL, find service */ - status = gai_serv(servname, hints, res); - if ((status == 0) && (*res == NULL)) status = EAI_NODATA; - return status; - } - - if (servname == NULL) - { - /* If service is NULL, find node */ - status = gai_node(nodename, hints, res); - if ((status == 0) && (*res == NULL)) status = EAI_NODATA; - return status; - } - - /* Find node + service */ - status = gai_nodeserv(nodename, servname, hints, res); - if ((status == 0) && (*res == NULL)) status = EAI_NODATA; - return status; -} - diff --git a/gen.subproj/getgrent.c b/gen.subproj/getgrent.c index 36a01d2..2a198b8 100644 --- a/gen.subproj/getgrent.c +++ b/gen.subproj/getgrent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/gethostbyname.3 b/gen.subproj/gethostbyname.3 index 8f23b28..ca14ce8 100644 --- a/gen.subproj/gethostbyname.3 +++ b/gen.subproj/gethostbyname.3 @@ -139,16 +139,7 @@ which is intended to allow lookups in address families other than .Dv AF_INET , for example .Dv AF_INET6 . -Currently the -.Fa af -argument must be specified as -.Dv AF_INET -else the function will return -.Dv NULL -after having set -.Va h_errno -to -.Dv NETDB_INTERNAL +Both of these address families are supported in the Mac OS X implemention. .Pp The .Fn sethostent @@ -260,9 +251,7 @@ is defined, and and .Fn endhostent are redefined, -when -.Xr libc 3 -is built to use only the routines to lookup in +when libc is built to use only the routines to lookup in .Pa /etc/hosts and not the name server. .Pp diff --git a/gen.subproj/getifaddrs.c b/gen.subproj/getifaddrs.c index 9522032..b2e286e 100644 --- a/gen.subproj/getifaddrs.c +++ b/gen.subproj/getifaddrs.c @@ -77,6 +77,10 @@ #define HAVE_IFM_DATA #endif +#ifdef __APPLE__ +#define HAVE_IFM_DATA +#endif + int getifaddrs(struct ifaddrs **pif) { diff --git a/gen.subproj/getipnodebyname.3 b/gen.subproj/getipnodebyname.3 index 7d52521..0e15009 100644 --- a/gen.subproj/getipnodebyname.3 +++ b/gen.subproj/getipnodebyname.3 @@ -455,6 +455,4 @@ and .Fn getnameinfo 3 are recommended. .Pp -The current implementation is not thread-safe. -.Pp The text was shamelessly copied from RFC2553. diff --git a/gen.subproj/getnameinfo.c b/gen.subproj/getnameinfo.c deleted file mode 100644 index 2f71a73..0000000 --- a/gen.subproj/getnameinfo.c +++ /dev/null @@ -1,384 +0,0 @@ -/* $FreeBSD: src/lib/libc/net/getnameinfo.c,v 1.5 2000/07/05 05:09:17 itojun Exp $ */ -/* $KAME: getnameinfo.c,v 1.43 2000/06/12 04:27:03 itojun Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Issues to be discussed: - * - Thread safe-ness must be checked - * - Return values. There seems to be no standard for return value (RFC2553) - * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). - * - RFC2553 says that we should raise error on short buffer. X/Open says - * we need to truncate the result. We obey RFC2553 (and X/Open should be - * modified). - * - What is "local" in NI_FQDN? - * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other. - * - (KAME extension) NI_WITHSCOPEID when called with global address, - * and sin6_scope_id filled - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SUCCESS 0 -#define ANY 0 -#define YES 1 -#define NO 0 - -static struct afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; -} afdl [] = { -#ifdef INET6 - {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, -#endif - {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, - {0, 0, 0}, -}; - -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; - - -#ifdef INET6 -static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *, - size_t, int)); -static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int)); -#endif - -#define ENI_NOSOCKET EAI_FAIL /*XXX*/ -#define ENI_NOSERVNAME EAI_NONAME -#define ENI_NOHOSTNAME EAI_NONAME -#define ENI_MEMORY EAI_MEMORY -#define ENI_SYSTEM EAI_SYSTEM -#define ENI_FAMILY EAI_FAMILY -#define ENI_SALEN EAI_FAMILY - -int -getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) - const struct sockaddr *sa; - size_t salen; - char *host; - size_t hostlen; - char *serv; - size_t servlen; - int flags; -{ - struct afd *afd; - struct servent *sp; - struct hostent *hp; - u_short port; - int family, i; - const char *addr; - u_int32_t v4a; - char numserv[512]; - char numaddr[512]; - - if (sa == NULL) - return ENI_NOSOCKET; - -#ifdef NOTDEF - if (sa->sa_len != salen) - return ENI_SALEN; -#endif - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return ENI_FAMILY; - - found: - if (salen != afd->a_socklen) - return ENI_SALEN; - - /* network byte order */ - port = ((const struct sockinet *)sa)->si_port; - addr = (const char *)sa + afd->a_off; - - if (serv == NULL || servlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: RFC2553 says that serv == NULL OR servlen == 0 - * means that the caller does not want the result. - */ - } else { - if (flags & NI_NUMERICSERV) - sp = NULL; - else { - sp = getservbyport(port, - (flags & NI_DGRAM) ? "udp" : "tcp"); - } - if (sp) { - if (strlen(sp->s_name) > servlen) - return ENI_MEMORY; - strcpy(serv, sp->s_name); - } else { - snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); - if (strlen(numserv) > servlen) - return ENI_MEMORY; - strcpy(serv, numserv); - } - } - - switch (sa->sa_family) { - case AF_INET: - v4a = (u_int32_t) - ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - flags |= NI_NUMERICHOST; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0) - flags |= NI_NUMERICHOST; - break; -#ifdef INET6 - case AF_INET6: - { - const struct sockaddr_in6 *sin6; - sin6 = (const struct sockaddr_in6 *)sa; - switch (sin6->sin6_addr.s6_addr[0]) { - case 0x00: - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) - ; - else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) - ; - else - flags |= NI_NUMERICHOST; - break; - default: - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - flags |= NI_NUMERICHOST; - } - else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) - flags |= NI_NUMERICHOST; - break; - } - } - break; -#endif - } - if (host == NULL || hostlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: RFC2553 says that host == NULL OR hostlen == 0 - * means that the caller does not want the result. - */ - } else if (flags & NI_NUMERICHOST) { - int numaddrlen; - - /* NUMERICHOST and NAMEREQD conflicts with each other */ - if (flags & NI_NAMEREQD) - return ENI_NOHOSTNAME; - - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_SYSTEM; - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return ENI_MEMORY; - strcpy(host, numaddr); - break; - } - } else { -#if 0 - int h_error; - hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); -#else - hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); -#endif - - if (hp) { -#if 0 - /* - * commented out, since "for local host" is not - * implemented here - see RFC2553 p30 - */ - if (flags & NI_NOFQDN) { - char *p; - p = strchr(hp->h_name, '.'); - if (p) - *p = '\0'; - } -#endif - if (strlen(hp->h_name) > hostlen) { -#if 0 - freehostent(hp); -#endif - return ENI_MEMORY; - } - strcpy(host, hp->h_name); -#if 0 - freehostent(hp); -#endif - } else { - if (flags & NI_NAMEREQD) - return ENI_NOHOSTNAME; - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, - flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, host, - hostlen) == NULL) - return ENI_SYSTEM; - break; - } - } - } - return SUCCESS; -} - -#ifdef INET6 -static int -ip6_parsenumeric(sa, addr, host, hostlen, flags) - const struct sockaddr *sa; - const char *addr; - char *host; - size_t hostlen; - int flags; -{ - int numaddrlen; - char numaddr[512]; - - if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) - == NULL) - return ENI_SYSTEM; - - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return ENI_MEMORY; - strcpy(host, numaddr); - -#ifdef NI_WITHSCOPEID - if ( -#ifdef DONT_OPAQUE_SCOPEID - (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) || - IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) && -#endif - ((const struct sockaddr_in6 *)sa)->sin6_scope_id) { -#ifndef ALWAYS_WITHSCOPE - if (flags & NI_WITHSCOPEID) -#endif /* !ALWAYS_WITHSCOPE */ - { - char scopebuf[MAXHOSTNAMELEN]; - int scopelen; - - /* ip6_sa2str never fails */ - scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa, - scopebuf, sizeof(scopebuf), - flags); - if (scopelen + 1 + numaddrlen + 1 > hostlen) - return ENI_MEMORY; - /* - * construct - */ - memcpy(host + numaddrlen + 1, scopebuf, - scopelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + scopelen] = '\0'; - } - } -#endif /* NI_WITHSCOPEID */ - - return 0; -} - -/* ARGSUSED */ -static int -ip6_sa2str(sa6, buf, bufsiz, flags) - const struct sockaddr_in6 *sa6; - char *buf; - size_t bufsiz; - int flags; -{ - unsigned int ifindex = (unsigned int)sa6->sin6_scope_id; - const struct in6_addr *a6 = &sa6->sin6_addr; - -#ifdef NI_NUMERICSCOPE - if (flags & NI_NUMERICSCOPE) { - return(snprintf(buf, bufsiz, "%d", sa6->sin6_scope_id)); - } -#endif - - /* if_indextoname() does not take buffer size. not a good api... */ - if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) && - bufsiz >= IF_NAMESIZE) { - char *p = if_indextoname(ifindex, buf); - if (p) { - return(strlen(p)); - } - } - - /* last resort */ - return(snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id)); -} -#endif /* INET6 */ diff --git a/gen.subproj/getproto.c b/gen.subproj/getproto.c index 1f09b7c..edcb05b 100644 --- a/gen.subproj/getproto.c +++ b/gen.subproj/getproto.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getprotoent.c b/gen.subproj/getprotoent.c index ed158c9..7bf64ff 100644 --- a/gen.subproj/getprotoent.c +++ b/gen.subproj/getprotoent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getprotoname.c b/gen.subproj/getprotoname.c index 0e4b7f3..acec539 100644 --- a/gen.subproj/getprotoname.c +++ b/gen.subproj/getprotoname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getpwent.c b/gen.subproj/getpwent.c index 0f2d8c4..e2429b9 100644 --- a/gen.subproj/getpwent.c +++ b/gen.subproj/getpwent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -192,7 +193,9 @@ tokenize(const char *data, const char *sep) /* back over trailing whitespace */ i--; - while ((buf[i] == ' ') || (buf[i] == '\t') || (buf[i] == '\n')) i--; + if (i > -1) { /* did we actually copy anything? */ + while ((buf[i] == ' ') || (buf[i] == '\t') || (buf[i] == '\n')) i--; + } buf[++i] = '\0'; tokens = appendString(buf, tokens); diff --git a/gen.subproj/getservbyname.c b/gen.subproj/getservbyname.c index 6139e9e..b802989 100644 --- a/gen.subproj/getservbyname.c +++ b/gen.subproj/getservbyname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getservbyport.c b/gen.subproj/getservbyport.c index 4af1e10..35fc30f 100644 --- a/gen.subproj/getservbyport.c +++ b/gen.subproj/getservbyport.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getservent.c b/gen.subproj/getservent.c index 134fb71..fe48d81 100644 --- a/gen.subproj/getservent.c +++ b/gen.subproj/getservent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/inet_ntop.c b/gen.subproj/inet_ntop.c dissimilarity index 75% index 99bc6c7..d4f08ae 100644 --- a/gen.subproj/inet_ntop.c +++ b/gen.subproj/inet_ntop.c @@ -1,82 +1,167 @@ - -#include -#include -#include -#include -#include - -void __res_close() -{ -} - -const char *inet_ntop6(const struct in6_addr *addr,char *buf,size_t len) -{ - const u_int16_t *ap=addr->__u6_addr.__u6_addr16; - int colon=2; - int i; - char *bp=buf; - - for(i=0;i<8;i++,ap++) - { - if(bp>=buf+len-1) - { - buf[len-1]=0; - return buf; - } - if(*ap || colon==-1) - { - if(colon==2) - colon=0; - if(colon) - colon=-1; - sprintf(bp,"%x",*ap); - bp+=strlen(bp); - if(i!=7) - *bp++=':'; - } - else - { - if(colon==2) - { - *bp++=':'; - *bp++=':'; - } - else if(!colon && i!=7) - *bp++=':'; - colon=1; - } - } - *bp=0; - return buf; -} - -const char *inet_ntop4(const struct in_addr *addr,char *buf,size_t len) -{ - const u_int8_t *ap=(u_int8_t*)&addr->s_addr; - int i; - char *bp=buf; - - for(i=0;i<4;i++,ap++) - { - if(bp>=buf+len-1) - { - buf[len-1]=0; - return buf; - } - sprintf(bp,"%d",*ap); - bp+=strlen(bp); - if(i!=3) - *bp++='.'; - } - *bp=0; - return buf; -} - -const char *inet_ntop(int af,const void *addr,char *buf,size_t len) -{ - if(af==AF_INET6) - return inet_ntop6(addr,buf,len); - if(af==AF_INET) - return inet_ntop4(addr,buf,len); - return NULL; -} + +#include +#include +#include +#include +#include +#include +#include + +void __res_close() +{ +} + +#define MAX_V6_ADDR_LEN 64 + +static const char *hexchars = "0123456789abcdef"; + +const char * +inet_ntop6(const struct in6_addr *addr, char *dst, size_t size) +{ + char hexa[8][5], tmp[MAX_V6_ADDR_LEN]; + int zr[8]; + size_t len; + int32_t i, j, k, skip; + uint8_t x8, hx8; + uint16_t x16; + struct in_addr a4; + + if (addr == NULL) return NULL; + + memset(tmp, 0, MAX_V6_ADDR_LEN); + + /* check for mapped or compat addresses */ + i = IN6_IS_ADDR_V4MAPPED(addr); + j = IN6_IS_ADDR_V4COMPAT(addr); + if ((i != 0) || (j != 0)) + { + a4.s_addr = addr->__u6_addr.__u6_addr32[3]; + sprintf(tmp, "::%s%s", (i != 0) ? "ffff:" : "", inet_ntoa(a4)); + len = strlen(tmp) + 1; + if (len > size) return NULL; + memcpy(dst, tmp, len); + return dst; + } + + k = 0; + for (i = 0; i < 16; i += 2) + { + j = 0; + skip = 1; + + memset(hexa[k], 0, 5); + + x8 = addr->__u6_addr.__u6_addr8[i]; + + hx8 = x8 >> 4; + if (hx8 != 0) + { + skip = 0; + hexa[k][j++] = hexchars[hx8]; + } + + hx8 = x8 & 0x0f; + if ((skip == 0) || ((skip == 1) && (hx8 != 0))) + { + skip = 0; + hexa[k][j++] = hexchars[hx8]; + } + + x8 = addr->__u6_addr.__u6_addr8[i + 1]; + + hx8 = x8 >> 4; + if ((skip == 0) || ((skip == 1) && (hx8 != 0))) + { + hexa[k][j++] = hexchars[hx8]; + } + + hx8 = x8 & 0x0f; + hexa[k][j++] = hexchars[hx8]; + + k++; + } + + /* find runs of zeros for :: convention */ + j = 0; + for (i = 7; i >= 0; i--) + { + zr[i] = j; + x16 = addr->__u6_addr.__u6_addr16[i]; + if (x16 == 0) j++; + else j = 0; + zr[i] = j; + } + + /* find longest run of zeros */ + k = -1; + j = 0; + for(i = 0; i < 8; i++) + { + if (zr[i] > j) + { + k = i; + j = zr[i]; + } + } + + for(i = 0; i < 8; i++) + { + if (i != k) zr[i] = 0; + } + + len = 0; + for (i = 0; i < 8; i++) + { + if (zr[i] != 0) + { + /* check for leading zero */ + if (i == 0) tmp[len++] = ':'; + tmp[len++] = ':'; + i += (zr[i] - 1); + continue; + } + for (j = 0; hexa[i][j] != '\0'; j++) tmp[len++] = hexa[i][j]; + if (i != 7) tmp[len++] = ':'; + } + + /* trailing NULL */ + len++; + + if (len > size) return NULL; + memcpy(dst, tmp, len); + return dst; +} + +const char * +inet_ntop4(const struct in_addr *addr, char *buf, size_t len) +{ + const u_int8_t *ap = (u_int8_t *)&addr->s_addr; + int i; + char *bp=buf; + + for (i = 0; i < 4; i++, ap++) + { + if (bp >= buf + len - 1) + { + buf[len-1] = 0; + return buf; + } + + sprintf(bp, "%d", *ap); + bp += strlen(bp); + if (i != 3) *bp++='.'; + } + + *bp = 0; + return buf; +} + +const char * +inet_ntop(int af, const void *addr, char *buf, size_t len) +{ + if(af==AF_INET6) + return inet_ntop6(addr, buf, len); + if(af==AF_INET) + return inet_ntop4(addr, buf, len); + return NULL; +} diff --git a/gen.subproj/inet_pton.c b/gen.subproj/inet_pton.c index 7858ba8..e49eae4 100644 --- a/gen.subproj/inet_pton.c +++ b/gen.subproj/inet_pton.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$Id: inet_pton.c,v 1.2 2002/01/17 22:22:25 majka Exp $"; +static char rcsid[] = "$Id: inet_pton.c,v 1.3 2003/04/10 18:53:29 majka Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef HAVE_CONFIG_H @@ -30,6 +30,7 @@ static char rcsid[] = "$Id: inet_pton.c,v 1.2 2002/01/17 22:22:25 majka Exp $"; #include #include #include +#include #include #define IN6ADDRSZ 16 @@ -78,21 +79,37 @@ static int inet_pton6 __P((const char *src, u_char *dst)); * Paul Vixie, 1996. */ int -inet_pton(af, src, dst) - int af; - const char *src; - void *dst; +inet_pton(int af, const char *src, void *dst) { - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); + int status; + char *p, *s; + + switch (af) + { + case AF_INET: return (inet_pton4(src, dst)); + #ifdef INET6 - case AF_INET6: - return (inet_pton6(src, dst)); -#endif - default: - errno = EAFNOSUPPORT; - return (-1); + case AF_INET6: + /* Ignore trailing %xxx (interface specification) */ + + p = NULL; + s = (char *)src; + + if (src != NULL) p = strrchr(src, '%'); + if (p != NULL) + { + s = strdup(src); + s[p - src] = '\0'; + } + + status = inet_pton6(s, dst); + if (p != NULL) free(s); + return status; +#endif + + default: + errno = EAFNOSUPPORT; + return -1; } /* NOTREACHED */ } diff --git a/gen.subproj/initgroups.c b/gen.subproj/initgroups.c index cf7fabf..fed0c42 100644 --- a/gen.subproj/initgroups.c +++ b/gen.subproj/initgroups.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/linkaddr.3 b/gen.subproj/linkaddr.3 deleted file mode 100644 index 4c74a84..0000000 --- a/gen.subproj/linkaddr.3 +++ /dev/null @@ -1,140 +0,0 @@ -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley at BSDI. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 -.\" $FreeBSD: src/lib/libc/net/linkaddr.3,v 1.8.2.3 2001/08/17 15:42:38 ru Exp $ -.\" -.Dd June 17, 1996 -.Dt LINK_ADDR 3 -.Os -.Sh NAME -.Nm link_addr , -.Nm link_ntoa -.Nd elementary address specification routines for link level access -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.Fd #include -.Fd #include -.Fd #include -.Ft void -.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" -.Ft char * -.Fn link_ntoa "const struct sockaddr_dl *sdl" -.Sh DESCRIPTION -The routine -.Fn link_addr -interprets character strings representing -link-level addresses, returning binary information suitable -for use in system calls. -The routine -.Fn link_ntoa -takes -a link-level -address and returns an -.Tn ASCII -string representing some of the information present, -including the link level address itself, and the interface name -or number, if present. -This facility is experimental and is -still subject to change. -.Pp -For -.Fn link_addr , -the string -.Fa addr -may contain -an optional network interface identifier of the form -.Dq "name unit-number" , -suitable for the first argument to -.Xr ifconfig 8 , -followed in all cases by a colon and -an interface address in the form of -groups of hexadecimal digits -separated by periods. -Each group represents a byte of address; -address bytes are filled left to right from -low order bytes through high order bytes. -.Pp -.\" A regular expression may make this format clearer: -.\" .Bd -literal -offset indent -.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* -.\" .Ed -.\" .Pp -Thus -.Li le0:8.0.9.13.d.30 -represents an ethernet address -to be transmitted on the first Lance ethernet interface. -.Pp -The direct use of these functions is deprecated in favor of the -.Xr addr2ascii 3 -interface; however, portable programs cannot rely on the latter as it is -not yet widely implemented. -.Sh RETURN VALUES -.Fn link_ntoa -always returns a null terminated string. -.Fn link_addr -has no return value. -(See -.Sx BUGS . ) -.Sh SEE ALSO -.Xr addr2ascii 3 -.\" .Xr iso 4 -.Sh HISTORY -The -.Fn link_addr -and -.Fn link_ntoa -functions appeared in -.Bx 4.3 Reno . -.Sh BUGS -The returned values for link_ntoa -reside in a static memory area. -.Pp -The function -.Fn link_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. -.Pp -If the -.Va sdl_len -field of the link socket address -.Fa sdl -is 0, -.Fn link_ntoa -will not insert a colon before the interface address bytes. -If this translated address is given to -.Fn link_addr -without inserting an initial colon, -the latter will not interpret it correctly. diff --git a/gen.subproj/map_v4v6.c b/gen.subproj/map_v4v6.c index 2ed171c..66a1afc 100644 --- a/gen.subproj/map_v4v6.c +++ b/gen.subproj/map_v4v6.c @@ -63,12 +63,12 @@ static char rcsid[] = "$FreeBSD: src/lib/libc/net/map_v4v6.c,v 1.5.2.1 2001/03/0 #include #include #include -#include +#include #include #include #include -#include +#include #include #include diff --git a/gen.subproj/printerdb.c b/gen.subproj/printerdb.c index c1ec9fe..1dbda2f 100644 --- a/gen.subproj/printerdb.c +++ b/gen.subproj/printerdb.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/Makefile b/lookup.subproj/Makefile index 7148858..32f6ba8 100644 --- a/lookup.subproj/Makefile +++ b/lookup.subproj/Makefile @@ -13,15 +13,14 @@ PROJECTVERSION = 2.8 PROJECT_TYPE = Component HFILES = aliasdb.h bootparams.h lookup_types.h lu_overrides.h\ - lu_host.h lu_utils.h netdb_async.h netgr.h printerdb.h + lu_host.h lu_utils.h netdb.h netdb_async.h netgr.h printerdb.h -CFILES = lu_alias.c lu_bootp.c lu_bootparam.c lu_fstab.c lu_group.c\ - lu_host.c lu_host_async.c lu_netgroup.c lu_network.c lu_printer.c\ - lu_protocol.c lu_rpc.c lu_service.c lu_user.c lu_utils.c - -OTHERSRCS = Makefile.preamble Makefile Makefile.postamble lookup.defs\ - _lu_types.x +CFILES = getaddrinfo.c lu_alias.c lu_bootp.c lu_bootparam.c lu_fstab.c\ + lu_group.c lu_host.c lu_host_async.c lu_netgroup.c lu_network.c\ + lu_printer.c lu_protocol.c lu_rpc.c lu_service.c lu_user.c lu_utils.c +OTHERSRCS = Makefile.preamble Makefile Makefile.postamble getaddrinfo.3\ + getnameinfo.3 lookup.defs _lu_types.x MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles CODE_GEN_STYLE = DYNAMIC @@ -32,7 +31,7 @@ DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) -PUBLIC_HEADERS = aliasdb.h bootparams.h printerdb.h +PUBLIC_HEADERS = aliasdb.h bootparams.h netdb.h printerdb.h diff --git a/lookup.subproj/Makefile.postamble b/lookup.subproj/Makefile.postamble index 447fe32..f4013b1 100644 --- a/lookup.subproj/Makefile.postamble +++ b/lookup.subproj/Makefile.postamble @@ -7,8 +7,15 @@ async_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(ASYNC_HEADER_DIR_SUFFIX) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(ASYNC_HEADER_DIR_SUFFIX): $(MKDIRS) $@ -netinfo_hdrs: $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX) - $(SILENT) $(FASTCP) $(NETINFO_HDRS) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX) +netinfo_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX) + $(SILENT) $(FASTCP) $(NETINFO_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX) -$(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX): +$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX): $(MKDIRS) $@ + +install-man-page: + mkdir -p "$(DSTROOT)/usr/share/man/man3" + install -c -m 644 getaddrinfo.3 "$(DSTROOT)/usr/share/man/man3" + install -c -m 644 getnameinfo.3 "$(DSTROOT)/usr/share/man/man3" + $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/freeaddrinfo.3" + $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/gai_strerror.3" diff --git a/lookup.subproj/Makefile.preamble b/lookup.subproj/Makefile.preamble index 83a0b9c..365735b 100644 --- a/lookup.subproj/Makefile.preamble +++ b/lookup.subproj/Makefile.preamble @@ -9,3 +9,4 @@ PUBLIC_HEADER_DIR_SUFFIX = PRIVATE_HEADER_DIR = /usr/local/include ASYNC_HEADER_DIR_SUFFIX = / NETINFO_HEADER_DIR_SUFFIX = /netinfo +AFTER_POSTINSTALL += install-man-page diff --git a/lookup.subproj/PB.project b/lookup.subproj/PB.project index e3a62e0..19077d8 100644 --- a/lookup.subproj/PB.project +++ b/lookup.subproj/PB.project @@ -8,11 +8,13 @@ lu_overrides.h, lu_host.h, lu_utils.h, + netdb.h, netdb_async.h, netgr.h, printerdb.h ); OTHER_LINKED = ( + getaddrinfo.c, lu_alias.c, lu_bootp.c, lu_bootparam.c, @@ -28,10 +30,18 @@ lu_service.c, lu_user.c ); - OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, lookup.defs, _lu_types.x); + OTHER_SOURCES = ( + Makefile.preamble, + Makefile, + Makefile.postamble, + getaddrinfo.3, + getnameinfo.3, + lookup.defs, + _lu_types.x + ); PRECOMPILED_HEADERS = (); PROJECT_HEADERS = (); - PUBLIC_HEADERS = (aliasdb.h, bootparams.h, printerdb.h); + PUBLIC_HEADERS = (aliasdb.h, bootparams.h, netdb.h, printerdb.h); }; LANGUAGE = English; MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; diff --git a/lookup.subproj/_lu_types.x b/lookup.subproj/_lu_types.x index 0fa320e..5e0b56c 100644 --- a/lookup.subproj/_lu_types.x +++ b/lookup.subproj/_lu_types.x @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/aliasdb.h b/lookup.subproj/aliasdb.h index 7961135..15149cb 100644 --- a/lookup.subproj/aliasdb.h +++ b/lookup.subproj/aliasdb.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/bootparams.h b/lookup.subproj/bootparams.h index 377298d..a02eb15 100644 --- a/lookup.subproj/bootparams.h +++ b/lookup.subproj/bootparams.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/gen.subproj/getaddrinfo.3 b/lookup.subproj/getaddrinfo.3 similarity index 99% rename from gen.subproj/getaddrinfo.3 rename to lookup.subproj/getaddrinfo.3 index c51fcac..19b1b79 100644 --- a/gen.subproj/getaddrinfo.3 +++ b/lookup.subproj/getaddrinfo.3 @@ -55,7 +55,7 @@ "const struct addrinfo *hints" "struct addrinfo **res" .Ft void .Fn freeaddrinfo "struct addrinfo *ai" -.Ft "char *" +.Ft "const char *" .Fn gai_strerror "int ecode" .\" .Sh DESCRIPTION diff --git a/lookup.subproj/getaddrinfo.c b/lookup.subproj/getaddrinfo.c new file mode 100644 index 0000000..944c42b --- /dev/null +++ b/lookup.subproj/getaddrinfo.c @@ -0,0 +1,1579 @@ +/* + * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lu_utils.h" +#include "netdb_async.h" + +#define SOCK_UNSPEC 0 +#define IPPROTO_UNSPEC 0 + +#define LONG_STRING_LENGTH 8192 +#define _LU_MAXLUSTRLEN 256 +#define LU_QBUF_SIZE 8192 + +#define MAX_LOOKUP_ATTEMPTS 10 + +#define INET_NTOP_AF_INET_OFFSET 4 +#define INET_NTOP_AF_INET6_OFFSET 8 + +extern mach_port_t _lookupd_port(); + +static int gai_proc = -1; +static int gni_proc = -1; + +static int32_t supported_family[] = +{ + PF_UNSPEC, + PF_INET, + PF_INET6 +}; +static int32_t supported_family_count = 3; + +static int32_t supported_socket[] = +{ + SOCK_RAW, + SOCK_UNSPEC, + SOCK_DGRAM, + SOCK_STREAM +}; +static int32_t supported_socket_count = 4; + +static int32_t supported_protocol[] = +{ + IPPROTO_UNSPEC, + IPPROTO_ICMPV6, + IPPROTO_UDP, + IPPROTO_TCP +}; +static int32_t supported_protocol_count = 4; + +static int32_t supported_socket_protocol_pair[] = +{ + SOCK_RAW, IPPROTO_UNSPEC, + SOCK_RAW, IPPROTO_UDP, + SOCK_RAW, IPPROTO_TCP, + SOCK_RAW, IPPROTO_ICMPV6, + SOCK_UNSPEC, IPPROTO_UNSPEC, + SOCK_UNSPEC, IPPROTO_UDP, + SOCK_UNSPEC, IPPROTO_TCP, + SOCK_UNSPEC, IPPROTO_ICMPV6, + SOCK_DGRAM, IPPROTO_UNSPEC, + SOCK_DGRAM, IPPROTO_UDP, + SOCK_STREAM, IPPROTO_UNSPEC, + SOCK_STREAM, IPPROTO_TCP +}; +static int32_t supported_socket_protocol_pair_count = 12; + +static int +gai_family_type_check(int32_t f) +{ + int32_t i; + + for (i = 0; i < supported_family_count; i++) + { + if (f == supported_family[i]) return 0; + } + + return 1; +} + +static int +gai_socket_type_check(int32_t s) +{ + int32_t i; + + for (i = 0; i < supported_socket_count; i++) + { + if (s == supported_socket[i]) return 0; + } + + return 1; +} + +static int +gai_protocol_type_check(int32_t p) +{ + int32_t i; + + for (i = 0; i < supported_protocol_count; i++) + { + if (p == supported_protocol[i]) return 0; + } + + return 1; +} + +static int +gai_socket_protocol_type_check(int32_t s, int32_t p) +{ + int32_t i, j, ss, sp; + + for (i = 0, j = 0; i < supported_socket_protocol_pair_count; i++, j+=2) + { + ss = supported_socket_protocol_pair[j]; + sp = supported_socket_protocol_pair[j+1]; + if ((s == ss) && (p == sp)) return 0; + } + + return 1; +} + +const char * +gai_strerror(int32_t err) +{ + switch (err) + { + case EAI_ADDRFAMILY: return "Address family for nodename not supported"; + case EAI_AGAIN: return "Temporary failure in name resolution"; + case EAI_BADFLAGS: return "Invalid value for ai_flags"; + case EAI_FAIL: return "Non-recoverable failure in name resolution"; + case EAI_FAMILY: return "ai_family not supported"; + case EAI_MEMORY: return "Memory allocation failure"; + case EAI_NODATA: return "No address associated with nodename"; + case EAI_NONAME: return "nodename nor servname provided, or not known"; + case EAI_SERVICE: return "servname not supported for ai_socktype"; + case EAI_SOCKTYPE: return "ai_socktype not supported"; + case EAI_SYSTEM: return "System error"; + case EAI_BADHINTS: return "Bad hints"; + case EAI_PROTOCOL: return "ai_protocol not supported"; + } + + return "Unknown error"; +} + +static void +append_addrinfo(struct addrinfo **l, struct addrinfo *a) +{ + struct addrinfo *x; + + if (l == NULL) return; + if (a == NULL) return; + + if (*l == NULL) + { + *l = a; + return; + } + + x = *l; + + if (a->ai_family == PF_INET6) + { + if (x->ai_family == PF_INET) + { + *l = a; + a->ai_next = x; + return; + } + + while ((x->ai_next != NULL) && (x->ai_next->ai_family != PF_INET)) x = x->ai_next; + a->ai_next = x->ai_next; + x->ai_next = a; + } + else + { + while (x->ai_next != NULL) x = x->ai_next; + a->ai_next = NULL; + x->ai_next = a; + } +} + +static int +encode_kv(XDR *x, const char *k, const char *v) +{ + int32_t n = 1; + + if (!xdr_string(x, (char **)&k, _LU_MAXLUSTRLEN)) return 1; + if (!xdr_int(x, &n)) return 1; + if (!xdr_string(x, (char **)&v, _LU_MAXLUSTRLEN)) return 1; + + return 0; +} + +void +freeaddrinfo(struct addrinfo *a) +{ + struct addrinfo *next; + + while (a != NULL) + { + next = a->ai_next; + if (a->ai_addr != NULL) free(a->ai_addr); + if (a->ai_canonname != NULL) free(a->ai_canonname); + free(a); + a = next; + } +} + +static struct addrinfo * +new_addrinfo_v4(int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in_addr addr, uint32_t iface, char *cname) +{ + struct addrinfo *a; + struct sockaddr_in *sa; + int32_t len; + + a = (struct addrinfo *)calloc(1, sizeof(struct addrinfo)); + if (a == NULL) return NULL; + + a->ai_next = NULL; + + a->ai_flags = flags; + a->ai_family = PF_INET; + a->ai_socktype = sock; + a->ai_protocol = proto; + + a->ai_addrlen = sizeof(struct sockaddr_in); + + sa = (struct sockaddr_in *)calloc(1, a->ai_addrlen); + if (sa == NULL) + { + free(a); + return NULL; + } + + sa->sin_len = a->ai_addrlen; + sa->sin_family = PF_INET; + sa->sin_port = htons(port); + sa->sin_addr = addr; + + /* Kludge: Jam the interface number into sin_zero. */ + memmove(sa->sin_zero, &iface, sizeof(uint32_t)); + + a->ai_addr = (struct sockaddr *)sa; + + if (cname != NULL) + { + len = strlen(cname) + 1; + a->ai_canonname = malloc(len); + memmove(a->ai_canonname, cname, len); + } + + return a; +} + +static struct addrinfo * +new_addrinfo_v6(int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in6_addr addr, uint32_t scopeid, char *cname) +{ + struct addrinfo *a; + struct sockaddr_in6 *sa; + int32_t len; + + a = (struct addrinfo *)calloc(1, sizeof(struct addrinfo)); + if (a == NULL) return NULL; + + a->ai_next = NULL; + + a->ai_flags = flags; + a->ai_family = PF_INET6; + a->ai_socktype = sock; + a->ai_protocol = proto; + + a->ai_addrlen = sizeof(struct sockaddr_in6); + + sa = (struct sockaddr_in6 *)calloc(1, a->ai_addrlen); + if (sa == NULL) + { + free(a); + return NULL; + } + + sa->sin6_len = a->ai_addrlen; + sa->sin6_family = PF_INET6; + sa->sin6_port = htons(port); + sa->sin6_addr = addr; + sa->sin6_scope_id = scopeid; + a->ai_addr = (struct sockaddr *)sa; + + if (cname != NULL) + { + len = strlen(cname) + 1; + a->ai_canonname = malloc(len); + memmove(a->ai_canonname, cname, len); + } + + return a; +} + +/* + * getaddrinfo support in lookupd + * Input dict may contain the following + * + * name: nodename + * service: servname + * protocol: [IPPROTO_UNSPEC] | IPPROTO_UDP | IPPROTO_TCP + * socktype: [SOCK_UNSPEC] | SOCK_DGRAM | SOCK_STREAM + * family: [PF_UNSPEC] | PF_INET | PF_INET6 + * canonname: [0] | 1 + * passive: [0] | 1 + * numerichost: [0] | 1 + * + * Output dictionary may contain the following + * All values are encoded as strings. + * + * flags: unsigned long + * family: unsigned long + * socktype: unsigned long + * protocol: unsigned long + * port: unsigned long + * address: char * + * scopeid: unsigned long + * canonname: char * + * + */ + +static struct addrinfo * +gai_lookupd_process_dictionary(XDR *inxdr) +{ + int32_t i, nkeys, nvals; + char *key, *val; + uint32_t flags, family, socktype, protocol, longport, scopeid; + uint16_t port; + char *addr, *canonname; + struct addrinfo *a; + struct in_addr a4; + struct in6_addr a6; + + flags = 0; + family = PF_UNSPEC; + socktype = SOCK_UNSPEC; + protocol = IPPROTO_UNSPEC; + port = 0; + scopeid = 0; + addr = NULL; + canonname = NULL; + + if (!xdr_int(inxdr, &nkeys)) return NULL; + + for (i = 0; i < nkeys; i++) + { + key = NULL; + val = NULL; + + if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH)) return NULL; + if (!xdr_int(inxdr, &nvals)) + { + free(key); + return NULL; + } + + if (nvals != 1) + { + free(key); + return NULL; + } + + if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH)) + { + free(key); + return NULL; + } + + if (!strcmp(key, "flags")) + { + flags = atoi(val); + } + else if (!strcmp(key, "family")) + { + family = atoi(val); + } + else if (!strcmp(key, "socktype")) + { + socktype = atoi(val); + } + else if (!strcmp(key, "protocol")) + { + protocol = atoi(val); + } + else if (!strcmp(key, "port")) + { + longport = atoi(val); + port = longport; + } + else if (!strcmp(key, "scopeid")) + { + scopeid = atoi(val); + } + else if (!strcmp(key, "address")) addr = strdup(val); + else if (!strcmp(key, "canonname")) canonname = strdup(val); + free(key); + free(val); + } + + if (family == PF_UNSPEC) + { + if (addr != NULL) free(addr); + if (canonname != NULL) free(canonname); + return NULL; + } + + a = NULL; + if (family == PF_INET) + { + inet_aton(addr, &a4); + a = new_addrinfo_v4(flags, socktype, protocol, port, a4, scopeid, canonname); + } + else if (family == PF_INET6) + { + inet_pton(AF_INET6, addr, &a6); + a = new_addrinfo_v6(flags, socktype, protocol, port, a6, scopeid, canonname); + } + + if (addr != NULL) free(addr); + if (canonname != NULL) free(canonname); + + return a; +} + +static int +gai_make_query(const char *nodename, const char *servname, const struct addrinfo *hints, char *buf, uint32_t *len) +{ + int32_t numerichost, family, proto, socktype, canonname, passive; + uint32_t na; + XDR outxdr; + char str[64], *cname; + + numerichost = 0; + family = PF_UNSPEC; + proto = IPPROTO_UNSPEC; + socktype = SOCK_UNSPEC; + canonname = 0; + passive = 0; + cname = NULL; + + if (hints != NULL) + { + family = hints->ai_family; + if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1; + if (hints->ai_flags & AI_CANONNAME) canonname = 1; + if ((hints->ai_flags & AI_PASSIVE) == 1) passive = 1; + + proto = hints->ai_protocol; + if (hints->ai_socktype == SOCK_DGRAM) + { + socktype = SOCK_DGRAM; + proto = IPPROTO_UDP; + } + if (hints->ai_socktype == SOCK_STREAM) + { + socktype = SOCK_STREAM; + proto = IPPROTO_TCP; + } + } + + xdrmem_create(&outxdr, buf, *len, XDR_ENCODE); + + /* Attribute count */ + na = 0; + if (nodename != NULL) na++; + if (servname != NULL) na++; + if (proto != IPPROTO_UNSPEC) na++; + if (socktype != SOCK_UNSPEC) na++; + if (family != PF_UNSPEC) na++; + if (canonname != 0) na++; + if (passive != 0) na++; + if (numerichost != 0) na++; + + if (!xdr_int(&outxdr, &na)) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + + if (nodename != NULL) + { + if (encode_kv(&outxdr, "name", nodename) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (servname != NULL) + { + if (encode_kv(&outxdr, "service", servname) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (proto != IPPROTO_UNSPEC) + { + snprintf(str, 64, "%u", proto); + if (encode_kv(&outxdr, "protocol", str) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (socktype != SOCK_UNSPEC) + { + snprintf(str, 64, "%u", socktype); + if (encode_kv(&outxdr, "socktype", str) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (family != PF_UNSPEC) + { + snprintf(str, 64, "%u", family); + if (encode_kv(&outxdr, "family", str) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (canonname != 0) + { + if (encode_kv(&outxdr, "canonname", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (passive != 0) + { + if (encode_kv(&outxdr, "passive", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (numerichost != 0) + { + if (encode_kv(&outxdr, "numerichost", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + *len = xdr_getpos(&outxdr); + + xdr_destroy(&outxdr); + + return 0; +} + +static int32_t +is_a_number(const char *s) +{ + int32_t i, len; + + if (s == NULL) return 0; + + len = strlen(s); + for (i = 0; i < len; i++) + { + if (isdigit(s[i]) == 0) return 0; + } + + return 1; +} + +int +gai_files(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) +{ + int32_t i, numericserv, numerichost, family, proto, wantv4, wantv6; + int16_t port; + struct servent *s; + struct hostent *h; + char *protoname, *loopv4, *loopv6; + struct in_addr a4; + struct in6_addr a6; + struct addrinfo *a; + + numericserv = 0; + if (servname != NULL) numericserv = is_a_number(servname); + + family = PF_UNSPEC; + if (hints != NULL) family = hints->ai_family; + + numerichost = 0; + + if (nodename == NULL) + { + numerichost = 1; + + loopv4 = "127.0.0.1"; + loopv6 = "0:0:0:0:0:0:0:1"; + + if ((hints != NULL) && ((hints->ai_flags & AI_PASSIVE) == 1)) + { + loopv4 = "0.0.0.0"; + loopv6 = "0:0:0:0:0:0:0:0"; + } + + if ((family == PF_UNSPEC) || (family == PF_INET)) + { + inet_pton(AF_INET, loopv4, &a4); + } + + if ((family == PF_UNSPEC) || (family == PF_INET6)) + { + inet_pton(AF_INET6, loopv6, &a6); + } + } + else + { + if ((family == PF_UNSPEC) || (family == PF_INET)) + { + numerichost = inet_pton(AF_INET, nodename, &a4); + if ((numerichost == 1) && (family == PF_UNSPEC)) family = PF_INET; + } + + if ((family == PF_UNSPEC) || (family == PF_INET6)) + { + numerichost = inet_pton(AF_INET6, nodename, &a6); + if ((numerichost == 1) && (family == PF_UNSPEC)) family = PF_INET6; + } + } + + wantv4 = 1; + wantv6 = 1; + if (family == PF_INET6) wantv4 = 0; + if (family == PF_INET) wantv6 = 0; + + proto = IPPROTO_UNSPEC; + protoname = NULL; + + if (hints != NULL) + { + proto = hints->ai_protocol; + if (proto == IPPROTO_UNSPEC) + { + if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP; + else if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP; + } + } + + if (proto == IPPROTO_UDP) protoname = "udp"; + else if (proto == IPPROTO_TCP) protoname = "tcp"; + + s = NULL; + port = 0; + + if (numericserv != 0) + { + port = htons(atoi(servname)); + } + else if (servname != NULL) + { + s = getservbyname(servname, protoname); + if (s != NULL) port = s->s_port; + } + + /* new_addrinfo_v4 and new_addrinfo_v6 expect port in host byte order */ + port = ntohs(port); + + if (numerichost != 0) + { + if (wantv4 == 1) + { + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP)) + { + a = new_addrinfo_v4(0, SOCK_DGRAM, IPPROTO_UDP, port, a4, 0, NULL); + append_addrinfo(res, a); + } + + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP)) + { + a = new_addrinfo_v4(0, SOCK_STREAM, IPPROTO_TCP, port, a4, 0, NULL); + append_addrinfo(res, a); + } + } + + if (wantv6 == 1) + { + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP)) + { + a = new_addrinfo_v6(0, SOCK_DGRAM, IPPROTO_UDP, port, a6, 0, NULL); + append_addrinfo(res, a); + } + + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP)) + { + a = new_addrinfo_v6(0, SOCK_STREAM, IPPROTO_TCP, port, a6, 0, NULL); + append_addrinfo(res, a); + } + } + + return 0; + } + + if (wantv4 == 1) + { + h = gethostbyname(nodename); + if (h == NULL) return 0; + + for (i = 0; h->h_addr_list[i] != 0; i++) + { + memmove((void *)&a4.s_addr, h->h_addr_list[i], h->h_length); + + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP)) + { + a = new_addrinfo_v4(0, SOCK_DGRAM, IPPROTO_UDP, port, a4, 0, NULL); + append_addrinfo(res, a); + } + + if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP)) + { + a = new_addrinfo_v4(0, SOCK_STREAM, IPPROTO_TCP, port, a4, 0, NULL); + append_addrinfo(res, a); + } + } + } + + return 0; +} + +static int +gai_lookupd(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) +{ + uint32_t n, i, qlen, rlen; + XDR inxdr; + char qbuf[LU_QBUF_SIZE]; + char *rbuf; + char *cname; + mach_port_t server_port; + kern_return_t status; + struct addrinfo *a; + + server_port = MACH_PORT_NULL; + if (_lu_running()) server_port = _lookupd_port(0); + if (server_port == MACH_PORT_NULL) + { + /* lookupd isn't available - fall back to the flat files */ + return gai_files(nodename, servname, hints, res); + } + + if (gai_proc < 0) + { + status = _lookup_link(server_port, "getaddrinfo", &gai_proc); + if (status != KERN_SUCCESS) return EAI_SYSTEM; + } + + qlen = LU_QBUF_SIZE; + i = gai_make_query(nodename, servname, hints, qbuf, &qlen); + if (i != 0) return EAI_SYSTEM; + + qlen /= BYTES_PER_XDR_UNIT; + + rbuf = NULL; + + status = _lookup_all(server_port, gai_proc, (unit *)qbuf, qlen, &rbuf, &rlen); + if (status != KERN_SUCCESS) return EAI_NODATA; + + rlen *= BYTES_PER_XDR_UNIT; + + xdrmem_create(&inxdr, rbuf, rlen, XDR_DECODE); + + if (!xdr_int(&inxdr, &n)) + { + xdr_destroy(&inxdr); + return EAI_SYSTEM; + } + + cname = NULL; + for (i = 0; i < n; i++) + { + a = gai_lookupd_process_dictionary(&inxdr); + if ((cname == NULL) && (a->ai_canonname != NULL)) cname = a->ai_canonname; + append_addrinfo(res, a); + } + + xdr_destroy(&inxdr); + if (rbuf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)rbuf, rlen); + + if ((cname != NULL) && (res != NULL) && (res[0] != NULL) && (res[0]->ai_canonname == NULL)) + { + res[0]->ai_canonname = strdup(cname); + } + + return 0; +} + +static int +gai_checkhints(const struct addrinfo *hints) +{ + if (hints == NULL) return 0; + if (hints->ai_addrlen != 0) return EAI_BADHINTS; + if (hints->ai_canonname != NULL) return EAI_BADHINTS; + if (hints->ai_addr != NULL) return EAI_BADHINTS; + if (hints->ai_next != NULL) return EAI_BADHINTS; + + /* Check for supported protocol family */ + if (gai_family_type_check(hints->ai_family) != 0) return EAI_FAMILY; + + /* Check for supported socket */ + if (gai_socket_type_check(hints->ai_socktype) != 0) return EAI_BADHINTS; + + /* Check for supported protocol */ + if (gai_protocol_type_check(hints->ai_protocol) != 0) return EAI_BADHINTS; + + /* Check that socket type is compatible with protocol */ + if (gai_socket_protocol_type_check(hints->ai_socktype, hints->ai_protocol) != 0) return EAI_BADHINTS; + + return 0; +} + +int +getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) +{ + int32_t status, nodenull, servnull; + + if (res == NULL) return 0; + *res = NULL; + + /* Check input */ + nodenull = 0; + if ((nodename == NULL) || (nodename[0] == '\0')) nodenull = 1; + + servnull = 0; + if ((servname == NULL) || (servname[0] == '\0')) servnull = 1; + + if ((nodenull == 1) && (servnull == 1)) return EAI_NONAME; + status = gai_checkhints(hints); + if (status != 0) return status; + + if (nodenull == 1) status = gai_lookupd(NULL, servname, hints, res); + else if (servnull == 1) status = gai_lookupd(nodename, NULL, hints, res); + else status = gai_lookupd(nodename, servname, hints, res); + + if ((status == 0) && (*res == NULL)) status = EAI_NODATA; + + return status; +} + +int32_t +getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints, getaddrinfo_async_callback callback, void *context) +{ + int32_t status; + uint32_t i, qlen; + char qbuf[LU_QBUF_SIZE]; + mach_port_t server_port; + + *p = MACH_PORT_NULL; + + if ((nodename == NULL) && (servname == NULL)) return EAI_NONAME; + + status = gai_checkhints(hints); + if (status != 0) return EAI_BADHINTS; + + server_port = MACH_PORT_NULL; + if (_lu_running()) server_port = _lookupd_port(0); + if (server_port == MACH_PORT_NULL) return EAI_SYSTEM; + + if (gai_proc < 0) + { + status = _lookup_link(server_port, "getaddrinfo", &gai_proc); + if (status != KERN_SUCCESS) return EAI_SYSTEM; + } + + qlen = LU_QBUF_SIZE; + i = gai_make_query(nodename, servname, hints, qbuf, &qlen); + if (i != 0) return EAI_SYSTEM; + + qlen /= BYTES_PER_XDR_UNIT; + + return lu_async_start(p, gai_proc, qbuf, qlen, (void *)callback, context); +} + +int32_t +getaddrinfo_async_send(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints) +{ + return getaddrinfo_async_start(p, nodename, servname, hints, NULL, NULL); +} + +static int +gai_extract_data(char *buf, uint32_t len, struct addrinfo **res) +{ + XDR xdr; + uint32_t i, n; + char *cname; + struct addrinfo *a; + + *res = NULL; + + if (buf == NULL) return EAI_NODATA; + if (len == 0) return EAI_NODATA; + + xdrmem_create(&xdr, buf, len, XDR_DECODE); + + if (!xdr_int(&xdr, &n)) + { + xdr_destroy(&xdr); + return EAI_SYSTEM; + } + + cname = NULL; + for (i = 0; i < n; i++) + { + a = gai_lookupd_process_dictionary(&xdr); + if (a == NULL) break; + + if ((cname == NULL) && (a->ai_canonname != NULL)) cname = a->ai_canonname; + append_addrinfo(res, a); + } + + xdr_destroy(&xdr); + + if ((cname != NULL) && (res != NULL) && (res[0] != NULL) && (res[0]->ai_canonname == NULL)) + { + res[0]->ai_canonname = strdup(cname); + } + + if (*res == NULL) return EAI_NODATA; + return 0; +} + +int32_t +getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res) +{ + kern_return_t status; + char *buf; + uint32_t len; + + if (res == NULL) return 0; + *res = NULL; + + buf = NULL; + len = 0; + + status = lu_async_receive(p, &buf, &len); + if (status < 0) return EAI_FAIL; + + status = gai_extract_data(buf, len, res); + if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len); + if (status != 0) return status; + + if (*res == NULL) return EAI_NODATA; + + return 0; +} + +int32_t +getaddrinfo_async_handle_reply(void *msg) +{ + getaddrinfo_async_callback callback; + void *context; + char *buf; + uint32_t len; + int status; + struct addrinfo *res; + + callback = (getaddrinfo_async_callback)NULL; + context = NULL; + buf = NULL; + len = 0; + res = NULL; + + status = lu_async_handle_reply(msg, &buf, &len, (void **)&callback, &context); + if (status != KERN_SUCCESS) + { + if (status == MIG_REPLY_MISMATCH) return 0; + if (callback != NULL) callback(EAI_SYSTEM, NULL, context); + return EAI_SYSTEM; + } + + status = gai_extract_data(buf, len, &res); + if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len); + if (status != 0) + { + if (callback != NULL) callback(status, NULL, context); + return status; + } + + if (res == NULL) + { + callback(EAI_NODATA, NULL, context); + return EAI_NODATA; + } + + callback(0, res, context); + return 0; +} + +/* + * getnameinfo + */ + +/* + * getnameinfo support in lookupd + * Input dict may contain the following + * + * ip_address: node address + * ipv6_address: node address + * port: service number + * protocol: [tcp] | udp + * fqdn: [1] | 0 + * numerichost: [0] | 1 + * name_required: [0] | 1 + * numericserv: [0] | 1 + * + * Output dictionary may contain the following + * All values are encoded as strings. + * + * name: char * + * service: char * + */ + +static int +gni_lookupd_process_dictionary(XDR *inxdr, char **host, char **serv) +{ + int32_t i, nkeys, nvals; + char *key, *val; + + if ((host == NULL) || (serv == NULL)) return EAI_SYSTEM; + if (!xdr_int(inxdr, &nkeys)) return EAI_SYSTEM; + + for (i = 0; i < nkeys; i++) + { + key = NULL; + val = NULL; + + if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH)) return EAI_SYSTEM; + if (!xdr_int(inxdr, &nvals)) + { + free(key); + return EAI_SYSTEM; + } + + if (nvals != 1) + { + free(key); + return EAI_SYSTEM; + } + + if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH)) + { + free(key); + return EAI_SYSTEM; + } + + if (!strcmp(key, "name")) + { + *host = val; + val = NULL; + } + + else if (!strcmp(key, "service")) + { + *serv = val; + val = NULL; + } + + if (key != NULL) free(key); + if (val != NULL) free(val); + } + + return 0; +} + +static int +gni_make_query(const struct sockaddr *sa, size_t salen, int wanthost, int wantserv, int flags, char *buf, uint32_t *len) +{ + XDR outxdr; + uint16_t port; + char str[_LU_MAXLUSTRLEN], *key, ifname[IF_NAMESIZE]; + uint32_t a4, ifnum, offset, na, proto, fqdn, numerichost, numericserv, name_req; + struct sockaddr_in6 *s6; + + if (sa == NULL) return EAI_FAIL; + if (sa->sa_len != salen) return EAI_FAMILY; + + proto = IPPROTO_TCP; + fqdn = 1; + numerichost = 0; + numericserv = 0; + name_req = 0; + + offset = INET_NTOP_AF_INET_OFFSET; + key = "ip_address"; + port = 0; + + if (sa->sa_family == PF_INET) + { + a4 = ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr); + if (IN_MULTICAST(a4) || IN_EXPERIMENTAL(a4)) flags |= NI_NUMERICHOST; + a4 >>= IN_CLASSA_NSHIFT; + if (a4 == 0) flags |= NI_NUMERICHOST; + + port = ((struct sockaddr_in *)sa)->sin_port; + } + else if (sa->sa_family == PF_INET6) + { + s6 = (struct sockaddr_in6 *)sa; + switch (s6->sin6_addr.s6_addr[0]) + { + case 0x00: + if (IN6_IS_ADDR_V4MAPPED(&s6->sin6_addr)) + { + } + else if (IN6_IS_ADDR_LOOPBACK(&s6->sin6_addr)) + { + } + else + { + flags |= NI_NUMERICHOST; + } + break; + default: + if (IN6_IS_ADDR_LINKLOCAL(&s6->sin6_addr)) + { + flags |= NI_NUMERICHOST; + } + else if (IN6_IS_ADDR_MULTICAST(&s6->sin6_addr)) + { + flags |= NI_NUMERICHOST; + } + break; + } + + offset = INET_NTOP_AF_INET6_OFFSET; + key = "ipv6_address"; + port = s6->sin6_port; + } + else + { + return EAI_FAMILY; + } + + na = 0; + + if (wanthost != 0) na++; + if (wantserv != 0) na++; + + if (flags & NI_NOFQDN) + { + fqdn = 0; + na++; + } + + if (flags & NI_NUMERICHOST) + { + numerichost = 1; + na++; + } + + if (flags & NI_NUMERICSERV) + { + numericserv = 1; + na++; + } + + if (flags & NI_NAMEREQD) + { + name_req = 1; + na++; + } + + if (flags & NI_DGRAM) + { + proto = IPPROTO_UDP; + na++; + } + + xdrmem_create(&outxdr, buf, *len, XDR_ENCODE); + + if (!xdr_int(&outxdr, &na)) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + + if (wanthost != 0) + { + inet_ntop(sa->sa_family, (char *)(sa) + offset, str, _LU_MAXLUSTRLEN); + + if ((flags & NI_WITHSCOPEID) && (sa->sa_family == AF_INET6)) + { + ifnum = ((struct sockaddr_in6 *)sa)->sin6_scope_id; + if (if_indextoname(ifnum, ifname) != NULL) + { + strcat(str, "%"); + strcat(str, ifname); + } + } + + if (encode_kv(&outxdr, key, str) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (wantserv != 0) + { + snprintf(str, _LU_MAXLUSTRLEN, "%hu", port); + if (encode_kv(&outxdr, "port", str) != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (proto == IPPROTO_UDP) + { + if (encode_kv(&outxdr, "protocol", "udp") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (fqdn == 0) + { + if (encode_kv(&outxdr, "fqdn", "0") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (numerichost == 1) + { + if (encode_kv(&outxdr, "numerichost", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (numericserv == 1) + { + if (encode_kv(&outxdr, "numericserv", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + if (name_req == 1) + { + if (encode_kv(&outxdr, "name_required", "1") != 0) + { + xdr_destroy(&outxdr); + return EAI_SYSTEM; + } + } + + *len = xdr_getpos(&outxdr); + + xdr_destroy(&outxdr); + + return 0; +} + +int +getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) +{ + uint32_t n, i, qlen, rlen; + int wanth, wants; + XDR inxdr; + char qbuf[LU_QBUF_SIZE]; + char *rbuf, *hval, *sval; + mach_port_t server_port; + kern_return_t status; + struct sockaddr_in *s4; + struct sockaddr_in6 *s6; + + /* Check input */ + if (sa == NULL) return EAI_FAIL; + + /* V4 mapped and compat addresses are converted to plain V4 */ + if (sa->sa_family == AF_INET6) + { + s6 = (struct sockaddr_in6 *)sa; + if ((IN6_IS_ADDR_V4MAPPED(&s6->sin6_addr)) || (IN6_IS_ADDR_V4COMPAT(&s6->sin6_addr))) + { + s4 = (struct sockaddr_in *)calloc(1, sizeof(struct sockaddr_in)); + s4->sin_len = sizeof(struct sockaddr_in); + s4->sin_family = AF_INET; + s4->sin_port = s6->sin6_port; + memcpy(&(s4->sin_addr.s_addr), &(s6->sin6_addr.s6_addr[12]), 4); + + i = getnameinfo((const struct sockaddr *)s4, s4->sin_len, host, hostlen, serv, servlen, flags); + free(s4); + return i; + } + } + + wanth = 0; + if ((host != NULL) && (hostlen != 0)) wanth = 1; + + wants = 0; + if ((serv != NULL) && (servlen != 0)) wants = 1; + + if ((wanth == 0) && (wants == 0)) return 0; + + /* + * Special cases handled by the library + */ + if ((wanth == 1) && (flags & NI_NUMERICHOST)) + { + i = INET_NTOP_AF_INET_OFFSET; + if (sa->sa_family == PF_INET6) i = INET_NTOP_AF_INET6_OFFSET; + if (inet_ntop(sa->sa_family, (char *)(sa) + i, host, hostlen) == NULL) return EAI_FAIL; + + if (wants == 0) return 0; + } + + if ((wants == 1) && (flags & NI_NUMERICSERV)) + { + if (sa->sa_family == PF_INET) + { + s4 = (struct sockaddr_in *)sa; + n = snprintf(serv, servlen, "%hu", ntohs(s4->sin_port)); + if (n >= servlen) return EAI_FAIL; + } + else if (sa->sa_family == PF_INET6) + { + s6 = (struct sockaddr_in6 *)sa; + n = snprintf(serv, servlen, "%hu", ntohs(s6->sin6_port)); + if (n >= servlen) return EAI_FAIL; + } + else return EAI_FAMILY; + + if (wanth == 0) return 0; + } + + if ((wanth == 1) && (flags & NI_NUMERICHOST) && (wants == 1) && (flags & NI_NUMERICSERV)) return 0; + + /* + * Ask lookupd + */ + server_port = MACH_PORT_NULL; + if (_lu_running()) server_port = _lookupd_port(0); + if (server_port == MACH_PORT_NULL) return EAI_SYSTEM; + + if (gni_proc < 0) + { + status = _lookup_link(server_port, "getnameinfo", &gni_proc); + if (status != KERN_SUCCESS) return EAI_SYSTEM; + } + + qlen = LU_QBUF_SIZE; + i = gni_make_query(sa, salen, wanth, wants, flags, qbuf, &qlen); + if (i != 0) return EAI_SYSTEM; + + qlen /= BYTES_PER_XDR_UNIT; + + rbuf = NULL; + + status = _lookup_all(server_port, gni_proc, (unit *)qbuf, qlen, &rbuf, &rlen); + if (status != KERN_SUCCESS) return EAI_NONAME; + + rlen *= BYTES_PER_XDR_UNIT; + + xdrmem_create(&inxdr, rbuf, rlen, XDR_DECODE); + + if (!xdr_int(&inxdr, &n)) + { + xdr_destroy(&inxdr); + return EAI_SYSTEM; + } + + if (n != 1) + { + xdr_destroy(&inxdr); + return EAI_NONAME; + } + + hval = NULL; + sval = NULL; + + i = gni_lookupd_process_dictionary(&inxdr, &hval, &sval); + + xdr_destroy(&inxdr); + if (rbuf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)rbuf, rlen); + + if (i != 0) return i; + + i = 0; + if (hval != NULL) i = strlen(hval) + 1; + if ((host != NULL) && (hostlen != 0) && (i != 0)) + { + if (i > hostlen) return EAI_FAIL; + memcpy(host, hval, i); + free(hval); + } + + i = 0; + if (sval != NULL) i = strlen(sval) + 1; + if ((serv != NULL) && (servlen != 0) && (i != 0)) + { + if (i > servlen) return EAI_FAIL; + memcpy(serv, sval, i); + free(sval); + } + + return 0; +} + +int32_t +getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags, getnameinfo_async_callback callback, void *context) +{ + uint32_t i, qlen; + char qbuf[LU_QBUF_SIZE]; + mach_port_t server_port; + kern_return_t status; + + /* Check input */ + if (sa == NULL) return EAI_FAIL; + + server_port = MACH_PORT_NULL; + if (_lu_running()) server_port = _lookupd_port(0); + if (server_port == MACH_PORT_NULL) return EAI_SYSTEM; + + if (gni_proc < 0) + { + status = _lookup_link(server_port, "getnameinfo", &gni_proc); + if (status != KERN_SUCCESS) return EAI_SYSTEM; + } + + qlen = LU_QBUF_SIZE; + i = gni_make_query(sa, salen, 1, 1, flags, qbuf, &qlen); + if (i != 0) return EAI_SYSTEM; + + qlen /= BYTES_PER_XDR_UNIT; + + return lu_async_start(p, gni_proc, qbuf, qlen, (void *)callback, context); +} + +int32_t +getnameinfo_async_send(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags) +{ + return getnameinfo_async_start(p, sa, salen, flags, NULL, NULL); +} + +static int +gni_extract_data(char *buf, uint32_t len, char **host, char **serv) +{ + XDR xdr; + uint32_t n; + + *host = NULL; + *serv = NULL; + + if (buf == NULL) return EAI_NODATA; + if (len == 0) return EAI_NODATA; + + xdrmem_create(&xdr, buf, len, XDR_DECODE); + + if (!xdr_int(&xdr, &n)) + { + xdr_destroy(&xdr); + return EAI_SYSTEM; + } + + if (n != 1) + { + xdr_destroy(&xdr); + return EAI_NONAME; + } + + return gni_lookupd_process_dictionary(&xdr, host, serv); +} + +int32_t +getnameinfo_async_receive(mach_port_t p, char **host, char **serv) +{ + kern_return_t status; + char *buf; + uint32_t len; + + buf = NULL; + len = 0; + + status = lu_async_receive(p, &buf, &len); + if (status < 0) return EAI_FAIL; + + status = gni_extract_data(buf, len, host, serv); + if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len); + if (status != 0) return status; + + return 0; +} + +int32_t +getnameinfo_async_handle_reply(void *msg) +{ + getnameinfo_async_callback callback; + void *context; + char *buf, *hval, *sval; + uint32_t len; + int status; + + callback = (getnameinfo_async_callback)NULL; + context = NULL; + buf = NULL; + len = 0; + + status = lu_async_handle_reply(msg, &buf, &len, (void **)&callback, &context); + if (status != KERN_SUCCESS) + { + if (status == MIG_REPLY_MISMATCH) return 0; + if (callback != NULL) callback(EAI_SYSTEM, NULL, NULL, context); + return EAI_SYSTEM; + } + + hval = NULL; + sval = NULL; + + status = gni_extract_data(buf, len, &hval, &sval); + if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len); + if (status != 0) + { + if (callback != NULL) callback(status, NULL, NULL, context); + return status; + } + + callback(0, hval, sval, context); + return 0; +} diff --git a/gen.subproj/getnameinfo.3 b/lookup.subproj/getnameinfo.3 similarity index 100% rename from gen.subproj/getnameinfo.3 rename to lookup.subproj/getnameinfo.3 diff --git a/lookup.subproj/lookup.defs b/lookup.subproj/lookup.defs index 430e2b4..d148783 100644 --- a/lookup.subproj/lookup.defs +++ b/lookup.subproj/lookup.defs @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lookup_types.h b/lookup.subproj/lookup_types.h index 7d8fcd2..fa0be9e 100644 --- a/lookup.subproj/lookup_types.h +++ b/lookup.subproj/lookup_types.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_alias.c b/lookup.subproj/lu_alias.c index 7d22d91..eae5f5b 100644 --- a/lookup.subproj/lu_alias.c +++ b/lookup.subproj/lu_alias.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_bootp.c b/lookup.subproj/lu_bootp.c index d3a9aa9..ebcf4dd 100644 --- a/lookup.subproj/lu_bootp.c +++ b/lookup.subproj/lu_bootp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -36,6 +37,7 @@ #include #include #include +#include #include #include "_lu_types.h" diff --git a/lookup.subproj/lu_bootparam.c b/lookup.subproj/lu_bootparam.c index 9594b74..b7a3ede 100644 --- a/lookup.subproj/lu_bootparam.c +++ b/lookup.subproj/lu_bootparam.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_fstab.c b/lookup.subproj/lu_fstab.c index be1d532..e68bb63 100644 --- a/lookup.subproj/lu_fstab.c +++ b/lookup.subproj/lu_fstab.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_group.c b/lookup.subproj/lu_group.c index 3a8233b..58cb7c4 100644 --- a/lookup.subproj/lu_group.c +++ b/lookup.subproj/lu_group.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -44,6 +45,15 @@ #include "lu_utils.h" #include "lu_overrides.h" +#define GROUP_CACHE_SIZE 10 +#define DEFAULT_GROUP_CACHE_TTL 10 + +static pthread_mutex_t _group_cache_lock = PTHREAD_MUTEX_INITIALIZER; +static void *_group_cache[GROUP_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static unsigned int _group_cache_best_before[GROUP_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned int _group_cache_index = 0; +static unsigned int _group_cache_ttl = DEFAULT_GROUP_CACHE_TTL; + static pthread_mutex_t _group_lock = PTHREAD_MUTEX_INITIALIZER; #define GR_GET_NAME 1 @@ -141,9 +151,10 @@ extract_group(XDR *xdr) g->gr_passwd = vals[0]; j = 1; } - else if ((g->gr_gid == -2) && (!strcmp("gid", key))) + else if ((g->gr_gid == (gid_t)-2) && (!strcmp("gid", key))) { g->gr_gid = atoi(vals[0]); + if ((g->gr_gid == 0) && (strcmp(vals[0], "0"))) g->gr_gid = -2; } else if ((g->gr_mem == NULL) && (!strcmp("users", key))) { @@ -306,6 +317,128 @@ recycle_group(struct lu_thread_info *tdata, struct group *in) free(in); } +__private_extern__ unsigned int +get_group_cache_ttl() +{ + return _group_cache_ttl; +} + +__private_extern__ void +set_group_cache_ttl(unsigned int ttl) +{ + int i; + + pthread_mutex_lock(&_group_cache_lock); + + _group_cache_ttl = ttl; + + if (ttl == 0) + { + for (i = 0; i < GROUP_CACHE_SIZE; i++) + { + if (_group_cache[i] == NULL) continue; + + free_group((struct group *)_group_cache[i]); + _group_cache[i] = NULL; + _group_cache_best_before[i] = 0; + } + } + + pthread_mutex_unlock(&_group_cache_lock); +} + +static void +cache_group(struct group *gr) +{ + struct timeval now; + struct group *grcache; + + if (_group_cache_ttl == 0) return; + if (gr == NULL) return; + + pthread_mutex_lock(&_group_cache_lock); + + grcache = copy_group(gr); + + gettimeofday(&now, NULL); + + if (_group_cache[_group_cache_index] != NULL) + free_group((struct group *)_group_cache[_group_cache_index]); + + _group_cache[_group_cache_index] = grcache; + _group_cache_best_before[_group_cache_index] = now.tv_sec + _group_cache_ttl; + _group_cache_index = (_group_cache_index + 1) % GROUP_CACHE_SIZE; + + pthread_mutex_unlock(&_group_cache_lock); +} + +static struct group * +cache_getgrnam(const char *name) +{ + int i; + struct group *gr, *res; + struct timeval now; + + if (_group_cache_ttl == 0) return NULL; + if (name == NULL) return NULL; + + pthread_mutex_lock(&_group_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < GROUP_CACHE_SIZE; i++) + { + if (_group_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _group_cache_best_before[i]) continue; + + gr = (struct group *)_group_cache[i]; + + if (gr->gr_name == NULL) continue; + + if (!strcmp(name, gr->gr_name)) + { + res = copy_group(gr); + pthread_mutex_unlock(&_group_cache_lock); + return res; + } + } + + pthread_mutex_unlock(&_group_cache_lock); + return NULL; +} + +static struct group * +cache_getgrgid(int gid) +{ + int i; + struct group *gr, *res; + struct timeval now; + + if (_group_cache_ttl == 0) return NULL; + + pthread_mutex_lock(&_group_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < GROUP_CACHE_SIZE; i++) + { + if (_group_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _group_cache_best_before[i]) continue; + + gr = (struct group *)_group_cache[i]; + + if ((gid_t)gid == gr->gr_gid) + { + res = copy_group(gr); + pthread_mutex_unlock(&_group_cache_lock); + return res; + } + } + + pthread_mutex_unlock(&_group_cache_lock); + return NULL; +} + static struct group * lu_getgrgid(int gid) { @@ -425,8 +558,56 @@ lu_getgrnam(const char *name) return g; } +int +_old_getgrouplist(const char *uname, int agroup, int *groups, int *grpcnt) +{ + struct group *grp; + int i, ngroups; + int ret, maxgroups; + + ret = 0; + ngroups = 0; + maxgroups = *grpcnt; + + /* + * When installing primary group, duplicate it; + * the first element of groups is the effective gid + * and will be overwritten when a setgid file is executed. + */ + groups[ngroups++] = agroup; + if (maxgroups > 1) groups[ngroups++] = agroup; + + /* + * Scan the group file to find additional groups. + */ + setgrent(); + + while ((grp = getgrent())) + { + if (grp->gr_gid == (gid_t)agroup) continue; + for (i = 0; grp->gr_mem[i]; i++) + { + if (!strcmp(grp->gr_mem[i], uname)) + { + if (ngroups >= maxgroups) + { + ret = -1; + break; + } + + groups[ngroups++] = grp->gr_gid; + break; + } + } + } + + endgrent(); + *grpcnt = ngroups; + return ret; +} + static int -lu_initgroups(const char *name, int basegid) +lu_getgrouplist(const char *name, int basegid, int *groups, int *grpcnt, int dupbase) { unsigned int datalen; XDR outxdr; @@ -434,13 +615,24 @@ lu_initgroups(const char *name, int basegid) static int proc = -1; char *lookup_buf; char namebuf[_LU_MAXLUSTRLEN + BYTES_PER_XDR_UNIT]; - int groups[NGROUPS]; int ngroups; int a_group; int i, j, count; - groups[0] = basegid; - + if (groups == NULL) return -1; + if (*grpcnt == 0) return -1; + + ngroups = 0; + groups[ngroups++] = basegid; + if (*grpcnt == 1) return 0; + + if (dupbase != 0) + { + /* getgrouplist duplicates the primary group! */ + groups[ngroups++] = basegid; + if (*grpcnt == 2) return 0; + } + if (proc < 0) { if (_lookup_link(_lu_port, "initgroups", &proc) != KERN_SUCCESS) @@ -481,24 +673,51 @@ lu_initgroups(const char *name, int basegid) return -1; } - if (count > NGROUPS) count = NGROUPS; - - ngroups = 0; - for (i = 0; i < count; i++) { if (!xdr_int(&inxdr, &a_group)) break; - for (j = 0; j < ngroups; j++) + j = 0; + if (dupbase != 0) j = 1; + for (; j < ngroups; j++) { if (groups[j] == a_group) break; } - if (j >= ngroups) groups[ngroups++] = a_group; - + + if (j >= ngroups) + { + groups[ngroups++] = a_group; + if (ngroups == *grpcnt) break; + } } + xdr_destroy(&inxdr); vm_deallocate(mach_task_self(), (vm_address_t)lookup_buf, datalen); + *grpcnt = ngroups; + return 0; +} + +int +getgrouplist(const char *uname, int agroup, int *groups, int *grpcnt) +{ + if (_lu_running()) + { + return lu_getgrouplist(uname, agroup, groups, grpcnt, 1); + } + + return _old_getgrouplist(uname, agroup, groups, grpcnt); +} + +static int +lu_initgroups(const char *name, int basegid) +{ + int status, ngroups, groups[NGROUPS]; + + ngroups = NGROUPS; + status = lu_getgrouplist(name, basegid, groups, &ngroups, 0); + if (status < 0) return status; + return setgroups(ngroups, groups); } @@ -531,7 +750,7 @@ lu_getgrent() tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info)); _lu_data_set_key(_lu_data_key_group, tdata); } - + if (tdata->lu_vm == NULL) { if (proc < 0) @@ -589,8 +808,27 @@ static struct group * getgr_internal(const char *name, gid_t gid, int source) { struct group *res = NULL; + int from_cache; - if (_lu_running()) + from_cache = 0; + res = NULL; + + switch (source) + { + case GR_GET_NAME: + res = cache_getgrnam(name); + break; + case GR_GET_GID: + res = cache_getgrgid(gid); + break; + default: res = NULL; + } + + if (res != NULL) + { + from_cache = 1; + } + else if (_lu_running()) { switch (source) { @@ -625,6 +863,8 @@ getgr_internal(const char *name, gid_t gid, int source) pthread_mutex_unlock(&_group_lock); } + if (from_cache == 0) cache_group(res); + return res; } diff --git a/lookup.subproj/lu_host.c b/lookup.subproj/lu_host.c index d34da5b..8fd7987 100644 --- a/lookup.subproj/lu_host.c +++ b/lookup.subproj/lu_host.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,6 +42,25 @@ #include "lu_host.h" #include "lu_utils.h" +#define HOST_CACHE_SIZE 10 +#define DEFAULT_HOST_CACHE_TTL 10 + +#define CACHE_BYNAME 0 +#define CACHE_BYADDR 1 + +static pthread_mutex_t _host_cache_lock = PTHREAD_MUTEX_INITIALIZER; +static unsigned int _host_cache_ttl = DEFAULT_HOST_CACHE_TTL; + +static void *_host_byname_cache[HOST_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static int _host_byname_cache_flavor[HOST_CACHE_SIZE] = { WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING }; +static unsigned int _host_byname_cache_best_before[HOST_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned int _host_byname_cache_index = 0; + +static void *_host_byaddr_cache[HOST_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static int _host_byaddr_cache_flavor[HOST_CACHE_SIZE] = { WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING }; +static unsigned int _host_byaddr_cache_best_before[HOST_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned int _host_byaddr_cache_index = 0; + static pthread_mutex_t _host_lock = PTHREAD_MUTEX_INITIALIZER; extern struct hostent *_res_gethostbyaddr(); @@ -264,9 +284,15 @@ extract_host(XDR *xdr, int want, int *err) free(mapvals); } + if (h->h_addr_list == NULL) + { + freehostent(h); + *err = NO_DATA; + return NULL; + } + if (h->h_name == NULL) h->h_name = strdup(""); if (h->h_aliases == NULL) h->h_aliases = (char **)calloc(1, sizeof(char *)); - if (h->h_addr_list == NULL) h->h_addr_list = (char **)calloc(1, sizeof(char *)); return h; } @@ -398,6 +424,185 @@ fake_hostent6(const char *name, struct in6_addr addr) return h; } +__private_extern__ unsigned int +get_host_cache_ttl() +{ + return _host_cache_ttl; +} + +__private_extern__ void +set_host_cache_ttl(unsigned int ttl) +{ + int i; + + pthread_mutex_lock(&_host_cache_lock); + + _host_cache_ttl = ttl; + + if (ttl == 0) + { + for (i = 0; i < HOST_CACHE_SIZE; i++) + { + if (_host_byname_cache[i] == NULL) continue; + + freehostent((struct hostent *)_host_byname_cache[i]); + _host_byname_cache[i] = NULL; + _host_byname_cache_flavor[i] = WANT_NOTHING; + _host_byname_cache_best_before[i] = 0; + } + + for (i = 0; i < HOST_CACHE_SIZE; i++) + { + if (_host_byaddr_cache[i] == NULL) continue; + + freehostent((struct hostent *)_host_byaddr_cache[i]); + _host_byaddr_cache[i] = NULL; + _host_byaddr_cache_flavor[i] = WANT_NOTHING; + _host_byaddr_cache_best_before[i] = 0; + } + } + + pthread_mutex_unlock(&_host_cache_lock); +} + +static void +cache_host(struct hostent *h, int want, int how) +{ + struct timeval now; + struct hostent *hcache; + + if (_host_cache_ttl == 0) return; + if (h == NULL) return; + + pthread_mutex_lock(&_host_cache_lock); + + hcache = copy_host(h); + + gettimeofday(&now, NULL); + + if (how == CACHE_BYNAME) + { + if (_host_byname_cache[_host_byname_cache_index] != NULL) + freehostent((struct hostent *)_host_byname_cache[_host_byname_cache_index]); + + _host_byname_cache[_host_byname_cache_index] = hcache; + _host_byname_cache_flavor[_host_byname_cache_index] = want; + _host_byname_cache_best_before[_host_byname_cache_index] = now.tv_sec + _host_cache_ttl; + _host_byname_cache_index = (_host_byname_cache_index + 1) % HOST_CACHE_SIZE; + } + else + { + if (_host_byaddr_cache[_host_byaddr_cache_index] != NULL) + freehostent((struct hostent *)_host_byaddr_cache[_host_byaddr_cache_index]); + + _host_byaddr_cache[_host_byaddr_cache_index] = hcache; + _host_byaddr_cache_flavor[_host_byaddr_cache_index] = want; + _host_byaddr_cache_best_before[_host_byaddr_cache_index] = now.tv_sec + _host_cache_ttl; + _host_byaddr_cache_index = (_host_byaddr_cache_index + 1) % HOST_CACHE_SIZE; + } + + pthread_mutex_unlock(&_host_cache_lock); +} + +static struct hostent * +cache_gethostbyname(const char *name, int want) +{ + int i; + struct hostent *h, *res; + char **aliases; + struct timeval now; + + if (_host_cache_ttl == 0) return NULL; + if (name == NULL) return NULL; + + pthread_mutex_lock(&_host_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < HOST_CACHE_SIZE; i++) + { + if (_host_byname_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _host_byname_cache_best_before[i]) continue; + + if (_host_byname_cache_flavor[i] != want) continue; + + h = (struct hostent *)_host_byname_cache[i]; + + if (h->h_name != NULL) + { + if (!strcmp(name, h->h_name)) + { + res = copy_host(h); + pthread_mutex_unlock(&_host_cache_lock); + return res; + } + } + + aliases = h->h_aliases; + if (aliases == NULL) + { + pthread_mutex_unlock(&_host_cache_lock); + return NULL; + } + + for (; *aliases != NULL; *aliases++) + { + if (!strcmp(name, *aliases)) + { + res = copy_host(h); + pthread_mutex_unlock(&_host_cache_lock); + return res; + } + } + } + + pthread_mutex_unlock(&_host_cache_lock); + return NULL; +} + +static struct hostent * +cache_gethostbyaddr(const char *addr, int want) +{ + int i, j, len; + struct hostent *h, *res; + struct timeval now; + + if (addr == NULL) return NULL; + if (_host_cache_ttl == 0) return NULL; + + pthread_mutex_lock(&_host_cache_lock); + + gettimeofday(&now, NULL); + + len = IPV4_ADDR_LEN; + if (want > WANT_A4_ONLY) len = IPV6_ADDR_LEN; + + for (i = 0; i < HOST_CACHE_SIZE; i++) + { + if (_host_byaddr_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _host_byaddr_cache_best_before[i]) continue; + + if (_host_byaddr_cache_flavor[i] != want) continue; + + h = (struct hostent *)_host_byaddr_cache[i]; + + if (h->h_addr_list == NULL) continue; + + for (j = 0; h->h_addr_list[j] != NULL; j++) + { + if (memcmp(addr, h->h_addr_list[j], len) == 0) + { + res = copy_host(h); + pthread_mutex_unlock(&_host_cache_lock); + return res; + } + } + } + + pthread_mutex_unlock(&_host_cache_lock); + return NULL; +} + static struct hostent * lu_gethostbyaddr(const char *addr, int want, int *err) { @@ -413,7 +618,7 @@ lu_gethostbyaddr(const char *addr, int want, int *err) family = AF_INET; len = IPV4_ADDR_LEN; - if (want > WANT_A4_ONLY) + if ((want == WANT_A6_ONLY) || (want == WANT_A6_PLUS_MAPPED_A4)) { family = AF_INET6; len = IPV6_ADDR_LEN; @@ -589,7 +794,7 @@ lu_endhostent() struct lu_thread_info *tdata; tdata = _lu_data_create_key(_lu_data_key_host, free_lu_thread_info_host); - _lu_data_free_vm_xdr(tdata); + _lu_data_free_vm_xdr(tdata); } static void @@ -611,7 +816,7 @@ lu_gethostent(int want, int *err) tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info)); _lu_data_set_key(_lu_data_key_host, tdata); } - + if (tdata->lu_vm == NULL) { if (proc < 0) @@ -675,14 +880,29 @@ static struct hostent * gethostbyaddrerrno(const char *addr, int len, int type, int *err) { struct hostent *res = NULL; - int want; + int want, from_cache; *err = 0; want = WANT_A4_ONLY; if (type == AF_INET6) want = WANT_A6_ONLY; - if (_lu_running()) + if ((type == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr))) + { + addr += 12; + len = 4; + type = AF_INET; + want = WANT_MAPPED_A4_ONLY; + } + + from_cache = 0; + res = cache_gethostbyaddr(addr, want); + + if (res != NULL) + { + from_cache = 1; + } + else if (_lu_running()) { res = lu_gethostbyaddr(addr, want, err); } @@ -695,6 +915,8 @@ gethostbyaddrerrno(const char *addr, int len, int type, int *err) pthread_mutex_unlock(&_host_lock); } + if (from_cache == 0) cache_host(res, want, CACHE_BYADDR); + return res; } @@ -726,7 +948,7 @@ gethostbynameerrno(const char *name, int *err) { struct hostent *res = NULL; struct in_addr addr; - int i, is_addr; + int i, is_addr, from_cache; *err = 0; @@ -760,6 +982,9 @@ gethostbynameerrno(const char *name, int *err) if ((is_addr == 1) && (name[i-1] == '.')) is_addr = 0; + res = NULL; + from_cache = 0; + if (is_addr == 1) { if (inet_aton(name, &addr) == 0) @@ -769,6 +994,16 @@ gethostbynameerrno(const char *name, int *err) } res = fake_hostent(name, addr); } + + if (res == NULL) + { + res = cache_gethostbyname(name, WANT_A4_ONLY); + } + + if (res != NULL) + { + from_cache = 1; + } else if (_lu_running()) { res = lu_gethostbyname(name, WANT_A4_ONLY, err); @@ -791,11 +1026,14 @@ gethostbynameerrno(const char *name, int *err) } res = gethostbyaddrerrno((char *)&addr, sizeof(addr), AF_INET, err); - if (res == NULL) { + if (res == NULL) + { res = fake_hostent(name, addr); } } + if (from_cache == 0) cache_host(res, WANT_A4_ONLY, CACHE_BYNAME); + return res; } @@ -823,6 +1061,31 @@ gethostbyname(const char *name) } struct hostent * +gethostbyname2(const char *name, int af) +{ + struct hostent *res; + struct lu_thread_info *tdata; + + res = getipnodebyname(name, af, 0, &h_errno); + if (res == NULL) + { + errno = EAFNOSUPPORT; + h_errno = NETDB_INTERNAL; + return NULL; + } + + tdata = _lu_data_create_key(_lu_data_key_host, free_lu_thread_info_host); + if (tdata == NULL) + { + tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info)); + _lu_data_set_key(_lu_data_key_host, tdata); + } + + recycle_host(tdata, res); + return (struct hostent *)tdata->lu_entry; +} + +struct hostent * gethostent(void) { struct hostent *res = NULL; @@ -924,19 +1187,14 @@ getipnodebyaddr(const void *src, size_t len, int af, int *err) *err = 0; - if ((af == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)src) || is_a4_compat((const char *)src))) - { - src += 12; - len = 4; - af = AF_INET; - } - res = gethostbyaddrerrno((const char *)src, len, af, err); - if (res == NULL) { + if (res == NULL) + { return NULL; } - if (res->h_name == NULL) { + if (res->h_name == NULL) + { freehostent(res); return NULL; } @@ -947,7 +1205,7 @@ getipnodebyaddr(const void *src, size_t len, int af, int *err) struct hostent * getipnodebyname(const char *name, int af, int flags, int *err) { - int status, want, really_want, if4, if6; + int status, want, really_want, if4, if6, from_cache; struct hostent *res; struct ifaddrs *ifa, *ifap; struct in_addr addr4; @@ -1079,9 +1337,14 @@ getipnodebyname(const char *name, int af, int flags, int *err) } } - res = NULL; + from_cache = 0; + res = cache_gethostbyname(name, want); - if (_lu_running()) + if (res != NULL) + { + from_cache = 1; + } + else if (_lu_running()) { res = lu_gethostbyname(name, want, err); if ((res == NULL) && @@ -1106,5 +1369,7 @@ getipnodebyname(const char *name, int af, int flags, int *err) return NULL; } + if (from_cache == 0) cache_host(res, want, CACHE_BYNAME); + return res; } diff --git a/lookup.subproj/lu_host.h b/lookup.subproj/lu_host.h index 130bc4d..9ca4daf 100644 --- a/lookup.subproj/lu_host.h +++ b/lookup.subproj/lu_host.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -28,6 +29,7 @@ #include +#define WANT_NOTHING 0xfeedface #define WANT_A4_ONLY 0 #define WANT_A6_ONLY 1 #define WANT_A6_PLUS_MAPPED_A4 2 diff --git a/lookup.subproj/lu_host_async.c b/lookup.subproj/lu_host_async.c index 2874719..1bbeced 100644 --- a/lookup.subproj/lu_host_async.c +++ b/lookup.subproj/lu_host_async.c @@ -2,28 +2,30 @@ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ #include -#include /* async gethostbyXXX function prototypes */ +/* async gethostbyXXX function prototypes */ +#include #include #include #include @@ -36,6 +38,7 @@ #include #include #include +#include #include "lu_host.h" #include "lu_utils.h" @@ -45,99 +48,92 @@ extern int _lu_running(void); extern int h_errno; +#define msgh_request_port msgh_remote_port +#define msgh_reply_port msgh_local_port -#define msgh_request_port msgh_remote_port -#define msgh_reply_port msgh_local_port - -typedef union { - gethostbyaddr_async_callback hostAddr; - gethostbyname_async_callback hostName; - getipnodebyaddr_async_callback nodeAddr; - getipnodebyname_async_callback nodeName; +typedef union +{ + gethostbyaddr_async_callback hostAddr; + gethostbyname_async_callback hostName; + getipnodebyaddr_async_callback nodeAddr; + getipnodebyname_async_callback nodeName; } a_request_callout_t; -typedef struct a_requests { - struct a_requests *next; - int retry; - struct { - int proc; - ooline_data data; - unsigned int dataLen; - int want; +typedef struct a_requests +{ + struct a_requests *next; + int retry; + struct + { + int proc; + ooline_data data; + unsigned int dataLen; + int want; } request; - mach_port_t replyPort; - a_request_callout_t callout; - void *context; - struct hostent *hent; /* if reply known in XXX_start() */ + mach_port_t replyPort; + a_request_callout_t callout; + void *context; + struct hostent *hent; /* if reply known in XXX_start() */ } a_requests_t; -static a_requests_t *a_requests = NULL; -static pthread_mutex_t a_requests_lock = PTHREAD_MUTEX_INITIALIZER; +static a_requests_t *a_requests = NULL; +static pthread_mutex_t a_requests_lock = PTHREAD_MUTEX_INITIALIZER; #define MAX_LOOKUP_ATTEMPTS 10 - static kern_return_t -_lookup_all_tx -( - mach_port_t server, - int proc, - ooline_data indata, - mach_msg_type_number_t indataCnt, - mach_port_t *replyPort -) +_lookup_all_tx(mach_port_t server, int proc, ooline_data indata, mach_msg_type_number_t indataCnt, mach_port_t *replyPort) { - typedef struct { - mach_msg_header_t Head; - NDR_record_t NDR; - int proc; - mach_msg_type_number_t indataCnt; - unit indata[4096]; + typedef struct + { + mach_msg_header_t Head; + NDR_record_t NDR; + int proc; + mach_msg_type_number_t indataCnt; + unit indata[4096]; } Request; - Request In; - register Request *InP = &In; - mach_msg_return_t mr; - unsigned int msgh_size; + Request In; + register Request *InP = &In; + mach_msg_return_t mr; + unsigned int msgh_size; - if (indataCnt > 4096) { - return MIG_ARRAY_TOO_LARGE; - } + if (indataCnt > 4096) return MIG_ARRAY_TOO_LARGE; - if (*replyPort == MACH_PORT_NULL) { - mr = mach_port_allocate(mach_task_self(), - MACH_PORT_RIGHT_RECEIVE, - replyPort); - if (mr != KERN_SUCCESS) { - return mr; - } + if (*replyPort == MACH_PORT_NULL) + { + mr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, replyPort); + if (mr != KERN_SUCCESS) return mr; } msgh_size = (sizeof(Request) - 16384) + ((4 * indataCnt)); - InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); -/* InP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */ - InP->Head.msgh_request_port = server; - InP->Head.msgh_reply_port = *replyPort; - InP->Head.msgh_id = 4241776; - InP->NDR = NDR_record; - InP->proc = proc; - InP->indataCnt = indataCnt; - (void)memcpy((char *)InP->indata, (const char *)indata, 4 * indataCnt); - - mr = mach_msg(&InP->Head, /* msg */ - MACH_SEND_MSG, /* options */ - msgh_size, /* send_size */ - 0, /* rcv_size */ - MACH_PORT_NULL, /* rcv_name */ - MACH_MSG_TIMEOUT_NONE, /* timeout */ - MACH_PORT_NULL); /* notify */ - switch (mr) { - case MACH_MSG_SUCCESS : + InP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE); +// InP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */ + InP->Head.msgh_request_port = server; + InP->Head.msgh_reply_port = *replyPort; + InP->Head.msgh_id = 4241776; + InP->NDR = NDR_record; + InP->proc = proc; + InP->indataCnt = indataCnt; + memcpy((char *)InP->indata, (const char *)indata, 4 * indataCnt); + + mr = mach_msg(&InP->Head, /* msg */ + MACH_SEND_MSG, /* options */ + msgh_size, /* send_size */ + 0, /* rcv_size */ + MACH_PORT_NULL, /* rcv_name */ + MACH_MSG_TIMEOUT_NONE, /* timeout */ + MACH_PORT_NULL); /* notify */ + + switch (mr) + { + case MACH_MSG_SUCCESS: mr = KERN_SUCCESS; break; case MACH_SEND_INVALID_REPLY : - (void)mach_port_destroy(mach_task_self(), *replyPort); + (void)mach_port_mod_refs(mach_task_self(), *replyPort, MACH_PORT_RIGHT_RECEIVE, -1); + *replyPort = MACH_PORT_NULL; break; default: break; @@ -146,55 +142,57 @@ _lookup_all_tx return mr; } - static kern_return_t -_lookup_all_rx -( - void *msg, - ooline_data *outdata, - mach_msg_type_number_t *outdataCnt, - security_token_t *token -) +_lookup_all_rx(void *msg, ooline_data *outdata, mach_msg_type_number_t *outdataCnt, security_token_t *token) { - typedef struct { - mach_msg_header_t Head; - mach_msg_body_t msgh_body; - mach_msg_ool_descriptor_t outdata; - NDR_record_t NDR; - mach_msg_type_number_t outdataCnt; - mach_msg_format_0_trailer_t trailer; + typedef struct + { + mach_msg_header_t Head; + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t outdata; + NDR_record_t NDR; + mach_msg_type_number_t outdataCnt; + mach_msg_format_0_trailer_t trailer; } Reply; /* * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; * } mig_reply_error_t; */ - register Reply *OutP = msg; - mach_msg_format_0_trailer_t *TrailerP; - boolean_t msgh_simple; + register Reply *OutP = msg; + mach_msg_format_0_trailer_t *TrailerP; + boolean_t msgh_simple; - if (OutP->Head.msgh_id != (4241776 + 100)) { - if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) - return MIG_SERVER_DIED; - else - return MIG_REPLY_MISMATCH; + if (OutP->Head.msgh_id != (4241776 + 100)) + { + if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED; + else return MIG_REPLY_MISMATCH; } msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX); - TrailerP = (mach_msg_format_0_trailer_t *)((vm_offset_t)OutP + - round_msg(OutP->Head.msgh_size)); - if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) - return MIG_TRAILER_ERROR; + TrailerP = (mach_msg_format_0_trailer_t *)((vm_offset_t)OutP + round_msg(OutP->Head.msgh_size)); + if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) return MIG_TRAILER_ERROR; + + if (OutP->NDR.int_rep != NDR_record.int_rep) + { + if (msgh_simple) + { + ((mig_reply_error_t *)OutP)->RetCode = OSReadSwapInt32(&(((mig_reply_error_t *)OutP)->RetCode), 0); + } + else + { + OutP->outdataCnt = OSReadSwapInt32(&(OutP->outdataCnt), 0); + } + } - if (msgh_simple && ((mig_reply_error_t *)OutP)->RetCode != KERN_SUCCESS) - return ((mig_reply_error_t *)OutP)->RetCode; + if (msgh_simple && ((mig_reply_error_t *)OutP)->RetCode != KERN_SUCCESS) return ((mig_reply_error_t *)OutP)->RetCode; - *outdata = (ooline_data)(OutP->outdata.address); + *outdata = (ooline_data)(OutP->outdata.address); *outdataCnt = OutP->outdataCnt; *token = TrailerP->msgh_sender; @@ -202,83 +200,93 @@ _lookup_all_rx return KERN_SUCCESS; } - static a_requests_t * request_extract(mach_port_t port) { - a_requests_t *request0, *request; + a_requests_t *request0, *request; pthread_mutex_lock(&a_requests_lock); + request0 = NULL; - request = a_requests; - while (request) { - if (port == request->replyPort) { + request = a_requests; + + while (request != NULL) + { + if (port == request->replyPort) + { /* request found, remove from list */ - if (request0) { + if (request0 != NULL) + { request0->next = request->next; - } else { + } + else + { a_requests = request->next; } + break; - } else { + } + else + { /* not this request, skip to next */ request0 = request; - request = request->next; + request = request->next; } } + pthread_mutex_unlock(&a_requests_lock); return request; } - static void request_queue(a_requests_t *request) { pthread_mutex_lock(&a_requests_lock); + request->next = a_requests; a_requests = request; + pthread_mutex_unlock(&a_requests_lock); return; } - static boolean_t sendCannedReply(a_requests_t *request, int *error) { /* * typedef struct { - * mach_msg_header_t Head; - * NDR_record_t NDR; - * kern_return_t RetCode; + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; * } mig_reply_error_t; */ - mig_reply_error_t Out; - register mig_reply_error_t *OutP = &Out; + mig_reply_error_t Out; + register mig_reply_error_t *OutP = &Out; + kern_return_t kr; + mach_msg_return_t mr; + unsigned int msgh_size; - kern_return_t kr; - mach_msg_return_t mr; - unsigned int msgh_size; + mach_port_t sendPort; + mach_msg_type_name_t sendType; /* * allocate reply port */ - kr = mach_port_allocate(mach_task_self(), - MACH_PORT_RIGHT_RECEIVE, - &request->replyPort); - if (kr != KERN_SUCCESS) { + kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &request->replyPort); + if (kr != KERN_SUCCESS) + { *error = NO_RECOVERY; return FALSE; } - kr = mach_port_insert_right(mach_task_self(), - request->replyPort, - request->replyPort, - MACH_MSG_TYPE_MAKE_SEND); - if (kr != KERN_SUCCESS) { - (void) mach_port_destroy(mach_task_self(), request->replyPort); + kr = mach_port_extract_right(mach_task_self(), request->replyPort, MACH_MSG_TYPE_MAKE_SEND_ONCE, &sendPort, &sendType); + if (kr != KERN_SUCCESS) + { + (void)mach_port_destroy(mach_task_self(), request->replyPort); + request->replyPort = MACH_PORT_NULL; *error = NO_RECOVERY; return FALSE; } @@ -287,25 +295,23 @@ sendCannedReply(a_requests_t *request, int *error) * queue reply message */ msgh_size = sizeof(Out); - OutP->Head.msgh_bits = MACH_MSGH_BITS(19, 0); -/* OutP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */ - OutP->Head.msgh_request_port = request->replyPort; - OutP->Head.msgh_reply_port = MACH_PORT_NULL; - OutP->Head.msgh_id = 4241776 + 100; - OutP->RetCode = MIG_REMOTE_ERROR; - OutP->NDR = NDR_record; - - mr = mach_msg(&OutP->Head, /* msg */ - MACH_SEND_MSG, /* options */ - msgh_size, /* send_size */ - 0, /* rcv_size */ - MACH_PORT_NULL, /* rcv_name */ - MACH_MSG_TIMEOUT_NONE, /* timeout */ - MACH_PORT_NULL); /* notify */ - if (mr != MACH_MSG_SUCCESS) { - if (mr == MACH_SEND_INVALID_REPLY) { + OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0); +// OutP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */ + OutP->Head.msgh_request_port = sendPort; + OutP->Head.msgh_reply_port = MACH_PORT_NULL; + OutP->Head.msgh_id = 4241776 + 100; + OutP->RetCode = MIG_REMOTE_ERROR; + OutP->NDR = NDR_record; + + mr = mach_msg(&OutP->Head, MACH_SEND_MSG, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (mr != MACH_MSG_SUCCESS) + { + if (mr == MACH_SEND_INVALID_REPLY) + { (void)mach_port_destroy(mach_task_self(), request->replyPort); + request->replyPort = MACH_PORT_NULL; } + *error = NO_RECOVERY; return FALSE; } @@ -313,34 +319,61 @@ sendCannedReply(a_requests_t *request, int *error) return TRUE; } +static void +_async_cancel(mach_port_t port) +{ + a_requests_t *request; -mach_port_t -_gethostbyaddr_async_start(const char *addr, - int len, - int type, - a_request_callout_t callout, - void *context, - int *error) + request = request_extract(port); + if (request) + { + (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1); + if (request->request.data) free(request->request.data); + if (request->hent) freehostent(request->hent); + free(request); + } + + return; +} + +static mach_port_t +_gethostbyaddr_async_start(const char *addr, int len, int type, a_request_callout_t callout, void *context, int *error) { - void *address; - int proc; - a_requests_t *request; - int want; + void *address; + int proc; + a_requests_t *request; + int want; + static int proc4 = -1; + struct in_addr *v4addr; + static int proc6 = -1; + struct in6_addr *v6addr; + + want = WANT_A4_ONLY; + if (type == AF_INET6) want = WANT_A6_ONLY; + + if ((type == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr))) + { + addr += 12; + len = 4; + type = AF_INET; + want = WANT_MAPPED_A4_ONLY; + } - switch (type) { - case AF_INET : + switch (type) + { + case AF_INET: { - static int proc4 = -1; - struct in_addr *v4addr; - - if (proc4 < 0) { - if (_lookup_link(_lu_port, "gethostbyaddr", &proc4) != KERN_SUCCESS) { + if (proc4 < 0) + { + if (_lookup_link(_lu_port, "gethostbyaddr", &proc4) != KERN_SUCCESS) + { *error = NO_RECOVERY; return MACH_PORT_NULL; } } - if (len != sizeof(struct in_addr)) { + if (len != sizeof(struct in_addr)) + { *error = NO_RECOVERY; return NULL; } @@ -350,24 +383,23 @@ _gethostbyaddr_async_start(const char *addr, v4addr->s_addr = htonl(v4addr->s_addr); address = (void *)v4addr; - proc = proc4; - want = WANT_A4_ONLY; + proc = proc4; break; } - case AF_INET6 : + case AF_INET6: { - static int proc6 = -1; - struct in6_addr *v6addr; - - if (proc6 < 0) { - if (_lookup_link(_lu_port, "getipv6nodebyaddr", &proc6) != KERN_SUCCESS) { + if (proc6 < 0) + { + if (_lookup_link(_lu_port, "getipv6nodebyaddr", &proc6) != KERN_SUCCESS) + { *error = NO_RECOVERY; return MACH_PORT_NULL; } } - if (len != sizeof(struct in6_addr)) { + if (len != sizeof(struct in6_addr)) + { *error = NO_RECOVERY; return NULL; } @@ -380,38 +412,36 @@ _gethostbyaddr_async_start(const char *addr, v6addr->__u6_addr.__u6_addr32[3] = htonl(v6addr->__u6_addr.__u6_addr32[3]); address = (void *)v6addr; - proc = proc6; - want = WANT_A6_ONLY; + proc = proc6; break; } - default: + default: *error = NO_RECOVERY; return MACH_PORT_NULL; } request = malloc(sizeof(a_requests_t)); - request->next = NULL; - request->retry = MAX_LOOKUP_ATTEMPTS; - request->request.proc = proc; - request->request.data = (ooline_data)address; + request->next = NULL; + request->retry = MAX_LOOKUP_ATTEMPTS; + request->request.proc = proc; + request->request.data = (ooline_data)address; request->request.dataLen = len / BYTES_PER_XDR_UNIT; - request->request.want = want; - request->replyPort = MACH_PORT_NULL; - request->callout = callout; - request->context = context; - request->hent = NULL; + request->request.want = want; + request->replyPort = MACH_PORT_NULL; + request->callout = callout; + request->context = context; + request->hent = NULL; /* * allocate reply port, send query to lookupd */ - if (_lookup_all_tx(_lu_port, - request->request.proc, - request->request.data, - request->request.dataLen, - &request->replyPort) == KERN_SUCCESS) { + if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS) + { request_queue(request); - } else { + } + else + { if (request->request.data) free(request->request.data); free(request); *error = NO_RECOVERY; @@ -421,60 +451,57 @@ _gethostbyaddr_async_start(const char *addr, return request->replyPort; } - -boolean_t -_gethostbyaddr_async_handleReply(void *replyMsg, - a_requests_t **requestP, - struct hostent **he, - int *error) +static boolean_t +_gethostbyaddr_async_handleReply(void *replyMsg, a_requests_t **requestP, struct hostent **he, int *error) { - int count; - ooline_data data; - unsigned int datalen; - XDR inxdr; - mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg; - a_requests_t *request; - kern_return_t status; - security_token_t token; + int count; + ooline_data data; + unsigned int datalen; + XDR inxdr; + mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg; + a_requests_t *request; + kern_return_t status; + security_token_t token; request = request_extract(msg->msgh_local_port); - if (!request) { + if (!request) + { /* excuse me, what happenned to the request info? */ return FALSE; } *requestP = request; - *he = NULL; - *error = 0; + *he = NULL; + *error = 0; /* unpack the reply */ status = _lookup_all_rx(replyMsg, &data, &datalen, &token); - switch (status) { - case KERN_SUCCESS : + switch (status) + { + case KERN_SUCCESS: break; - case MIG_SERVER_DIED : - if (--request->retry > 0) { + case MIG_SERVER_DIED: + if (--request->retry > 0) + { /* retry the request */ - if (_lookup_all_tx(_lu_port, - request->request.proc, - request->request.data, - request->request.dataLen, - &request->replyPort) == KERN_SUCCESS) { + if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS) + { request_queue(request); return FALSE; } } /* fall through */ - default : + default: *error = HOST_NOT_FOUND; return TRUE; } datalen *= BYTES_PER_XDR_UNIT; - if (token.val[0] != 0) { + if (token.val[0] != 0) + { vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = NO_RECOVERY; return TRUE; @@ -483,18 +510,20 @@ _gethostbyaddr_async_handleReply(void *replyMsg, xdrmem_create(&inxdr, data, datalen, XDR_DECODE); count = 0; - if (!xdr_int(&inxdr, &count)) { + if (!xdr_int(&inxdr, &count)) + { xdr_destroy(&inxdr); vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = NO_RECOVERY; return TRUE; } - if (count == 0) { + if (count == 0) + { xdr_destroy(&inxdr); vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = HOST_NOT_FOUND; - *he = NULL; + *he = NULL; return TRUE; } @@ -504,18 +533,14 @@ _gethostbyaddr_async_handleReply(void *replyMsg, return TRUE; } - mach_port_t -gethostbyaddr_async_start(const char *addr, - int len, - int type, - gethostbyaddr_async_callback callout, - void *context) +gethostbyaddr_async_start(const char *addr, int len, int type, gethostbyaddr_async_callback callout, void *context) { - a_request_callout_t cb; - mach_port_t mp; + a_request_callout_t cb; + mach_port_t mp; - if (!_lu_running()) { + if (!_lu_running()) + { h_errno = NO_RECOVERY; return MACH_PORT_NULL; } @@ -525,121 +550,121 @@ gethostbyaddr_async_start(const char *addr, return mp; } +void +gethostbyaddr_async_cancel(mach_port_t port) +{ + _async_cancel(port); + return; +} void gethostbyaddr_async_handleReply(void *replyMsg) { - int error = 0; - struct hostent *he = NULL; - a_requests_t *request = NULL; + int error = 0; + struct hostent *he = NULL; + a_requests_t *request = NULL; - if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) { + if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) + { /* if we have an answer to provide */ h_errno = error; (request->callout.hostAddr)(he, request->context); - (void)mach_port_destroy(mach_task_self(), request->replyPort); + (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1); if (request->request.data) free(request->request.data); free(request); - if (he) freehostent(he); + if (he != NULL) freehostent(he); } return; } - mach_port_t -getipnodebyaddr_async_start(const void *addr, - size_t len, - int af, - int *error, - getipnodebyaddr_async_callback callout, - void *context) +getipnodebyaddr_async_start(const void *addr, size_t len, int af, int *error, getipnodebyaddr_async_callback callout, void *context) { - a_request_callout_t cb; - mach_port_t mp; + a_request_callout_t cb; + mach_port_t mp; - if (!_lu_running()) { + if (!_lu_running()) + { *error = NO_RECOVERY; return MACH_PORT_NULL; } - if ((af == AF_INET6) && - (len == sizeof(struct in6_addr)) && - (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr))) { - /* - * this is really a v4 address - */ - addr += sizeof(struct in6_addr) - sizeof(struct in_addr); - len = sizeof(struct in_addr); - af = AF_INET; - } - cb.nodeAddr = callout; mp = _gethostbyaddr_async_start(addr, len, af, cb, context, error); return mp; } +void +getipnodebyaddr_async_cancel(mach_port_t port) +{ + _async_cancel(port); + return; +} void getipnodebyaddr_async_handleReply(void *replyMsg) { - int error = 0; - struct hostent *he = NULL; - a_requests_t *request = NULL; + int error = 0; + struct hostent *he = NULL; + a_requests_t *request = NULL; - if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) { + if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) + { /* if we have an answer to provide */ (request->callout.nodeAddr)(he, error, request->context); - (void)mach_port_destroy(mach_task_self(), request->replyPort); + (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1); if (request->request.data) free(request->request.data); free(request); /* * Note: it is up to the callback function to call - * freehostent(). + * freehostent(). */ } return; } - -mach_port_t -_gethostbyname_async_start(const char *name, - int want, - int *error, - a_request_callout_t callout, - void *context) +static mach_port_t +_gethostbyname_async_start(const char *name, int want, int *error, a_request_callout_t callout, void *context) { - int af; - boolean_t is_addr = FALSE; - mach_port_t mp = MACH_PORT_NULL; - XDR outxdr; - static int proc; - a_requests_t *request; - - if ((name == NULL) || (name[0] == '\0')) { + int af; + boolean_t is_addr = FALSE; + mach_port_t mp = MACH_PORT_NULL; + XDR outxdr; + static int proc; + a_requests_t *request; + static int proc4 = -1; + static int proc6 = -1; + struct in_addr v4addr; + struct in6_addr v6addr; + + if ((name == NULL) || (name[0] == '\0')) + { *error = NO_DATA; return MACH_PORT_NULL; } - af = (want == WANT_A4_ONLY) ? AF_INET : AF_INET6; - - if ((af == AF_INET) || (want == WANT_MAPPED_A4_ONLY)) { - static int proc4 = -1; + af = (want == WANT_A4_ONLY) ? AF_INET: AF_INET6; - if (proc4 < 0) { - if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) { + if ((af == AF_INET) || (want == WANT_MAPPED_A4_ONLY)) + { + if (proc4 < 0) + { + if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) + { *error = NO_RECOVERY; return MACH_PORT_NULL; } } proc = proc4; - } else /* if (af == AF_INET6) */ { - static int proc6 = -1; - - if (proc6 < 0) { + } + else /* if (af == AF_INET6) */ + { + if (proc6 < 0) + { if (_lookup_link(_lu_port, "getipv6nodebyname", &proc6) != KERN_SUCCESS) { *error = NO_RECOVERY; @@ -650,24 +675,24 @@ _gethostbyname_async_start(const char *name, } request = malloc(sizeof(a_requests_t)); - request->next = NULL; - request->retry = MAX_LOOKUP_ATTEMPTS; - request->request.proc = proc; - request->request.data = NULL; + request->next = NULL; + request->retry = MAX_LOOKUP_ATTEMPTS; + request->request.proc = proc; + request->request.data = NULL; request->request.dataLen = 0; - request->request.want = want; - request->replyPort = MACH_PORT_NULL; - request->callout = callout; - request->context = context; - request->hent = NULL; - - switch (af) { - case AF_INET : + request->request.want = want; + request->replyPort = MACH_PORT_NULL; + request->callout = callout; + request->context = context; + request->hent = NULL; + + switch (af) + { + case AF_INET: { - struct in_addr v4addr; - memset(&v4addr, 0, sizeof(struct in_addr)); - if (inet_aton(name, &v4addr) == 1) { + if (inet_aton(name, &v4addr) == 1) + { /* return a fake hostent */ request->hent = fake_hostent(name, v4addr); is_addr = TRUE; @@ -675,13 +700,11 @@ _gethostbyname_async_start(const char *name, break; } - case AF_INET6 : + case AF_INET6: { - struct in_addr v4addr; - struct in6_addr v6addr; - memset(&v6addr, 0, sizeof(struct in6_addr)); - if (inet_pton(af, name, &v6addr) == 1) { + if (inet_pton(af, name, &v6addr) == 1) + { /* return a fake hostent */ request->hent = fake_hostent6(name, v6addr); is_addr = TRUE; @@ -689,8 +712,10 @@ _gethostbyname_async_start(const char *name, } memset(&v4addr, 0, sizeof(struct in_addr)); - if (inet_aton(name, &v4addr) == 1) { - if (want == WANT_A4_ONLY) { + if (inet_aton(name, &v4addr) == 1) + { + if (want == WANT_A4_ONLY) + { free(request); *error = HOST_NOT_FOUND; return MACH_PORT_NULL; @@ -708,20 +733,24 @@ _gethostbyname_async_start(const char *name, break; } - default: + default: free(request); *error = NO_RECOVERY; return MACH_PORT_NULL; } - if (is_addr) { + if (is_addr) + { /* * queue reply message */ - if (sendCannedReply(request, error)) { + if (sendCannedReply(request, error)) + { request_queue(request); return request->replyPort; - } else { + } + else + { freehostent(request->hent); free(request); return MACH_PORT_NULL; @@ -729,10 +758,11 @@ _gethostbyname_async_start(const char *name, } request->request.dataLen = _LU_MAXLUSTRLEN + BYTES_PER_XDR_UNIT; - request->request.data = malloc(request->request.dataLen); + request->request.data = malloc(request->request.dataLen); xdrmem_create(&outxdr, request->request.data, request->request.dataLen, XDR_ENCODE); - if (!xdr__lu_string(&outxdr, (_lu_string *)&name)) { + if (!xdr__lu_string(&outxdr, (_lu_string *)&name)) + { xdr_destroy(&outxdr); free(request->request.data); free(request); @@ -745,14 +775,13 @@ _gethostbyname_async_start(const char *name, /* * allocate reply port, send query to lookupd */ - if (_lookup_all_tx(_lu_port, - request->request.proc, - request->request.data, - request->request.dataLen, - &request->replyPort) == KERN_SUCCESS) { + if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS) + { request_queue(request); mp = request->replyPort; - } else { + } + else + { free(request->request.data); free(request); *error = NO_RECOVERY; @@ -763,35 +792,32 @@ _gethostbyname_async_start(const char *name, return mp; } - -boolean_t -_gethostbyname_async_handleReply(void *replyMsg, - a_requests_t **requestP, - struct hostent **he, - int *error) +static boolean_t +_gethostbyname_async_handleReply(void *replyMsg, a_requests_t **requestP, struct hostent **he, int *error) { - - int count; - unsigned int datalen; - XDR inxdr; - ooline_data data; - mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg; - a_requests_t *request; - kern_return_t status; - security_token_t token; - int want; + int count; + unsigned int datalen; + XDR inxdr; + ooline_data data; + mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg; + a_requests_t *request; + kern_return_t status; + security_token_t token; + int want; request = request_extract(msg->msgh_local_port); - if (!request) { + if (!request) + { /* excuse me, what happenned to the request info? */ return FALSE; } *requestP = request; - *he = NULL; - *error = 0; + *he = NULL; + *error = 0; - if (request->hent) { + if (request->hent) + { /* * if the reply was already available when the * request was made @@ -802,34 +828,34 @@ _gethostbyname_async_handleReply(void *replyMsg, /* unpack the reply */ status = _lookup_all_rx(replyMsg, &data, &datalen, &token); - switch (status) { - case KERN_SUCCESS : + switch (status) + { + case KERN_SUCCESS: break; - case MIG_SERVER_DIED : - if (--request->retry > 0) { + case MIG_SERVER_DIED: + if (--request->retry > 0) + { /* * retry the request */ - if (_lookup_all_tx(_lu_port, - request->request.proc, - request->request.data, - request->request.dataLen, - &request->replyPort) == KERN_SUCCESS) { + if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS) + { request_queue(request); return FALSE; } } /* fall through */ - default : + default: *error = HOST_NOT_FOUND; return TRUE; } datalen *= BYTES_PER_XDR_UNIT; - if (token.val[0] != 0) { + if (token.val[0] != 0) + { vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = NO_RECOVERY; return TRUE; @@ -838,14 +864,16 @@ _gethostbyname_async_handleReply(void *replyMsg, xdrmem_create(&inxdr, data, datalen, XDR_DECODE); count = 0; - if (!xdr_int(&inxdr, &count)) { + if (!xdr_int(&inxdr, &count)) + { xdr_destroy(&inxdr); vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = NO_RECOVERY; return TRUE; } - if (count == 0) { + if (count == 0) + { xdr_destroy(&inxdr); vm_deallocate(mach_task_self(), (vm_address_t)data, datalen); *error = HOST_NOT_FOUND; @@ -861,67 +889,70 @@ _gethostbyname_async_handleReply(void *replyMsg, return TRUE; } - mach_port_t -gethostbyname_async_start(const char *name, - gethostbyname_async_callback callout, - void *context) +gethostbyname_async_start(const char *name, gethostbyname_async_callback callout, void *context) { - a_request_callout_t cb; - int error; - mach_port_t mp = MACH_PORT_NULL; + a_request_callout_t cb; + int error; + mach_port_t mp = MACH_PORT_NULL; - if (!_lu_running()) { + if (!_lu_running()) + { h_errno = NO_RECOVERY; return MACH_PORT_NULL; } cb.hostName = callout; mp = _gethostbyname_async_start(name, WANT_A4_ONLY, &error, cb, context); - if (!mp) { + if (mp == MACH_PORT_NULL) + { h_errno = error; } + return mp; } +void +gethostbyname_async_cancel(mach_port_t port) +{ + _async_cancel(port); + return; +} void gethostbyname_async_handleReply(void *replyMsg) { - int error; - struct hostent *he; - a_requests_t *request; + int error; + struct hostent *he; + a_requests_t *request; - if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) { + if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) + { /* if we have an answer to provide */ h_errno = error; (request->callout.hostAddr)(he, request->context); - (void)mach_port_destroy(mach_task_self(), request->replyPort); + (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1); if (request->request.data) free(request->request.data); free(request); - if (he) freehostent(he); + if (he != NULL) freehostent(he); } return; } - mach_port_t -getipnodebyname_async_start(const char *name, - int af, - int flags, - int *error, - getipnodebyname_async_callback callout, - void *context) +getipnodebyname_async_start(const char *name, int af, int flags, int *error, getipnodebyname_async_callback callout, void *context) { - a_request_callout_t cb; - int if4 = 0; - int if6 = 0; - mach_port_t mp = MACH_PORT_NULL; - int want = WANT_A4_ONLY; - - if (!_lu_running()) { + a_request_callout_t cb; + int if4 = 0; + int if6 = 0; + mach_port_t mp = MACH_PORT_NULL; + int want = WANT_A4_ONLY; + struct ifaddrs *ifa, *ifap; + + if (!_lu_running()) + { h_errno = NO_RECOVERY; return MACH_PORT_NULL; } @@ -929,22 +960,24 @@ getipnodebyname_async_start(const char *name, /* * IF AI_ADDRCONFIG is set, we need to know what interface flavors we really have. */ - if (flags & AI_ADDRCONFIG) { - struct ifaddrs *ifa, *ifap; - - if (getifaddrs(&ifa) < 0) { + if (flags & AI_ADDRCONFIG) + { + if (getifaddrs(&ifa) < 0) + { *error = NO_RECOVERY; return MACH_PORT_NULL; } - for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next) { - if (ifap->ifa_addr == NULL) - continue; - if ((ifap->ifa_flags & IFF_UP) == 0) - continue; - if (ifap->ifa_addr->sa_family == AF_INET) { + for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next) + { + if (ifap->ifa_addr == NULL) continue; + if ((ifap->ifa_flags & IFF_UP) == 0) continue; + if (ifap->ifa_addr->sa_family == AF_INET) + { if4++; - } else if (ifap->ifa_addr->sa_family == AF_INET6) { + } + else if (ifap->ifa_addr->sa_family == AF_INET6) + { if6++; } } @@ -952,7 +985,8 @@ getipnodebyname_async_start(const char *name, freeifaddrs(ifa); /* Bail out if there are no interfaces */ - if ((if4 == 0) && (if6 == 0)) { + if ((if4 == 0) && (if6 == 0)) + { *error = NO_ADDRESS; return MACH_PORT_NULL; } @@ -962,27 +996,37 @@ getipnodebyname_async_start(const char *name, * Figure out what we want. * If user asked for AF_INET, we only want V4 addresses. */ - switch (af) { - case AF_INET : + switch (af) + { + case AF_INET: { want = WANT_A4_ONLY; - if ((flags & AI_ADDRCONFIG) && (if4 == 0)) { + if ((flags & AI_ADDRCONFIG) && (if4 == 0)) + { *error = NO_ADDRESS; return MACH_PORT_NULL; } } break; - case AF_INET6 : + + case AF_INET6: { want = WANT_A6_ONLY; - if (flags & (AI_V4MAPPED|AI_V4MAPPED_CFG)) { - if (flags & AI_ALL) { + if (flags & (AI_V4MAPPED|AI_V4MAPPED_CFG)) + { + if (flags & AI_ALL) + { want = WANT_A6_PLUS_MAPPED_A4; - } else { + } + else + { want = WANT_A6_OR_MAPPED_A4_IF_NO_A6; } - } else { - if ((flags & AI_ADDRCONFIG) && (if6 == 0)) { + } + else + { + if ((flags & AI_ADDRCONFIG) && (if6 == 0)) + { *error = NO_ADDRESS; return MACH_PORT_NULL; } @@ -996,30 +1040,36 @@ getipnodebyname_async_start(const char *name, return mp; } +void +getipnodebyname_async_cancel(mach_port_t port) +{ + _async_cancel(port); + return; +} void getipnodebyname_async_handleReply(void *replyMsg) { - int error = 0; - struct hostent *he = NULL; - a_requests_t *request = NULL; + int error = 0; + struct hostent *he = NULL; + a_requests_t *request = NULL; + static int proc4 = -1; - if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) { + if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) + { /* * we have an answer to provide */ - if ((he == NULL) && - (error == HOST_NOT_FOUND) && - ((request->request.want == WANT_A6_PLUS_MAPPED_A4) || - (request->request.want == WANT_A6_OR_MAPPED_A4_IF_NO_A6))) { + if ((he == NULL) && (error == HOST_NOT_FOUND) && ((request->request.want == WANT_A6_PLUS_MAPPED_A4) || (request->request.want == WANT_A6_OR_MAPPED_A4_IF_NO_A6))) + { /* * no host found (yet), if requested we send a * followup query to lookupd. */ - static int proc4 = -1; - - if (proc4 < 0) { - if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) { + if (proc4 < 0) + { + if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) + { error = NO_RECOVERY; goto answer; } @@ -1027,26 +1077,25 @@ getipnodebyname_async_handleReply(void *replyMsg) request->request.proc = proc4; request->request.want = WANT_MAPPED_A4_ONLY; - if (_lookup_all_tx(_lu_port, - request->request.proc, - request->request.data, - request->request.dataLen, - &request->replyPort) == KERN_SUCCESS) { + if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS) + { request_queue(request); return; - } else { + } + else + { error = NO_RECOVERY; } } - answer : +answer: (request->callout.nodeName)(he, error, request->context); - (void)mach_port_destroy(mach_task_self(), request->replyPort); - if (request->request.data) free(request->request.data); + (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1); + if (request->request.data != NULL) free(request->request.data); free(request); /* * Note: it is up to the callback function to call - * freehostent(). + * freehostent(). */ } diff --git a/lookup.subproj/lu_netgroup.c b/lookup.subproj/lu_netgroup.c index 5a32b0b..1d69938 100644 --- a/lookup.subproj/lu_netgroup.c +++ b/lookup.subproj/lu_netgroup.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_network.c b/lookup.subproj/lu_network.c index e603b9b..874c7d0 100644 --- a/lookup.subproj/lu_network.c +++ b/lookup.subproj/lu_network.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_overrides.h b/lookup.subproj/lu_overrides.h index c7134b2..beeb91c 100644 --- a/lookup.subproj/lu_overrides.h +++ b/lookup.subproj/lu_overrides.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_printer.c b/lookup.subproj/lu_printer.c index 86fd0b7..40b139a 100644 --- a/lookup.subproj/lu_printer.c +++ b/lookup.subproj/lu_printer.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_protocol.c b/lookup.subproj/lu_protocol.c index e511863..6da9ed7 100644 --- a/lookup.subproj/lu_protocol.c +++ b/lookup.subproj/lu_protocol.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -339,7 +340,7 @@ lu_endprotoent() { struct lu_thread_info *tdata; - tdata = _lu_data_create_key(_lu_data_key_service, free_lu_thread_info_protocol); + tdata = _lu_data_create_key(_lu_data_key_protocol, free_lu_thread_info_protocol); _lu_data_free_vm_xdr(tdata); } diff --git a/lookup.subproj/lu_rpc.c b/lookup.subproj/lu_rpc.c index 3689087..3de239d 100644 --- a/lookup.subproj/lu_rpc.c +++ b/lookup.subproj/lu_rpc.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/lu_service.c b/lookup.subproj/lu_service.c index 7d73677..b1001f4 100644 --- a/lookup.subproj/lu_service.c +++ b/lookup.subproj/lu_service.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -39,6 +40,15 @@ #include "lookup.h" #include "lu_utils.h" +#define SERVICE_CACHE_SIZE 10 +#define DEFAULT_SERVICE_CACHE_TTL 10 + +static pthread_mutex_t _service_cache_lock = PTHREAD_MUTEX_INITIALIZER; +static void *_service_cache[SERVICE_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static unsigned int _service_cache_best_before[SERVICE_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned int _service_cache_index = 0; +static unsigned int _service_cache_ttl = DEFAULT_SERVICE_CACHE_TTL; + static pthread_mutex_t _service_lock = PTHREAD_MUTEX_INITIALIZER; #define S_GET_NAME 1 @@ -234,6 +244,156 @@ recycle_service(struct lu_thread_info *tdata, struct servent *in) free(in); } +__private_extern__ unsigned int +get_service_cache_ttl() +{ + return _service_cache_ttl; +} + +__private_extern__ void +set_service_cache_ttl(unsigned int ttl) +{ + int i; + + pthread_mutex_lock(&_service_cache_lock); + + _service_cache_ttl = ttl; + + if (ttl == 0) + { + for (i = 0; i < SERVICE_CACHE_SIZE; i++) + { + if (_service_cache[i] == NULL) continue; + + free_service((struct servent *)_service_cache[i]); + _service_cache[i] = NULL; + _service_cache_best_before[i] = 0; + } + } + + pthread_mutex_unlock(&_service_cache_lock); +} + +static void +cache_service(struct servent *s) +{ + struct timeval now; + struct servent *scache; + + if (_service_cache_ttl == 0) return; + if (s == NULL) return; + + pthread_mutex_lock(&_service_cache_lock); + + scache = copy_service(s); + + gettimeofday(&now, NULL); + + if (_service_cache[_service_cache_index] != NULL) + free_service((struct servent *)_service_cache[_service_cache_index]); + + _service_cache[_service_cache_index] = scache; + _service_cache_best_before[_service_cache_index] = now.tv_sec + _service_cache_ttl; + _service_cache_index = (_service_cache_index + 1) % SERVICE_CACHE_SIZE; + + pthread_mutex_unlock(&_service_cache_lock); +} + +static struct servent * +cache_getservbyname(const char *name, const char *proto) +{ + int i; + struct servent *s, *res; + struct timeval now; + char **aliases; + + if (_service_cache_ttl == 0) return NULL; + if (name == NULL) return NULL; + + pthread_mutex_lock(&_service_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < SERVICE_CACHE_SIZE; i++) + { + if (_service_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _service_cache_best_before[i]) continue; + + s = (struct servent *)_service_cache[i]; + + if (s->s_name != NULL) + { + if (!strcmp(name, s->s_name)) + { + if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto)))) + { + res = copy_service(s); + pthread_mutex_unlock(&_service_cache_lock); + return res; + } + } + } + + aliases = s->s_aliases; + if (aliases == NULL) + { + pthread_mutex_unlock(&_service_cache_lock); + return NULL; + } + + for (; *aliases != NULL; *aliases++) + { + if (!strcmp(name, *aliases)) + { + if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto)))) + { + res = copy_service(s); + pthread_mutex_unlock(&_service_cache_lock); + return res; + } + } + } + } + + pthread_mutex_unlock(&_service_cache_lock); + return NULL; +} + +static struct servent * +cache_getservbyport(int port, const char *proto) +{ + int i; + struct servent *s, *res; + struct timeval now; + + if (_service_cache_ttl == 0) return NULL; + + pthread_mutex_lock(&_service_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < SERVICE_CACHE_SIZE; i++) + { + if (_service_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _service_cache_best_before[i]) continue; + + s = (struct servent *)_service_cache[i]; + + if (port == s->s_port) + { + if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto)))) + { + res = copy_service(s); + pthread_mutex_unlock(&_service_cache_lock); + return res; + } + } + } + + pthread_mutex_unlock(&_service_cache_lock); + return NULL; +} + static struct servent * lu_getservbyport(int port, const char *proto) { @@ -415,7 +575,7 @@ lu_getservent() tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info)); _lu_data_set_key(_lu_data_key_service, tdata); } - + if (tdata->lu_vm == NULL) { if (proc < 0) @@ -474,6 +634,7 @@ getserv(const char *name, const char *proto, int port, int source) { struct servent *res = NULL; struct lu_thread_info *tdata; + int from_cache; tdata = _lu_data_create_key(_lu_data_key_service, free_lu_thread_info_service); if (tdata == NULL) @@ -482,7 +643,25 @@ getserv(const char *name, const char *proto, int port, int source) _lu_data_set_key(_lu_data_key_service, tdata); } - if (_lu_running()) + from_cache = 0; + res = NULL; + + switch (source) + { + case S_GET_NAME: + res = cache_getservbyname(name, proto); + break; + case S_GET_PORT: + res = cache_getservbyport(port, proto); + break; + default: res = NULL; + } + + if (res != NULL) + { + from_cache = 1; + } + else if (_lu_running()) { switch (source) { @@ -517,6 +696,8 @@ getserv(const char *name, const char *proto, int port, int source) pthread_mutex_unlock(&_service_lock); } + if (from_cache == 0) cache_service(res); + recycle_service(tdata, res); return (struct servent *)tdata->lu_entry; } diff --git a/lookup.subproj/lu_user.c b/lookup.subproj/lu_user.c index c927670..46a3577 100644 --- a/lookup.subproj/lu_user.c +++ b/lookup.subproj/lu_user.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -41,6 +42,15 @@ #include "lu_utils.h" #include "lu_overrides.h" +#define USER_CACHE_SIZE 10 +#define DEFAULT_USER_CACHE_TTL 10 + +static pthread_mutex_t _user_cache_lock = PTHREAD_MUTEX_INITIALIZER; +static void *_user_cache[USER_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; +static unsigned int _user_cache_best_before[USER_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static unsigned int _user_cache_index = 0; +static unsigned int _user_cache_ttl = DEFAULT_USER_CACHE_TTL; + static pthread_mutex_t _user_lock = PTHREAD_MUTEX_INITIALIZER; #define PW_GET_NAME 1 @@ -155,13 +165,15 @@ extract_user(XDR *xdr) p->pw_shell = vals[0]; j = 1; } - else if ((p->pw_uid == -2) && (!strcmp("uid", key))) + else if ((p->pw_uid == (uid_t)-2) && (!strcmp("uid", key))) { p->pw_uid = atoi(vals[0]); + if ((p->pw_uid == 0) && (strcmp(vals[0], "0"))) p->pw_uid = -2; } - else if ((p->pw_gid == -2) && (!strcmp("gid", key))) + else if ((p->pw_gid == (gid_t)-2) && (!strcmp("gid", key))) { p->pw_gid = atoi(vals[0]); + if ((p->pw_gid == 0) && (strcmp(vals[0], "0"))) p->pw_gid = -2; } else if (!strcmp("change", key)) { @@ -340,6 +352,128 @@ recycle_user(struct lu_thread_info *tdata, struct passwd *in) free(in); } +__private_extern__ unsigned int +get_user_cache_ttl() +{ + return _user_cache_ttl; +} + +__private_extern__ void +set_user_cache_ttl(unsigned int ttl) +{ + int i; + + pthread_mutex_lock(&_user_cache_lock); + + _user_cache_ttl = ttl; + + if (ttl == 0) + { + for (i = 0; i < USER_CACHE_SIZE; i++) + { + if (_user_cache[i] == NULL) continue; + + free_user((struct passwd *)_user_cache[i]); + _user_cache[i] = NULL; + _user_cache_best_before[i] = 0; + } + } + + pthread_mutex_unlock(&_user_cache_lock); +} + +static void +cache_user(struct passwd *pw) +{ + struct timeval now; + struct passwd *pwcache; + + if (_user_cache_ttl == 0) return; + if (pw == NULL) return; + + pthread_mutex_lock(&_user_cache_lock); + + pwcache = copy_user(pw); + + gettimeofday(&now, NULL); + + if (_user_cache[_user_cache_index] != NULL) + free_user((struct passwd *)_user_cache[_user_cache_index]); + + _user_cache[_user_cache_index] = pwcache; + _user_cache_best_before[_user_cache_index] = now.tv_sec + _user_cache_ttl; + _user_cache_index = (_user_cache_index + 1) % USER_CACHE_SIZE; + + pthread_mutex_unlock(&_user_cache_lock); +} + +static struct passwd * +cache_getpwnam(const char *name) +{ + int i; + struct passwd *pw, *res; + struct timeval now; + + if (_user_cache_ttl == 0) return NULL; + if (name == NULL) return NULL; + + pthread_mutex_lock(&_user_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < USER_CACHE_SIZE; i++) + { + if (_user_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _user_cache_best_before[i]) continue; + + pw = (struct passwd *)_user_cache[i]; + + if (pw->pw_name == NULL) continue; + + if (!strcmp(name, pw->pw_name)) + { + res = copy_user(pw); + pthread_mutex_unlock(&_user_cache_lock); + return res; + } + } + + pthread_mutex_unlock(&_user_cache_lock); + return NULL; +} + +static struct passwd * +cache_getpwuid(int uid) +{ + int i; + struct passwd *pw, *res; + struct timeval now; + + if (_user_cache_ttl == 0) return NULL; + + pthread_mutex_lock(&_user_cache_lock); + + gettimeofday(&now, NULL); + + for (i = 0; i < USER_CACHE_SIZE; i++) + { + if (_user_cache_best_before[i] == 0) continue; + if ((unsigned int)now.tv_sec > _user_cache_best_before[i]) continue; + + pw = (struct passwd *)_user_cache[i]; + + if ((uid_t)uid == pw->pw_uid) + { + res = copy_user(pw); + pthread_mutex_unlock(&_user_cache_lock); + return res; + } + } + + pthread_mutex_unlock(&_user_cache_lock); + return NULL; +} + static struct passwd * lu_getpwuid(int uid) { @@ -492,7 +626,7 @@ lu_getpwent() tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info)); _lu_data_set_key(_lu_data_key_user, tdata); } - + if (tdata->lu_vm == NULL) { if (proc < 0) @@ -549,29 +683,33 @@ lu_getpwent() static struct passwd * getpw_internal(const char *name, uid_t uid, int source) { - struct passwd *res = NULL; - static char *loginName = NULL; - static struct passwd *loginEnt = NULL; + static char *loginName = NULL; + static struct passwd *loginEnt = NULL; + struct passwd *res; + char *l; + int from_cache; if (loginName == NULL) { - char *l = getlogin(); - - pthread_mutex_lock(&_user_lock); - if ((loginEnt == NULL) && (l != NULL) && (*l != '\0')) + l = getlogin(); + if ((l != NULL) && (strcmp("root", l) != 0)) { - if (_lu_running()) + pthread_mutex_lock(&_user_lock); + if ((loginEnt == NULL) && (l != NULL) && (*l != '\0')) { - loginEnt = lu_getpwnam(l); - } - else - { - loginEnt = copy_user(_old_getpwnam(l)); - } + if (_lu_running()) + { + loginEnt = lu_getpwnam(l); + } + else + { + loginEnt = copy_user(_old_getpwnam(l)); + } - loginName = l; + loginName = l; + } + pthread_mutex_unlock(&_user_lock); } - pthread_mutex_unlock(&_user_lock); } if (loginEnt != NULL) @@ -600,7 +738,25 @@ getpw_internal(const char *name, uid_t uid, int source) } } - if (_lu_running()) + from_cache = 0; + res = NULL; + + switch (source) + { + case PW_GET_NAME: + res = cache_getpwnam(name); + break; + case PW_GET_UID: + res = cache_getpwuid(uid); + break; + default: res = NULL; + } + + if (res != NULL) + { + from_cache = 1; + } + else if (_lu_running()) { switch (source) { @@ -635,6 +791,8 @@ getpw_internal(const char *name, uid_t uid, int source) pthread_mutex_unlock(&_user_lock); } + if (from_cache == 0) cache_user(res); + return res; } @@ -715,7 +873,8 @@ endpwent(void) if (_lu_running()) lu_endpwent(); else _old_endpwent(); } - int + +int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result) { return getpw_r(name, -2, PW_GET_NAME, pwd, buffer, bufsize, result); diff --git a/lookup.subproj/lu_utils.c b/lookup.subproj/lu_utils.c index 5e25864..dc30591 100644 --- a/lookup.subproj/lu_utils.c +++ b/lookup.subproj/lu_utils.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -32,10 +33,16 @@ #include "_lu_types.h" #include "lookup.h" #include "lu_utils.h" +#include "netdb_async.h" #define MAX_LOOKUP_ATTEMPTS 10 +#define _LU_MAXLUSTRLEN 256 +#define QBUF_SIZE 4096 + +#define LU_MESSAGE_SEND_ID 4241776 +#define LU_MESSAGE_REPLY_ID 4241876 -static pthread_key_t _info_key = NULL; +static pthread_key_t _info_key = NULL; static pthread_once_t _info_key_initialized = PTHREAD_ONCE_INIT; struct _lu_data_s @@ -46,7 +53,340 @@ struct _lu_data_s void (**idata_destructor)(void *); }; -#define _LU_MAXLUSTRLEN 256 +typedef struct _lu_async_request_s +{ + mach_port_t reply_port; + uint32_t retry; + uint32_t proc; + void *context; + void *callback; + ooline_data request_buffer; + mach_msg_type_number_t request_buffer_len; + struct _lu_async_request_s *next; +} _lu_async_request_t; + +typedef struct +{ + mach_msg_header_t head; + NDR_record_t NDR; + int proc; + mach_msg_type_number_t query_data_len; + unit query_data[QBUF_SIZE]; +} _lu_query_msg_t; + +typedef struct +{ + mach_msg_header_t head; + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t reply_data; + NDR_record_t NDR; + mach_msg_type_number_t reply_data_len; + mach_msg_format_0_trailer_t trailer; +} _lu_reply_msg_t; + +static pthread_mutex_t _lu_worklist_lock = PTHREAD_MUTEX_INITIALIZER; +static _lu_async_request_t *_lu_worklist = NULL; + +/* Send an asynchronous query message to lookupd */ +static kern_return_t +_lu_async_send(_lu_async_request_t *r) +{ + _lu_query_msg_t in; + register _lu_query_msg_t *inp = ∈ + mach_msg_return_t status; + unsigned int msgh_size; + + if (r == NULL) return KERN_FAILURE; + + if (r->retry == 0) return MIG_SERVER_DIED; + r->retry--; + + if (r->request_buffer_len > QBUF_SIZE) return MIG_ARRAY_TOO_LARGE; + + msgh_size = (sizeof(_lu_query_msg_t) - 16384) + ((4 * r->request_buffer_len)); + inp->head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); + inp->head.msgh_remote_port = _lu_port; + inp->head.msgh_local_port = r->reply_port; + inp->head.msgh_id = LU_MESSAGE_SEND_ID; + inp->NDR = NDR_record; + inp->proc = r->proc; + inp->query_data_len = r->request_buffer_len; + memcpy(inp->query_data, r->request_buffer, 4 * r->request_buffer_len); + + status = mach_msg(&inp->head, MACH_SEND_MSG, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (status == MACH_MSG_SUCCESS) return KERN_SUCCESS; + + if (status == MACH_SEND_INVALID_REPLY) + { + mach_port_mod_refs(mach_task_self(), r->reply_port, MACH_PORT_RIGHT_RECEIVE, -1); + r->reply_port = MACH_PORT_NULL; + } + + return status; +} + +static _lu_async_request_t * +_lu_worklist_remove(mach_port_t p) +{ + _lu_async_request_t *r, *n; + + if (p == MACH_PORT_NULL) return NULL; + if (_lu_worklist == NULL) return NULL; + + pthread_mutex_lock(&_lu_worklist_lock); + + if (_lu_worklist->reply_port == p) + { + r = _lu_worklist; + _lu_worklist = r->next; + pthread_mutex_unlock(&_lu_worklist_lock); + return r; + } + + for (r = _lu_worklist; r != NULL; r = r->next) + { + n = r->next; + if (n == NULL) break; + + if (n->reply_port == p) + { + r->next = n->next; + pthread_mutex_unlock(&_lu_worklist_lock); + return n; + } + } + + pthread_mutex_unlock(&_lu_worklist_lock); + return NULL; +} + +static _lu_async_request_t * +_lu_worklist_find(mach_port_t p) +{ + _lu_async_request_t *r; + + if (p == MACH_PORT_NULL) return NULL; + if (_lu_worklist == NULL) return NULL; + + pthread_mutex_lock(&_lu_worklist_lock); + + for (r = _lu_worklist; r != NULL; r = r->next) + { + if (r->reply_port == p) + { + pthread_mutex_unlock(&_lu_worklist_lock); + return r; + } + } + + pthread_mutex_unlock(&_lu_worklist_lock); + return NULL; +} + +static void +_lu_free_request(_lu_async_request_t *r) +{ + if (r == NULL) return; + + if (r->request_buffer != NULL) free(r->request_buffer); + r->request_buffer = NULL; + + if (r->reply_port != MACH_PORT_NULL) mach_port_destroy(mach_task_self(), r->reply_port); + r->reply_port = MACH_PORT_NULL; + + free(r); +} + +/* Receive an asynchronous reply message from lookupd */ +kern_return_t +lu_async_receive(mach_port_t p, char **buf, uint32_t *len) +{ + _lu_reply_msg_t *r; + kern_return_t status; + uint32_t size; + _lu_async_request_t *req; + + size = sizeof(_lu_reply_msg_t); + + r = (_lu_reply_msg_t *)calloc(1, size); + if (r == NULL) return KERN_RESOURCE_SHORTAGE; + + r->head.msgh_local_port = p; + r->head.msgh_size = size; + status = mach_msg(&(r->head), MACH_RCV_MSG, 0, size, r->head.msgh_local_port, 0, MACH_PORT_NULL); + if (status != KERN_SUCCESS) + { + free(r); + return status; + } + + req = _lu_worklist_remove(r->head.msgh_local_port); + if (req == NULL) + { + free(r); + return KERN_FAILURE; + } + + *buf = r->reply_data.address; + *len = r->reply_data.size; + + free(r); + + _lu_free_request(req); + return KERN_SUCCESS; +} + +static void +_lu_worklist_append(_lu_async_request_t *r) +{ + _lu_async_request_t *p; + + if (r == NULL) return; + + pthread_mutex_lock(&_lu_worklist_lock); + + if (_lu_worklist == NULL) + { + _lu_worklist = r; + pthread_mutex_unlock(&_lu_worklist_lock); + return; + } + + for (p = _lu_worklist; p->next != NULL; p = p->next); + p->next = r; + + pthread_mutex_unlock(&_lu_worklist_lock); +} + +void +lu_async_call_cancel(mach_port_t p) +{ + _lu_async_request_t *req; + + req = _lu_worklist_remove(p); + if (req != NULL) _lu_free_request(req); + else if (p != MACH_PORT_NULL) mach_port_destroy(mach_task_self(), p); +} + +static _lu_async_request_t * +_lu_create_request(uint32_t proc, const char *buf, uint32_t len, void *callback, void *context) +{ + _lu_async_request_t *r; + kern_return_t status; + + if (_lu_port == NULL) return NULL; + + r = (_lu_async_request_t *)calloc(1, sizeof(_lu_async_request_t)); + if (r == NULL) return NULL; + + status = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &(r->reply_port)); + if (status != KERN_SUCCESS) + { + _lu_free_request(r); + return NULL; + } + + r->retry = MAX_LOOKUP_ATTEMPTS; + + r->context = context; + r->callback = callback; + r->proc = proc; + + r->request_buffer = malloc(len * BYTES_PER_XDR_UNIT); + memcpy(r->request_buffer, buf, len * BYTES_PER_XDR_UNIT); + r->request_buffer_len = len; + + r->next = NULL; + + return r; +} + +kern_return_t +lu_async_start(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len, void *callback, void *context) +{ + _lu_async_request_t *r; + kern_return_t status; + uint32_t retry; + + if (p == NULL) return KERN_FAILURE; + + *p = MACH_PORT_NULL; + + if (!_lu_running()) return KERN_FAILURE; + + /* Make a request struct to keep track */ + r = _lu_create_request(proc, buf, len, callback, context); + if (r == NULL) return KERN_FAILURE; + + status = MIG_SERVER_DIED; + for (retry = 0; (status == MIG_SERVER_DIED) && (retry < MAX_LOOKUP_ATTEMPTS); retry++) + { + /* send to lookupd */ + status = _lu_async_send(r); + } + + if (status != KERN_SUCCESS) + { + _lu_free_request(r); + return status; + } + + /* Add request to worklist */ + _lu_worklist_append(r); + + *p = r->reply_port; + return KERN_SUCCESS; +} + +kern_return_t +lu_async_send(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len) +{ + return lu_async_start(p, proc, buf, len, NULL, NULL); +} + +int +lu_async_handle_reply(void *msg, char **buf, uint32_t *len, void **callback, void **context) +{ + _lu_reply_msg_t *r; + _lu_async_request_t *req; + kern_return_t status; + uint32_t retry; + + if (msg == NULL) return -1; + r = (_lu_reply_msg_t *)msg; + + /* If reply status was an error, resend */ + if (r->head.msgh_id != LU_MESSAGE_REPLY_ID) + { + if (r->head.msgh_id == MACH_NOTIFY_SEND_ONCE) + { + /* if MiG server (lookupd) died */ + req = _lu_worklist_find(r->head.msgh_local_port); + if (req == NULL) return -1; + + status = MIG_SERVER_DIED; + for (retry = 0; (status == MIG_SERVER_DIED) && (retry < MAX_LOOKUP_ATTEMPTS); retry++) + { + /* send to lookupd */ + status = _lu_async_send(req); + } + + if (status != KERN_SUCCESS) return -1; + } + return MIG_REPLY_MISMATCH; + } + + req = _lu_worklist_remove(r->head.msgh_local_port); + if (req == NULL) return -1; + + *buf = r->reply_data.address; + *len = r->reply_data.size; + *callback = req->callback; + *context = req->context; + + _lu_free_request(req); + return 0; +} ni_proplist * _lookupd_xdr_dictionary(XDR *inxdr) diff --git a/lookup.subproj/lu_utils.h b/lookup.subproj/lu_utils.h index ae987c0..edd7097 100644 --- a/lookup.subproj/lu_utils.h +++ b/lookup.subproj/lu_utils.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/netdb.h b/lookup.subproj/netdb.h new file mode 100644 index 0000000..17016f9 --- /dev/null +++ b/lookup.subproj/netdb.h @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/* + * ++Copyright++ 1980, 1983, 1988, 1993 + * - + * Copyright (c) 1980, 1983, 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * - + * Portions Copyright (c) 1993 by Digital Equipment Corporation. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies, and that + * the name of Digital Equipment Corporation not be used in advertising or + * publicity pertaining to distribution of the document or software without + * specific, written prior permission. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + * - + * --Copyright-- + */ + +/* + * @(#)netdb.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NETDB_H_ +#define _NETDB_H_ + +#include +#include +#include + +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + +extern int h_errno; + +/* + * Structures returned by network data base library. All addresses are + * supplied in host order, and returned in network order (suitable for + * use in system calls). + */ +struct hostent { + char *h_name; /* official name of host */ + char **h_aliases; /* alias list */ + int h_addrtype; /* host address type */ + int h_length; /* length of address */ + char **h_addr_list; /* list of addresses from name server */ +#define h_addr h_addr_list[0] /* address, for backward compatiblity */ +}; + +/* + * Assumption here is that a network number + * fits in an unsigned long -- probably a poor one. + */ +struct netent { + char *n_name; /* official name of net */ + char **n_aliases; /* alias list */ + int n_addrtype; /* net address type */ + unsigned long n_net; /* network # */ +}; + +struct servent { + char *s_name; /* official service name */ + char **s_aliases; /* alias list */ + int s_port; /* port # */ + char *s_proto; /* protocol to use */ +}; + +struct protoent { + char *p_name; /* official protocol name */ + char **p_aliases; /* alias list */ + int p_proto; /* protocol # */ +}; + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ + +#define NETDB_INTERNAL -1 /* see errno */ +#define NETDB_SUCCESS 0 /* no problem */ +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ +#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ +#define NO_DATA 4 /* Valid name, no data record of requested type */ +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ + +/* + * Error return codes from getaddrinfo() + */ +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* + * Flag values for getaddrinfo() + */ +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +/* valid flags for addrinfo */ +#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) + +#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ +#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ +#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ +/* special recommended flags for getipnodebyname */ +#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) + +/* + * Constants for getnameinfo() + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Flag values for getnameinfo() + */ +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 +#define NI_WITHSCOPEID 0x00000020 + +/* + * Scope delimit character + */ +#define SCOPE_DELIMITER '%' + +__BEGIN_DECLS +void endhostent(void); +void endnetent(void); +void endprotoent(void); +void endservent(void); +void freehostent(struct hostent *); +struct hostent *gethostbyaddr(const char *, int, int); +struct hostent *gethostbyname(const char *); +struct hostent *gethostbyname2(const char *, int); +struct hostent *gethostent(void); +struct hostent *getipnodebyaddr(const void *, size_t, int, int *); +struct hostent *getipnodebyname(const char *, int, int, int *); +struct netent *getnetbyaddr(long, int); +struct netent *getnetbyname(const char *); +struct netent *getnetent(void); +struct protoent *getprotobyname(const char *); +struct protoent *getprotobynumber(int); +struct protoent *getprotoent(void); +struct servent *getservbyname(const char *, const char *); +struct servent *getservbyport(int, const char *); +struct servent *getservent(void); +struct rpcent *getrpcbyname(const char *name); +struct rpcent *getrpcbynumber(long number); +struct rpcent *getrpcent(void); +void setrpcent(int stayopen); +void endrpcent(void); + +void herror(const char *); +const char *hstrerror(int); +int innetgr(const char *, const char *, const char *, const char *); +void sethostent(int); +/* void sethostfile(const char *); */ +void setnetent(int); +void setprotoent(int); +void setservent(int); +const char *gai_strerror(int); +void freeaddrinfo(struct addrinfo *); +int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); +int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); +__END_DECLS + +#endif /* !_NETDB_H_ */ diff --git a/lookup.subproj/netdb_async.h b/lookup.subproj/netdb_async.h dissimilarity index 91% index 561bb5f..d6e23f5 100644 --- a/lookup.subproj/netdb_async.h +++ b/lookup.subproj/netdb_async.h @@ -1,257 +1,300 @@ -/* - * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ - -#ifndef _NETDB_ASYNC_H_ -#define _NETDB_ASYNC_H_ - -#include -#include -#include - -__BEGIN_DECLS - -/* - @typedef gethostbyaddr_async_callback - @discussion Type of the callback function used when a - gethostbyaddr_async_start() request is delivered. - @param hent The resolved host entry. - @param context The context provided when the request - was initiated. - */ -typedef void (*gethostbyaddr_async_callback) ( - struct hostent *hent, - void *context - ); - -/*! - @function gethostbyaddr_async_start - @description Asynchronously resolves an Internet address - @param addr The address to be resolved. - @param len The length, in bytes, of the address. - @param type - @param callout The function to be called when the specified - address has been resolved. - @param context A user specified context which will be passed - to the callout function. - @result A mach reply port which will be sent a message when - the addr resolution has completed. This message - should be passed to the gethostbyaddr_async_handleReply - function. A NULL value indicates that no address - was specified or some other error occurred which - prevented the resolution from being started. - */ -mach_port_t -gethostbyaddr_async_start ( - const char *addr, - int len, - int type, - gethostbyaddr_async_callback callout, - void *context - ); - - -/*! - @function gethostbyaddr_async_handleReply - @description This function should be called with the Mach message sent - to the port returned by the call to gethostbyaddr_async_start. - The reply message will be interpreted and will result in a - call to the specified callout function. - @param replyMsg The Mach message. - */ -void -gethostbyaddr_async_handleReply ( - void *replyMsg - ); - - -/* - @typedef gethostbyname_async_callback - @discussion Type of the callback function used when a - gethostbyname_async_start() request is delivered. - @param hent The resolved host entry. - @param context The context provided when the request - was initiated. - */ -typedef void (*gethostbyname_async_callback) ( - struct hostent *hent, - void *context - ); - -/*! - @function gethostbyname_async_start - @description Asynchronously resolves a hostname - @param name The hostname to be resolved. - @param callout The function to be called when the specified - hostname has been resolved. - @param context A user specified context which will be passed - to the callout function. - @result A mach reply port which will be sent a message when - the name resolution has completed. This message - should be passed to the gethostbyname_async_handleReply - function. A NULL value indicates that no hostname - was specified or some other error occurred which - prevented the resolution from being started. - */ -mach_port_t -gethostbyname_async_start ( - const char *name, - gethostbyname_async_callback callout, - void *context - ); - - -/*! - @function gethostbyname_async_handleReply - @description This function should be called with the Mach message sent - to the port returned by the call to gethostbyname_async_start. - The reply message will be interpreted and will result in a - call to the specified callout function. - @param replyMsg The Mach message. - */ -void -gethostbyname_async_handleReply ( - void *replyMsg - ); - - -/* - @typedef getipnodebyaddr_async_callback - @discussion Type of the callback function used when a - getipnodebyaddr_async_start() request is delivered. - @param hent The resolved host entry. If not NULL, the caller - must call freehostent() on the host entry. - @param error If error code if the resolved host entry is NULL - @param context The context provided when the request - was initiated. - */ -typedef void (*getipnodebyaddr_async_callback) ( - struct hostent *hent, - int error, - void *context - ); - -/*! - @function getipnodebyaddr_async_start - @description Asynchronously resolves an Internet address - @param addr The address to be resolved. - @param len The length, in bytes, of the address. - @param af The address family - @param error - @param callout The function to be called when the specified - address has been resolved. - @param context A user specified context which will be passed - to the callout function. - @result A mach reply port which will be sent a message when - the addr resolution has completed. This message - should be passed to the getipnodebyaddr_async_handleReply - function. A NULL value indicates that no address - was specified or some other error occurred which - prevented the resolution from being started. - */ -mach_port_t -getipnodebyaddr_async_start ( - const void *addr, - size_t len, - int af, - int *error, - getipnodebyaddr_async_callback callout, - void *context - ); - - -/*! - @function getipnodebyaddr_async_handleReply - @description This function should be called with the Mach message sent - to the port returned by the call to getipnodebyaddr_async_start. - The reply message will be interpreted and will result in a - call to the specified callout function. - @param replyMsg The Mach message. - */ -void -getipnodebyaddr_async_handleReply ( - void *replyMsg - ); - - -/* - @typedef getipnodebyname_async_callback - @discussion Type of the callback function used when a - getipnodebyname_async_start() request is delivered. - @param hent The resolved host entry. If not NULL, the caller - must call freehostent() on the host entry. - @param error If error code if the resolved host entry is NULL - @param context The context provided when the request - was initiated. - */ -typedef void (*getipnodebyname_async_callback) ( - struct hostent *hent, - int error, - void *context - ); - -/*! - @function getipnodebyname_async_start - @description Asynchronously resolves a hostname - @param name The hostname to be resolved. - @param af - @param flags - @param error - @param callout The function to be called when the specified - hostname has been resolved. - @param context A user specified context which will be passed - to the callout function. - @result A mach reply port which will be sent a message when - the name resolution has completed. This message - should be passed to the getipnodebyname_async_handleReply - function. A NULL value indicates that no hostname - was specified or some other error occurred which - prevented the resolution from being started. - */ -mach_port_t -getipnodebyname_async_start ( - const char *name, - int af, - int flags, - int *error, - getipnodebyname_async_callback callout, - void *context - ); - - -/*! - @function getipnodebyname_async_handleReply - @description This function should be called with the Mach message sent - to the port returned by the call to getipnodebyname_async_start. - The reply message will be interpreted and will result in a - call to the specified callout function. - @param replyMsg The Mach message. - */ -void -getipnodebyname_async_handleReply ( - void *replyMsg - ); - -__END_DECLS - -#endif /* !_NETDB_ASYNC_H_ */ +/* + * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _NETDB_ASYNC_H_ +#define _NETDB_ASYNC_H_ + +#include +#include +#include + +#define gethostbyname_async_handle_reply gethostbyname_async_handleReply +#define gethostbyaddr_async_handle_reply gethostbyaddr_async_handleReply +#define getipnodebyaddr_async_handle_reply getipnodebyaddr_async_handleReply +#define getipnodebyname_async_handle_reply getipnodebyname_async_handleReply + +__BEGIN_DECLS + +/* + * Private asynchronous lookup API + */ + +/* + * Cancel an outstanding call and free its resources. + */ +extern void lu_async_call_cancel(mach_port_t p); + +/* + * Make an asynchronous lookupd call. + * Sends data buffer to lookupd and returns a port. + * The buffer must be encoded for lookupd. + */ +extern kern_return_t lu_async_start(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len, void *callback, void *context); +extern kern_return_t lu_async_send(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len); + +/* + * Receive a reply for an asynchronous lookupd call. + * Receives the reply message and gets a raw (undecoded) data buffer. + */ +extern kern_return_t lu_async_receive(mach_port_t p, char **buf, uint32_t *len); + +/* + * Takes a reply message and provides the callback, context, and raw data buffers. + * This routine does not invoke the callback. Type-specific asynchronous + * routines built on top of this API will decode the data buffer and invoke + * the callback routine. + */ +extern int lu_async_handle_reply(void *msg, char **buf, uint32_t *len, void **callback, void **context); + + +/* + * Type-specific routines. + */ + +/* + * getaddrinfo + */ +typedef void (*getaddrinfo_async_callback)(int32_t status, struct addrinfo *res, void *context); +int32_t getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints, getaddrinfo_async_callback callback, void *context); +int32_t getaddrinfo_async_send(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints); +int32_t getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res); +int32_t getaddrinfo_async_handle_reply(void *msg); + + +/* + * getnameinfo + */ +typedef void (*getnameinfo_async_callback)(int32_t status, char *host, char *serv, void *context); +int32_t getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags, getnameinfo_async_callback callback, void *context); +int32_t getnameinfo_async_send(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags); +int32_t getnameinfo_async_receive(mach_port_t p, char **host, char **serv); +int32_t getnameinfo_async_handle_reply(void *msg); + +/* + * DNS + */ +typedef void (*dns_async_callback)(int32_t status, char *buf, uint32_t len, struct sockaddr *from, int fromlen, void *context); +int32_t dns_async_start(mach_port_t *p, const char *name, uint16_t dnsclass, uint16_t dnstype, uint32_t do_search, dns_async_callback callback, void *context); +int32_t dns_async_send(mach_port_t *p, const char *name, uint16_t dnsclass, uint16_t dnstype, uint32_t do_search); +int32_t dns_async_receive(mach_port_t p, char **buf, uint32_t *len, struct sockaddr **from, uint32_t *fromlen); +int32_t dns_async_handle_reply(void *msg); + +/* + * Host lookup asynchronous API + * These routines don't use the asynchronous lookupd access support + * described above. There will eventually be converted. + * The API is syntactically similar. + */ + +/* + @typedef gethostbyaddr_async_callback + @discussion Type of the callback function used when a + gethostbyaddr_async_start() request is delivered. + @param hent The resolved host entry. + @param context The context provided when the request + was initiated. + */ +typedef void (*gethostbyaddr_async_callback)(struct hostent *hent, void *context); + +/*! + @function gethostbyaddr_async_start + @description Asynchronously resolves an Internet address + @param addr The address to be resolved. + @param len The length, in bytes, of the address. + @param type + @param callout The function to be called when the specified + address has been resolved. + @param context A user specified context which will be passed + to the callout function. + @result A mach reply port which will be sent a message when + the addr resolution has completed. This message + should be passed to the gethostbyaddr_async_handleReply + function. A NULL value indicates that no address + was specified or some other error occurred which + prevented the resolution from being started. + */ +mach_port_t +gethostbyaddr_async_start(const char *addr, int len, int type, gethostbyaddr_async_callback callout, void *context); + +/*! + @function gethostbyaddr_async_cancel + @description Cancel an asynchronous request currently in progress. + @param port The mach reply port associated with the request to be cancelled. + */ +void gethostbyaddr_async_cancel(mach_port_t port); + +/*! + @function gethostbyaddr_async_handleReply + @description This function should be called with the Mach message sent + to the port returned by the call to gethostbyaddr_async_start. + The reply message will be interpreted and will result in a + call to the specified callout function. + @param replyMsg The Mach message. + */ +void gethostbyaddr_async_handleReply(void *replyMsg); + +/* + @typedef gethostbyname_async_callback + @discussion Type of the callback function used when a + gethostbyname_async_start() request is delivered. + @param hent The resolved host entry. + @param context The context provided when the request was initiated. + */ +typedef void (*gethostbyname_async_callback)(struct hostent *hent, void *context); + +/*! + @function gethostbyname_async_start + @description Asynchronously resolves a hostname + @param name The hostname to be resolved. + @param callout The function to be called when the specified + hostname has been resolved. + @param context A user specified context which will be passed + to the callout function. + @result A mach reply port which will be sent a message when + the name resolution has completed. This message + should be passed to the gethostbyname_async_handleReply + function. A NULL value indicates that no hostname + was specified or some other error occurred which + prevented the resolution from being started. + */ +mach_port_t gethostbyname_async_start(const char *name, gethostbyname_async_callback callout, void *context); + +/*! + @function gethostbyname_async_cancel + @description Cancel an asynchronous request currently in progress. + @param port The mach reply port associated with the request to be cancelled. + */ +void gethostbyname_async_cancel(mach_port_t port); + +/*! + @function gethostbyname_async_handleReply + @description This function should be called with the Mach message sent + to the port returned by the call to gethostbyname_async_start. + The reply message will be interpreted and will result in a + call to the specified callout function. + @param replyMsg The Mach message. + */ +void gethostbyname_async_handleReply(void *replyMsg); + +/* + @typedef getipnodebyaddr_async_callback + @discussion Type of the callback function used when a + getipnodebyaddr_async_start() request is delivered. + @param hent The resolved host entry. If not NULL, the caller + must call freehostent() on the host entry. + @param error If error code if the resolved host entry is NULL + @param context The context provided when the request was initiated. + */ +typedef void (*getipnodebyaddr_async_callback)(struct hostent *hent, int error, void *context); + +/*! + @function getipnodebyaddr_async_start + @description Asynchronously resolves an Internet address + @param addr The address to be resolved. + @param len The length, in bytes, of the address. + @param af The address family + @param error + @param callout The function to be called when the specified + address has been resolved. + @param context A user specified context which will be passed + to the callout function. + @result A mach reply port which will be sent a message when + the addr resolution has completed. This message + should be passed to the getipnodebyaddr_async_handleReply + function. A NULL value indicates that no address + was specified or some other error occurred which + prevented the resolution from being started. + */ +mach_port_t getipnodebyaddr_async_start(const void *addr, size_t len, int af, int *error, getipnodebyaddr_async_callback callout, void *context); + +/*! + @function getipnodebyaddr_async_cancel + @description Cancel an asynchronous request currently in progress. + @param port The mach reply port associated with the request to be cancelled. + */ +void getipnodebyaddr_async_cancel(mach_port_t port); + +/*! + @function getipnodebyaddr_async_handleReply + @description This function should be called with the Mach message sent + to the port returned by the call to getipnodebyaddr_async_start. + The reply message will be interpreted and will result in a + call to the specified callout function. + @param replyMsg The Mach message. + */ +void getipnodebyaddr_async_handleReply(void *replyMsg); + + +/* + @typedef getipnodebyname_async_callback + @discussion Type of the callback function used when a + getipnodebyname_async_start() request is delivered. + @param hent The resolved host entry. If not NULL, the caller + must call freehostent() on the host entry. + @param error If error code if the resolved host entry is NULL + @param context The context provided when the request was initiated. + */ +typedef void (*getipnodebyname_async_callback)(struct hostent *hent, int error, void *context); + +/*! + @function getipnodebyname_async_start + @description Asynchronously resolves a hostname + @param name The hostname to be resolved. + @param af + @param flags + @param error + @param callout The function to be called when the specified + hostname has been resolved. + @param context A user specified context which will be passed + to the callout function. + @result A mach reply port which will be sent a message when + the name resolution has completed. This message + should be passed to the getipnodebyname_async_handleReply + function. A NULL value indicates that no hostname + was specified or some other error occurred which + prevented the resolution from being started. + */ +mach_port_t getipnodebyname_async_start(const char *name, int af, int flags, int *error, getipnodebyname_async_callback callout, void *context); + +/*! + @function getipnodebyname_async_cancel + @description Cancel an asynchronous request currently in progress. + @param port The mach reply port associated with the request to be cancelled. + */ +void getipnodebyname_async_cancel(mach_port_t port); + +/*! + @function getipnodebyname_async_handleReply + @description This function should be called with the Mach message sent + to the port returned by the call to getipnodebyname_async_start. + The reply message will be interpreted and will result in a + call to the specified callout function. + @param replyMsg The Mach message. + */ +void getipnodebyname_async_handleReply(void *replyMsg); + +__END_DECLS + +#endif /* !_NETDB_ASYNC_H_ */ diff --git a/lookup.subproj/netgr.h b/lookup.subproj/netgr.h index f2b1917..e4ce236 100644 --- a/lookup.subproj/netgr.h +++ b/lookup.subproj/netgr.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/lookup.subproj/printerdb.h b/lookup.subproj/printerdb.h index 8058f4d..e3d8d8c 100644 --- a/lookup.subproj/printerdb.h +++ b/lookup.subproj/printerdb.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mdns.subproj/DNSServiceDiscovery.c b/mdns.subproj/DNSServiceDiscovery.c index 0d01e46..d3ef6a0 100644 --- a/mdns.subproj/DNSServiceDiscovery.c +++ b/mdns.subproj/DNSServiceDiscovery.c @@ -2,21 +2,24 @@ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ @@ -275,6 +278,10 @@ dns_service_discovery_ref DNSServiceRegistrationCreate return NULL; } + if (!txtRecord) { + txtRecord = ""; + } + result = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort); if (result != KERN_SUCCESS) { printf("Mach port receive creation failed, %s\n", mach_error_string(result)); diff --git a/mdns.subproj/DNSServiceDiscovery.h b/mdns.subproj/DNSServiceDiscovery.h index 3cd32f1..68a95dc 100644 --- a/mdns.subproj/DNSServiceDiscovery.h +++ b/mdns.subproj/DNSServiceDiscovery.h @@ -2,21 +2,24 @@ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the -* "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mdns.subproj/DNSServiceDiscoveryDefines.h b/mdns.subproj/DNSServiceDiscoveryDefines.h index 51dffe7..69a9571 100644 --- a/mdns.subproj/DNSServiceDiscoveryDefines.h +++ b/mdns.subproj/DNSServiceDiscoveryDefines.h @@ -2,21 +2,24 @@ * Copyright (c) 2001 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ @@ -25,7 +28,7 @@ #include -#define DNS_SERVICE_DISCOVERY_SERVER "DNSServiceDiscoveryServer" +#define DNS_SERVICE_DISCOVERY_SERVER "com.apple.mDNSResponder" typedef char DNSCString[1024]; typedef char sockaddr_t[128]; diff --git a/mdns.subproj/DNSServiceDiscoveryReply.defs b/mdns.subproj/DNSServiceDiscoveryReply.defs index d26c20b..13991ea 100644 --- a/mdns.subproj/DNSServiceDiscoveryReply.defs +++ b/mdns.subproj/DNSServiceDiscoveryReply.defs @@ -2,21 +2,24 @@ * Copyright (c) 2001 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mdns.subproj/DNSServiceDiscoveryRequest.defs b/mdns.subproj/DNSServiceDiscoveryRequest.defs index 29495f8..589beda 100644 --- a/mdns.subproj/DNSServiceDiscoveryRequest.defs +++ b/mdns.subproj/DNSServiceDiscoveryRequest.defs @@ -2,21 +2,24 @@ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. - * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/mdns.subproj/Makefile b/mdns.subproj/Makefile index 6b2d9b7..18a40c0 100644 --- a/mdns.subproj/Makefile +++ b/mdns.subproj/Makefile @@ -12,14 +12,14 @@ NAME = mdns PROJECTVERSION = 2.8 PROJECT_TYPE = Component -HFILES = DNSServiceDiscoveryDefines.h DNSServiceDiscovery.h +HFILES = DNSServiceDiscoveryDefines.h DNSServiceDiscovery.h dns_sd.h dnssd_ipc.h -CFILES = DNSServiceDiscovery.c +CFILES = DNSServiceDiscovery.c dnssd_clientstub.c dnssd_ipc.c OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\ DNSServiceDiscoveryReply.defs DNSServiceDiscoveryRequest.defs - + MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles CODE_GEN_STYLE = DYNAMIC MAKEFILE = subproj.make @@ -28,6 +28,7 @@ LIBS = DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) +PUBLIC_HEADERS = dns_sd.h diff --git a/mdns.subproj/Makefile.postamble b/mdns.subproj/Makefile.postamble index b00b2ab..11fac3f 100644 --- a/mdns.subproj/Makefile.postamble +++ b/mdns.subproj/Makefile.postamble @@ -99,8 +99,12 @@ # derived files should go. # -mdns_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) - $(SILENT) $(FASTCP) $(MDNS_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) +mdns_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) + $(SILENT) $(FASTCP) $(INTERNAL_MDNS_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) + $(SILENT) $(FASTCP) $(PUBLIC_MDNS_HEADERS) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX): $(MKDIRS) $@ + +$(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX): + $(MKDIRS) $@ diff --git a/mdns.subproj/Makefile.preamble b/mdns.subproj/Makefile.preamble index 2a9ecd4..cde6a14 100644 --- a/mdns.subproj/Makefile.preamble +++ b/mdns.subproj/Makefile.preamble @@ -139,15 +139,18 @@ DSTROOT = $(HOME) # Additional flags (MiG generated files) OTHER_OFILES = DNSServiceDiscoveryRequestUser.o DNSServiceDiscoveryReplyServer.o -#private headers -MDNS_HDRS = DNSServiceDiscoveryRequest.defs DNSServiceDiscoveryRequest.h \ - DNSServiceDiscoveryReply.defs DNSServiceDiscoveryReply.h DNSServiceDiscoveryDefines.h +# private headers +INTERNAL_MDNS_HDRS = DNSServiceDiscoveryRequest.defs\ + DNSServiceDiscoveryRequest.h \ + DNSServiceDiscoveryReply.defs\ + DNSServiceDiscoveryReply.h \ + DNSServiceDiscoveryDefines.h -BEFORE_INSTALLHDRS += $(SFILE_DIR) $(MDNS_HDRS) +# public headers +PUBLIC_MDNS_HEADERS = DNSServiceDiscovery.h + +BEFORE_INSTALLHDRS += $(SFILE_DIR) $(INTERNAL_MDNS_HDRS) AFTER_INSTALLHDRS += mdns_hdrs PRIVATE_HEADER_DIR = /AppleInternal/Developer/Headers MDNS_HEADER_DIR_SUFFIX = /DNSServiceDiscovery -# public headers -OTHER_PUBLIC_HEADERS = DNSServiceDiscovery.h -PUBLIC_HEADER_DIR_SUFFIX = /DNSServiceDiscovery diff --git a/mdns.subproj/PB.project b/mdns.subproj/PB.project index eec7d5c..ee7d0e0 100644 --- a/mdns.subproj/PB.project +++ b/mdns.subproj/PB.project @@ -2,8 +2,8 @@ DYNAMIC_CODE_GEN = YES; English_RESOURCES = {}; FILESTABLE = { - H_FILES = (DNSServiceDiscoveryDefines.h, DNSServiceDiscovery.h); - OTHER_LINKED = (DNSServiceDiscovery.c); + H_FILES = (DNSServiceDiscoveryDefines.h, DNSServiceDiscovery.h, dns_sd.h, dnssd_ipc.h); + OTHER_LINKED = (DNSServiceDiscovery.c, dnssd_clientstub.c, dnssd_ipc.c); OTHER_RESOURCES = (); OTHER_SOURCES = ( Makefile.preamble, @@ -12,7 +12,7 @@ DNSServiceDiscoveryReply.defs, DNSServiceDiscoveryRequest.defs ); - PUBLIC_HEADERS = (); + PUBLIC_HEADERS = (dns_sd.h); SUBPROJECTS = (); }; LANGUAGE = English; diff --git a/mdns.subproj/dns_sd.h b/mdns.subproj/dns_sd.h new file mode 100644 index 0000000..c3bf1f4 --- /dev/null +++ b/mdns.subproj/dns_sd.h @@ -0,0 +1,1013 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _DNS_SD_H +#define _DNS_SD_H + +#include +#include +#include +#include + + +/* DNSServiceRef, DNSRecordRef + * + * Opaque internal data types. + * Note: client is responsible for serializing access to these structures if + * they are shared between concurrent threads. + */ + +typedef struct _DNSServiceRef_t *DNSServiceRef; +typedef struct _DNSRecordRef_t *DNSRecordRef; + +/* General flags used in functions defined below */ +enum + { + kDNSServiceFlagsMoreComing = 1, + kDNSServiceFlagsFinished = 0, /* i.e. bit not set */ + /* MoreComing indicates to a Browse callback that another result is + * queued. Applications should not update their UI to display browse + * results when the MoreComing flag is set, instead deferring the update + * until the callback's flag is Finished. */ + + kDNSServiceFlagsAdd = 2, + kDNSServiceFlagsDefault = 4, + kDNSServiceFlagsRemove = 0, /* i.e. bit not set */ + /* Flags for domain enumeration and browse reply callbacks. + * "Default" applies only to enumeration and is only valid in + * conjuction with "Add" + */ + + kDNSServiceFlagsNoAutoRename = 8, + kDNSServiceFlagsAutoRename = 0, /* i.e. bit not set */ + /* Flag for specifying renaming behavior on name conflict when registering + * non-shared records. NoAutorename is only valid if a name is explicitly + * specified when registering a service (ie the default name is not used.) + */ + + + kDNSServiceFlagsShared = 16, + kDNSServiceFlagsUnique = 32, + /* Flag for registering individual records on a connected + * DNSServiceRef. Shared indicates that there may be multiple records + * with this name on the network (e.g. PTR records). Unique indicates that the + * record's name is to be unique on the network (e.g. SRV records). + */ + + kDNSServiceFlagsBrowseDomains = 64, + kDNSServiceFlagsRegistrationDomains = 128 + /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains. + * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains + * enumerates domains recommended for registration. + */ + }; + +/* possible error code values */ +enum + { + kDNSServiceErr_NoError = 0, + kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */ + kDNSServiceErr_NoSuchName = -65538, + kDNSServiceErr_NoMemory = -65539, + kDNSServiceErr_BadParam = -65540, + kDNSServiceErr_BadReference = -65541, + kDNSServiceErr_BadState = -65542, + kDNSServiceErr_BadFlags = -65543, + kDNSServiceErr_Unsupported = -65544, + kDNSServiceErr_NotInitialized = -65545, + kDNSServiceErr_AlreadyRegistered = -65547, + kDNSServiceErr_NameConflict = -65548, + kDNSServiceErr_Invalid = -65549, + kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */ + kDNSServiceErr_BadinterfaceIndex = -65552 + /* mDNS Error codes are in the range + * FFFE FF00 (-65792) to FFFE FFFF (-65537) */ + }; + + +/* Maximum length, in bytes, of a domain name represented as an escaped C-String */ +#define kDNSServiceMaxDomainName 1005 + + +typedef uint32_t DNSServiceFlags; +typedef int32_t DNSServiceErrorType; + + +/********************************************************************************************* + * + * Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions + * + *********************************************************************************************/ + + +/* DNSServiceRefSockFD() + * + * Access underlying Unix domain socket for an initialized DNSServiceRef. + * The DNS Service Discovery implmementation uses this socket to communicate between + * the client and the mDNSResponder daemon. The application MUST NOT directly read from + * or write to this socket. Access to the socket is provided so that it can be used as a + * run loop source, or in a select() loop: when data is available for reading on the socket, + * DNSServiceProcessResult() should be called, which will extract the daemon's reply from + * the socket, and pass it to the appropriate application callback. By using a run loop or + * select(), results from the daemon can be processed asynchronously. Without using these + * constructs, DNSServiceProcessResult() will block until the response from the daemon arrives. + * The client is responsible for ensuring that the data on the socket is processed in a timely + * fashion - the daemon may terminate its connection with a client that does not clear its + * socket buffer. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls. + * + * return value: The DNSServiceRef's underlying socket descriptor, or -1 on + * error. + */ + +int DNSServiceRefSockFD(DNSServiceRef sdRef); + +/* DNSServiceProcessResult() + * + * Read a reply from the daemon, calling the appropriate application callback. This call will + * block until the daemon's response is received. Use DNSServiceRefSockFD() in + * conjunction with a run loop or select() to determine the presence of a response from the + * server before calling this function to process the reply without blocking. Call this function + * at any point if it is acceptable to block until the daemon's response arrives. Note that the + * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is + * a reply from the daemon - the daemon may terminate its connection with a client that does not + * process the daemon's responses. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls + * that take a callback parameter. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns + * an error code indicating the specific failure that occurred. + */ + +DNSServiceErrorType DNSServiceProcessResult(DNSServiceRef sdRef); + +/* DNSServiceRefDeallocate() + * + * Terminate a connection with the daemon and free memory associated with the DNSServiceRef. + * Any services or records registered with this DNSServiceRef will be deregistered. Any + * Browse, Resolve, or Query operations called with this reference will be terminated. + * + * Note: If the reference's underlying socket is used in a run loop or select() call, it should + * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's + * socket. + * + * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs + * created via this reference will be invalidated by this call - the resource records are + * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly, + * if the reference was initialized with DNSServiceRegister, and an extra resource record was + * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call + * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent + * functions. + * + * Note: This call is to be used only with the DNSServiceRef defined by this API. It is + * not compatible with dns_service_discovery_ref objects defined in the legacy Mach-based + * DNSServiceDiscovery.h API. + * + * sdRef: A DNSServiceRef initialized by any of the DNSService calls. + * + */ + +void DNSServiceRefDeallocate(DNSServiceRef sdRef); + + +/********************************************************************************************* + * + * Domain Enumeration + * + *********************************************************************************************/ + +/* DNSServiceEnumerateDomains() + * + * Asynchronously enumerate domains available for browsing and registration. + * Currently, the only domain returned is "local.", but other domains will be returned in future. + * + * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains + * are to be found. + * + * + * DNSServiceDomainEnumReply Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains(). + * + * flags: Possible values are: + * 1 (MoreComing) + * 2 (Add/Remove) + * 4 (Add Default) + * + * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given + * interface is determined via the if_nametoindex() family of calls.) + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates + * the failure that occurred (other parameters are undefined if errorCode is nonzero). + * + * replyDomain: The name of the domain. + * + * context: The context pointer passed to DNSServiceEnumerateDomains. + * + */ + +typedef void (*DNSServiceDomainEnumReply) + ( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *replyDomain, + void *context + ); + +/* DNSServiceEnumerateDomains() Parameters: + * + * + * sdRef: A pointer to an uninitialized sdRef. May be passed to + * DNSServiceRefDeallocate() to cancel the enumeration. + * + * flags: Possible values are: + * 0 (BrowseDomains) to enumerate domains recommended for browsing. + * 32 (RegistrationDomains) to enumerate domains recommended for registration. + * + * interfaceIndex: If non-zero, specifies the interface on which to look for domains. + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to enumerate domains on + * all interfaces. + * + * callBack: The function to be called when a domain is found or the call asynchronously + * fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is not invoked and the DNSServiceRef + * is not initialized.) + */ + +DNSServiceErrorType DNSServiceEnumerateDomains + ( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceDomainEnumReply callBack, + void *context /* may be NULL */ + ); + +/********************************************************************************************* + * + * Service Registration + * + *********************************************************************************************/ + +/* Register a service that is discovered via Browse() and Resolve() calls. + * + * + * DNSServiceRegisterReply() Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceRegister(). + * + * flags: Currently unused, reserved for future use. + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred (including name conflicts, if the + * kDNSServiceFlagsNoAutoRenameOnConflict flag was passed to the + * callout.) Other parameters are undefined if errorCode is nonzero. + * + * name: The service name registered (if the application did not specify a name in + * DNSServiceRegister(), this indicates what name was automatically chosen). + * + * regtype: The type of service registered, as it was passed to the callout. + * + * domain: The domain on which the service was registered (if the application did not + * specify a domain in DNSServiceRegister(), this indicates the default domain + * on which the service was registered). + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (*DNSServiceRegisterReply) + ( + DNSServiceRef sdRef, + DNSServiceFlags flags, + DNSServiceErrorType errorCode, + const char *name, + const char *regtype, + const char *domain, + void *context + ); + +/* DNSServiceRegister() Parameters: + * + * sdRef: A pointer to an uninitialized sdRef. If this call succeeds, the reference + * may be passed to + * DNSServiceRefDeallocate() to deregister the service. + * + * interfaceIndex: If non-zero, specifies the interface on which to register the service + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to register on all + * available interfaces. Pass -1 to register a service only on the local + * machine (service will not be visible to remote hosts.) + * + * flags: Indicates the renaming behavior on name conflict (most applications + * will pass 0). See flag definitions above for details. + * + * name: If non-NULL, specifies the service name to be registered. + * Most applications will not specify a name, in which case the + * computer name is used (this name is communicated to the client via + * the callback). + * + * regtype: The service type followed by the protocol, separated by a dot + * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp". + * + * domain: If non-NULL, specifies the domain on which to advertise the service. + * Most applications will not specify a domain, instead automatically + * registering in the default domain(s). + * + * host: If non-NULL, specifies the SRV target host name. Most applications + * will not specify a host, instead automatically using the machine's + * default host name(s). Note that specifying a non-NULL host does NOT + * create an address record for that host - the application is responsible + * for ensuring that the appropriate address record exists, or creating it + * via DNSServiceRegisterRecord(). + * + * port: The port on which the service accepts connections. Pass 0 for a + * "placeholder" service (i.e. a service that will not be discovered by + * browsing, but will cause a name conflict if another client tries to + * register that same name.) Most clients will not use placeholder services. + * + * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL. + * + * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord + * MUST be a properly formatted DNS TXT record, i.e. + * ... + * + * callBack: The function to be called when the registration completes or asynchronously + * fails. The client MAY pass NULL for the callback - The client will NOT be notified + * of the default values picked on its behalf, and the client will NOT be notified of any + * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration + * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL. + * The client may still deregister the service at any time via DNSServiceRefDeallocate(). + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized.) + * + */ + +DNSServiceErrorType DNSServiceRegister + ( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *name, /* may be NULL */ + const char *regtype, + const char *domain, /* may be NULL */ + const char *host, /* may be NULL */ + uint16_t port, + uint16_t txtLen, + const void *txtRecord, /* may be NULL */ + DNSServiceRegisterReply callBack, /* may be NULL */ + void *context /* may be NULL */ + ); + +/* DNSServiceAddRecord() + * + * Add a record to a registered service. The name of the record will be the same as the + * registered service's name. + * The record can later be updated or deregistered by passing the RecordRef initialized + * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * + * + * Parameters; + * + * sdRef: A DNSServiceRef initialized by DNSServiceRegister(). + * + * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this + * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also + * invalidated and may not be used further. + * + * flags: Currently ignored, reserved for future use. + * + * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h. + * + * rdlen: The length, in bytes, of the rdata. + * + * rdata: The raw rdata to be contained in the added resource record. + * + * ttl: The time to live of the resource record, in seconds. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred (the RecordRef is not initialized). + */ + +DNSServiceErrorType DNSServiceAddRecord + ( + DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + DNSServiceFlags flags, + uint16_t rrtype, + uint16_t rdlen, + const void *rdata, + uint32_t ttl + ); + +/* DNSServiceUpdateRecord + * + * Update a registered resource record. The record must either be: + * - The primary txt record of a service registered via DNSServiceRegister() + * - A record added to a registered service via DNSServiceAddRecord() + * - An individual record registered by DNSServiceRegisterRecord() + * + * + * Parameters: + * + * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister() + * or DNSServiceCreateConnection(). + * + * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the + * service's primary txt record. + * + * flags: Currently ignored, reserved for future use. + * + * rdlen: The length, in bytes, of the new rdata. + * + * rdata: The new rdata to be contained in the updated resource record. + * + * ttl: The time to live of the updated resource record, in seconds. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred. + */ + +DNSServiceErrorType DNSServiceUpdateRecord + ( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, /* may be NULL */ + DNSServiceFlags flags, + uint16_t rdlen, + const void *rdata, + uint32_t ttl + ); + +/* DNSServiceRemoveRecord + * + * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister + * an record registered individually via DNSServiceRegisterRecord(). + * + * Parameters: + * + * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the + * record being removed was registered via DNSServiceAddRecord()) or by + * DNSServiceCreateConnection() (if the record being removed was registered via + * DNSServiceRegisterRecord()). + * + * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord() + * or DNSServiceRegisterRecord(). + * + * flags: Currently ignored, reserved for future use. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an + * error code indicating the error that occurred. + */ + +DNSServiceErrorType DNSServiceRemoveRecord + ( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, + DNSServiceFlags flags + ); + + +/********************************************************************************************* + * + * Service Discovery + * + *********************************************************************************************/ + + +/* Browse for instances of a service. + * + * + * DNSServiceBrowseReply() Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceBrowse(). + * + * flags: Possible values are MoreComing and Add/Remove. See flag definitions + * for details. + * + * interfaceIndex: The interface on which the service is advertised. This index should + * be passed to DNSServiceResolve() when resolving the service. + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * the errorCode is nonzero. + * + * serviceName: The service name discovered. + * + * regtype: The service type, as passed in to DNSServiceBrowse(). + * + * domain: The domain on which the service was discovered (if the application did not + * specify a domain in DNSServicBrowse(), this indicates the domain on which the + * service was discovered.) + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (*DNSServiceBrowseReply) + ( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *serviceName, + const char *regtype, + const char *replyDomain, + void *context + ); + +/* DNSServiceBrowse() Parameters: + * + * sdRef: A pointer to an uninitialized sdRef. May be passed to + * DNSServiceRefDeallocate() to terminate the browse. + * + * flags: Currently ignored, reserved for future use. + * + * interfaceIndex: If non-zero, specifies the interface on which to browse for services + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Most applications will pass 0 to browse on all available + * interfaces. Pass -1 to only browse for services provided on the local host. + * + * regtype: The service type being browsed for followed by the protocol, separated by a + * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp". + * + * domain: If non-NULL, specifies the domain on which to browse for services. + * Most applications will not specify a domain, instead browsing on the + * default domain(s). + * + * callBack: The function to be called when an instance of the service being browsed for + * is found, or if the call asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is not invoked and the DNSServiceRef + * is not initialized.) + */ + +DNSServiceErrorType DNSServiceBrowse + ( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *regtype, + const char *domain, /* may be NULL */ + DNSServiceBrowseReply callBack, + void *context /* may be NULL */ + ); + +/* DNSServiceResolve() + * + * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and + * txt record. + * + * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use + * DNSServiceQueryRecord() instead, as it is more efficient for this task. + * + * Note: When the desired results have been returned, the client MUST terminate the resolve by calling + * DNSServiceRefDeallocate(). + * + * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record and + * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple + * SRV or TXT records, DNSServiceQueryRecord() should be used. + * + * DNSServiceResolveReply Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceResolve(). + * + * flags: Currently unused, reserved for future use. + * + * interfaceIndex: The interface on which the service was resolved. + * + * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * the errorCode is nonzero. + * + * fullname: The full service domain name, in the form ... + * (Any literal dots (".") are escaped with a backslash ("\."), and literal + * backslashes are escaped with a second backslash ("\\"), e.g. a web server + * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local."). + * This is the appropriate format to pass to standard system DNS APIs such as + * res_query(), or to the special-purpose functions included in this API that + * take fullname parameters. + * + * hosttarget: The target hostname of the machine providing the service. This name can + * be passed to functions like gethostbyname() to identify the host's IP address. + * + * port: The port number on which connections are accepted for this service. + * + * txtLen: The length of the txt record, in bytes. + * + * txtRecord: The service's primary txt record, in standard txt record format. + * + + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (*DNSServiceResolveReply) + ( + DNSServiceRef sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + const char *hosttarget, + uint16_t port, + uint16_t txtLen, + const char *txtRecord, + void *context + ); + +/* DNSServiceResolve() Parameters + * + * sdRef: A pointer to an uninitialized sdRef. May be passed to + * DNSServiceRefDeallocate() to terminate the resolve. + * + * flags: Currently ignored, reserved for future use. + * + * interfaceIndex: The interface on which to resolve the service. The client should + * pass the interface on which the servicename was discovered, i.e. + * the interfaceIndex passed to the DNSServiceBrowseReply callback, + * or 0 to resolve the named service on all available interfaces. + * + * name: The servicename to be resolved. + * + * regtype: The service type being resolved followed by the protocol, separated by a + * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp". + * + * domain: The domain on which the service is registered, i.e. the domain passed + * to the DNSServiceBrowseReply callback. + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized.) + */ + + +DNSServiceErrorType DNSServiceResolve + ( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *name, + const char *regtype, + const char *domain, + DNSServiceResolveReply callBack, + void *context /* may be NULL */ + ); + + +/********************************************************************************************* + * + * Special Purpose Calls (most applications will not use these) + * + *********************************************************************************************/ + +/* DNS Naming Conventions: + * + * The following functions refer to resource records by their full domain name, unlike the above + * functions which divide the name into servicename/regtype/domain fields. In the above functions, + * a dot (".") is considered to be a literal dot in the servicename field (e.g. "Dr. Pepper") and + * a label separator in the regtype ("_ftp._tcp") or domain ("apple.com") fields. Literal dots in + * the domain field would be escaped with a backslash, and literal backslashes would be escaped with + * a second backslash (this is generally not an issue, as domain names on the Internet today almost + * never use characters other than letters, digits, or hyphens, and the dots are label separators.) + * Furthermore, this is transparent to the caller, so long as the fields are passed between functions + * without manipulation. However, the following, special-purpose calls use a single, full domain name. + * As such, all dots are considered to be label separators, unless escaped, and all backslashes are + * considered to be escape characters, unless preceded by a second backslash. For example, the name + * "Dr. Smith \ Dr. Johnson" could be passed literally as a service name parameter in the above calls, + * but in the special purpose call, the dots and backslash would have to be escaped + * (e.g. "Dr\. Smith \\ Dr\. Johnson._ftp._tcp.apple.com" for an ftp service on the apple.com domain.) + */ + +/* DNSServiceConstructFullName() + * + * Concatenate a three-part domain name (as returned by the above callbacks) into a properly-escaped + * full domain name. Note that callbacks in the above functions ALREADY ESCAPE strings where necessary. + * + * Parameters: + * + * fullName: A pointer to a buffer that where the resulting full domain name is to be written. + * The buffer must be kDNSServiceDiscoveryMaxDomainName (1005) bytes in length to + * accommodate the longest legal domain name without buffer overrun. + * + * service: The service name - any dots or slashes must NOT be escaped. + * May be NULL (to construct a PTR record name, e.g. + * "_ftp._tcp.apple.com"). + * + * regtype: The service type followed by the protocol, separated by a dot + * (e.g. "_ftp._tcp"). + * + * domain: The domain name, e.g. "apple.com". Any literal dots or backslashes + * must be escaped. + * + * return value: Returns 0 on success, -1 on error. + * + */ + +int DNSServiceConstructFullName + ( + char *fullName, + const char *service, /* may be NULL */ + const char *regtype, + const char *domain + ); + +/* DNSServiceCreateConnection() + * + * Create a connection to the daemon allowing efficient registration of + * multiple individual records. + * + * + * Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating + * the reference (via DNSServiceRefDeallocate()) severs the + * connection and deregisters all records registered on this connection. + * + * return value: Returns kDNSServiceErr_NoError on success, otherwise returns + * an error code indicating the specific failure that occurred (in which + * case the DNSServiceRef is not initialized). + */ + +DNSServiceErrorType DNSServiceCreateConnection(DNSServiceRef *sdRef); + + +/* DNSServiceRegisterRecord + * + * Register an individual resource record on a connected DNSServiceRef. + * + * Note that name conflicts occurring for records registered via this call must be handled + * by the client in the callback. + * + * + * DNSServiceRegisterRecordReply() parameters: + * + * sdRef: The connected DNSServiceRef initialized by + * DNSServiceDiscoveryConnect(). + * + * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above + * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is + * invalidated, and may not be used further. + * + * flags: Currently unused, reserved for future use. + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred (including name conflicts.) + * Other parameters are undefined if errorCode is nonzero. + * + * context: The context pointer that was passed to the callout. + * + */ + + typedef void (*DNSServiceRegisterRecordReply) + ( + DNSServiceRef sdRef, + DNSRecordRef RecordRef, + DNSServiceFlags flags, + DNSServiceErrorType errorCode, + void *context + ); + + +/* DNSServiceRegisterRecord() Parameters: + * + * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection(). + * + * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this + * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord(). + * (To deregister ALL records registered on a single connected DNSServiceRef + * and deallocate each of their corresponding DNSServiceRecordRefs, call + * DNSServiceRefDealloocate()). + * + * flags: Possible values are Shared/Unique (see flag type definitions for details). + * + * interfaceIndex: If non-zero, specifies the interface on which to register the record + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Passing 0 causes the record to be registered on all interfaces. + * Passing -1 causes the record to only be visible on the local host. + * + * fullname: The full domain name of the resource record. + * + * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined + * in nameser.h. + * + * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the + * Internet class). + * + * rdlen: Length, in bytes, of the rdata. + * + * rdata: A pointer to the raw rdata, as it is to appear in the DNS record. + * + * ttl: The time to live of the resource record, in seconds. + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails (e.g. because of a name conflict.) + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSRecordRef is + * not initialized.) + */ + + +DNSServiceErrorType DNSServiceRegisterRecord + ( + DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata, + uint32_t ttl, + DNSServiceRegisterRecordReply callBack, + void *context /* may be NULL */ + ); + + +/* DNSServiceQueryRecord + * + * Query for an arbitrary DNS record. + * + * + * DNSServiceQueryRecordReply() Callback Parameters: + * + * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord(). + * + * flags: Possible values are Finished/MoreComing. + * + * interfaceIndex: The interface on which the query was resolved (the index for a given + * interface is determined via the if_nametoindex() family of calls). + * + * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will + * indicate the failure that occurred. Other parameters are undefined if + * errorCode is nonzero. + * + * fullname: The resource record's full domain name. + * + * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h. + * + * rrclass: The class of the resource record, as defined in nameser.h (usually 1). + * + * rdlen: The length, in bytes, of the resource record rdata. + * + * rdata: The raw rdata of the resource record. + * + * ttl: The resource record's time to live, in seconds. + * + * context: The context pointer that was passed to the callout. + * + */ + +typedef void (*DNSServiceQueryRecordReply) + ( + DNSServiceRef DNSServiceRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + DNSServiceErrorType errorCode, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata, + uint32_t ttl, + void *context + ); + +/* DNSServiceQueryRecord() Parameters: + * + * sdRef: A pointer to an uninitialized DNSServiceRef. + * + * flags: Currently unused, reserved for future use. + * + * interfaceIndex: If non-zero, specifies the interface on which to issue the query + * (the index for a given interface is determined via the if_nametoindex() + * family of calls.) Passing 0 causes the name to be queried for on all + * interfaces. Passing -1 causes the name to be queried for only on the + * local host. + * + * fullname: The full domain name of the resource record to be queried for. + * + * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc) + * as defined in nameser.h. + * + * rrclass: The class of the resource record, as defined in nameser.h + * (usually 1 for the Internet class). + * + * callBack: The function to be called when a result is found, or if the call + * asynchronously fails. + * + * context: An application context pointer which is passed to the callback function + * (may be NULL). + * + * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous + * errors are delivered to the callback), otherwise returns an error code indicating + * the error that occurred (the callback is never invoked and the DNSServiceRef + * is not initialized.) + */ + +DNSServiceErrorType DNSServiceQueryRecord + ( + DNSServiceRef *sdRef, + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + DNSServiceQueryRecordReply callBack, + void *context /* may be NULL */ + ); + +/* DNSServiceReconfirmRecord + * + * Instruct the daemon to verify the validity of a resource record that appears to + * be out of date (e.g. because tcp connection to a service's target failed.) + * Causes the record to be flushed from the daemon's cache (as well as all other + * daemons' caches on the network) if the record is determined to be invalid. + * + * Parameters: + * + * flags: Currently unused, reserved for future use. + * + * fullname: The resource record's full domain name. + * + * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h. + * + * rrclass: The class of the resource record, as defined in nameser.h (usually 1). + * + * rdlen: The length, in bytes, of the resource record rdata. + * + * rdata: The raw rdata of the resource record. + * + */ + +void DNSServiceReconfirmRecord + ( + DNSServiceFlags flags, + uint32_t interfaceIndex, + const char *fullname, + uint16_t rrtype, + uint16_t rrclass, + uint16_t rdlen, + const void *rdata + ); + + +#endif // _DNS_SD_H + diff --git a/mdns.subproj/dnssd_clientstub.c b/mdns.subproj/dnssd_clientstub.c new file mode 100644 index 0000000..eed342f --- /dev/null +++ b/mdns.subproj/dnssd_clientstub.c @@ -0,0 +1,992 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include "dnssd_ipc.h" +#include +#include + + + +#define CTL_PATH_PREFIX "/tmp/dnssd_clippath." +// error socket (if needed) is named "dnssd_clipath.[pid].xxx:n" where xxx are the +// last 3 digits of the time (in seconds) and n is the 6-digit microsecond time + +// general utility functions +static DNSServiceRef connect_to_server(void); +DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reuse_sd); +static ipc_msg_hdr *create_hdr(int op, int *len, char **data_start, int reuse_socket); +static int my_read(int sd, char *buf, int len); +static int my_write(int sd, char *buf, int len); +static int domain_ends_in_dot(const char *dom); +// server response handlers +static void handle_query_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *msg); +static void handle_browse_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data); +static void handle_regservice_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data); +static void handle_regrecord_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data); +static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data); +static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data); + +typedef struct _DNSServiceRef_t + { + int sockfd; // connected socket between client and daemon + int op; // request/reply_op_t + process_reply_callback process_reply; + void *app_callback; + void *app_context; + uint32_t max_index; //largest assigned record index - 0 if no additl. recs registered + } _DNSServiceRef_t; + +typedef struct _DNSRecordRef_t + { + void *app_context; + DNSServiceRegisterRecordReply app_callback; + DNSRecordRef recref; + int record_index; // index is unique to the ServiceDiscoveryRef + DNSServiceRef sdr; + } _DNSRecordRef_t; + + +// exported functions + +int DNSServiceRefSockFD(DNSServiceRef sdRef) + { + if (!sdRef) return -1; + return sdRef->sockfd; + } + +// handle reply from server, calling application client callback. If there is no reply +// from the daemon on the socket contained in sdRef, the call will block. +DNSServiceErrorType DNSServiceProcessResult(DNSServiceRef sdRef) + { + ipc_msg_hdr hdr; + char *data; + + if (!sdRef || sdRef->sockfd < 0 || !sdRef->process_reply) + return kDNSServiceErr_BadReference; + + if (my_read(sdRef->sockfd, (void *)&hdr, sizeof(hdr)) < 0) + return kDNSServiceErr_Unknown; + if (hdr.version != VERSION) + return kDNSServiceErr_Incompatible; + data = malloc(hdr.datalen); + if (!data) return kDNSServiceErr_NoMemory; + if (my_read(sdRef->sockfd, data, hdr.datalen) < 0) + return kDNSServiceErr_Unknown; + sdRef->process_reply(sdRef, &hdr, data); + free(data); + return kDNSServiceErr_NoError; + } + + +void DNSServiceRefDeallocate(DNSServiceRef sdRef) + { + if (!sdRef) return; + if (sdRef->sockfd > 0) close(sdRef->sockfd); + free(sdRef); + } + + +DNSServiceErrorType DNSServiceResolve + ( + DNSServiceRef *sdRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *name, + const char *regtype, + const char *domain, + const DNSServiceResolveReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef sdr; + DNSServiceErrorType err; + + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = NULL; + + // calculate total message length + len = sizeof(flags); + len += sizeof(interfaceIndex); + len += strlen(name) + 1; + len += strlen(regtype) + 1; + len += strlen(domain) + 1; + + hdr = create_hdr(resolve_request, &len, &ptr, 1); + if (!hdr) goto error; + msg = (void *)hdr; + + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(name, &ptr); + put_string(regtype, &ptr); + put_string(domain, &ptr); + + sdr = connect_to_server(); + if (!sdr) goto error; + err = deliver_request(msg, sdr, 1); + if (err) + { + DNSServiceRefDeallocate(sdr); + return err; + } + sdr->op = resolve_request; + sdr->process_reply = handle_resolve_response; + sdr->app_callback = callBack; + sdr->app_context = context; + *sdRef = sdr; + + return err; + +error: + if (msg) free(msg); + if (*sdRef) { free(*sdRef); *sdRef = NULL; } + return kDNSServiceErr_Unknown; + } + + +static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + char fullname[kDNSServiceMaxDomainName]; + char target[kDNSServiceMaxDomainName]; + uint16_t port, txtlen; + uint32_t ifi; + DNSServiceErrorType err; + char *txtrecord; + + (void)hdr; //unused + + flags = get_flags(&data); + ifi = get_long(&data); + err = get_error_code(&data); + get_string(&data, fullname, kDNSServiceMaxDomainName); + get_string(&data, target, kDNSServiceMaxDomainName); + port = get_short(&data); + txtlen = get_short(&data); + txtrecord = get_rdata(&data, txtlen); + + ((DNSServiceResolveReply)sdr->app_callback)(sdr, flags, ifi, err, fullname, target, port, txtlen, txtrecord, sdr->app_context); + } + + + + +DNSServiceErrorType DNSServiceQueryRecord +( + DNSServiceRef *sdRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *name, + const uint16_t rrtype, + const uint16_t rrclass, + const DNSServiceQueryRecordReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef sdr; + DNSServiceErrorType err; + + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = NULL; + + if (!name) name = "\0"; + + // calculate total message length + len = sizeof(flags); + len += sizeof(uint32_t); //interfaceIndex + len += strlen(name) + 1; + len += 2 * sizeof(uint16_t); // rrtype, rrclass + + hdr = create_hdr(query_request, &len, &ptr, 1); + if (!hdr) goto error; + msg = (void *)hdr; + + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(name, &ptr); + put_short(rrtype, &ptr); + put_short(rrclass, &ptr); + + sdr = connect_to_server(); + if (!sdr) goto error; + err = deliver_request(msg, sdr, 1); + if (err) + { + DNSServiceRefDeallocate(sdr); + return err; + } + + sdr->op = query_request; + sdr->process_reply = handle_query_response; + sdr->app_callback = callBack; + sdr->app_context = context; + *sdRef = sdr; + return err; + +error: + if (msg) free(msg); + if (*sdRef) { free(*sdRef); *sdRef = NULL; } + return kDNSServiceErr_Unknown; + } + + +static void handle_query_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + uint32_t interfaceIndex, ttl; + DNSServiceErrorType errorCode; + char name[256]; + uint16_t rrtype, rrclass, rdlen; + char *rdata; + (void)hdr;//Unused + + flags = get_flags(&data); + interfaceIndex = get_long(&data); + errorCode = get_error_code(&data); + (get_string(&data, name, 256) < 0); + rrtype = get_short(&data); + rrclass = get_short(&data); + rdlen = get_short(&data); + rdata = get_rdata(&data, rdlen); + ttl = get_long(&data); + if (!rdata) return; + ((DNSServiceQueryRecordReply)sdr->app_callback)(sdr, flags, interfaceIndex, errorCode, name, rrtype, rrclass, + rdlen, rdata, ttl, sdr->app_context); + return; + } + +DNSServiceErrorType DNSServiceBrowse +( + DNSServiceRef *sdRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *regtype, + const char *domain, + const DNSServiceBrowseReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef sdr; + DNSServiceErrorType err; + + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = NULL; + + if (!domain) domain = ""; + + len = sizeof(flags); + len += sizeof(interfaceIndex); + len += strlen(regtype) + 1; + len += strlen(domain) + 1; + + hdr = create_hdr(browse_request, &len, &ptr, 1); + if (!hdr) goto error; + msg = (char *)hdr; + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(regtype, &ptr); + put_string(domain, &ptr); + + sdr = connect_to_server(); + if (!sdr) goto error; + err = deliver_request(msg, sdr, 1); + if (err) + { + DNSServiceRefDeallocate(sdr); + return err; + } + sdr->op = browse_request; + sdr->process_reply = handle_browse_response; + sdr->app_callback = callBack; + sdr->app_context = context; + *sdRef = sdr; + return err; + +error: + if (msg) free(msg); + if (*sdRef) { free(*sdRef); *sdRef = NULL; } + return kDNSServiceErr_Unknown; + } + + + + +static void handle_browse_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + uint32_t interfaceIndex; + DNSServiceErrorType errorCode; + char replyName[256], replyType[256], replyDomain[256]; + (void)hdr;//Unused + + flags = get_flags(&data); + interfaceIndex = get_long(&data); + errorCode = get_error_code(&data); + get_string(&data, replyName, 256); + get_string(&data, replyType, 256); + get_string(&data, replyDomain, 256); + ((DNSServiceBrowseReply)sdr->app_callback)(sdr, flags, interfaceIndex, errorCode, replyName, replyType, replyDomain, sdr->app_context); + } + + +DNSServiceErrorType DNSServiceRegister + ( + DNSServiceRef *sdRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *name, + const char *regtype, + const char *domain, + const char *host, + const uint16_t port, + const uint16_t txtLen, + const void *txtRecord, + const DNSServiceRegisterReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef sdr; + DNSServiceErrorType err; + + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = NULL; + + if (!name) name = ""; + if (!regtype) return kDNSServiceErr_BadParam; + if (!domain) domain = ""; + if (!host) host = ""; + if (!txtRecord) (char *)txtRecord = ""; + + // auto-name must also have auto-rename + if (!name[0] && (flags & kDNSServiceFlagsNoAutoRename)) + return kDNSServiceErr_BadParam; + + // no callback must have auto-name + if (!callBack && name[0]) return kDNSServiceErr_BadParam; + + len = sizeof(DNSServiceFlags); + len += sizeof(uint32_t); // interfaceIndex + len += strlen(name) + strlen(regtype) + strlen(domain) + strlen(host) + 4; + len += 2 * sizeof(uint16_t); // port, txtLen + len += txtLen; + + hdr = create_hdr(reg_service_request, &len, &ptr, 1); + if (!hdr) goto error; + if (!callBack) hdr->flags |= IPC_FLAGS_NOREPLY; + msg = (char *)hdr; + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(name, &ptr); + put_string(regtype, &ptr); + put_string(domain, &ptr); + put_string(host, &ptr); + put_short(port, &ptr); + put_short(txtLen, &ptr); + put_rdata(txtLen, txtRecord, &ptr); + + sdr = connect_to_server(); + if (!sdr) goto error; + err = deliver_request(msg, sdr, 1); + if (err) + { + DNSServiceRefDeallocate(sdr); + return err; + } + + sdr->op = reg_service_request; + sdr->process_reply = callBack ? handle_regservice_response : NULL; + sdr->app_callback = callBack; + sdr->app_context = context; + *sdRef = sdr; + + return err; + +error: + if (msg) free(msg); + if (*sdRef) { free(*sdRef); *sdRef = NULL; } + return kDNSServiceErr_Unknown; + } + + +static void handle_regservice_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + uint32_t interfaceIndex; + DNSServiceErrorType errorCode; + char name[256], regtype[256], domain[256]; + (void)hdr;//Unused + + flags = get_flags(&data); + interfaceIndex = get_long(&data); + errorCode = get_error_code(&data); + get_string(&data, name, 256); + get_string(&data, regtype, 256); + get_string(&data, domain, 256); + ((DNSServiceRegisterReply)sdr->app_callback)(sdr, flags, errorCode, name, regtype, domain, sdr->app_context); + } + +DNSServiceErrorType DNSServiceEnumerateDomains +( + DNSServiceRef *sdRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const DNSServiceDomainEnumReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef sdr; + DNSServiceErrorType err; + + + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = NULL; + + len = sizeof(DNSServiceFlags); + len += sizeof(uint32_t); + + hdr = create_hdr(enumeration_request, &len, &ptr, 1); + if (!hdr) goto error; + msg = (void *)hdr; + + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + + sdr = connect_to_server(); + if (!sdr) goto error; + err = deliver_request(msg, sdr, 1); + if (err) + { + DNSServiceRefDeallocate(sdr); + return err; + } + + sdr->op = enumeration_request; + sdr->process_reply = handle_enumeration_response; + sdr->app_callback = callBack; + sdr->app_context = context; + *sdRef = sdr; + return err; + +error: + if (msg) free(msg); + if (*sdRef) { free(*sdRef); *sdRef = NULL; } + return kDNSServiceErr_Unknown; + } + + +static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + uint32_t interfaceIndex; + DNSServiceErrorType err; + char domain[256]; + (void)hdr;//Unused + + flags = get_flags(&data); + interfaceIndex = get_long(&data); + err = get_error_code(&data); + get_string(&data, domain, 256); + ((DNSServiceDomainEnumReply)sdr->app_callback)(sdr, flags, interfaceIndex, err, domain, sdr->app_context); + } + + +DNSServiceErrorType DNSServiceCreateConnection(DNSServiceRef *sdRef) + { + if (!sdRef) return kDNSServiceErr_BadParam; + *sdRef = connect_to_server(); + if (!*sdRef) + return kDNSServiceErr_Unknown; + (*sdRef)->op = connection; + (*sdRef)->process_reply = handle_regrecord_response; + return 0; + } + + + +static void handle_regrecord_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data) + { + DNSServiceFlags flags; + uint32_t interfaceIndex; + DNSServiceErrorType errorCode; + DNSRecordRef rref = hdr->client_context.context; + + if (sdr->op != connection) + { + rref->app_callback(rref->sdr, rref, 0, kDNSServiceErr_Unknown, rref->app_context); + return; + } + flags = get_flags(&data); + interfaceIndex = get_long(&data); + errorCode = get_error_code(&data); + + rref->app_callback(rref->sdr, rref, flags, errorCode, rref->app_context); + } + +DNSServiceErrorType DNSServiceRegisterRecord +( + const DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *fullname, + const uint16_t rrtype, + const uint16_t rrclass, + const uint16_t rdlen, + const void *rdata, + const uint32_t ttl, + const DNSServiceRegisterRecordReply callBack, + void *context + ) + { + char *msg = NULL, *ptr; + int len; + ipc_msg_hdr *hdr = NULL; + DNSServiceRef tmp = NULL; + DNSRecordRef rref = NULL; + + if (!sdRef || sdRef->op != connection || sdRef->sockfd < 0) + return kDNSServiceErr_BadReference; + *RecordRef = NULL; + + len = sizeof(DNSServiceFlags); + len += 2 * sizeof(uint32_t); // interfaceIndex, ttl + len += 3 * sizeof(uint16_t); // rrtype, rrclass, rdlen + len += strlen(fullname) + 1; + len += rdlen; + + hdr = create_hdr(reg_record_request, &len, &ptr, 0); + if (!hdr) goto error; + msg = (char *)hdr; + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(fullname, &ptr); + put_short(rrtype, &ptr); + put_short(rrclass, &ptr); + put_short(rdlen, &ptr); + put_rdata(rdlen, rdata, &ptr); + put_long(ttl, &ptr); + + rref = malloc(sizeof(_DNSRecordRef_t)); + if (!rref) goto error; + rref->app_context = context; + rref->app_callback = callBack; + rref->record_index = sdRef->max_index++; + rref->sdr = sdRef; + *RecordRef = rref; + hdr->client_context.context = rref; + hdr->reg_index = rref->record_index; + + return deliver_request(msg, sdRef, 0); + +error: + if (rref) free(rref); + if (tmp) free(tmp); + if (hdr) free(hdr); + return kDNSServiceErr_Unknown; + } + +//sdRef returned by DNSServiceRegister() +DNSServiceErrorType DNSServiceAddRecord + ( + const DNSServiceRef sdRef, + DNSRecordRef *RecordRef, + const DNSServiceFlags flags, + const uint16_t rrtype, + const uint16_t rdlen, + const void *rdata, + const uint32_t ttl + ) + { + ipc_msg_hdr *hdr; + int len = 0; + char *ptr; + DNSRecordRef rref; + + if (!sdRef || (sdRef->op != reg_service_request) || !RecordRef) + return kDNSServiceErr_BadReference; + *RecordRef = NULL; + + len += 2 * sizeof(uint16_t); //rrtype, rdlen + len += rdlen; + len += sizeof(uint32_t); + len += sizeof(DNSServiceFlags); + + hdr = create_hdr(add_record_request, &len, &ptr, 0); + if (!hdr) return kDNSServiceErr_Unknown; + put_flags(flags, &ptr); + put_short(rrtype, &ptr); + put_short(rdlen, &ptr); + put_rdata(rdlen, rdata, &ptr); + put_long(ttl, &ptr); + + rref = malloc(sizeof(_DNSRecordRef_t)); + if (!rref) goto error; + rref->app_context = NULL; + rref->app_callback = NULL; + rref->record_index = sdRef->max_index++; + rref->sdr = sdRef; + *RecordRef = rref; + hdr->client_context.context = rref; + hdr->reg_index = rref->record_index; + return deliver_request((char *)hdr, sdRef, 0); + +error: + if (hdr) free(hdr); + if (rref) free(rref); + if (*RecordRef) *RecordRef = NULL; + return kDNSServiceErr_Unknown; +} + + +//DNSRecordRef returned by DNSServiceRegisterRecord or DNSServiceAddRecord +DNSServiceErrorType DNSServiceUpdateRecord + ( + const DNSServiceRef sdRef, + DNSRecordRef RecordRef, + const DNSServiceFlags flags, + const uint16_t rdlen, + const void *rdata, + const uint32_t ttl + ) + { + ipc_msg_hdr *hdr; + int len = 0; + char *ptr; + + if (!sdRef || !RecordRef || !sdRef->max_index) + return kDNSServiceErr_BadReference; + + len += sizeof(uint16_t); + len += rdlen; + len += sizeof(uint32_t); + len += sizeof(DNSServiceFlags); + + hdr = create_hdr(update_record_request, &len, &ptr, 0); + if (!hdr) return kDNSServiceErr_Unknown; + hdr->reg_index = RecordRef ? RecordRef->record_index : TXT_RECORD_INDEX; + put_flags(flags, &ptr); + put_short(rdlen, &ptr); + put_rdata(rdlen, rdata, &ptr); + put_long(ttl, &ptr); + return deliver_request((char *)hdr, sdRef, 0); + } + + + +DNSServiceErrorType DNSServiceRemoveRecord +( + const DNSServiceRef sdRef, + const DNSRecordRef RecordRef, + const DNSServiceFlags flags + ) + { + ipc_msg_hdr *hdr; + int len = 0; + char *ptr; + DNSServiceErrorType err; + + if (!sdRef || !RecordRef || !sdRef->max_index) + return kDNSServiceErr_BadReference; + + len += sizeof(flags); + hdr = create_hdr(remove_record_request, &len, &ptr, 0); + if (!hdr) return kDNSServiceErr_Unknown; + hdr->reg_index = RecordRef->record_index; + put_flags(flags, &ptr); + err = deliver_request((char *)hdr, sdRef, 0); + if (!err) free(RecordRef); + return err; + } + + +void DNSServiceReconfirmRecord +( + const DNSServiceFlags flags, + const uint32_t interfaceIndex, + const char *fullname, + const uint16_t rrtype, + const uint16_t rrclass, + const uint16_t rdlen, + const void *rdata + ) + { + char *ptr; + int len; + ipc_msg_hdr *hdr; + DNSServiceRef tmp; + + len = sizeof(DNSServiceFlags); + len += sizeof(uint32_t); + len += strlen(fullname) + 1; + len += 3 * sizeof(uint16_t); + len += rdlen; + tmp = connect_to_server(); + if (!tmp) return; + hdr = create_hdr(reconfirm_record_request, &len, &ptr, 1); + if (!hdr) return; + + put_flags(flags, &ptr); + put_long(interfaceIndex, &ptr); + put_string(fullname, &ptr); + put_short(rrtype, &ptr); + put_short(rrclass, &ptr); + put_short(rdlen, &ptr); + put_rdata(rdlen, rdata, &ptr); + my_write(tmp->sockfd, (char *)hdr, len); + DNSServiceRefDeallocate(tmp); + } + + +int DNSServiceConstructFullName + ( + char *fullName, + const char *service, /* may be NULL */ + const char *regtype, + const char *domain + ) + { + int len; + u_char c; + char *fn = fullName; + const char *s = service; + const char *r = regtype; + const char *d = domain; + + if (service) + { + while(*s) + { + c = *s++; + if (c == '.' || (c == '\\')) *fn++ = '\\'; // escape dot and backslash literals + else if (c <= ' ') // escape non-printable characters + { + *fn++ = '\\'; + *fn++ = (char) ('0' + (c / 100)); + *fn++ = (char) ('0' + (c / 10) % 10); + c = (u_char)('0' + (c % 10)); + } + *fn++ = c; + } + *fn++ = '.'; + } + + if (!regtype) return -1; + len = strlen(regtype); + if (domain_ends_in_dot(regtype)) len--; + if (len < 4) return -1; // regtype must end in _udp or _tcp + if (strncmp((regtype + len - 4), "_tcp", 4) && strncmp((regtype + len - 4), "_udp", 4)) return -1; + while(*r) + *fn++ = *r++; + if (!domain_ends_in_dot(regtype)) *fn++ = '.'; + + if (!domain) return -1; + len = strlen(domain); + if (!len) return -1; + while(*d) + *fn++ = *d++; + if (!domain_ends_in_dot(domain)) *fn++ = '.'; + *fn = '\0'; + return 0; + } + +static int domain_ends_in_dot(const char *dom) + { + while(*dom && *(dom + 1)) + { + if (*dom == '\\') // advance past escaped byte sequence + { + if (*(dom + 1) >= '0' && *(dom + 1) <= '9') dom += 4; + else dom += 2; + } + else dom++; // else read one character + } + return (*dom == '.'); + } + + + + // return a connected service ref (deallocate with DNSServiceRefDeallocate) +static DNSServiceRef connect_to_server(void) + { + struct sockaddr_un saddr; + DNSServiceRef sdr; + + sdr = malloc(sizeof(_DNSServiceRef_t)); + if (!sdr) return NULL; + + if ((sdr->sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) + { + free(sdr); + return NULL; + } + + saddr.sun_family = AF_LOCAL; + strcpy(saddr.sun_path, MDNS_UDS_SERVERPATH); + if (connect(sdr->sockfd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) + { + free(sdr); + return NULL; + } + return sdr; + } + + + + +int my_write(int sd, char *buf, int len) + { + if (send(sd, buf, len, MSG_WAITALL) != len) return -1; + return 0; + } + + +// read len bytes. return 0 on success, -1 on error +int my_read(int sd, char *buf, int len) + { + if (recv(sd, buf, len, MSG_WAITALL) != len) return -1; + return 0; + } + + +DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reuse_sd) + { + ipc_msg_hdr *hdr = msg; + mode_t mask; + struct sockaddr_un caddr, daddr; // (client and daemon address structs) + char *path = NULL; + int listenfd = -1, errsd = -1, len; + DNSServiceErrorType err = kDNSServiceErr_Unknown; + + if (!hdr || sdr->sockfd < 0) return kDNSServiceErr_Unknown; + + if (!reuse_sd) + { + // setup temporary error socket + if ((listenfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) + goto cleanup; + + bzero(&caddr, sizeof(caddr)); + caddr.sun_family = AF_LOCAL; + caddr.sun_len = sizeof(struct sockaddr_un); + path = (char *)msg + sizeof(ipc_msg_hdr); + strcpy(caddr.sun_path, path); + mask = umask(0); + if (bind(listenfd, (struct sockaddr *)&caddr, sizeof(caddr)) < 0) + { + umask(mask); + goto cleanup; + } + umask(mask); + listen(listenfd, 1); + } + + if (my_write(sdr->sockfd, msg, hdr->datalen + sizeof(ipc_msg_hdr)) < 0) + goto cleanup; + free(msg); + msg = NULL; + + if (reuse_sd) errsd = sdr->sockfd; + else + { + len = sizeof(daddr); + errsd = accept(listenfd, (struct sockaddr *)&daddr, &len); + if (errsd < 0) goto cleanup; + } + + len = recv(errsd, &err, sizeof(err), MSG_WAITALL); + if (len != sizeof(err)) + { + err = kDNSServiceErr_Unknown; + } +cleanup: + if (!reuse_sd && listenfd > 0) close(listenfd); + if (!reuse_sd && errsd > 0) close(errsd); + if (!reuse_sd && path) unlink(path); + if (msg) free(msg); + return err; + } + + + +/* create_hdr + * + * allocate and initialize an ipc message header. value of len should initially be the + * length of the data, and is set to the value of the data plus the header. data_start + * is set to point to the beginning of the data section. reuse_socket should be non-zero + * for calls that can receive an immediate error return value on their primary socket. + * if zero, the path to a control socket is appended at the beginning of the message buffer. + * data_start is set past this string. + */ + +static ipc_msg_hdr *create_hdr(int op, int *len, char **data_start, int reuse_socket) + { + char *msg = NULL; + ipc_msg_hdr *hdr; + int datalen; + char ctrl_path[256]; + struct timeval time; + + if (!reuse_socket) + { + if (gettimeofday(&time, NULL) < 0) return NULL; + sprintf(ctrl_path, "%s%d-%.3x-%.6u", CTL_PATH_PREFIX, (int)getpid(), + time.tv_sec & 0xFFF, time.tv_usec); + + *len += strlen(ctrl_path) + 1; + } + + + datalen = *len; + *len += sizeof(ipc_msg_hdr); + + // write message to buffer + msg = malloc(*len); + if (!msg) return NULL; + + bzero(msg, *len); + hdr = (void *)msg; + hdr->datalen = datalen; + hdr->version = VERSION; + hdr->op.request_op = op; + if (reuse_socket) hdr->flags |= IPC_FLAGS_REUSE_SOCKET; + *data_start = msg + sizeof(ipc_msg_hdr); + if (!reuse_socket) put_string(ctrl_path, data_start); + return hdr; + } diff --git a/mdns.subproj/dnssd_ipc.c b/mdns.subproj/dnssd_ipc.c new file mode 100644 index 0000000..d2a36c7 --- /dev/null +++ b/mdns.subproj/dnssd_ipc.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#include "dnssd_ipc.h" + + +void put_flags(const DNSServiceFlags flags, char **ptr) + { + memcpy(*ptr, &flags, sizeof(DNSServiceFlags)); + *ptr += sizeof(flags); + } + +DNSServiceFlags get_flags(char **ptr) + { + DNSServiceFlags flags; + + flags = *(DNSServiceFlags *)*ptr; + *ptr += sizeof(DNSServiceFlags); + return flags; + } + +void put_long(const uint32_t l, char **ptr) + { + + *(uint32_t *)(*ptr) = l; + *ptr += sizeof(uint32_t); + } + +uint32_t get_long(char **ptr) + { + uint32_t l; + + l = *(uint32_t *)(*ptr); + *ptr += sizeof(uint32_t); + return l; + } + +void put_error_code(const DNSServiceErrorType error, char **ptr) + { + memcpy(*ptr, &error, sizeof(error)); + *ptr += sizeof(DNSServiceErrorType); + } + +DNSServiceErrorType get_error_code(char **ptr) + { + DNSServiceErrorType error; + + error = *(DNSServiceErrorType *)(*ptr); + *ptr += sizeof(DNSServiceErrorType); + return error; + } + +void put_short(const uint16_t s, char **ptr) + { + *(uint16_t *)(*ptr) = s; + *ptr += sizeof(uint16_t); + } + +uint16_t get_short(char **ptr) + { + uint16_t s; + + s = *(uint16_t *)(*ptr); + *ptr += sizeof(uint16_t); + return s; + } + + +int put_string(const char *str, char **ptr) + { + if (!str) str = ""; + strcpy(*ptr, str); + *ptr += strlen(str) + 1; + return 0; + } + +// !!!KRS we don't properly handle the case where the string is longer than the buffer!!! +int get_string(char **ptr, char *buffer, int buflen) + { + int overrun; + + overrun = (int)strlen(*ptr) < buflen ? 0 : -1; + strncpy(buffer, *ptr, buflen - 1); + buffer[buflen - 1] = '\0'; + *ptr += strlen(buffer) + 1; + return overrun; + } + +void put_rdata(const int rdlen, const char *rdata, char **ptr) + { + memcpy(*ptr, rdata, rdlen); + *ptr += rdlen; + } + +char *get_rdata(char **ptr, int rdlen) + { + char *rd; + + rd = *ptr; + *ptr += rdlen; + return rd; + } + + + + + + + + + diff --git a/mdns.subproj/dnssd_ipc.h b/mdns.subproj/dnssd_ipc.h new file mode 100644 index 0000000..e83d3ac --- /dev/null +++ b/mdns.subproj/dnssd_ipc.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + + + +#ifndef DNSSD_IPC_H +#define DNSSD_IPC_H + +#include "dns_sd.h" +#include +#include +#include +#include +#include +#include +#include + +#define UDSDEBUG // verbose debug output + +// General UDS constants +#define MDNS_UDS_SERVERPATH "/var/run/mDNSResponder" +#define LISTENQ 100 +#define TXT_RECORD_INDEX -1 // record index for default text record +#define MAX_CTLPATH 256 // longest legal control path length + +// IPC data encoding constants and types +#define VERSION 1 +#define IPC_FLAGS_NOREPLY 1 // set flag if no asynchronous replies are to be sent to client +#define IPC_FLAGS_REUSE_SOCKET 2 // set flag if synchronous errors are to be sent via the primary socket + // (if not set, first string in message buffer must be path to error socket + + +typedef enum + { + connection = 1, // connected socket via DNSServiceConnect() + reg_record_request, // reg/remove record only valid for connected sockets + remove_record_request, + enumeration_request, + reg_service_request, + browse_request, + resolve_request, + query_request, + reconfirm_record_request, + add_record_request, + update_record_request + } request_op_t; + +typedef enum + { + enumeration_reply = 64, + reg_service_reply, + browse_reply, + resolve_reply, + query_reply, + reg_record_reply + } reply_op_t; + + +typedef struct ipc_msg_hdr_struct ipc_msg_hdr; + + +// client stub callback to process message from server and deliver results to +// client application + +typedef void (*process_reply_callback) + ( + DNSServiceRef sdr, + ipc_msg_hdr *hdr, + char *msg + ); + +// allow 64-bit client to interoperate w/ 32-bit daemon +typedef union + { + void *context; + uint32_t ptr64[2]; + } client_context_t; + + +typedef struct ipc_msg_hdr_struct + { + uint32_t version; + uint32_t datalen; + uint32_t flags; + union + { + request_op_t request_op; + reply_op_t reply_op; + } op; + client_context_t client_context; // context passed from client, returned by server in corresponding reply + int reg_index; // identifier for a record registered via DNSServiceRegisterRecord() on a + // socket connected by DNSServiceConnect(). Must be unique in the scope of the connection, such that and + // index/socket pair uniquely identifies a record. (Used to select records for removal by DNSServiceRemoveRecord()) + } ipc_msg_hdr_struct; + + + + +// routines to write to and extract data from message buffers. +// caller responsible for bounds checking. +// ptr is the address of the pointer to the start of the field. +// it is advanced to point to the next field, or the end of the message + + +void put_flags(const DNSServiceFlags flags, char **ptr); +DNSServiceFlags get_flags(char **ptr); + +void put_long(const uint32_t l, char **ptr); +uint32_t get_long(char **ptr); + +void put_error_code(const DNSServiceErrorType, char **ptr); +DNSServiceErrorType get_error_code(char **ptr); + +int put_string(const char *str, char **ptr); +int get_string(char **ptr, char *buffer, int buflen); + +void put_rdata(const int rdlen, const char *rdata, char **ptr); +char *get_rdata(char **ptr, int rdlen); // return value is rdata pointed to by *ptr - + // rdata is not copied from buffer. + +void put_short(uint16_t s, char **ptr); +uint16_t get_short(char **ptr); + + + +#endif // DNSSD_IPC_H + + + + + + + + + + + diff --git a/netinfo.subproj/Makefile b/netinfo.subproj/Makefile index 4861159..015435b 100644 --- a/netinfo.subproj/Makefile +++ b/netinfo.subproj/Makefile @@ -29,7 +29,7 @@ DEBUG_LIBS = $(LIBS) PROF_LIBS = $(LIBS) -PUBLIC_HEADERS = ni.h ni_util.h nibind_prot.x ni_prot.x +PRIVATE_HEADERS = ni.h ni_util.h nibind_prot.x ni_prot.x diff --git a/netinfo.subproj/Makefile.preamble b/netinfo.subproj/Makefile.preamble index 680d1b6..e90b6f4 100644 --- a/netinfo.subproj/Makefile.preamble +++ b/netinfo.subproj/Makefile.preamble @@ -2,6 +2,6 @@ OTHER_OFILES = nibind_prot_clnt.o ni_prot_clnt.o nibind_prot_xdr.o ni_prot_xdr.o NETINFO_HEADERS = nibind_prot.h ni_prot.h AFTER_PREBUILD = $(NETINFO_HEADERS) AFTER_POSTINSTALL += install-netinfo-man -OTHER_PUBLIC_HEADERS = $(NETINFO_HEADERS) +OTHER_PRIVATE_HEADERS = $(NETINFO_HEADERS) BEFORE_INSTALLHEADERS += $(NETINFO_HEADERS) -PUBLIC_HEADER_DIR_SUFFIX = /netinfo +PRIVATE_HEADER_DIR = /usr/local/include/netinfo diff --git a/netinfo.subproj/PB.project b/netinfo.subproj/PB.project index 3635900..a527e89 100644 --- a/netinfo.subproj/PB.project +++ b/netinfo.subproj/PB.project @@ -12,7 +12,7 @@ netinfo.3, netinfo.5 ); - PUBLIC_HEADERS = (ni.h, ni_util.h); + PRIVATE_HEADERS = (ni.h, ni_util.h, ni_prot.x, nibind_prot.x); }; LANGUAGE = English; MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; diff --git a/netinfo.subproj/clib.h b/netinfo.subproj/clib.h index d284ec5..b890b6b 100644 --- a/netinfo.subproj/clib.h +++ b/netinfo.subproj/clib.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/mm.h b/netinfo.subproj/mm.h index 7c32dee..ff7e5cd 100644 --- a/netinfo.subproj/mm.h +++ b/netinfo.subproj/mm.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/multi_call.c b/netinfo.subproj/multi_call.c index 47b031f..4d28f17 100644 --- a/netinfo.subproj/multi_call.c +++ b/netinfo.subproj/multi_call.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -124,7 +125,7 @@ decodemsg( if (!xdr_u_int(xdr, &port) || !xdr_u_int(xdr, &len) || - !(buf = xdr_inline(xdr, len))) { + !(buf = (long *)xdr_inline(xdr, len))) { return (0); } xdrmem_create(&bufxdr, (char *)buf, len * BYTES_PER_XDR_UNIT, diff --git a/netinfo.subproj/ni.h b/netinfo.subproj/ni.h index 6de58bc..c707952 100644 --- a/netinfo.subproj/ni.h +++ b/netinfo.subproj/ni.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -33,6 +34,10 @@ #define SUN_RPC 1 #endif +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -121,4 +126,9 @@ void ni_setwritetimeout(void *, int); void ni_setabort(void *, int); void ni_needwrite(void *, int); -#endif __NI_HEADER__ \ No newline at end of file +#ifdef __cplusplus +} +#endif + +#endif __NI_HEADER__ + diff --git a/netinfo.subproj/ni_error.c b/netinfo.subproj/ni_error.c index 63aaff8..e4b692b 100644 --- a/netinfo.subproj/ni_error.c +++ b/netinfo.subproj/ni_error.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/ni_glue.c b/netinfo.subproj/ni_glue.c index 7ec53c9..7b5d7c8 100644 --- a/netinfo.subproj/ni_glue.c +++ b/netinfo.subproj/ni_glue.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -34,6 +35,7 @@ #include #include #include +#include #include "clib.h" #include "sys_interfaces.h" @@ -1224,7 +1226,11 @@ getparent(ni_private *oldni, ni_private **newni) ni_clear(ni); if (get_daddr(dupni, ".", ni) == 0) { - if (oldni->abort == 1) break; + if (oldni->abort == 1) + { + ni_free(dupni); + break; + } } else { @@ -1318,10 +1324,7 @@ ni_addrtag( void * -ni_new( - void *oldni, - const char *domain - ) +ni_new(void *oldni, const char *domain) { ni_private *ni; ni_status status; @@ -1329,78 +1332,78 @@ ni_new( struct sockaddr_in sin; struct hostent *he; - if (oldni == NULL) { + if (domain == NULL) return NULL; + + sep = index(domain, '@'); + if (sep != NULL) + { + tag = strncpy((char *)malloc(sep - domain + 1), domain, sep - domain); + tag[sep - domain] = '\0'; + addr = strcpy ((char *)malloc(strlen(sep + 1)), sep + 1); + sin.sin_addr.s_addr = inet_addr(addr); + if (sin.sin_addr.s_addr == INADDR_NONE) + { + he = gethostbyname(addr); + if (he == NULL) + { + free(addr); + free(tag); + return NULL; + } + + bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length); + } + + ni = ni_connect(&sin, tag); + free(addr); + free(tag); + + return (void *)ni; + } + + ni = NULL; + + if (oldni == NULL) + { ni = ni_alloc(); - if (!connectlocal(ni)) { + if (connectlocal(ni) == 0) + { free(ni); - return (NULL); + return NULL; } - if (strcmp(domain, "..") == 0) { + + if (strcmp(domain, ".") == 0) return (void *)ni; + + if (strcmp(domain, "..") == 0) + { oldni = ni; status = getparent((ni_private *)oldni, &ni); ni_free(oldni); - if (status != NI_OK) { - return (NULL); - } - } else if ((sep = index(domain, '@')) != NULL) { - free(ni); - tag = strncpy((char *)malloc(sep-domain+1), domain, sep-domain); - tag[sep-domain] = '\0'; - addr = strcpy ((char *)malloc(strlen(sep+1)), sep+1); - sin.sin_addr.s_addr = inet_addr(addr); - if (sin.sin_addr.s_addr == INADDR_NONE) { - he = gethostbyname(addr); - if (he == NULL) { - free(addr); - free(tag); - return (NULL); - } - bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length); - } - ni = ni_connect(&sin, tag); - free(addr); - free(tag); - } else if (strcmp(domain, ".") != 0) { - /* - * nothing else makes sense - */ - free(ni); - return (NULL); - } - } else { - if (strcmp(domain, "..") == 0) { - status = getparent((ni_private *)oldni, &ni); - if (status != NI_OK) { - return (NULL); - } - } else if ((sep = index(domain, '@')) != NULL) { - tag = strncpy((char *)malloc(sep-domain+1), domain, sep-domain); - tag[sep-domain] = '\0'; - addr = strcpy ((char *)malloc(strlen(sep+1)), sep+1); - sin.sin_addr.s_addr = inet_addr(addr); - if (sin.sin_addr.s_addr == INADDR_NONE) { - he = gethostbyname(addr); - if (he == NULL) { - free(addr); - free(tag); - return (NULL); - } - bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length); - } - ni = ni_connect(&sin, tag); - free(addr); - free(tag); - } else { - ni = ni_alloc(); - *ni = *NIP(oldni); - ni_clear(ni); - if (!get_daddr(oldni, (ni_name)domain, ni)) { - ni_free(ni); - ni = NULL; - } + if (status != NI_OK) return NULL; + return (void *)ni; } + + ni_free(ni); + return NULL; } - return ((void *)ni); + + if (strcmp(domain, "..") == 0) + { + status = getparent((ni_private *)oldni, &ni); + if (status != NI_OK) return NULL; + return (void *)ni; + } + + ni = ni_alloc(); + *ni = *NIP(oldni); + ni_clear(ni); + if (!get_daddr(oldni, (ni_name)domain, ni)) + { + ni_free(ni); + return NULL; + } + + return (void *)ni; } @@ -2178,9 +2181,12 @@ socket_open( int proto ) { + struct sockaddr_in bindsin; int sock; int reuse = 1; + memset(&bindsin, 0, sizeof(bindsin)); + /* * If no port number given ask the pmap for one */ @@ -2199,11 +2205,23 @@ socket_open( if (sock < 0) { return (-1); } - (void)bindresvport(sock, (struct sockaddr_in *)0); + if (-1 == bindresvport(sock, NULL) && errno == EADDRNOTAVAIL) { + /* XXX - we're hitting this case way too often under load */ + /* fail gracefully: some address is better than none most of the time */ + syslog(LOG_DEBUG, "Libinfo[%s():%d] bindresvport(): %m", __func__, __LINE__); + if (-1 == bind(sock, &bindsin, sizeof(bindsin))) { + /* The system is really sad now if it can't give me any address... */ + syslog(LOG_DEBUG, "Libinfo[%s():%d] bind(): %m", __func__, __LINE__); + (void)close(sock); + return -1; + } + } setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(int)); + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int)); if (proto == IPPROTO_TCP) { if (connect(sock, (struct sockaddr *)raddr, sizeof(*raddr)) < 0) { + syslog(LOG_DEBUG, "Libinfo[%s():%d] connect(): %m", __func__, __LINE__); (void)close(sock); return (-1); } diff --git a/netinfo.subproj/ni_prot.x b/netinfo.subproj/ni_prot.x index a83e0fe..e925c99 100644 --- a/netinfo.subproj/ni_prot.x +++ b/netinfo.subproj/ni_prot.x @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/ni_pwdomain.c b/netinfo.subproj/ni_pwdomain.c index 9d9c541..3626da2 100644 --- a/netinfo.subproj/ni_pwdomain.c +++ b/netinfo.subproj/ni_pwdomain.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/ni_useful.c b/netinfo.subproj/ni_useful.c index 9364584..f8bf7ff 100644 --- a/netinfo.subproj/ni_useful.c +++ b/netinfo.subproj/ni_useful.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/ni_util.c b/netinfo.subproj/ni_util.c index e99f78c..4e855b5 100644 --- a/netinfo.subproj/ni_util.c +++ b/netinfo.subproj/ni_util.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/ni_util.h b/netinfo.subproj/ni_util.h index 6cb2c56..65a3114 100644 --- a/netinfo.subproj/ni_util.h +++ b/netinfo.subproj/ni_util.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -31,6 +32,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define NI_INDEX_NULL ((ni_index)-1) #define NI_INIT(objp) bzero((void *)(objp), sizeof(*(objp))) @@ -95,4 +100,9 @@ ni_status ni_find(void **, ni_id *, ni_name, unsigned int); */ ni_status ni_url(char *, void **, ni_id *); -#endif !_NI_UTIL_H_ \ No newline at end of file +#ifdef __cplusplus +} +#endif + +#endif !_NI_UTIL_H_ + diff --git a/netinfo.subproj/nibind_prot.x b/netinfo.subproj/nibind_prot.x index 19ef737..421ad8c 100644 --- a/netinfo.subproj/nibind_prot.x +++ b/netinfo.subproj/nibind_prot.x @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/sys_interfaces.c b/netinfo.subproj/sys_interfaces.c index 682da1a..9fe4e14 100644 --- a/netinfo.subproj/sys_interfaces.c +++ b/netinfo.subproj/sys_interfaces.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/netinfo.subproj/sys_interfaces.h b/netinfo.subproj/sys_interfaces.h index 03d4d52..7d379eb 100644 --- a/netinfo.subproj/sys_interfaces.h +++ b/netinfo.subproj/sys_interfaces.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/Makefile b/nis.subproj/Makefile index 05745d4..8792e4b 100644 --- a/nis.subproj/Makefile +++ b/nis.subproj/Makefile @@ -28,7 +28,7 @@ CFILES = getdomainname.c getnetgrent.c innetgr.c setdomainname.c\ OTHERSRCS = Makefile.preamble Makefile yp_all.3 yp_bind.3 yp_first.3\ yp_get_default_domain.3 yp_master.3 yp_match.3 yp_next.3\ yp_order.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypprot_err.3\ - ypserv.acl.5 + Makefile.postamble MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles diff --git a/util.subproj/Makefile.postamble b/nis.subproj/Makefile.postamble similarity index 81% copy from util.subproj/Makefile.postamble copy to nis.subproj/Makefile.postamble index b2a9e16..e8f240c 100644 --- a/util.subproj/Makefile.postamble +++ b/nis.subproj/Makefile.postamble @@ -107,13 +107,23 @@ # You should avoid redefining things like "install" or "app", as they are # owned by the top-level Makefile API and no context has been set up for where # derived files should go. -# -install-man-page: - mkdir -p "$(DSTROOT)/usr/share/man/man3" - install -c -m 644 rcmd.3 "$(DSTROOT)/usr/share/man/man3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/iruserok.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/iruserok_sa.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rcmd_af.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport_af.3" - $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/ruserok.3" + +# BUILD_OFILES_LIST_ONLY = YES + +MAN3DIR=/usr/share/man/man3 +MAN5DIR=/usr/share/man/man5 + +install-nis-man: + install -m 755 -o root -g wheel -d $(DSTROOT)$(MAN3DIR) + install -m 644 -o root -g wheel -c yp_all.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_bind.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_first.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_get_default_domain.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_master.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_match.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_next.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_order.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yp_unbind.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c ypclnt.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c yperr_string.3 "$(DSTROOT)$(MAN3DIR)" + install -m 644 -o root -g wheel -c ypprot_err.3 "$(DSTROOT)$(MAN3DIR)" diff --git a/nis.subproj/PB.project b/nis.subproj/PB.project index ecec27f..8771000 100644 --- a/nis.subproj/PB.project +++ b/nis.subproj/PB.project @@ -40,6 +40,7 @@ ); OTHER_SOURCES = ( Makefile.preamble, + Makefile.postamble, Makefile, yp_all.3, yp_bind.3, @@ -52,8 +53,7 @@ yp_unbind.3, ypclnt.3, yperr_string.3, - ypprot_err.3, - ypserv.acl.5 + ypprot_err.3 ); PUBLIC_HEADERS = (ypclnt.h, yp_prot.h); }; diff --git a/nis.subproj/getdomainname.c b/nis.subproj/getdomainname.c index e0e4dc8..6f278a8 100644 --- a/nis.subproj/getdomainname.c +++ b/nis.subproj/getdomainname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -29,11 +30,11 @@ #include int -getdomainname(char *val, size_t len) +getdomainname(char *val, int len) { int mib[2]; mib[0] = CTL_KERN; mib[1] = KERN_DOMAINNAME; - return sysctl(mib, 2, (void *)val, &len, NULL, 0); + return sysctl(mib, 2, (void *)val, (size_t *)&len, NULL, 0); } diff --git a/nis.subproj/getnetgrent.c b/nis.subproj/getnetgrent.c index 3894676..cb100f0 100644 --- a/nis.subproj/getnetgrent.c +++ b/nis.subproj/getnetgrent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/innetgr.c b/nis.subproj/innetgr.c index 6553520..c70d4ea 100644 --- a/nis.subproj/innetgr.c +++ b/nis.subproj/innetgr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/setdomainname.c b/nis.subproj/setdomainname.c index 1541c01..b7a0928 100644 --- a/nis.subproj/setdomainname.c +++ b/nis.subproj/setdomainname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_domainname.c b/nis.subproj/xdr_domainname.c index 5308c1e..3abdd20 100644 --- a/nis.subproj/xdr_domainname.c +++ b/nis.subproj/xdr_domainname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_keydat.c b/nis.subproj/xdr_keydat.c index 9e0c6f0..5614751 100644 --- a/nis.subproj/xdr_keydat.c +++ b/nis.subproj/xdr_keydat.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_mapname.c b/nis.subproj/xdr_mapname.c index 6c4323a..c8c26df 100644 --- a/nis.subproj/xdr_mapname.c +++ b/nis.subproj/xdr_mapname.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_peername.c b/nis.subproj/xdr_peername.c index 7c4726d..3d9d5f0 100644 --- a/nis.subproj/xdr_peername.c +++ b/nis.subproj/xdr_peername.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_valdat.c b/nis.subproj/xdr_valdat.c index 1ab9024..080e09f 100644 --- a/nis.subproj/xdr_valdat.c +++ b/nis.subproj/xdr_valdat.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypbind_binding.c b/nis.subproj/xdr_ypbind_binding.c index 53b82fa..2f068e6 100644 --- a/nis.subproj/xdr_ypbind_binding.c +++ b/nis.subproj/xdr_ypbind_binding.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypbind_resp.c b/nis.subproj/xdr_ypbind_resp.c index 832973f..c3a060b 100644 --- a/nis.subproj/xdr_ypbind_resp.c +++ b/nis.subproj/xdr_ypbind_resp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypbind_resptype.c b/nis.subproj/xdr_ypbind_resptype.c index 12096e2..2fc0dc4 100644 --- a/nis.subproj/xdr_ypbind_resptype.c +++ b/nis.subproj/xdr_ypbind_resptype.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypbind_setdom.c b/nis.subproj/xdr_ypbind_setdom.c index be681a2..824d434 100644 --- a/nis.subproj/xdr_ypbind_setdom.c +++ b/nis.subproj/xdr_ypbind_setdom.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypmaplist.c b/nis.subproj/xdr_ypmaplist.c index 137ea49..aff6ff0 100644 --- a/nis.subproj/xdr_ypmaplist.c +++ b/nis.subproj/xdr_ypmaplist.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypreq_key.c b/nis.subproj/xdr_ypreq_key.c index eababd8..699214e 100644 --- a/nis.subproj/xdr_ypreq_key.c +++ b/nis.subproj/xdr_ypreq_key.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypreq_nokey.c b/nis.subproj/xdr_ypreq_nokey.c index b3e1552..d2aa2b9 100644 --- a/nis.subproj/xdr_ypreq_nokey.c +++ b/nis.subproj/xdr_ypreq_nokey.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_all.c b/nis.subproj/xdr_ypresp_all.c index cee7c8a..57b6efa 100644 --- a/nis.subproj/xdr_ypresp_all.c +++ b/nis.subproj/xdr_ypresp_all.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_key_val.c b/nis.subproj/xdr_ypresp_key_val.c index dfb11b8..65135fa 100644 --- a/nis.subproj/xdr_ypresp_key_val.c +++ b/nis.subproj/xdr_ypresp_key_val.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_maplist.c b/nis.subproj/xdr_ypresp_maplist.c index cce1529..43a3134 100644 --- a/nis.subproj/xdr_ypresp_maplist.c +++ b/nis.subproj/xdr_ypresp_maplist.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_master.c b/nis.subproj/xdr_ypresp_master.c index b844a40..a9f80ab 100644 --- a/nis.subproj/xdr_ypresp_master.c +++ b/nis.subproj/xdr_ypresp_master.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_order.c b/nis.subproj/xdr_ypresp_order.c index 4660014..2ae322d 100644 --- a/nis.subproj/xdr_ypresp_order.c +++ b/nis.subproj/xdr_ypresp_order.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypresp_val.c b/nis.subproj/xdr_ypresp_val.c index 26226e0..bb5e542 100644 --- a/nis.subproj/xdr_ypresp_val.c +++ b/nis.subproj/xdr_ypresp_val.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/xdr_ypstat.c b/nis.subproj/xdr_ypstat.c index 15a4842..620bcae 100644 --- a/nis.subproj/xdr_ypstat.c +++ b/nis.subproj/xdr_ypstat.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_all.c b/nis.subproj/yp_all.c index 55778c8..3a2be72 100644 --- a/nis.subproj/yp_all.c +++ b/nis.subproj/yp_all.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_bind.c b/nis.subproj/yp_bind.c index a8b9c9d..d0ba3c6 100644 --- a/nis.subproj/yp_bind.c +++ b/nis.subproj/yp_bind.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_first.c b/nis.subproj/yp_first.c index 5bdcf11..6dc84da 100644 --- a/nis.subproj/yp_first.c +++ b/nis.subproj/yp_first.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_get_default_domain.c b/nis.subproj/yp_get_default_domain.c index 373d1a4..3092f25 100644 --- a/nis.subproj/yp_get_default_domain.c +++ b/nis.subproj/yp_get_default_domain.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_maplist.c b/nis.subproj/yp_maplist.c index e795ad2..09b3fa0 100644 --- a/nis.subproj/yp_maplist.c +++ b/nis.subproj/yp_maplist.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_master.c b/nis.subproj/yp_master.c index b3a0795..0a4a4d2 100644 --- a/nis.subproj/yp_master.c +++ b/nis.subproj/yp_master.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_order.c b/nis.subproj/yp_order.c index 44b7a7c..294fa81 100644 --- a/nis.subproj/yp_order.c +++ b/nis.subproj/yp_order.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yp_prot.h b/nis.subproj/yp_prot.h index 1be2a2e..4f72f4f 100644 --- a/nis.subproj/yp_prot.h +++ b/nis.subproj/yp_prot.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/ypclnt.h b/nis.subproj/ypclnt.h index c09e8b1..0ca164c 100644 --- a/nis.subproj/ypclnt.h +++ b/nis.subproj/ypclnt.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yperr_string.c b/nis.subproj/yperr_string.c index 4b98ee6..0c040f5 100644 --- a/nis.subproj/yperr_string.c +++ b/nis.subproj/yperr_string.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/ypinternal.h b/nis.subproj/ypinternal.h index 03e40fc..7406285 100644 --- a/nis.subproj/ypinternal.h +++ b/nis.subproj/ypinternal.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -79,8 +80,6 @@ extern int _yplib_timeout; void _yp_unbind __P((struct dom_binding *)); int _yp_check __P((char **)); -int getdomainname(char *val, size_t len); - #ifdef YPMATCHCACHE static bool_t ypmatch_add __P((const char *, const char *, diff --git a/nis.subproj/ypmatch_cache.c b/nis.subproj/ypmatch_cache.c index e689913..b3514e9 100644 --- a/nis.subproj/ypmatch_cache.c +++ b/nis.subproj/ypmatch_cache.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/yppasswdd_xdr.c b/nis.subproj/yppasswdd_xdr.c index 2d3fe2f..4f7d336 100644 --- a/nis.subproj/yppasswdd_xdr.c +++ b/nis.subproj/yppasswdd_xdr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/ypprot_err.c b/nis.subproj/ypprot_err.c index 7c955fb..5d09fcc 100644 --- a/nis.subproj/ypprot_err.c +++ b/nis.subproj/ypprot_err.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/nis.subproj/ypserv.acl.5 b/nis.subproj/ypserv.acl.5 deleted file mode 100644 index 000824a..0000000 --- a/nis.subproj/ypserv.acl.5 +++ /dev/null @@ -1,177 +0,0 @@ -.\" $OpenBSD: ypserv.acl.5,v 1.5 1996/07/04 21:17:15 deraadt Exp $ -.\" Copyright (c) 1994 Mats O Jansson -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by Mats O Jansson -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS -.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd July 2, 1994 -.Dt YPSERV.ACL 5 -.Os -.Sh NAME -.Nm ypserv.acl -.Nd -.Xr ypserv 8 -configuration file -.Sh DESCRIPTION -The -.Nm ypserv.acl -file controls which hosts can connect to the -.Nm YP -server. -.Pp -The format is more complex than the format for -.Xr securenet 5 . -The first two verbs on each line controls if the line will -.Nm allow -or -.Nm deny -access for a -.Nm host , -network -.Nm (net) -or -.Nm all -hosts. -.Pp -The -.Nm YP -server reads the configuration file and build a list in memory. This list -is processed from the beginning for every incomming request. As soon a -match is found in the list the search terminates and it returns success -or failure depending on -.Nm allow -or -.Nm deny . -If no match was found in the list success is returned. -.Pp -If access is denied every call will cause a -.Nm no such domain -error for the caller. -.Pp -There is no default name for this file. Start -.Nm ypserv -with a -.Ar -a filename -to read a file with this format. -.Pp -The following different syntax can be used: -.Pp -< -.Nm allow|deny -> -.Nm host -< -.Nm hostname|ip-address -> -.Pp -If -.Nm hostname -has more than one ip address then all will be added to the list. -.Pp -< -.Nm allow|deny -> -.Nm net -< -.Nm netname|netnumber -> -.Op Nm netmask -.Pp -If -.Nm netmask -part of the command isn't given then the netmask will be assumed to be a -class A, B or C net depending on the net number. -.Pp -< -.Nm allow|deny -> -.Nm all -.Pp -A line containing one of these commands will always match any host. -.Sh EXAMPLES -.Pp -A configuration file might appear as follows: -.Bd -literal -# This is an example of an access control file to be used by ypserv. -# -# This file is parsed line by line. First match will terminate the check -# of the caller. -# - -########################################################################### -# This is the commands that will match a single host -# -# allow host -# deny host -# -# To process hostname gethostbyname is called. If the hostname has -# multiple ip-addresses all will be added (I hope). ip-address -# processed by inet_aton. -deny host jodie - -########################################################################### -# This is the commands that will match a network -# -# allow net [netmask ] -# deny net [netmask ] -# -# To process netname getnetbyname is called, and inet_aton is used for -# netnumber. inet_aton both access numbers as 255.255.255.0 and 0xffffff00. -# -# If netmask isn't given the parser will assume netmask from the first bits -# of the network number. So if the network is subneted the you have to add -# the netmask. In my case I've got the network 139.58.253.0 at home so too -# allow any of my computers to talk with the server I need the following -# line -# -allow net mojathome netmask 255.255.255.0 - -########################################################################### -# At last we have a command that will match any caller: -# -# allow all -# deny all -# - -# reject all connections -deny all - -.Ed -.Sh FILES -.Bl -tag -width /var/yp/ypserv.acl -compact -.It Pa /var/yp/ypserv.acl -A -.Xr ypserv 8 -configuration file. -.El -.Sh SEE ALSO -.Xr yp 8 , -.Xr ypserv 8 , -.Xr securenet 5 -.Sh AUTHOR -Mats O Jansson - diff --git a/rpc.subproj/auth.h b/rpc.subproj/auth.h index bc5f843..359c37f 100644 --- a/rpc.subproj/auth.h +++ b/rpc.subproj/auth.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/auth_none.c b/rpc.subproj/auth_none.c index e2901a0..a888176 100644 --- a/rpc.subproj/auth_none.c +++ b/rpc.subproj/auth_none.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/auth_unix.c b/rpc.subproj/auth_unix.c index f2902c1..737591d 100644 --- a/rpc.subproj/auth_unix.c +++ b/rpc.subproj/auth_unix.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/auth_unix.h b/rpc.subproj/auth_unix.h index a26f59a..1e0fe81 100644 --- a/rpc.subproj/auth_unix.h +++ b/rpc.subproj/auth_unix.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/authunix_prot.c b/rpc.subproj/authunix_prot.c index 38864f2..aa2132d 100644 --- a/rpc.subproj/authunix_prot.c +++ b/rpc.subproj/authunix_prot.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/bindresvport.c b/rpc.subproj/bindresvport.c index ae903ae..0a5891a 100644 --- a/rpc.subproj/bindresvport.c +++ b/rpc.subproj/bindresvport.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -71,17 +72,6 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/2 #include /* - * Bind a socket to a privileged IP port - */ -int -bindresvport(sd, sin) - int sd; - struct sockaddr_in *sin; -{ - return bindresvport_sa(sd, (struct sockaddr *)sin); -} - -/* * Bind a socket to a privileged port for whatever protocol. */ int @@ -164,3 +154,14 @@ bindresvport_sa(sd, sa) } return (error); } + +/* + * Bind a socket to a privileged IP port + */ +int +bindresvport(sd, sin) + int sd; + struct sockaddr_in *sin; +{ + return bindresvport_sa(sd, (struct sockaddr *)sin); +} diff --git a/rpc.subproj/clnt.h b/rpc.subproj/clnt.h index 1efee44..d1d30e5 100644 --- a/rpc.subproj/clnt.h +++ b/rpc.subproj/clnt.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -51,7 +52,7 @@ * * from: @(#)clnt.h 1.31 88/02/08 SMI * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC - * $Id: clnt.h,v 1.2 1999/10/14 21:56:52 wsanchez Exp $ + * $Id: clnt.h,v 1.3 2003/07/03 21:56:21 majka Exp $ */ /* @@ -143,19 +144,20 @@ struct rpc_err { * Created by individual implementations, see e.g. rpc_udp.c. * Client is responsible for initializing auth, see e.g. auth_none.c. */ -typedef struct { - AUTH *cl_auth; /* authenticator */ +typedef struct CLIENT CLIENT; +struct CLIENT +{ + AUTH *cl_auth; /* authenticator */ struct clnt_ops { - enum clnt_stat (*cl_call)(); /* call remote procedure */ - void (*cl_abort)(); /* abort a call */ - void (*cl_geterr)(); /* get specific error code */ - bool_t (*cl_freeres)(); /* frees results */ - void (*cl_destroy)();/* destroy this structure */ - bool_t (*cl_control)();/* the ioctl() of rpc */ + enum clnt_stat (*cl_call)(CLIENT *, u_long, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* call remote procedure */ + void (*cl_abort)(void); /* abort a call */ + void (*cl_geterr)(CLIENT *, struct rpc_err *); /* get specific error code */ + bool_t (*cl_freeres)(CLIENT *, xdrproc_t, void *); /* frees results */ + void (*cl_destroy)(CLIENT *); /* destroy this structure */ + bool_t (*cl_control)(CLIENT *, int, char *); /* the ioctl() of rpc */ } *cl_ops; - caddr_t cl_private; /* private stuff */ -} CLIENT; - + caddr_t cl_private; /* private stuff */ +}; /* * client side rpc interface ops diff --git a/rpc.subproj/clnt_generic.c b/rpc.subproj/clnt_generic.c index 3901b60..2d9fb04 100644 --- a/rpc.subproj/clnt_generic.c +++ b/rpc.subproj/clnt_generic.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/clnt_perror.c b/rpc.subproj/clnt_perror.c index 1e3ce14..3b6b5ec 100644 --- a/rpc.subproj/clnt_perror.c +++ b/rpc.subproj/clnt_perror.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: clnt_perror.c,v 1.3 2002/02/19 20:36:22 epeyton Exp $"; +static char *rcsid = "$Id: clnt_perror.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -275,6 +276,7 @@ clnt_spcreateerror(s) (void) sprintf(&str[strlen(str)], "Error %d", rpc_createerr.cf_error.re_errno); break; + default: break; } (void) strcat(str, "\n"); return (str); diff --git a/rpc.subproj/clnt_raw.c b/rpc.subproj/clnt_raw.c index 0fccf08..32273a3 100644 --- a/rpc.subproj/clnt_raw.c +++ b/rpc.subproj/clnt_raw.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/clnt_simple.c b/rpc.subproj/clnt_simple.c index 0ba26d0..5a0c13c 100644 --- a/rpc.subproj/clnt_simple.c +++ b/rpc.subproj/clnt_simple.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/clnt_tcp.c b/rpc.subproj/clnt_tcp.c index 71afd9d..674351d 100644 --- a/rpc.subproj/clnt_tcp.c +++ b/rpc.subproj/clnt_tcp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/clnt_udp.c b/rpc.subproj/clnt_udp.c index 446603a..efc1b8a 100644 --- a/rpc.subproj/clnt_udp.c +++ b/rpc.subproj/clnt_udp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/get_myaddress.c b/rpc.subproj/get_myaddress.c index 00cd672..4536827 100644 --- a/rpc.subproj/get_myaddress.c +++ b/rpc.subproj/get_myaddress.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/getrpcent.c b/rpc.subproj/getrpcent.c index 1a8fe44..c38a099 100644 --- a/rpc.subproj/getrpcent.c +++ b/rpc.subproj/getrpcent.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/getrpcport.c b/rpc.subproj/getrpcport.c index f7c51af..980088a 100644 --- a/rpc.subproj/getrpcport.c +++ b/rpc.subproj/getrpcport.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_clnt.c b/rpc.subproj/pmap_clnt.c index 087e4a8..afcfb05 100644 --- a/rpc.subproj/pmap_clnt.c +++ b/rpc.subproj/pmap_clnt.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_clnt.h b/rpc.subproj/pmap_clnt.h index 16e7fed..eff9bee 100644 --- a/rpc.subproj/pmap_clnt.h +++ b/rpc.subproj/pmap_clnt.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_getmaps.c b/rpc.subproj/pmap_getmaps.c index 2d8b341..8800c6d 100644 --- a/rpc.subproj/pmap_getmaps.c +++ b/rpc.subproj/pmap_getmaps.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_getport.c b/rpc.subproj/pmap_getport.c index 2e78d39..30f7740 100644 --- a/rpc.subproj/pmap_getport.c +++ b/rpc.subproj/pmap_getport.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_prot.c b/rpc.subproj/pmap_prot.c index b3d4a02..e0f0041 100644 --- a/rpc.subproj/pmap_prot.c +++ b/rpc.subproj/pmap_prot.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_prot.h b/rpc.subproj/pmap_prot.h index 1565f5e..a1b6b49 100644 --- a/rpc.subproj/pmap_prot.h +++ b/rpc.subproj/pmap_prot.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_prot2.c b/rpc.subproj/pmap_prot2.c index a5bd77d..fd9fbcd 100644 --- a/rpc.subproj/pmap_prot2.c +++ b/rpc.subproj/pmap_prot2.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/pmap_rmt.c b/rpc.subproj/pmap_rmt.c index 7474d9f..c749cbf 100644 --- a/rpc.subproj/pmap_rmt.c +++ b/rpc.subproj/pmap_rmt.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: pmap_rmt.c,v 1.4 2002/03/15 22:07:50 majka Exp $"; +static char *rcsid = "$Id: pmap_rmt.c,v 1.5 2003/06/05 21:43:28 majka Exp $"; #endif /* @@ -262,7 +263,7 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) fd_set readfds; register int i; bool_t done = FALSE; - register u_long xid; + u_long xid; u_long port; struct in_addr addrs[20]; struct sockaddr_in baddr, raddr; /* broadcast and response addresses */ @@ -299,14 +300,15 @@ clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) /* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */ rfd = open("/dev/random", O_RDONLY, 0); - if ((rfd < 0) || (read(rfd, &msg.rm_xid, sizeof(msg.rm_xid)) != sizeof(msg.rm_xid))) + if ((rfd < 0) || (read(rfd, &xid, sizeof(xid)) != sizeof(xid))) { gettimeofday(&t, (struct timezone *)0); - msg.rm_xid = getpid() ^ t.tv_sec ^ t.tv_usec; + xid = getpid() ^ t.tv_sec ^ t.tv_usec; } if (rfd > 0) close(rfd); t.tv_usec = 0; + msg.rm_xid = xid; msg.rm_direction = CALL; msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; msg.rm_call.cb_prog = PMAPPROG; diff --git a/rpc.subproj/pmap_rmt.h b/rpc.subproj/pmap_rmt.h index a6782a5..1eb1c79 100644 --- a/rpc.subproj/pmap_rmt.h +++ b/rpc.subproj/pmap_rmt.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/rpc.h b/rpc.subproj/rpc.h index da89dff..77166d4 100644 --- a/rpc.subproj/rpc.h +++ b/rpc.subproj/rpc.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/rpc_callmsg.c b/rpc.subproj/rpc_callmsg.c index 713be6d..4ab6b5f 100644 --- a/rpc.subproj/rpc_callmsg.c +++ b/rpc.subproj/rpc_callmsg.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: rpc_callmsg.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $"; +static char *rcsid = "$Id: rpc_callmsg.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -89,7 +90,7 @@ xdr_callmsg(xdrs, cmsg) if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) { return (FALSE); } - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + buf = (long *)XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT + RNDUP(cmsg->rm_call.cb_cred.oa_length) + 2 * BYTES_PER_XDR_UNIT + RNDUP(cmsg->rm_call.cb_verf.oa_length)); @@ -126,7 +127,7 @@ xdr_callmsg(xdrs, cmsg) } } if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); + buf = (long *)XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT); if (buf != NULL) { cmsg->rm_xid = IXDR_GET_LONG(buf); cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type); @@ -151,7 +152,7 @@ xdr_callmsg(xdrs, cmsg) oa->oa_base = (caddr_t) mem_alloc(oa->oa_length); } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); + buf = (long *)XDR_INLINE(xdrs, RNDUP(oa->oa_length)); if (buf == NULL) { if (xdr_opaque(xdrs, oa->oa_base, oa->oa_length) == FALSE) { @@ -167,7 +168,7 @@ xdr_callmsg(xdrs, cmsg) } } oa = &cmsg->rm_call.cb_verf; - buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); + buf = (long *)XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT); if (buf == NULL) { if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE || xdr_u_int(xdrs, &oa->oa_length) == FALSE) { @@ -185,7 +186,7 @@ xdr_callmsg(xdrs, cmsg) oa->oa_base = (caddr_t) mem_alloc(oa->oa_length); } - buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length)); + buf = (long *)XDR_INLINE(xdrs, RNDUP(oa->oa_length)); if (buf == NULL) { if (xdr_opaque(xdrs, oa->oa_base, oa->oa_length) == FALSE) { diff --git a/rpc.subproj/rpc_commondata.c b/rpc.subproj/rpc_commondata.c index a3a122c..95e50b0 100644 --- a/rpc.subproj/rpc_commondata.c +++ b/rpc.subproj/rpc_commondata.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/rpc_dtablesize.c b/rpc.subproj/rpc_dtablesize.c index 39a313a..628c06d 100644 --- a/rpc.subproj/rpc_dtablesize.c +++ b/rpc.subproj/rpc_dtablesize.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/rpc_msg.h b/rpc.subproj/rpc_msg.h index 53373d0..afd0d6d 100644 --- a/rpc.subproj/rpc_msg.h +++ b/rpc.subproj/rpc_msg.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/rpc_prot.c b/rpc.subproj/rpc_prot.c index ab74c4b..d62cbdc 100644 --- a/rpc.subproj/rpc_prot.c +++ b/rpc.subproj/rpc_prot.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -52,7 +53,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";*/ -static char *rcsid = "$Id: rpc_prot.c,v 1.2 1999/10/14 21:56:54 wsanchez Exp $"; +static char *rcsid = "$Id: rpc_prot.c,v 1.3 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -131,6 +132,7 @@ xdr_accepted_reply(xdrs, ar) if (! xdr_u_long(xdrs, &(ar->ar_vers.low))) return (FALSE); return (xdr_u_long(xdrs, &(ar->ar_vers.high))); + default: break; } return (TRUE); /* TRUE => open ended set of problems */ } @@ -261,6 +263,7 @@ rejected(rjct_stat, error) case AUTH_ERROR: error->re_status = RPC_AUTHERROR; return; + default: break; } /* something's wrong, but we don't know what ... */ error->re_status = RPC_FAILED; @@ -312,5 +315,7 @@ _seterr_reply(msg, error) error->re_vers.low = msg->acpted_rply.ar_vers.low; error->re_vers.high = msg->acpted_rply.ar_vers.high; break; + + default: break; } } diff --git a/rpc.subproj/svc.c b/rpc.subproj/svc.c index b0a6a9a..696ffbf 100644 --- a/rpc.subproj/svc.c +++ b/rpc.subproj/svc.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc.h b/rpc.subproj/svc.h index 8a3004e..ac30df5 100644 --- a/rpc.subproj/svc.h +++ b/rpc.subproj/svc.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_auth.c b/rpc.subproj/svc_auth.c index 0d8db83..6c79960 100644 --- a/rpc.subproj/svc_auth.c +++ b/rpc.subproj/svc_auth.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_auth.h b/rpc.subproj/svc_auth.h index 3dc0959..d4064ad 100644 --- a/rpc.subproj/svc_auth.h +++ b/rpc.subproj/svc_auth.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_auth_unix.c b/rpc.subproj/svc_auth_unix.c index 95f6ca8..04abeab 100644 --- a/rpc.subproj/svc_auth_unix.c +++ b/rpc.subproj/svc_auth_unix.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_auth_unix.c,v 1.4 2002/02/19 20:36:25 epeyton Exp $"; +static char *rcsid = "$Id: svc_auth_unix.c,v 1.5 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -99,7 +100,7 @@ _svcauth_unix(rqst, msg) aup->aup_gids = area->area_gids; auth_len = (u_int)msg->rm_call.cb_cred.oa_length; xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE); - buf = XDR_INLINE(&xdrs, auth_len); + buf = (long *)XDR_INLINE(&xdrs, auth_len); if (buf != NULL) { aup->aup_time = IXDR_GET_LONG(buf); str_len = IXDR_GET_U_LONG(buf); diff --git a/rpc.subproj/svc_raw.c b/rpc.subproj/svc_raw.c index 54e6f62..fd0769a 100644 --- a/rpc.subproj/svc_raw.c +++ b/rpc.subproj/svc_raw.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_run.c b/rpc.subproj/svc_run.c index 451591d..99c14c6 100644 --- a/rpc.subproj/svc_run.c +++ b/rpc.subproj/svc_run.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_simple.c b/rpc.subproj/svc_simple.c index 2268732..05431dc 100644 --- a/rpc.subproj/svc_simple.c +++ b/rpc.subproj/svc_simple.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/svc_tcp.c b/rpc.subproj/svc_tcp.c index 33e61b8..75f1a84 100644 --- a/rpc.subproj/svc_tcp.c +++ b/rpc.subproj/svc_tcp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: svc_tcp.c,v 1.3.84.1 2002/10/18 21:16:15 bbraun Exp $"; +static char *rcsid = "$Id: svc_tcp.c,v 1.5 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -334,41 +335,23 @@ readtcp(xprt, buf, len) register int sock = xprt->xp_sock; fd_set readfds; bool_t ready = FALSE; - struct timeval delta, start, tv, tmp1, tmp2; - delta = wait_per_try; - gettimeofday(&start, NULL); do { FD_COPY(&svc_fdset, &readfds); FD_SET(sock, &readfds); - tv = delta; - switch( select(max(svc_maxfd, sock) + 1, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv) ) { - case -1: - if( errno != EINTR ) - goto fatal_err; - gettimeofday(&tmp1, NULL); - timersub(&tmp1, &start, &tmp2); - timersub(&wait_per_try, &tmp2, &tmp1); - if( tmp1.tv_sec < 0 || !timerisset(&tmp1) ) - goto fatal_err; - delta = tmp1; - continue; - case 0: + if (select(max(svc_maxfd, sock) + 1, &readfds, NULL, NULL, &wait_per_try) <= 0) + { + if (errno == EINTR) continue; goto fatal_err; - default: - if(!FD_ISSET(sock, &readfds)) { - svc_getreqset(&readfds); - gettimeofday(&tmp1, NULL); - timersub(&tmp1, &start, &tmp2); - timersub(&wait_per_try, &tmp2, &tmp1); - if( tmp1.tv_sec < 0 || !timerisset(&tmp1) ) - goto fatal_err; - delta = tmp1; - continue; - } else { - ready = TRUE; - } + } + else if (FD_ISSET(sock, &readfds)) + { + ready = TRUE; + } + else + { + svc_getreqset(&readfds); } } while (!ready); diff --git a/rpc.subproj/svc_udp.c b/rpc.subproj/svc_udp.c index 5d799b8..be8494b 100644 --- a/rpc.subproj/svc_udp.c +++ b/rpc.subproj/svc_udp.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/types.h b/rpc.subproj/types.h index 79f7ede..2529d5d 100644 --- a/rpc.subproj/types.h +++ b/rpc.subproj/types.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/xdr.c b/rpc.subproj/xdr.c index 227f601..153e24e 100644 --- a/rpc.subproj/xdr.c +++ b/rpc.subproj/xdr.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr.c 1.35 87/08/12";*/ /*static char *sccsid = "from: @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $"; +static char *rcsid = "$Id: xdr.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -553,6 +554,7 @@ xdr_string(xdrs, cpp, maxsize) case XDR_ENCODE: size = strlen(sp); break; + default: break; } if (! xdr_u_int(xdrs, &size)) { return (FALSE); diff --git a/rpc.subproj/xdr.h b/rpc.subproj/xdr.h index 6289bc8..20cbf1a 100644 --- a/rpc.subproj/xdr.h +++ b/rpc.subproj/xdr.h @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -51,7 +52,7 @@ * * from: @(#)xdr.h 1.19 87/04/22 SMI * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC - * $Id: xdr.h,v 1.2 1999/10/14 21:56:54 wsanchez Exp $ + * $Id: xdr.h,v 1.3 2003/06/23 17:24:59 majka Exp $ */ /* @@ -129,22 +130,22 @@ typedef bool_t (*xdrproc_t)(); * an operations vector for the paticular implementation (e.g. see xdr_mem.c), * and two private fields for the use of the particular impelementation. */ -typedef struct { +typedef struct __rpc_xdr { enum xdr_op x_op; /* operation; fast additional param */ struct xdr_ops { - bool_t (*x_getlong)(); /* get a long from underlying stream */ - bool_t (*x_putlong)(); /* put a long to " */ - bool_t (*x_getbytes)();/* get some bytes from " */ - bool_t (*x_putbytes)();/* put some bytes to " */ - u_int (*x_getpostn)();/* returns bytes off from beginning */ - bool_t (*x_setpostn)();/* lets you reposition the stream */ - long * (*x_inline)(); /* buf quick ptr to buffered data */ - void (*x_destroy)(); /* free privates of this xdr_stream */ + bool_t (*x_getlong)(struct __rpc_xdr *, long *); + bool_t (*x_putlong)(struct __rpc_xdr *, long *); + bool_t (*x_getbytes)(struct __rpc_xdr *, caddr_t, u_int); + bool_t (*x_putbytes)(struct __rpc_xdr *, caddr_t, u_int); + u_int (*x_getpostn)(struct __rpc_xdr *); + bool_t (*x_setpostn)(struct __rpc_xdr *, u_int); + long *(*x_inline)(struct __rpc_xdr *, u_int); + void (*x_destroy)(struct __rpc_xdr *); } *x_ops; - caddr_t x_public; /* users' data */ - caddr_t x_private; /* pointer to private data */ - caddr_t x_base; /* private used for position info */ - int x_handy; /* extra private word */ + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + int x_handy; /* extra private word */ } XDR; /* diff --git a/rpc.subproj/xdr_array.c b/rpc.subproj/xdr_array.c index 95f1d0a..38ceb0e 100644 --- a/rpc.subproj/xdr_array.c +++ b/rpc.subproj/xdr_array.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_array.c,v 1.3.84.1 2002/08/06 19:46:15 bbraun Exp $"; +static char *rcsid = "$Id: xdr_array.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -70,7 +71,6 @@ static char *rcsid = "$Id: xdr_array.c,v 1.3.84.1 2002/08/06 19:46:15 bbraun Exp #include #include #include -#include #define LASTUNSIGNED ((u_int)0-1) @@ -102,8 +102,7 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) return (FALSE); } c = *sizep; - if ((c > maxsize || UINT_MAX/elsize < c) && - (xdrs->x_op != XDR_FREE)) { + if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { return (FALSE); } nodesize = c * elsize; @@ -128,6 +127,8 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) case XDR_FREE: return (TRUE); + + default: break; } /* diff --git a/rpc.subproj/xdr_float.c b/rpc.subproj/xdr_float.c index 775022a..8f3d2be 100644 --- a/rpc.subproj/xdr_float.c +++ b/rpc.subproj/xdr_float.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/rpc.subproj/xdr_mem.c b/rpc.subproj/xdr_mem.c index 88848e3..319b0f2 100644 --- a/rpc.subproj/xdr_mem.c +++ b/rpc.subproj/xdr_mem.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_mem.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $"; +static char *rcsid = "$Id: xdr_mem.c,v 1.5 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -104,7 +105,7 @@ xdrmem_create(xdrs, addr, size, op) void *addr; #else caddr_t addr; -#endif /* !NeXT */ +#endif u_int size; enum xdr_op op; { @@ -116,8 +117,7 @@ xdrmem_create(xdrs, addr, size, op) } static void -xdrmem_destroy(/*xdrs*/) - /*XDR *xdrs;*/ +xdrmem_destroy(XDR *xdrs) { } @@ -126,7 +126,6 @@ xdrmem_getlong(xdrs, lp) register XDR *xdrs; long *lp; { - if ((xdrs->x_handy -= sizeof(long)) < 0) return (FALSE); *lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private)))); @@ -139,7 +138,6 @@ xdrmem_putlong(xdrs, lp) register XDR *xdrs; long *lp; { - if ((xdrs->x_handy -= sizeof(long)) < 0) return (FALSE); *(long *)xdrs->x_private = (long)htonl((u_long)(*lp)); @@ -179,7 +177,6 @@ static u_int xdrmem_getpos(xdrs) register XDR *xdrs; { - return ((u_int)xdrs->x_private - (u_int)xdrs->x_base); } diff --git a/rpc.subproj/xdr_rec.c b/rpc.subproj/xdr_rec.c index 2722896..617f69a 100644 --- a/rpc.subproj/xdr_rec.c +++ b/rpc.subproj/xdr_rec.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -52,7 +53,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_rec.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $"; +static char *rcsid = "$Id: xdr_rec.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -375,6 +376,7 @@ xdrrec_setpos(xdrs, pos) return (TRUE); } break; + default: break; } return (FALSE); } @@ -404,6 +406,7 @@ xdrrec_inline(xdrs, len) rstrm->in_finger += len; } break; + default: break; } return (buf); } diff --git a/rpc.subproj/xdr_reference.c b/rpc.subproj/xdr_reference.c index acdd540..8d9927f 100644 --- a/rpc.subproj/xdr_reference.c +++ b/rpc.subproj/xdr_reference.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -53,7 +54,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_reference.c 1.11 87/08/11 SMI";*/ /*static char *sccsid = "from: @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id: xdr_reference.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $"; +static char *rcsid = "$Id: xdr_reference.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; #endif /* @@ -106,6 +107,7 @@ xdr_reference(xdrs, pp, size, proc) } bzero(loc, (int)size); break; + default: break; } stat = (*proc)(xdrs, loc, LASTUNSIGNED); diff --git a/rpc.subproj/xdr_stdio.c b/rpc.subproj/xdr_stdio.c index d4c6b49..fe0fcff 100644 --- a/rpc.subproj/xdr_stdio.c +++ b/rpc.subproj/xdr_stdio.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/util.subproj/Makefile b/util.subproj/Makefile index 499e7e6..f3bb751 100644 --- a/util.subproj/Makefile +++ b/util.subproj/Makefile @@ -12,10 +12,10 @@ NAME = util PROJECTVERSION = 2.8 PROJECT_TYPE = Component -CFILES = getgrouplist.c glob.c hton.c putpwpasswd.c pwcache.c rcmd.c\ +CFILES = glob.c hton.c putpwpasswd.c pwcache.c rcmd.c\ rcmdsh.c -OTHERSRCS = Makefile Makefile.preamble Makefile.postamble rcmd.3 +OTHERSRCS = Makefile Makefile.preamble Makefile.postamble rcmd.3 hosts.equiv.5 MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles diff --git a/util.subproj/Makefile.postamble b/util.subproj/Makefile.postamble index b2a9e16..d5e61ec 100644 --- a/util.subproj/Makefile.postamble +++ b/util.subproj/Makefile.postamble @@ -117,3 +117,5 @@ install-man-page: $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport_af.3" $(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/ruserok.3" + mkdir -p "$(DSTROOT)/usr/share/man/man5" + install -c -m 644 hosts.equiv.5 "$(DSTROOT)/usr/share/man/man5" diff --git a/util.subproj/Makefile.preamble b/util.subproj/Makefile.preamble index 9b478c6..4a51a2c 100644 --- a/util.subproj/Makefile.preamble +++ b/util.subproj/Makefile.preamble @@ -1,3 +1,3 @@ AFTER_POSTINSTALL += install-man-page OTHER_CFLAGS = \ - -DINET6=1 \ + -DINET6=1 diff --git a/util.subproj/PB.project b/util.subproj/PB.project index 2c20a90..90b1556 100644 --- a/util.subproj/PB.project +++ b/util.subproj/PB.project @@ -1,8 +1,8 @@ { DYNAMIC_CODE_GEN = YES; FILESTABLE = { - OTHER_LINKED = (getgrouplist.c, glob.c, hton.c, putpwpasswd.c, pwcache.c, rcmd.c, rcmdsh.c); - OTHER_SOURCES = (Makefile, Makefile.preamble, Makefile.postamble, rcmd.3); + OTHER_LINKED = (glob.c, hton.c, putpwpasswd.c, pwcache.c, rcmd.c, rcmdsh.c); + OTHER_SOURCES = (Makefile, Makefile.preamble, Makefile.postamble, rcmd.3, hosts.equiv.5); }; LANGUAGE = English; MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles"; diff --git a/util.subproj/getgrouplist.c b/util.subproj/getgrouplist.c deleted file mode 100644 index b342f60..0000000 --- a/util.subproj/getgrouplist.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. - * - * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * - * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * - * @APPLE_LICENSE_HEADER_END@ - */ -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * get credential - */ -#include -#include -#include - -int -getgrouplist(uname, agroup, groups, grpcnt) - const char *uname; - int agroup; - register int *groups; - int *grpcnt; -{ - register struct group *grp; - register int i, ngroups; - int ret, maxgroups; - - ret = 0; - ngroups = 0; - maxgroups = *grpcnt; - /* - * When installing primary group, duplicate it; - * the first element of groups is the effective gid - * and will be overwritten when a setgid file is executed. - */ - groups[ngroups++] = agroup; - if (maxgroups > 1) - groups[ngroups++] = agroup; - /* - * Scan the group file to find additional groups. - */ - setgrent(); - while ((grp = getgrent())) { - if (grp->gr_gid == agroup) - continue; - for (i = 0; grp->gr_mem[i]; i++) { - if (!strcmp(grp->gr_mem[i], uname)) { - if (ngroups >= maxgroups) { - ret = -1; - break; - } - groups[ngroups++] = grp->gr_gid; - break; - } - } - } - endgrent(); - *grpcnt = ngroups; - return (ret); -} diff --git a/util.subproj/glob.c b/util.subproj/glob.c index b27c283..af6e8b7 100644 --- a/util.subproj/glob.c +++ b/util.subproj/glob.c @@ -2,23 +2,24 @@ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. - * + * + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. - * + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * * @APPLE_LICENSE_HEADER_END@ */ /* diff --git a/util.subproj/hosts.equiv.5 b/util.subproj/hosts.equiv.5 new file mode 100755 index 0000000..c96e48f --- /dev/null +++ b/util.subproj/hosts.equiv.5 @@ -0,0 +1,180 @@ +.\" $OpenBSD: hosts.equiv.5,v 1.1 1997/11/30 05:35:25 deraadt Exp $ +.\" +.\" Copyright (c) 1997 Todd Vierling +.\" Copyright (c) 1997 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Todd Vierling . +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the NetBSD +.\" Foundation, Inc. and its contributors. +.\" 4. Neither the name of The NetBSD Foundation nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 26, 1997 +.Dt HOSTS.EQUIV 5 +.Os +.Sh NAME +.Nm hosts.equiv , +.Nm .rhosts +.Nd trusted remote hosts and host-user pairs +.Sh DESCRIPTION +The +.Nm hosts.equiv +and +.Nm .rhosts +files list hosts and users which are ``trusted'' by the local host when a +connection is made via +.Xr rlogind 8 , +.Xr rshd 8 , +or any other server that uses +.Xr ruserok 3 . +This mechanism bypasses password checks, and is required for access via +.Xr rsh 1 . +.Pp +Each line of these files has the format: +.Pp +.Bd -unfilled -offset indent -compact +hostname [username] +.Ed +.Pp +The +.Em hostname +may be specified as a host name (typically a fully qualified host +name in a DNS environment) or address, +.Em +@netgroup +(from which only the host names are checked), +or a ``+'' wildcard (allow all hosts). +.Pp +The +.Em username , +if specified, may be given as a user name on the remote host, +.Em +@netgroup +(from which only the user names are checked), +or a ``+'' wildcard (allow all remote users). +.Pp +If a +.Em username +is specified, only that user from the specified host may login to the +local machine. If a +.Em username +is not specified, any user may login with the same user name. +.Sh EXAMPLES +.Li somehost +.Bd -filled -offset indent -compact +A common usage: users on +.Em somehost +may login to the local host as the same user name. +.Ed +.Li somehost username +.Bd -filled -offset indent -compact +The user +.Em username +on +.Em somehost +may login to the local host. If specified in +.Em /etc/hosts.equiv , +the user may login with only the same user name. +.Ed +.Li +@anetgroup username +.Bd -filled -offset indent -compact +The user +.Em username +may login to the local host from any machine listed in the netgroup +.Em anetgroup . +.Ed +.Bd -literal -compact ++ ++ + +.Ed +.Bd -filled -offset indent -compact +Two severe security hazards. In the first case, allows a user on any +machine to login to the local host as the same user name. In the second +case, allows any user on any machine to login to the local host (as any +user, if in +.Em /etc/hosts.equiv ) . +.Ed +.Sh WARNINGS +The username checks provided by this mechanism are +.Em not +secure, as the remote user name is received by the server unchecked +for validity. Therefore this mechanism should only be used +in an environment where all hosts are completely trusted. +.Pp +A numeric host address instead of a host name can help security +considerations somewhat; the address is then used directly by +.Xr iruserok 3 . +.Pp +When a username (or netgroup, or +) is specified in +.Em /etc/hosts.equiv , +that user (or group of users, or all users, respectively) may login to +the local host as +.Em any local user . +Usernames in +.Em /etc/hosts.equiv +should therefore be used with extreme caution, or not at all. +.Pp +A +.Em .rhosts +file must be owned by the user whose home directory it resides in, and +must be writable only by that user. +.Pp +Logins as root only check root's +.Em .rhosts +file; the +.Em /etc/hosts.equiv +file is not checked for security. Access permitted through root's +.Em .rhosts +file is typically only for +.Xr rsh 1 , +as root must still login on the console for an interactive login such as +.Xr rlogin 1 . +.Sh FILES +.Bl -tag -width /etc/hosts.equiv -compact +.It Pa /etc/hosts.equiv +Global trusted host-user pairs list +.It Pa ~/.rhosts +Per-user trusted host-user pairs list +.El +.Sh SEE ALSO +.Xr rcp 1 , +.Xr rlogin 1 , +.Xr rsh 1 , +.Xr rcmd 3 , +.Xr ruserok 3 , +.Xr netgroup 5 +.Re +.Sh HISTORY +The +.Nm .rhosts +file format appeared in +.Bx 4.2 . +.Sh BUGS +The +.Xr ruserok 3 +implementation currently skips negative entries (preceded with a +``-'' sign) and does not treat them as ``short-circuit'' negative entries. diff --git a/util.subproj/hton.c b/util.subproj/hton.c index 312d514..4b765bb 100644 --- a/util.subproj/hton.c +++ b/util.subproj/hton.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/util.subproj/putpwpasswd.c b/util.subproj/putpwpasswd.c index 976ef2f..60bbdbc 100644 --- a/util.subproj/putpwpasswd.c +++ b/util.subproj/putpwpasswd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ diff --git a/util.subproj/pwcache.c b/util.subproj/pwcache.c index 3f2b72b..dd0059d 100644 --- a/util.subproj/pwcache.c +++ b/util.subproj/pwcache.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -39,6 +40,7 @@ #include #include #include +#include #include #include diff --git a/util.subproj/rcmd.c b/util.subproj/rcmd.c index 4345fb7..29b256d 100644 --- a/util.subproj/rcmd.c +++ b/util.subproj/rcmd.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -84,7 +85,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include #include #endif -#include +#include /* wrapper for KAME-special getnameinfo() */ #ifndef NI_WITHSCOPEID @@ -96,6 +97,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #endif extern int innetgr __P(( const char *, const char *, const char *, const char * )); +extern int bindresvport_sa(int, struct sockaddr *); #define max(a, b) ((a > b) ? a : b) @@ -107,17 +109,6 @@ int __ivaliduser_sa __P((FILE *, const struct sockaddr *, socklen_t, static int __icheckhost __P((const struct sockaddr *, socklen_t, const char *)); - -int -rcmd(ahost, rport, locuser, remuser, cmd, fd2p) - char **ahost; - in_port_t rport; - const char *locuser, *remuser, *cmd; - int *fd2p; -{ - return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); -} - int rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) char **ahost; @@ -346,6 +337,16 @@ bad: } int +rcmd(ahost, rport, locuser, remuser, cmd, fd2p) + char **ahost; + in_port_t rport; + const char *locuser, *remuser, *cmd; + int *fd2p; +{ + return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); +} + +int rresvport(port) int *port; { @@ -404,57 +405,6 @@ rresvport_af(alport, family) int __check_rhosts_file = 1; char *__rcmd_errstr; -int -ruserok(rhost, superuser, ruser, luser) - const char *rhost, *ruser, *luser; - int superuser; -{ - struct addrinfo hints, *res, *r; - int error; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - error = getaddrinfo(rhost, "0", &hints, &res); - if (error) - return (-1); - - for (r = res; r; r = r->ai_next) { - if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser, - luser) == 0) { - freeaddrinfo(res); - return (0); - } - } - freeaddrinfo(res); - return (-1); -} - -/* - * New .rhosts strategy: We are passed an ip address. We spin through - * hosts.equiv and .rhosts looking for a match. When the .rhosts only - * has ip addresses, we don't have to trust a nameserver. When it - * contains hostnames, we spin through the list of addresses the nameserver - * gives us and look for a match. - * - * Returns 0 if ok, -1 if not ok. - */ -int -iruserok(raddr, superuser, ruser, luser) - unsigned long raddr; - int superuser; - const char *ruser, *luser; -{ - struct sockaddr_in sin; - - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr)); - return iruserok_sa((struct sockaddr *)&sin, sin.sin_len, superuser, - ruser, luser); -} - /* * AF independent extension of iruserok. * @@ -538,6 +488,57 @@ again: return (-1); } +int +ruserok(rhost, superuser, ruser, luser) + const char *rhost, *ruser, *luser; + int superuser; +{ + struct addrinfo hints, *res, *r; + int error; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_DGRAM; /*dummy*/ + error = getaddrinfo(rhost, "0", &hints, &res); + if (error) + return (-1); + + for (r = res; r; r = r->ai_next) { + if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser, + luser) == 0) { + freeaddrinfo(res); + return (0); + } + } + freeaddrinfo(res); + return (-1); +} + +/* + * New .rhosts strategy: We are passed an ip address. We spin through + * hosts.equiv and .rhosts looking for a match. When the .rhosts only + * has ip addresses, we don't have to trust a nameserver. When it + * contains hostnames, we spin through the list of addresses the nameserver + * gives us and look for a match. + * + * Returns 0 if ok, -1 if not ok. + */ +int +iruserok(raddr, superuser, ruser, luser) + unsigned long raddr; + int superuser; + const char *ruser, *luser; +{ + struct sockaddr_in sin; + + memset(&sin, 0, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_len = sizeof(struct sockaddr_in); + memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr)); + return iruserok_sa((struct sockaddr *)&sin, sin.sin_len, superuser, + ruser, luser); +} + /* * XXX * Don't make static, used by lpd(8). @@ -632,10 +633,12 @@ __ivaliduser_sa(hostf, raddr, salen, luser, ruser) #else #define ypdomain NULL #endif - /* We need to get the damn hostname back for netgroup matching. */ - if (getnameinfo(raddr, salen, hname, sizeof(hname), NULL, 0, - NI_NAMEREQD) != 0) - return (-1); + /* + * We try to get the hostname back for netgroup matching. + * However, the .rosts file may contain IP addresses as well + * as names, so a name is not always required. + */ + getnameinfo(raddr, salen, hname, sizeof(hname), NULL, 0, NI_NAMEREQD); while (fgets(buf, sizeof(buf), hostf)) { p = buf; diff --git a/util.subproj/rcmdsh.c b/util.subproj/rcmdsh.c index 988e614..ec03f90 100644 --- a/util.subproj/rcmdsh.c +++ b/util.subproj/rcmdsh.c @@ -3,21 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights - * Reserved. This file contains Original Code and/or Modifications of - * Original Code as defined in and that are subject to the Apple Public - * Source License Version 1.1 (the "License"). You may not use this file - * except in compliance with the License. Please obtain a copy of the - * License at http://www.apple.com/publicsource and read it before using - * this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * * The Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ -- 2.7.4