2D31A0FD128074E700D5A84C /* getifmaddrs.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D31A0FB128074E700D5A84C /* getifmaddrs.c */; };
2D4070B1129354A700FE81ED /* getnameinfo_link.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D4070B0129354A700FE81ED /* getnameinfo_link.c */; };
2D4070B2129354A700FE81ED /* getnameinfo_link.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D4070B0129354A700FE81ED /* getnameinfo_link.c */; };
+ 2D5DD5D21608E6E80051891A /* configuration_profile.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D5DD5D01608E6E80051891A /* configuration_profile.c */; };
+ 2D5DD5D31608E6E80051891A /* configuration_profile.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D5DD5D01608E6E80051891A /* configuration_profile.c */; };
3FCF60EC1257C272008D8BB1 /* herror.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283EE11478C200058CCB0 /* herror.c */; };
3FCF60ED1257C272008D8BB1 /* res_comp.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F711478C200058CCB0 /* res_comp.c */; };
- 3FCF60EE1257C272008D8BB1 /* res_data.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F811478C200058CCB0 /* res_data.c */; };
- 3FCF60EF1257C272008D8BB1 /* res_debug.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F911478C200058CCB0 /* res_debug.c */; };
- 3FCF60F01257C272008D8BB1 /* res_init.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FA11478C200058CCB0 /* res_init.c */; };
- 3FCF60F11257C272008D8BB1 /* res_mkquery.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FB11478C200058CCB0 /* res_mkquery.c */; };
3FCF60F21257C272008D8BB1 /* res_query.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FC11478C200058CCB0 /* res_query.c */; };
- 3FCF60F31257C272008D8BB1 /* res_send.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FE11478C200058CCB0 /* res_send.c */; };
3FCF60F41257C272008D8BB1 /* getifaddrs.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840411478C200058CCB0 /* getifaddrs.c */; };
3FCF60F51257C272008D8BB1 /* if_indextoname.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840A11478C200058CCB0 /* if_indextoname.c */; };
3FCF60F61257C272008D8BB1 /* if_nameindex.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840B11478C200058CCB0 /* if_nameindex.c */; };
3FCF60F71257C272008D8BB1 /* if_nametoindex.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840C11478C200058CCB0 /* if_nametoindex.c */; };
- 3FCF60F81257C272008D8BB1 /* inet_ntop.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841011478C200058CCB0 /* inet_ntop.c */; };
- 3FCF60F91257C272008D8BB1 /* inet_pton.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841111478C200058CCB0 /* inet_pton.c */; };
3FCF60FA1257C272008D8BB1 /* ip6opt.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841211478C200058CCB0 /* ip6opt.c */; };
3FCF60FB1257C272008D8BB1 /* map_v4v6.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841411478C200058CCB0 /* map_v4v6.c */; };
3FCF60FC1257C272008D8BB1 /* rthdr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841511478C200058CCB0 /* rthdr.c */; };
3FCF60FD1257C272008D8BB1 /* vars.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841611478C200058CCB0 /* vars.c */; };
3FCF610A1257C272008D8BB1 /* membership.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843E11478C200058CCB0 /* membership.c */; };
- 3FCF610B1257C272008D8BB1 /* ni_stub.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844411478C200058CCB0 /* ni_stub.c */; };
3FCF610C1257C272008D8BB1 /* getdomainname.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844611478C200058CCB0 /* getdomainname.c */; };
3FCF610D1257C272008D8BB1 /* getnetgrent.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844711478C200058CCB0 /* getnetgrent.c */; };
3FCF610E1257C272008D8BB1 /* innetgr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844811478C200058CCB0 /* innetgr.c */; };
3FCF61541257C272008D8BB1 /* xdr_sizeof.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284B611478C200058CCB0 /* xdr_sizeof.c */; };
3FCF61551257C272008D8BB1 /* xdr_stdio.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284B711478C200058CCB0 /* xdr_stdio.c */; };
3FCF61561257C272008D8BB1 /* hton.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BA11478C200058CCB0 /* hton.c */; };
- 3FCF61571257C272008D8BB1 /* putpwpasswd.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BC11478C200058CCB0 /* putpwpasswd.c */; };
3FCF61581257C272008D8BB1 /* rcmd.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BE11478C200058CCB0 /* rcmd.c */; };
- 3FCF61591257C272008D8BB1 /* rcmdsh.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BF11478C200058CCB0 /* rcmdsh.c */; };
3FCF615D1257C272008D8BB1 /* ether_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5285F6114793400058CCB0 /* ether_addr.c */; };
+ 3FFC065C167132160007509F /* cache_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841B11478C200058CCB0 /* cache_module.c */; };
+ 3FFC065D167132180007509F /* ds_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841C11478C200058CCB0 /* ds_module.c */; };
+ 3FFC065E1671321B0007509F /* file_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841D11478C200058CCB0 /* file_module.c */; };
+ 3FFC065F1671321E0007509F /* ils.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52842611478C200058CCB0 /* ils.c */; };
+ 3FFC0660167132270007509F /* kvbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52842911478C200058CCB0 /* kvbuf.c */; };
+ 3FFC0661167132270007509F /* libinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52842B11478C200058CCB0 /* libinfo.c */; };
+ 3FFC0662167132270007509F /* mdns_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52842E11478C200058CCB0 /* mdns_module.c */; };
+ 3FFC0663167132270007509F /* search_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843211478C200058CCB0 /* search_module.c */; };
+ 3FFC0664167132270007509F /* si_data.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843311478C200058CCB0 /* si_data.c */; };
+ 3FFC0665167132270007509F /* si_getaddrinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843511478C200058CCB0 /* si_getaddrinfo.c */; };
+ 3FFC0666167132270007509F /* si_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843611478C200058CCB0 /* si_module.c */; };
+ 3FFC0667167132270007509F /* thread_data.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843811478C200058CCB0 /* thread_data.c */; };
FC5284C011478C200058CCB0 /* herror.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283EE11478C200058CCB0 /* herror.c */; };
FC5284C811478C200058CCB0 /* res_comp.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F711478C200058CCB0 /* res_comp.c */; };
- FC5284C911478C200058CCB0 /* res_data.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F811478C200058CCB0 /* res_data.c */; };
- FC5284CA11478C200058CCB0 /* res_debug.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283F911478C200058CCB0 /* res_debug.c */; };
- FC5284CB11478C200058CCB0 /* res_init.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FA11478C200058CCB0 /* res_init.c */; };
- FC5284CC11478C200058CCB0 /* res_mkquery.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FB11478C200058CCB0 /* res_mkquery.c */; };
FC5284CD11478C200058CCB0 /* res_query.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FC11478C200058CCB0 /* res_query.c */; };
- FC5284CF11478C200058CCB0 /* res_send.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5283FE11478C200058CCB0 /* res_send.c */; };
FC5284D211478C200058CCB0 /* getifaddrs.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840411478C200058CCB0 /* getifaddrs.c */; };
FC5284D311478C200058CCB0 /* if_indextoname.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840A11478C200058CCB0 /* if_indextoname.c */; };
FC5284D411478C200058CCB0 /* if_nameindex.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840B11478C200058CCB0 /* if_nameindex.c */; };
FC5284D511478C200058CCB0 /* if_nametoindex.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52840C11478C200058CCB0 /* if_nametoindex.c */; };
- FC5284D711478C200058CCB0 /* inet_ntop.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841011478C200058CCB0 /* inet_ntop.c */; };
- FC5284D811478C200058CCB0 /* inet_pton.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841111478C200058CCB0 /* inet_pton.c */; };
FC5284D911478C200058CCB0 /* ip6opt.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841211478C200058CCB0 /* ip6opt.c */; };
FC5284DB11478C200058CCB0 /* map_v4v6.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841411478C200058CCB0 /* map_v4v6.c */; };
FC5284DC11478C200058CCB0 /* rthdr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52841511478C200058CCB0 /* rthdr.c */; };
FC5284F211478C200058CCB0 /* si_module.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843611478C200058CCB0 /* si_module.c */; };
FC5284F411478C200058CCB0 /* thread_data.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843811478C200058CCB0 /* thread_data.c */; };
FC5284F711478C200058CCB0 /* membership.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52843E11478C200058CCB0 /* membership.c */; };
- FC5284FC11478C200058CCB0 /* ni_stub.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844411478C200058CCB0 /* ni_stub.c */; };
FC5284FD11478C200058CCB0 /* getdomainname.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844611478C200058CCB0 /* getdomainname.c */; };
FC5284FE11478C200058CCB0 /* getnetgrent.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844711478C200058CCB0 /* getnetgrent.c */; };
FC5284FF11478C200058CCB0 /* innetgr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC52844811478C200058CCB0 /* innetgr.c */; };
FC52855811478C200058CCB0 /* xdr_sizeof.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284B611478C200058CCB0 /* xdr_sizeof.c */; };
FC52855911478C200058CCB0 /* xdr_stdio.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284B711478C200058CCB0 /* xdr_stdio.c */; };
FC52855A11478C200058CCB0 /* hton.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BA11478C200058CCB0 /* hton.c */; };
- FC52855C11478C200058CCB0 /* putpwpasswd.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BC11478C200058CCB0 /* putpwpasswd.c */; };
FC52855D11478C200058CCB0 /* rcmd.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BE11478C200058CCB0 /* rcmd.c */; };
- FC52855E11478C200058CCB0 /* rcmdsh.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5284BF11478C200058CCB0 /* rcmdsh.c */; };
- FC5285D4114791B50058CCB0 /* DSlibinfoMIG.defs in Sources */ = {isa = PBXBuildFile; fileRef = FC5285D1114791B50058CCB0 /* DSlibinfoMIG.defs */; };
FC5285F7114793400058CCB0 /* ether_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = FC5285F6114793400058CCB0 /* ether_addr.c */; };
/* End PBXBuildFile section */
2D31A0FB128074E700D5A84C /* getifmaddrs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getifmaddrs.c; sourceTree = "<group>"; };
2D4070B0129354A700FE81ED /* getnameinfo_link.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getnameinfo_link.c; sourceTree = "<group>"; };
2D4D4AB1122C5B83009791E5 /* inet6_rth_space.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_rth_space.3; sourceTree = "<group>"; };
+ 2D5DD5D01608E6E80051891A /* configuration_profile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = configuration_profile.c; sourceTree = "<group>"; };
+ 2D5DD5D11608E6E80051891A /* configuration_profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = configuration_profile.h; sourceTree = "<group>"; };
2DBB147712DBD63300D710E3 /* inet6_opt_init.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_opt_init.3; sourceTree = "<group>"; };
3FCF61621257C272008D8BB1 /* libsystem_sim_info.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_sim_info.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
D2AAC0630554660B00DB518D /* libsystem_info.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_info.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
FC5283EE11478C200058CCB0 /* herror.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = herror.c; sourceTree = "<group>"; };
- FC5283EF11478C200058CCB0 /* inet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inet.h; sourceTree = "<group>"; };
- FC5283F311478C200058CCB0 /* nameser8_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nameser8_compat.h; sourceTree = "<group>"; };
- FC5283F511478C200058CCB0 /* options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = options.h; sourceTree = "<group>"; };
- FC5283F611478C200058CCB0 /* portability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = portability.h; sourceTree = "<group>"; };
FC5283F711478C200058CCB0 /* res_comp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_comp.c; sourceTree = "<group>"; };
- FC5283F811478C200058CCB0 /* res_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_data.c; sourceTree = "<group>"; };
- FC5283F911478C200058CCB0 /* res_debug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_debug.c; sourceTree = "<group>"; };
- FC5283FA11478C200058CCB0 /* res_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_init.c; sourceTree = "<group>"; };
- FC5283FB11478C200058CCB0 /* res_mkquery.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_mkquery.c; sourceTree = "<group>"; };
FC5283FC11478C200058CCB0 /* res_query.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_query.c; sourceTree = "<group>"; };
- FC5283FE11478C200058CCB0 /* res_send.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = res_send.c; sourceTree = "<group>"; };
- FC5283FF11478C200058CCB0 /* resolv8_compat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resolv8_compat.h; sourceTree = "<group>"; };
FC52840211478C200058CCB0 /* gethostbyname.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = gethostbyname.3; sourceTree = "<group>"; };
FC52840311478C200058CCB0 /* getifaddrs.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = getifaddrs.3; sourceTree = "<group>"; };
FC52840411478C200058CCB0 /* getifaddrs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getifaddrs.c; sourceTree = "<group>"; };
FC52840D11478C200058CCB0 /* ifaddrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ifaddrs.h; sourceTree = "<group>"; };
FC52840E11478C200058CCB0 /* inet6_option_space.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_option_space.3; sourceTree = "<group>"; };
FC52840F11478C200058CCB0 /* inet6_rthdr_space.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_rthdr_space.3; sourceTree = "<group>"; };
- FC52841011478C200058CCB0 /* inet_ntop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inet_ntop.c; sourceTree = "<group>"; };
- FC52841111478C200058CCB0 /* inet_pton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inet_pton.c; sourceTree = "<group>"; };
FC52841211478C200058CCB0 /* ip6opt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip6opt.c; sourceTree = "<group>"; };
FC52841411478C200058CCB0 /* map_v4v6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = map_v4v6.c; sourceTree = "<group>"; };
FC52841511478C200058CCB0 /* rthdr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rthdr.c; sourceTree = "<group>"; };
FC52843F11478C200058CCB0 /* membership.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = membership.h; sourceTree = "<group>"; };
FC52844011478C200058CCB0 /* membershipPriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = membershipPriv.h; sourceTree = "<group>"; };
FC52844111478C200058CCB0 /* ntsid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ntsid.h; sourceTree = "<group>"; };
- FC52844411478C200058CCB0 /* ni_stub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ni_stub.c; sourceTree = "<group>"; };
FC52844611478C200058CCB0 /* getdomainname.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getdomainname.c; sourceTree = "<group>"; };
FC52844711478C200058CCB0 /* getnetgrent.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getnetgrent.c; sourceTree = "<group>"; };
FC52844811478C200058CCB0 /* innetgr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = innetgr.c; sourceTree = "<group>"; };
FC5284B711478C200058CCB0 /* xdr_stdio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xdr_stdio.c; sourceTree = "<group>"; };
FC5284B911478C200058CCB0 /* hosts.equiv.5 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hosts.equiv.5; sourceTree = "<group>"; };
FC5284BA11478C200058CCB0 /* hton.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hton.c; sourceTree = "<group>"; };
- FC5284BC11478C200058CCB0 /* putpwpasswd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = putpwpasswd.c; sourceTree = "<group>"; };
FC5284BD11478C200058CCB0 /* rcmd.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = rcmd.3; sourceTree = "<group>"; };
FC5284BE11478C200058CCB0 /* rcmd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rcmd.c; sourceTree = "<group>"; };
- FC5284BF11478C200058CCB0 /* rcmdsh.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rcmdsh.c; sourceTree = "<group>"; };
- FC5285D1114791B50058CCB0 /* DSlibinfoMIG.defs */ = {isa = PBXFileReference; explicitFileType = sourcecode.mig; fileEncoding = 4; name = DSlibinfoMIG.defs; path = usr/local/include/opendirectory/DSlibinfoMIG.defs; sourceTree = SDKROOT; };
FC5285F6114793400058CCB0 /* ether_addr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ether_addr.c; sourceTree = "<group>"; };
FCFDBF0A145CC5C100A39A66 /* grp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = grp.h; sourceTree = "<group>"; };
FCFDBF0B145CC5C100A39A66 /* pwd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pwd.h; sourceTree = "<group>"; };
isa = PBXGroup;
children = (
FC5283EE11478C200058CCB0 /* herror.c */,
- FC5283EF11478C200058CCB0 /* inet.h */,
- FC5283F311478C200058CCB0 /* nameser8_compat.h */,
- FC5283F511478C200058CCB0 /* options.h */,
- FC5283F611478C200058CCB0 /* portability.h */,
FC5283F711478C200058CCB0 /* res_comp.c */,
- FC5283F811478C200058CCB0 /* res_data.c */,
- FC5283F911478C200058CCB0 /* res_debug.c */,
- FC5283FA11478C200058CCB0 /* res_init.c */,
- FC5283FB11478C200058CCB0 /* res_mkquery.c */,
FC5283FC11478C200058CCB0 /* res_query.c */,
- FC5283FE11478C200058CCB0 /* res_send.c */,
- FC5283FF11478C200058CCB0 /* resolv8_compat.h */,
);
path = dns.subproj;
sourceTree = "<group>";
FC52840011478C200058CCB0 /* gen.subproj */ = {
isa = PBXGroup;
children = (
+ 2D5DD5D01608E6E80051891A /* configuration_profile.c */,
+ 2D5DD5D11608E6E80051891A /* configuration_profile.h */,
2DBB147712DBD63300D710E3 /* inet6_opt_init.3 */,
2D31A0FA128074E700D5A84C /* getifmaddrs.3 */,
2D31A0FB128074E700D5A84C /* getifmaddrs.c */,
FC52840E11478C200058CCB0 /* inet6_option_space.3 */,
FC52840F11478C200058CCB0 /* inet6_rthdr_space.3 */,
2D4D4AB1122C5B83009791E5 /* inet6_rth_space.3 */,
- FC52841011478C200058CCB0 /* inet_ntop.c */,
- FC52841111478C200058CCB0 /* inet_pton.c */,
FC52841211478C200058CCB0 /* ip6opt.c */,
FC52841411478C200058CCB0 /* map_v4v6.c */,
FC52841511478C200058CCB0 /* rthdr.c */,
isa = PBXGroup;
children = (
2D4070B0129354A700FE81ED /* getnameinfo_link.c */,
- FC5285D1114791B50058CCB0 /* DSlibinfoMIG.defs */,
FC52841811478C200058CCB0 /* aliasdb.h */,
FC52841911478C200058CCB0 /* bootparams.5 */,
FC52841A11478C200058CCB0 /* bootparams.h */,
path = membership.subproj;
sourceTree = "<group>";
};
- FC52844211478C200058CCB0 /* netinfo.subproj */ = {
- isa = PBXGroup;
- children = (
- FC52844411478C200058CCB0 /* ni_stub.c */,
- );
- path = netinfo.subproj;
- sourceTree = "<group>";
- };
FC52844511478C200058CCB0 /* nis.subproj */ = {
isa = PBXGroup;
children = (
children = (
FC5284B911478C200058CCB0 /* hosts.equiv.5 */,
FC5284BA11478C200058CCB0 /* hton.c */,
- FC5284BC11478C200058CCB0 /* putpwpasswd.c */,
FC5284BD11478C200058CCB0 /* rcmd.3 */,
FC5284BE11478C200058CCB0 /* rcmd.c */,
- FC5284BF11478C200058CCB0 /* rcmdsh.c */,
);
path = util.subproj;
sourceTree = "<group>";
files = (
3FCF60EC1257C272008D8BB1 /* herror.c in Sources */,
3FCF60ED1257C272008D8BB1 /* res_comp.c in Sources */,
- 3FCF60EE1257C272008D8BB1 /* res_data.c in Sources */,
- 3FCF60EF1257C272008D8BB1 /* res_debug.c in Sources */,
- 3FCF60F01257C272008D8BB1 /* res_init.c in Sources */,
- 3FCF60F11257C272008D8BB1 /* res_mkquery.c in Sources */,
3FCF60F21257C272008D8BB1 /* res_query.c in Sources */,
- 3FCF60F31257C272008D8BB1 /* res_send.c in Sources */,
3FCF60F41257C272008D8BB1 /* getifaddrs.c in Sources */,
3FCF60F51257C272008D8BB1 /* if_indextoname.c in Sources */,
3FCF60F61257C272008D8BB1 /* if_nameindex.c in Sources */,
3FCF60F71257C272008D8BB1 /* if_nametoindex.c in Sources */,
- 3FCF60F81257C272008D8BB1 /* inet_ntop.c in Sources */,
- 3FCF60F91257C272008D8BB1 /* inet_pton.c in Sources */,
3FCF60FA1257C272008D8BB1 /* ip6opt.c in Sources */,
3FCF60FB1257C272008D8BB1 /* map_v4v6.c in Sources */,
3FCF60FC1257C272008D8BB1 /* rthdr.c in Sources */,
3FCF60FD1257C272008D8BB1 /* vars.c in Sources */,
3FCF610A1257C272008D8BB1 /* membership.c in Sources */,
- 3FCF610B1257C272008D8BB1 /* ni_stub.c in Sources */,
3FCF610C1257C272008D8BB1 /* getdomainname.c in Sources */,
3FCF610D1257C272008D8BB1 /* getnetgrent.c in Sources */,
3FCF610E1257C272008D8BB1 /* innetgr.c in Sources */,
3FCF61541257C272008D8BB1 /* xdr_sizeof.c in Sources */,
3FCF61551257C272008D8BB1 /* xdr_stdio.c in Sources */,
3FCF61561257C272008D8BB1 /* hton.c in Sources */,
- 3FCF61571257C272008D8BB1 /* putpwpasswd.c in Sources */,
3FCF61581257C272008D8BB1 /* rcmd.c in Sources */,
- 3FCF61591257C272008D8BB1 /* rcmdsh.c in Sources */,
3FCF615D1257C272008D8BB1 /* ether_addr.c in Sources */,
2D31A0FD128074E700D5A84C /* getifmaddrs.c in Sources */,
2D4070B2129354A700FE81ED /* getnameinfo_link.c in Sources */,
+ 2D5DD5D31608E6E80051891A /* configuration_profile.c in Sources */,
+ 3FFC065C167132160007509F /* cache_module.c in Sources */,
+ 3FFC065D167132180007509F /* ds_module.c in Sources */,
+ 3FFC065E1671321B0007509F /* file_module.c in Sources */,
+ 3FFC065F1671321E0007509F /* ils.c in Sources */,
+ 3FFC0660167132270007509F /* kvbuf.c in Sources */,
+ 3FFC0661167132270007509F /* libinfo.c in Sources */,
+ 3FFC0662167132270007509F /* mdns_module.c in Sources */,
+ 3FFC0663167132270007509F /* search_module.c in Sources */,
+ 3FFC0664167132270007509F /* si_data.c in Sources */,
+ 3FFC0665167132270007509F /* si_getaddrinfo.c in Sources */,
+ 3FFC0666167132270007509F /* si_module.c in Sources */,
+ 3FFC0667167132270007509F /* thread_data.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
files = (
FC5284C011478C200058CCB0 /* herror.c in Sources */,
FC5284C811478C200058CCB0 /* res_comp.c in Sources */,
- FC5284C911478C200058CCB0 /* res_data.c in Sources */,
- FC5284CA11478C200058CCB0 /* res_debug.c in Sources */,
- FC5284CB11478C200058CCB0 /* res_init.c in Sources */,
- FC5284CC11478C200058CCB0 /* res_mkquery.c in Sources */,
FC5284CD11478C200058CCB0 /* res_query.c in Sources */,
- FC5284CF11478C200058CCB0 /* res_send.c in Sources */,
FC5284D211478C200058CCB0 /* getifaddrs.c in Sources */,
FC5284D311478C200058CCB0 /* if_indextoname.c in Sources */,
FC5284D411478C200058CCB0 /* if_nameindex.c in Sources */,
FC5284D511478C200058CCB0 /* if_nametoindex.c in Sources */,
- FC5284D711478C200058CCB0 /* inet_ntop.c in Sources */,
- FC5284D811478C200058CCB0 /* inet_pton.c in Sources */,
FC5284D911478C200058CCB0 /* ip6opt.c in Sources */,
FC5284DB11478C200058CCB0 /* map_v4v6.c in Sources */,
FC5284DC11478C200058CCB0 /* rthdr.c in Sources */,
FC5284F211478C200058CCB0 /* si_module.c in Sources */,
FC5284F411478C200058CCB0 /* thread_data.c in Sources */,
FC5284F711478C200058CCB0 /* membership.c in Sources */,
- FC5284FC11478C200058CCB0 /* ni_stub.c in Sources */,
FC5284FD11478C200058CCB0 /* getdomainname.c in Sources */,
FC5284FE11478C200058CCB0 /* getnetgrent.c in Sources */,
FC5284FF11478C200058CCB0 /* innetgr.c in Sources */,
FC52855811478C200058CCB0 /* xdr_sizeof.c in Sources */,
FC52855911478C200058CCB0 /* xdr_stdio.c in Sources */,
FC52855A11478C200058CCB0 /* hton.c in Sources */,
- FC52855C11478C200058CCB0 /* putpwpasswd.c in Sources */,
FC52855D11478C200058CCB0 /* rcmd.c in Sources */,
- FC52855E11478C200058CCB0 /* rcmdsh.c in Sources */,
- FC5285D4114791B50058CCB0 /* DSlibinfoMIG.defs in Sources */,
FC5285F7114793400058CCB0 /* ether_addr.c in Sources */,
2D31A0FC128074E700D5A84C /* getifmaddrs.c in Sources */,
2D4070B1129354A700FE81ED /* getnameinfo_link.c in Sources */,
+ 2D5DD5D21608E6E80051891A /* configuration_profile.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
"__DARWIN_NON_CANCELABLE=1",
"__MigTypeCheck=1",
"INET6=1",
- USE_OPTIONS_H,
);
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphone*][arch=*]" = (
CONFIG_IPHONE,
);
INSTALLHDRS_SCRIPT_PHASE = YES;
INSTALL_PATH = /usr/lib/system;
+ LINK_WITH_STANDARD_LIBRARIES = NO;
ORDER_FILE = "$(SDKROOT)/$(APPLE_INTERNAL_DIR)/OrderFiles/libsystem_info.order";
+ OTHER_LDFLAGS = (
+ "-Wl,-umbrella,System",
+ "-L/usr/lib/system",
+ "-lcompiler_rt",
+ "-ldispatch",
+ "-ldyld",
+ "-llaunch",
+ "-lsystem_asl",
+ "-lsystem_blocks",
+ "-lsystem_dnssd",
+ "-lsystem_kernel",
+ "-lsystem_notify",
+ "-lsystem_malloc",
+ "-lsystem_platform",
+ "-lsystem_pthread",
+ "-lsystem_c",
+ "-lxpc",
+ "-Wl,-upward-lsystem_network",
+ );
PRODUCT_NAME = info;
VERSION_INFO_EXPORT_DECL = static;
VERSION_INFO_PREFIX = __;
CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)";
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
VERSIONING_SYSTEM = "apple-generic";
"__DARWIN_NON_CANCELABLE=1",
"__MigTypeCheck=1",
"INET6=1",
- USE_OPTIONS_H,
);
"GCC_PREPROCESSOR_DEFINITIONS[sdk=iphone*][arch=*]" = (
CONFIG_IPHONE,
);
INSTALLHDRS_SCRIPT_PHASE = YES;
INSTALL_PATH = "$(SDKROOT)/usr/lib/system";
+ LINK_WITH_STANDARD_LIBRARIES = NO;
+ OTHER_LDFLAGS = (
+ "-Wl,-umbrella,System",
+ "-Wl,-upward-lSystem",
+ );
PRODUCT_NAME = info;
VERSION_INFO_EXPORT_DECL = static;
VERSION_INFO_PREFIX = __;
-/*
- * 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++ 1987, 1993
* -
#include <sys/param.h>
#include <sys/uio.h>
#include <netdb.h>
-#if defined(BSD) && (BSD >= 199103)
-# include <unistd.h>
-# include <string.h>
-#else
-# include "portability.h"
-#endif
+#include <string.h>
+#include <unistd.h>
-const char *h_errlist[] = {
+const char * const h_errlist[] = {
"Resolver Error 0 (no error)",
"Unknown host", /* 1 HOST_NOT_FOUND */
"Host name lookup failure", /* 2 TRY_AGAIN */
"Unknown server error", /* 3 NO_RECOVERY */
"No address associated with name", /* 4 NO_ADDRESS */
};
-int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
+const int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
-#if defined(__APPLE__)
-int h_errno = 0;
-#else
-extern int h_errno;
-#endif /* !NeXT */
+int h_errno;
/*
* herror --
* print the error indicated by the h_errno value.
*/
void
-herror(s)
- const char *s;
+herror(const char *s)
{
struct iovec iov[4];
register struct iovec *v = iov;
}
const char *
-hstrerror(err)
- int err;
+hstrerror(int err)
{
if (err < 0)
return ("Resolver internal error");
+++ /dev/null
-/*
- * 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++ 1983, 1993
- * -
- * Copyright (c) 1983, 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--
- */
-
-/*
- * @(#)inet.h 8.1 (Berkeley) 6/2/93
- * $Id: inet.h,v 1.10 2006/02/01 18:09:47 majka Exp $
- */
-
-#ifndef _INET_H_
-#define _INET_H_
-
-/* External definitions for functions in inet(3) */
-
-#include <_types.h>
-#include <stdint.h> /* uint32_t uint16_t */
-#include <machine/endian.h> /* htonl() and family if (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
-#include <sys/_endian.h> /* htonl() and family if (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
-#include <netinet/in.h> /* in_addr */
-
-__BEGIN_DECLS
-
-in_addr_t inet_addr(const char *);
-char *inet_ntoa(struct in_addr);
-const char *inet_ntop(int, const void *, char *, socklen_t);
-int inet_pton(int, const char *, void *);
-#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
-int ascii2addr(int, const char *, void *);
-char *addr2ascii(int, const void *, int, 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_net_ntop(int, const void *, int, char *, __darwin_size_t);
-int inet_net_pton(int, const char *, void *, __darwin_size_t);
-char *inet_neta(in_addr_t, char *, __darwin_size_t);
-unsigned int inet_nsap_addr(const char *, unsigned char *, int maxlen);
-char *inet_nsap_ntoa(int, const unsigned char *, char *ascii);
-#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */
-
-__END_DECLS
-
-#endif /* !_INET_H_ */
+++ /dev/null
-/*
- * 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++ 1983, 1990, 1993
- * -
- * Copyright (c) 1983, 1990, 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--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
-static char rcsid[] = "$Id: inet_addr.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-#include "portability.h"
-
-/* these are compatibility routines, not needed on recent BSD releases */
-
-/*
- * Ascii internet address interpretation routine.
- * The value returned is in network order.
- */
-u_long
-inet_addr(cp)
- register const char *cp;
-{
- struct in_addr val;
-
- if (inet_aton(cp, &val))
- return (val.s_addr);
- return (INADDR_NONE);
-}
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-inet_aton(cp, addr)
- register const char *cp;
- struct in_addr *addr;
-{
- register u_long val;
- register int base, n;
- register char c;
- u_int parts[4];
- register u_int *pp = parts;
-
- c = *cp;
- for (;;) {
- /*
- * Collect number up to ``.''.
- * Values are specified as for C:
- * 0x=hex, 0=octal, isdigit=decimal.
- */
- if (!isdigit(c))
- return (0);
- val = 0; base = 10;
- if (c == '0') {
- c = *++cp;
- if (c == 'x' || c == 'X')
- base = 16, c = *++cp;
- else
- base = 8;
- }
- for (;;) {
- if (isascii(c) && isdigit(c)) {
- val = (val * base) + (c - '0');
- c = *++cp;
- } else if (base == 16 && isascii(c) && isxdigit(c)) {
- val = (val << 4) |
- (c + 10 - (islower(c) ? 'a' : 'A'));
- c = *++cp;
- } else
- break;
- }
- if (c == '.') {
- /*
- * Internet format:
- * a.b.c.d
- * a.b.c (with c treated as 16 bits)
- * a.b (with b treated as 24 bits)
- */
- if (pp >= parts + 3)
- return (0);
- *pp++ = val;
- c = *++cp;
- } else
- break;
- }
- /*
- * Check for trailing characters.
- */
- if (c != '\0' && (!isascii(c) || !isspace(c)))
- return (0);
- /*
- * Concoct the address according to
- * the number of parts specified.
- */
- n = pp - parts + 1;
- switch (n) {
-
- case 0:
- return (0); /* initial nondigit */
-
- case 1: /* a -- 32 bits */
- break;
-
- case 2: /* a.b -- 8.24 bits */
- if (val > 0xffffff)
- return (0);
- val |= parts[0] << 24;
- break;
-
- case 3: /* a.b.c -- 8.8.16 bits */
- if (val > 0xffff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16);
- break;
-
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
- if (val > 0xff)
- return (0);
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
- break;
- }
- if (addr)
- addr->s_addr = htonl(val);
- return (1);
-}
+++ /dev/null
-/*
- * 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++ 1983, 1989, 1993
- * -
- * Copyright (c) 1983, 1989, 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--
- */
-
-/*
- * @(#)nameser.h 8.1 (Berkeley) 6/2/93
- * $Id: nameser8_compat.h,v 1.3 2004/10/28 21:58:13 emoy Exp $
- */
-
-#ifndef _NAMESER_H_
-#define _NAMESER_H_
-
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-
-#ifdef _AUX_SOURCE
-#include <sys/types.h> /* ech for A/UX */
-#define res_send ucb_res_send /* already def'd in libc */
-#define _res_close _ucb_res_close /* removing res_send.o from the library */
-#endif /* gives an undefined symbol... */
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__BIND > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __BIND 19950621 /* interface version stamp */
-
-/*
- * Define constants based on rfc883
- */
-#define PACKETSZ 512 /* maximum packet size */
-#define MAXDNAME 256 /* maximum domain name */
-#define MAXCDNAME 255 /* maximum compressed domain name */
-#define MAXLABEL 63 /* maximum length of domain label */
-#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
-#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
-#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
-#define INT32SZ 4 /* for systems without 32-bit ints */
-#define INT16SZ 2 /* for systems without 16-bit ints */
-#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
-
-/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Currently defined opcodes
- */
-#define QUERY 0x0 /* standard query */
-#define IQUERY 0x1 /* inverse query */
-#define STATUS 0x2 /* nameserver status query */
-/*#define xxx 0x3*/ /* 0x3 reserved */
-#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
-#ifdef ALLOW_UPDATES
- /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
-# define UPDATEA 0x9 /* add resource record */
-# define UPDATED 0xa /* delete a specific resource record */
-# define UPDATEDA 0xb /* delete all named resource record */
-# define UPDATEM 0xc /* modify a specific resource record */
-# define UPDATEMA 0xd /* modify all named resource record */
-# define ZONEINIT 0xe /* initial zone transfer */
-# define ZONEREF 0xf /* incremental zone referesh */
-#endif
-
-/*
- * Currently defined response codes
- */
-#define NOERROR 0 /* no error */
-#define FORMERR 1 /* format error */
-#define SERVFAIL 2 /* server failure */
-#define NXDOMAIN 3 /* non existent domain */
-#define NOTIMP 4 /* not implemented */
-#define REFUSED 5 /* query refused */
-#ifdef ALLOW_UPDATES
- /* non standard */
-# define NOCHANGE 0xf /* update failed to change db */
-#endif
-
-/*
- * Type values for resources and queries
- */
-#define T_A 1 /* host address */
-#define T_NS 2 /* authoritative server */
-#define T_MD 3 /* mail destination */
-#define T_MF 4 /* mail forwarder */
-#define T_CNAME 5 /* canonical name */
-#define T_SOA 6 /* start of authority zone */
-#define T_MB 7 /* mailbox domain name */
-#define T_MG 8 /* mail group member */
-#define T_MR 9 /* mail rename name */
-#define T_NULL 10 /* null resource record */
-#define T_WKS 11 /* well known service */
-#define T_PTR 12 /* domain name pointer */
-#define T_HINFO 13 /* host information */
-#define T_MINFO 14 /* mailbox information */
-#define T_MX 15 /* mail routing information */
-#define T_TXT 16 /* text strings */
-#define T_RP 17 /* responsible person */
-#define T_AFSDB 18 /* AFS cell database */
-#define T_X25 19 /* X_25 calling address */
-#define T_ISDN 20 /* ISDN calling address */
-#define T_RT 21 /* router */
-#define T_NSAP 22 /* NSAP address */
-#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
-#define T_SIG 24 /* security signature */
-#define T_KEY 25 /* security key */
-#define T_PX 26 /* X.400 mail mapping */
-#define T_GPOS 27 /* geographical position (withdrawn) */
-#define T_AAAA 28 /* IP6 Address */
-#define T_LOC 29 /* Location Information */
- /* non standard */
-#define T_UINFO 100 /* user (finger) information */
-#define T_UID 101 /* user ID */
-#define T_GID 102 /* group ID */
-#define T_UNSPEC 103 /* Unspecified format (binary data) */
- /* Query type values which do not appear in resource records */
-#define T_AXFR 252 /* transfer zone of authority */
-#define T_MAILB 253 /* transfer mailbox records */
-#define T_MAILA 254 /* transfer mail agent records */
-#define T_ANY 255 /* wildcard match */
-
-/*
- * Values for class field
- */
-
-#define C_IN 1 /* the arpa internet */
-#define C_CHAOS 3 /* for chaos net (MIT) */
-#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
- /* Query class values which do not appear in resource records */
-#define C_ANY 255 /* wildcard match */
-
-/*
- * Status return codes for T_UNSPEC conversion routines
- */
-#define CONV_SUCCESS 0
-#define CONV_OVERFLOW (-1)
-#define CONV_BADFMT (-2)
-#define CONV_BADCKSUM (-3)
-#define CONV_BADBUFLEN (-4)
-
-#ifndef BYTE_ORDER
-#if (BSD >= 199103)
-# include <machine/endian.h>
-#else
-#ifdef linux
-# include <endian.h>
-#else
-#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(__i386__) || \
- defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
- defined(__alpha__) || defined(__alpha)
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
- defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
- defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
- defined(apollo) || defined(__convex__) || defined(_CRAY) || \
- defined(__hppa) || defined(__hp9000) || \
- defined(__hp9000s300) || defined(__hp9000s700) || \
- defined (BIT_ZERO_ON_LEFT) || defined(m68k)
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-#endif /* linux */
-#endif /* BSD */
-#endif /* BYTE_ORDER */
-
-#if !defined(BYTE_ORDER) || \
- (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
- BYTE_ORDER != PDP_ENDIAN)
- /* you must determine what the correct bit order is for
- * your compiler - the next line is an intentional error
- * which will force your compiles to bomb until you fix
- * the above macros.
- */
- error "Undefined or invalid BYTE_ORDER";
-#endif
-
-/*
- * Structure for query header. The order of the fields is machine- and
- * compiler-dependent, depending on the byte/bit order and the layout
- * of bit fields. We use bit fields only in int variables, as this
- * is all ANSI requires. This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
- unsigned id :16; /* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
- /* fields in third byte */
- unsigned qr: 1; /* response flag */
- unsigned opcode: 4; /* purpose of message */
- unsigned aa: 1; /* authoritive answer */
- unsigned tc: 1; /* truncated message */
- unsigned rd: 1; /* recursion desired */
- /* fields in fourth byte */
- unsigned ra: 1; /* recursion available */
- unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned rcode :4; /* response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
- /* fields in third byte */
- unsigned rd :1; /* recursion desired */
- unsigned tc :1; /* truncated message */
- unsigned aa :1; /* authoritive answer */
- unsigned opcode :4; /* purpose of message */
- unsigned qr :1; /* response flag */
- /* fields in fourth byte */
- unsigned rcode :4; /* response code */
- unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned ra :1; /* recursion available */
-#endif
- /* remaining bytes */
- unsigned qdcount :16; /* number of question entries */
- unsigned ancount :16; /* number of answer entries */
- unsigned nscount :16; /* number of authority entries */
- unsigned arcount :16; /* number of resource entries */
-} HEADER;
-
-/*
- * Defines for handling compressed domain names
- */
-#define INDIR_MASK 0xc0
-
-/*
- * Structure for passing resource records around.
- */
-struct rrec {
- int16_t r_zone; /* zone number */
- int16_t r_class; /* class number */
- int16_t r_type; /* type number */
- u_int32_t r_ttl; /* time to live */
- int r_size; /* size of data area */
- char *r_data; /* pointer to data */
-};
-
-extern u_int16_t _getshort __P((const unsigned char *));
-extern u_int32_t _getlong __P((const unsigned char *));
-
-/*
- * Inline versions of get/put short/long. Pointer is advanced.
- *
- * These macros demonstrate the property of C whereby it can be
- * portable or it can be elegant but rarely both.
- */
-#define GETSHORT(s, cp) { \
- register unsigned char *t_cp = (unsigned char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) \
- | ((u_int16_t)t_cp[1]) \
- ; \
- (cp) += INT16SZ; \
-}
-
-#define GETLONG(l, cp) { \
- register unsigned char *t_cp = (unsigned char *)(cp); \
- (l) = ((u_int32_t)t_cp[0] << 24) \
- | ((u_int32_t)t_cp[1] << 16) \
- | ((u_int32_t)t_cp[2] << 8) \
- | ((u_int32_t)t_cp[3]) \
- ; \
- (cp) += INT32SZ; \
-}
-
-#define PUTSHORT(s, cp) { \
- register u_int16_t t_s = (u_int16_t)(s); \
- register unsigned char *t_cp = (unsigned char *)(cp); \
- *t_cp++ = t_s >> 8; \
- *t_cp = t_s; \
- (cp) += INT16SZ; \
-}
-
-#define PUTLONG(l, cp) { \
- register u_int32_t t_l = (u_int32_t)(l); \
- register unsigned char *t_cp = (unsigned char *)(cp); \
- *t_cp++ = t_l >> 24; \
- *t_cp++ = t_l >> 16; \
- *t_cp++ = t_l >> 8; \
- *t_cp = t_l; \
- (cp) += INT32SZ; \
-}
-
-#endif /* !_NAMESER_H_ */
+++ /dev/null
-/*
- * 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@
- */
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: nsap_addr.c,v 1.3 2003/02/18 17:29:24 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <ctype.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-#include "portability.h"
-
-#if !defined(isxdigit) /* XXX - could be a function */
-static int
-isxdigit(c)
- register int c;
-{
- return ((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'));
-}
-#endif
-
-static char
-xtob(c)
- register int c;
-{
- return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
-}
-
-u_int
-inet_nsap_addr(ascii, binary, maxlen)
- const char *ascii;
- u_char *binary;
- int maxlen;
-{
- register u_char c, nib;
- u_int len = 0;
-
- while ((c = *ascii++) != '\0' && len < maxlen) {
- if (c == '.' || c == '+' || c == '/')
- continue;
- if (!isascii(c))
- return (0);
- if (islower(c))
- c = toupper(c);
- if (isxdigit(c)) {
- nib = xtob(c);
- if (c = *ascii++) {
- c = toupper(c);
- if (isxdigit(c)) {
- *binary++ = (nib << 4) | xtob(c);
- len++;
- } else
- return (0);
- }
- else
- return (0);
- }
- else
- return (0);
- }
- return (len);
-}
-
-char *
-inet_nsap_ntoa(binlen, binary, ascii)
- int binlen;
- register const u_char *binary;
- register char *ascii;
-{
- register int nib;
- int i;
- static char tmpbuf[255*3];
- char *start;
-
- if (ascii)
- start = ascii;
- else {
- ascii = tmpbuf;
- start = tmpbuf;
- }
-
- if (binlen > 255)
- binlen = 255;
-
- for (i = 0; i < binlen; i++) {
- nib = *binary >> 4;
- *ascii++ = nib + (nib < 10 ? '0' : '7');
- nib = *binary++ & 0x0f;
- *ascii++ = nib + (nib < 10 ? '0' : '7');
- if (((i % 2) == 0 && (i + 1) < binlen))
- *ascii++ = '.';
- }
- *ascii = '\0';
- return (start);
-}
+++ /dev/null
-/*
- * 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@
- */
-/* options.h - specify the conditionally-compiled features
- * vix 28mar92 [moved out of the Makefile because they were getting too big]
- *
- * $Id: options.h,v 1.2 1999/10/14 21:56:45 wsanchez Exp $
- */
-
-/*
- * ++Copyright++
- * -
- * Copyright (c)
- * 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--
- */
-
-/* Key:
- * ucb = U C Berkeley 4.8.3 release
- * vix = Paul Vixie of Digital
- * del = Don Lewis of Harris
- * mcsun = Piet Beertema of EUNet
- * asp = Andrew Partan of UUNet
- * pma = Paul Albitz of Hewlett Packard
- * bb = Bryan Beecher of UMich
- * mpa = Mark Andrews of CSIRO - DMS
- * rossc = Ross Cartlidge of The Univeritsy of Sydney
- * mtr = Marshall Rose of TPC.INT
- * bg = Benoit Grange of INRIA
- * ckd = Christopher Davis of Kapor Enterprises
- * gns = Greg Shapiro of WPI
- */
-
-#ifndef DEBUG
-#define DEBUG /* enable -d flag and SIGUSR[12] support (ucb) */
-#endif
-
-/*#define ALLOW_T_UNSPEC enable the "unspec" RR type for old athena (ucb) */
-/*#define INVQ enable inverse queries (nslookup) (ucb/vix) */
-/*#define DSTORAGE debug malloc overruns using storage.o (ucb/vix) */
-/*#define DMALLOC trace malloc orphans using dmalloc.o (vix) */
-#define XFRNETS /* enable "xfrnets" command in named.boot (vix) */
-#define PID_FIX /* be careful about overwriting named.pid file (del) */
-#define FWD_LOOP /* try to break out of forwarding loops (del) */
-#define NO_GLUE /* don't accept or send out-of-zone glue (del) */
-#define BOGUSNS /* detect bogus nameservers (mcsun) */
-#define QRYLOG /* enable SIGWINCH for query logging (bb) */
-/*#define YPKLUDGE deal effectively with broken "ypserv -i" (mcsun) */
-#define TRACEROOT /* trace bogus root servers and ignore them (pma,bb) */
-/*#define LOCALDOM permit "domain" directive in named.boot (ucb) */
-#define FORCED_RELOAD /* refresh secondary zones on SIGHUP (pma) */
-#define SLAVE_FORWARD /* use sensible timeouts on slave forwarders (pma) */
-#define WANT_PIDFILE /* if you want the named.pid file (ucb/arc) */
-#define DOTTED_SERIAL /* if you want to be able to specify dotted serial#s */
-/*#define SENSIBLE_DOTS if you want dotted serial#s to make numeric sense */
-#define NCACHE /* negative caching (anant@isi.edu) */
-/*#define VALIDATE validation procedure (anant@isi.edu) (DO NOT USE!)*/
-/*#define SHORT_FNAMES file names used in named-xfer need to be short */
-#define RESOLVSORT /* allow sorting of addresses in gethostbyname (mpa) */
-#define STUBS /* allow transfers of NS only for a zone (mpa) */
-#ifndef LOGFAC
-#define LOGFAC LOG_DAEMON /* what syslog facility should named use? */
-#endif
-#define SECURE_ZONES /* if you want to inhibit world access to zones (gns)*/
-#define ROUND_ROBIN /* rotate databuf list after each access (mtr) */
-#define ADDAUTH /* return NS and glue w/ authorative answers (mpa) */
-#define RFC1535 /* use RFC 1535 default for "search" list (vix) */
-#define GEN_AXFR /* distinct zones within each class */
-#define DATUMREFCNT /* use reference counts on datums (mpa) */
-#define LAME_DELEGATION /* lame delegations (original-del,reworked-bb&del)*/
-#define LAME_LOGGING LOG_WARNING /* log lame delegations, set log level */
-#define GETSER_LOGGING LOG_INFO /* log errors/timeouts getting serial number */
-/*#define RETURNSOA good code that the world isn't ready for yet */
-#define CLEANCACHE /* useful and necessary in the face of NCACHE */
-#define PURGE_ZONE /* remove all traces of a zone when reloading (mpa) */
-#define STATS /* keep nameserver statistics; uses more memory */
-#define RENICE /* named-xfer should run at normal priority */
-#define XSTATS /* extended statistics, syslogged periodically (bg) */
-/*#define BIND_NOTIFY experimental - do not enable in customer products */
-/*#define LOC_RR support for (draft) LOC record parsing (ckd) */
-
-/*--------------------------------------------*
- * no user-servicable parts beyond this point *
- *--------------------------------------------*/
-
-/* if DSTORAGE is defined, we need to disable DMALLOC and remap
- * malloc and free to storage.o's exported names. storage.o also
- * includes a calloc and a realloc, but once we drag in its malloc
- * and free we'll get the others automatically and so will never
- * pull in those routines from libc.a.
- */
-#ifdef DSTORAGE
-# ifdef DMALLOC
-# undef DMALLOC
-# endif /*DMALLOC*/
-# define malloc rt_malloc
-# define free rt_free
-#endif /*DSTORAGE*/
-
-/* if DMALLOC is defined, grab the header file which will remap
- * all the malloc-style names to those exported by dmalloc.o. note
- * that DMALLOC also changes the function signatures of several
- * functions in private named source modules, and that this file
- * (options.h) must be included before any other private *.h files
- * since those *.h files have some conditional remapping to do.
- */
-#ifdef DMALLOC
-# include "dmalloc.h"
-#endif
-
-/* systems with killall(1M) don't need this
- */
-#ifdef __sgi
-# ifdef WANT_PIDFILE
-# undef WANT_PIDFILE
-# endif
-#endif
-
-#ifdef LAME_LOGGING
-# define LAME_DELEGATION
-#endif
-
-#if defined(XSTATS) && !defined(STATS)
-# define STATS
-#endif
+++ /dev/null
-/*
- * 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@
- */
-/* portability.h - include or define things that aren't present on all systems
- * vixie@decwrl 26dec92 [new]
- *
- * $Id: portability.h,v 1.3 2004/10/28 21:58:14 emoy Exp $
- */
-
-/*
- * ++Copyright++
- * -
- * Copyright (c)
- * 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--
- */
-
-/* XXX: this file has become a hopeless morass, and will be redone someday. */
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#ifndef TIME_H_INCLUDED
-# include <sys/time.h>
-# define TIME_H_INCLUDED
-#endif
-
-#ifdef ISC
-# ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-# endif
-# define SYSV
-# define SVR3
-# define _SYSV3
-# define NEED_STRTOUL
-# define NEED_FTRUNCATE
-# define USE_POSIX
-# include <sys/bsdtypes.h>
-# include <sys/sioctl.h>
-# include <sys/stream.h>
-# include <net/errno.h>
-#endif
-
-#if defined(__convex__)
-# if !defined(_POSIX_SOURCE)
-# define _POSIX_SOURCE
-# endif
-# define USE_UTIME
-# define NEED_PUTENV
-#endif
-
-#if defined(_CRAY)
-# if !defined(_POSIX_SOURCE)
-# define _POSIX_SOURCE
-# endif
-# define writev(a,b,c) __writev(a,b,c)
-# define setitimer(a,b,c) __setitimer(a,b,c)
-#endif
-
-/* This is defined in the Makefile for ISC compiles. */
-#if defined(ISC)
-# define ftruncate(a,b) __ftruncate(a,b)
-# define USE_MEMCPY
-# define USE_UTIME
-# define HAVE_FCHMOD 0
-#endif
-
-/* SCO UNIX defines only this unique symbol, apparently. */
-#if defined(M_UNIX)
-/* XXX - why is this POSIX_SOURCE instead of _POSIX_SOURCE? */
-# undef POSIX_SOURCE
-# define POSIX_SIGNALS
-# define HAVE_FCHMOD 0
-# define writev(a,b,c) __writev(a,b,c)
-# define ftruncate(a,b) __ftruncate(a,b)
-#endif
-
-#if defined(__APPLE__) && BSD < 199506
-# define NEED_PUTENV
-# define NEED_SETENV
-#endif
-
-#if defined(__sgi)
-# define BSD 43
-# define vfork fork
-#endif
-
-#if defined(SUNOS4)
-# define BSD 43
-#endif
-
-#if defined(_AUX_SOURCE)
-# define vfork fork
-# define NEED_STRERROR
-# define NEED_STRTOUL
-# define SIG_FN void
-# define USE_MEMCPY
-#endif
-
-
-#if defined(SVR4) && !defined(SYSV)
-# define SYSV
-#endif
-
-#if defined(_POSIX_SOURCE) || defined(__sgi) || defined(__ultrix) || \
- defined(__hpux) || (defined(BSD) && (BSD >= 199103)) || \
- (defined(sun) && defined(SYSV))
-# define USE_POSIX
-#endif
-
-#if defined(__ultrix) && !defined(BSD)
-# define BSD 42
-#endif
-
-#if defined(host_mips) && defined(SYSTYPE_BSD43)
-# define RISCOS_BSD
-#endif
-
-#if defined(SYSV) || defined(__ultrix) || defined(__osf__) \
- || (defined(BSD) && BSD >= 199306) || defined(linux)
-# define USE_UTIME
-# define HAVE_SETVBUF
-#endif
-
-#if defined(SYSV) && !defined(SVR4)
-# define vfork fork
-#endif
-
-#if defined(sun) || defined(SVR4)
-# define NETREAD_BROKEN
-#endif
-
-#if defined(BSD) && BSD >= 199006 && !defined(i386) && !defined(RISCOS_BSD)
-# define HAVE_DAEMON
-#endif
-
-#if !defined(BSD) || (BSD <= 199006)
-# if !defined(__APPLE__)
-# define NEED_INETADDR
-# endif
-# define NEED_INETATON
-#endif
-
-#if defined(__hpux)
-# if defined(__STDC__)
-# define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
-# define ctime(x) ctime((const time_t *)x)
-# endif /*__STDC__*/
-# if !defined(SYSV)
-# define USE_UTIME
-# define setlinebuf(x) setvbuf(x, NULL, _IOLBF, BUFSIZ)
-# if !defined(SIGWINCH) /*pre 9.0*/
-# define SIGWINCH SIGWINDOW
-# endif
-# endif /*SYSV*/
-/* XXX: better autodetection of the need for "struct linger" would be nice */
-# if 0
-struct linger {
- int l_onoff; /* option on/off */
- int l_linger; /* linger time */
-};
-# endif
-#endif /*__hpux*/
-
-#if defined(_SEQUENT_)
-# include <netinet/in_systm.h>
-# define USE_UTIME
-# define USE_POSIX
-# define NEED_GETTIMEOFDAY
-# define _TIMEZONE timezoneBSD
-struct timezoneBSD {
- int tz_minuteswest;
- int tz_dsttime;
-};
-#endif
-
-#ifndef __P
-# if defined(__STDC__) || defined(__GNUC__)
-# define __P(x) x
-# else
-# define __P(x) ()
-# endif
-#endif
-
-#ifndef _TIMEZONE
-# define _TIMEZONE timezone
-#endif
-
-#if defined(USE_POSIX)
-# include <stdlib.h>
-# include <unistd.h>
-# include <limits.h>
-
-#else
-
-# define NEED_STRTOUL
-
-# define STDIN_FILENO 0
-# define STDOUT_FILENO 1
-# define STDERR_FILENO 2
-# ifndef __APPLE__
-extern char *getenv __P((char *));
-# else
-extern char *getenv __P((const char *));
-# endif
-extern int errno;
-
-# if !defined(DMALLOC) && !defined(__APPLE__)
-extern char *malloc(), *realloc(), *calloc();
-# if defined(sun)
-extern int free();
-# else
-extern void free();
-# endif
-# endif
-
-extern int getdtablesize __P((void));
-# ifdef SHORT_FNAMES
-extern long pathconf __P((const char *path, int name));
-# endif
-
-#endif /*USE_POSIX*/
-
-#ifndef UINT_MAX
-# ifdef __STDC__
-# define UINT_MAX 4294967295u /* max value of an "unsigned int" */
-# else
-# define UINT_MAX ((unsigned)4294967295) /* max value of an "unsigned int" */
-# endif
-# define ULONG_MAX UINT_MAX /* max decimal value of a "unsigned long" */
-#endif
-
-#ifndef INT_MAX
-# define INT_MAX 2147483647 /* max decimal value of an "int" */
-#endif
-
-#ifndef RAND_MAX
-# define RAND_MAX 0x7fffffff
-#endif
-
-#ifndef IN_LOOPBACKNET
-# define IN_LOOPBACKNET 127
-#endif
-
-#ifndef INADDR_NONE
-# define INADDR_NONE 0xffffffff
-#endif
-
-#if defined(apollo)
- /* Defined in /usr/include/netinet/in.h but doesn't work */
-#undef IP_OPTIONS
-#endif
-
-#if !defined(__STDC__) && !defined(const)
-# define const /*constant*/
-#endif
-
-#if !defined(__convex__) && (!defined(BSD) || (BSD < 199103))
-int strcasecmp __P((const char *, const char *));
-#endif
-
-/* is USE_POSIX the right thing to use here? */
-#if (!defined(BSD) || (BSD <= 43)) && \
- !defined(NeXT) && \
- !defined(__convex__) && \
- !defined(USE_POSIX)
-# if !defined(NCR)
-extern void syslog();
-# endif
-extern char *ctime __P((const time_t *clock));
-extern int close(), setitimer(), recv(), sendto(), sigsetmask(),
- atoi(), getpid(), fork(), read(), ioctl(),
- setsockopt(), socket(), bind();
-#endif
-
-#if !defined(bcopy) /* some machines have their own macros for this */
-# if defined(USE_POSIX) || \
- (defined(__STDC__) && !defined(sun) && !defined(sequent))
-/* use ANSI C3.159-1989 (``ANSI C'') functions if possible;
- * ideally we would change the code to use them and then
- * define them in terms of bcopy et al if !defined(__STDC__)
- * but that's more work.
- */
-#if defined(USE_MEMCPY)
-# define bcopy(a,b,c) memcpy(b,a,c)
-#else
-# define bcopy(a,b,c) memmove(b,a,c)
-#endif
-# define bzero(a,b) memset(a,0,b)
-# define bcmp(a,b,c) memcmp(a,b,c)
-# else
-extern void bcopy();
-extern void bzero();
-extern int bcmp();
-# endif /* BSD */
-#endif /* bcopy */
-
-#if (!defined(BSD) || (BSD < 43) || defined(RISCOS_BSD)) \
- && !defined(USE_POSIX) && !defined(apollo) && !defined(sequent) \
- && !defined(M_UNIX)
-# define NEED_STRERROR
-#if !defined(ultrix) && !defined(NCR)
-# define NEED_PUTENV
-#endif
-#endif
-
-#if defined(SUNOS4)
-# define NEED_STRERROR
-# if defined(sun386)
-# define pid_t int
-# define NEED_STRCASECMP
-# endif
-#endif
-
-#if (!defined(BSD) || (BSD < 43))
-# define NEED_MKSTEMP
-# if !defined(__ultrix) && !defined(apollo)
-# define NEED_STRCASECMP
-# define NEED_MKTEMP
-# if !defined(SVR4)
-# define NEED_STRPBRK
-# endif
-# endif
-#endif
-
-#if defined(USE_POSIX)
-# define POSIX_SIGNALS
-#endif
-
-/*
- * Attempt to configure for type of function returned by signal-catching
- * functions (which signal and sigvec.sv_handler take a pointer to).
- * This can guess for BSD; otherwise, define SIG_FN externally.
- */
-#ifndef SIG_FN
-# ifdef BSD
-# if (BSD >= 199006) || defined(__APPLE__) || defined(__osf__) || defined(sun) \
- || defined(__ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
-# define SIG_FN void /* signal-catching functions return void */
-# else
-# define SIG_FN int /* signal-catching functions return int */
-# endif
-# else /*BSD*/
-# define SIG_FN void /* signal-catching functions return void */
-# endif /*BSD*/
-#endif
-
-#if !defined(ntohl) && !defined(htonl) && defined(BSD) && (BSD <= 43)
-/* if these aren't null macros in netinet/in.h, extern them here. */
-extern unsigned short htons(), ntohs();
-extern unsigned long htonl(), ntohl();
-#endif
-
-#if defined(USE_POSIX) && !defined(sun) && !defined(__sgi) \
- && !defined(__convex__) && !defined(__ultrix) && !defined(_AUX_SOURCE)
-# define PORT_NONBLOCK O_NONBLOCK
-# define PORT_WOULDBLK EAGAIN
-#else
-# define PORT_NONBLOCK O_NDELAY
-# define PORT_WOULDBLK EWOULDBLOCK
-#endif
-
-#if defined(USE_POSIX)
-# define USE_SETSID
-#endif
-
-#if defined(USE_POSIX) || !defined(SYSV)
-#define USE_WAITPID
-#endif
-
-#if !defined(USE_POSIX)
-#define waitpid(x,y,z) (wait3(y,z,(struct rusage *)NULL))
-#endif
-
-#if defined(__APPLE__) || defined(_AIX) || defined(sun386)
-# undef WIFEXITED
-# undef WEXITSTATUS
-# undef WIFSIGNALED
-# undef WTERMSIG
-#endif /* NeXT */
-
-#if defined(sequent)
-#define WEXITSTATUS(x) ((x).w_retcode)
-#define WTERMSIG(x) ((x).w_termsig)
-#endif /* sequent */
-
-#if !defined(WIFEXITED)
-# define WIFEXITED(x) (!(x & 0177))
-#endif
-#if !defined(WEXITSTATUS)
-# define WEXITSTATUS(x) (x >> 8)
-#endif
-#if !defined(WIFSIGNALED)
-# define WIFSIGNALED(x) ((x & 0177) && ((x & 0377) != 0177))
-#endif
-#if !defined(WTERMSIG)
-# define WTERMSIG(x) (x & 0177)
-#endif
-
-#ifndef S_ISDIR
-# ifndef S_IFMT
-# define S_IFMT 0170000
-# endif
-# ifndef S_IFDIR
-# define S_IFDIR 0040000
-# endif
-# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
-#endif
-
-#ifndef S_ISREG
-# ifndef S_IFMT
-# define S_IFMT 0170000
-# endif
-# ifndef S_IFREG
-# define S_IFREG 0100000
-# endif
-# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
-#endif
-
-#ifndef S_ISFIFO
-# ifndef S_IFMT
-# define S_IFMT 0170000
-# endif
-# ifndef S_IFIFO
-# define S_IFIFO 0010000
-# endif
-# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
-#endif
-
-#if defined(NEED_STRTOUL) && \
- (defined(__ultrix) || defined(__osf__) || defined(NeXT))
-# undef NEED_STRTOUL
-#endif
-
-#if defined(__ultrix) || defined(__osf__)
-# define MAYBE_HESIOD
-#endif
-
-#ifndef FD_SET
-#define NFDBITS 32
-#define FD_SETSIZE 32
-#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
-#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
-#endif
-
-#ifndef MIN
-# define MIN(x, y) ((x > y) ?y :x)
-#endif
-#ifndef MAX
-# define MAX(x, y) ((x > y) ?x :y)
-#endif
-
-#if !defined(PATH_MAX)
-# if defined(_POSIX_PATH_MAX)
-# define PATH_MAX _POSIX_PATH_MAX
-# else
-# if defined(MAXPATHLEN)
-# define PATH_MAX MAXPATHLEN
-# endif
-# endif
-#endif
-
-#if defined(BSD) || defined(__osf__) || defined(__convex__)
-# define HAVE_GETRUSAGE
-#endif
-
-/* May be set in the Makefile. */
-#if defined(HAVE_GETRUSAGE)
-# include <sys/resource.h>
-#endif
-
-/*
- * Because Convex has true library function feof() which is
- * patently wrong (it test bit _IOREAD) we need feof() as
- * a macro.
- */
-#if defined(__convex__) && !defined(feof)
-# define feof(p) ((p)->_flag&_IOEOF)
-#endif
-
-#if defined(M_UNIX) || defined(linux)
-# define SPURIOUS_ECONNREFUSED
-#endif
-
-/*
- * Assume that a system has fchmod() unless something above says otherwise.
- */
-#if !defined(HAVE_FCHMOD)
-# define HAVE_FCHMOD 1
-#endif
-
-/*
- * Prototype the functions we'll be supplying.
- */
-#ifdef NEED_PUTENV
-extern int putenv __P((char *));
-#endif
-
-#ifdef NEED_GETTIMEOFDAY
-extern int gettimeofday __P((struct timeval *, struct _TIMEZONE *));
-#endif
-/*
- * 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++ 1985, 1993
* -
#include <stdio.h>
#include <ctype.h>
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#if defined(BSD) && (BSD >= 199103)
-# include <unistd.h>
-# include <string.h>
-#else
-# include "portability.h"
-#endif
-
-static int dn_find __P((u_char *exp_dn, u_char *msg,
- u_char **dnptrs, u_char **lastdnptr));
+#include <arpa/nameser_compat.h>
+#include <nameser.h>
/*
* Expand compressed domain name 'comp_dn' to full domain name.
* Return size of compressed name or -1 if there was an error.
*/
int
-dn_expand(msg, eomorig, comp_dn, exp_dn, length)
- const u_char *msg, *eomorig, *comp_dn;
- char *exp_dn;
- int length;
+dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char *exp_dn, int length)
{
register const u_char *cp;
register char *dn;
return (len);
}
-/*
- * Compress domain name 'exp_dn' into 'comp_dn'.
- * Return the size of the compressed name or -1.
- * 'length' is the size of the array pointed to by 'comp_dn'.
- * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
- * is a pointer to the beginning of the message. The list ends with NULL.
- * 'lastdnptr' is a pointer to the end of the arrary pointed to
- * by 'dnptrs'. Side effect is to update the list of pointers for
- * labels inserted into the message as we compress the name.
- * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
- * is NULL, we don't update the list.
- */
-int
-dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
- const char *exp_dn;
- u_char *comp_dn, **dnptrs, **lastdnptr;
- int length;
-{
- register u_char *cp, *dn;
- register int c, l;
- u_char **cpp, **lpp, *sp, *eob;
- u_char *msg;
-
- dn = (u_char *)exp_dn;
- cp = comp_dn;
- eob = cp + length;
- lpp = cpp = NULL;
- if (dnptrs != NULL) {
- if ((msg = *dnptrs++) != NULL) {
- for (cpp = dnptrs; *cpp != NULL; cpp++)
- ;
- lpp = cpp; /* end of list to search */
- }
- } else
- msg = NULL;
- for (c = *dn++; c != '\0'; ) {
- /* look to see if we can use pointers */
- if (msg != NULL) {
- if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) {
- if (cp+1 >= eob)
- return (-1);
- *cp++ = (l >> 8) | INDIR_MASK;
- *cp++ = l % 256;
- return (cp - comp_dn);
- }
- /* not found, save it */
- if (lastdnptr != NULL && cpp < lastdnptr-1) {
- *cpp++ = cp;
- *cpp = NULL;
- }
- }
- sp = cp++; /* save ptr to length byte */
- do {
- if (c == '.') {
- c = *dn++;
- break;
- }
- if (c == '\\') {
- if ((c = *dn++) == '\0')
- break;
- }
- if (cp >= eob) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *cp++ = c;
- } while ((c = *dn++) != '\0');
- /* catch trailing '.'s but not '..' */
- if ((l = cp - sp - 1) == 0 && c == '\0') {
- cp--;
- break;
- }
- if (l <= 0 || l > MAXLABEL) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *sp = l;
- }
- if (cp >= eob) {
- if (msg != NULL)
- *lpp = NULL;
- return (-1);
- }
- *cp++ = '\0';
- return (cp - comp_dn);
-}
-
/*
* Skip over a compressed domain name. Return the size or -1.
*/
int
-__dn_skipname(comp_dn, eom)
- const u_char *comp_dn, *eom;
+__dn_skipname(const u_char *comp_dn, const u_char *eom)
{
register const u_char *cp;
register int n;
return (cp - comp_dn);
}
-static int
-mklower(ch)
- register int ch;
-{
- if (isascii(ch) && isupper(ch))
- return (tolower(ch));
- return (ch);
-}
-
-/*
- * Search for expanded name from a list of previously compressed names.
- * Return the offset from msg if found or -1.
- * dnptrs is the pointer to the first name on the list,
- * not the pointer to the start of the message.
- */
-static int
-dn_find(exp_dn, msg, dnptrs, lastdnptr)
- u_char *exp_dn, *msg;
- u_char **dnptrs, **lastdnptr;
-{
- register u_char *dn, *cp, **cpp;
- register int n;
- u_char *sp;
-
- for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
- dn = exp_dn;
- sp = cp = *cpp;
- while ((n = *cp++)) {
- /*
- * check for indirection
- */
- switch (n & INDIR_MASK) {
- case 0: /* normal case, n == len */
- while (--n >= 0) {
- if (*dn == '.')
- goto next;
- if (*dn == '\\')
- dn++;
- if (mklower(*dn++) != mklower(*cp++))
- goto next;
- }
- if ((n = *dn++) == '\0' && *cp == '\0')
- return (sp - msg);
- if (n == '.')
- continue;
- goto next;
-
- case INDIR_MASK: /* indirection */
- cp = msg + (((n & 0x3f) << 8) | *cp);
- break;
-
- default: /* illegal type */
- return (-1);
- }
- }
- if (*dn == '\0')
- return (sp - msg);
- next: ;
- }
- return (-1);
-}
-
/*
* Routines to insert/extract short/long's.
*/
u_int16_t
-_getshort(msgp)
- register const u_char *msgp;
+_getshort(const u_char *msgp)
{
- register u_int16_t u;
-
+ u_int16_t u;
GETSHORT(u, msgp);
- return (u);
-}
-
-#if defined(__APPLE__)
-/*
- * nExt machines have some funky library conventions, which we must maintain.
- */
-u_int16_t
-res_getshort(msgp)
- register const u_char *msgp;
-{
- return (_getshort(msgp));
+ return u;
}
-#endif
u_int32_t
-_getlong(msgp)
- register const u_char *msgp;
+_getlong(const u_char *msgp)
{
- register u_int32_t u;
-
+ u_int32_t u;
GETLONG(u, msgp);
- return (u);
-}
-
-void
-#if defined(__STDC__) || defined(__cplusplus)
-__putshort(register u_int16_t s, register u_char *msgp) /* must match proto */
-#else
-__putshort(s, msgp)
- register u_int16_t s;
- register u_char *msgp;
-#endif
-{
- PUTSHORT(s, msgp);
-}
-
-void
-__putlong(l, msgp)
- register u_int32_t l;
- register u_char *msgp;
-{
- PUTLONG(l, msgp);
-}
-
-#ifdef ultrix
-/* ultrix 4.0 had some icky packaging in its libc.a. alias for it here.
- * there is more gunk of this kind over in res_debug.c.
- */
-#undef putshort
-void
-#if defined(__STDC__) || defined(__cplusplus)
-putshort(register u_short s, register u_char *msgp)
-#else
-putshort(s, msgp)
- register u_short s;
- register u_char *msgp;
-#endif
-{
- __putshort(s, msgp);
-}
-#undef putlong
-void
-putlong(l, msgp)
- register u_int32_t l;
- register u_char *msgp;
-{
- __putlong(l, msgp);
-}
-
-#undef dn_skipname
-dn_skipname(comp_dn, eom)
- const u_char *comp_dn, *eom;
-{
- return (__dn_skipname(comp_dn, eom));
+ return u;
}
-#endif /* Ultrix 4.0 hackery */
+++ /dev/null
-/*
- * 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@
- */
-/*
- * This file contains global data but it is a `private_extern' in the
- * shared library so that its address and size can change.
- */
-
-#if defined(__APPLE__)
-
-/*
- * _res is declared to be the same size as struct __res_9_state
- * This allows both the BIND-8 library in libSystem (this one)
- * and the new BIND-9 library in libresolv to share the same
- * structure. We ues the __res_9_state's _pad variable to store
- * a version number when _res have been initialized by the BIND-9
- * library, and take precautions to make them work together.
- */
-#ifdef __LP64__
-#define RES_9_STATE_SIZE 552
-#else
-#define RES_9_STATE_SIZE 512
-#endif
-
-char _res[RES_9_STATE_SIZE] = {0};
-int _net_stayopen = 0;
-#endif
+++ /dev/null
-/*
- * 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++ 1985, 1990, 1993
- * -
- * Copyright (c) 1985, 1990, 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--
- */
-
-#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.5 2004/06/11 23:16:00 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <stdio.h>
-#include <netdb.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#if defined(BSD) && (BSD >= 199103)
-# include <string.h>
-#else
-# include "portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "options.h"
-#endif
-
-const char *_res_opcodes[] = {
- "QUERY",
- "IQUERY",
- "CQUERYM",
- "CQUERYU", /* experimental */
- "NOTIFY", /* experimental */
- "5",
- "6",
- "7",
- "8",
- "UPDATEA",
- "UPDATED",
- "UPDATEDA",
- "UPDATEM",
- "UPDATEMA",
- "ZONEINIT",
- "ZONEREF",
-};
-
-const char *_res_resultcodes[] = {
- "NOERROR",
- "FORMERR",
- "SERVFAIL",
- "NXDOMAIN",
- "NOTIMP",
- "REFUSED",
- "6",
- "7",
- "8",
- "9",
- "10",
- "11",
- "12",
- "13",
- "14",
- "NOCHANGE",
-};
-
-/* XXX: we should use getservbyport() instead. */
-static const char *
-dewks(wks)
- int wks;
-{
- static char nbuf[20];
-
- switch (wks) {
- case 5: return "rje";
- case 7: return "echo";
- case 9: return "discard";
- case 11: return "systat";
- case 13: return "daytime";
- case 15: return "netstat";
- case 17: return "qotd";
- case 19: return "chargen";
- case 20: return "ftp-data";
- case 21: return "ftp";
- case 23: return "telnet";
- case 25: return "smtp";
- case 37: return "time";
- case 39: return "rlp";
- case 42: return "name";
- case 43: return "whois";
- case 53: return "domain";
- case 57: return "apts";
- case 59: return "apfs";
- case 67: return "bootps";
- case 68: return "bootpc";
- case 69: return "tftp";
- case 77: return "rje";
- case 79: return "finger";
- case 87: return "link";
- case 95: return "supdup";
- case 100: return "newacct";
- case 101: return "hostnames";
- case 102: return "iso-tsap";
- case 103: return "x400";
- case 104: return "x400-snd";
- case 105: return "csnet-ns";
- case 109: return "pop-2";
- case 111: return "sunrpc";
- case 113: return "auth";
- case 115: return "sftp";
- case 117: return "uucp-path";
- case 119: return "nntp";
- case 121: return "erpc";
- case 123: return "ntp";
- case 133: return "statsrv";
- case 136: return "profile";
- case 144: return "NeWS";
- case 161: return "snmp";
- case 162: return "snmp-trap";
- case 170: return "print-srv";
- default: (void) sprintf(nbuf, "%d", wks); return (nbuf);
- }
-}
-
-/* XXX: we should use getprotobynumber() instead. */
-static const char *
-deproto(protonum)
- int protonum;
-{
- static char nbuf[20];
-
- switch (protonum) {
- case 1: return "icmp";
- case 2: return "igmp";
- case 3: return "ggp";
- case 5: return "st";
- case 6: return "tcp";
- case 7: return "ucl";
- case 8: return "egp";
- case 9: return "igp";
- case 11: return "nvp-II";
- case 12: return "pup";
- case 16: return "chaos";
- case 17: return "udp";
- default: (void) sprintf(nbuf, "%d", protonum); return (nbuf);
- }
-}
-
-static const u_char *
-do_rrset(msg, len, cp, cnt, pflag, file, hs)
- int cnt, pflag, len;
- const u_char *cp, *msg;
- const char *hs;
- FILE *file;
-{
- int n;
- int sflag;
-
- /*
- * Print answer records.
- */
- sflag = (_res.pfcode & pflag);
- if ((n = ntohs(cnt))) {
- if ((!_res.pfcode) ||
- ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
- fprintf(file, "%s", hs);
- while (--n >= 0) {
- if ((!_res.pfcode) || sflag) {
- cp = p_rr(cp, msg, file);
- } else {
- unsigned int dlen;
- cp += __dn_skipname(cp, cp + MAXCDNAME);
- cp += INT16SZ;
- cp += INT16SZ;
- cp += INT32SZ;
- dlen = _getshort((u_char*)cp);
- cp += INT16SZ;
- cp += dlen;
- }
- if ((cp - msg) > len)
- return (NULL);
- }
- if ((!_res.pfcode) ||
- ((sflag) && (_res.pfcode & RES_PRF_HEAD1)))
- putc('\n', file);
- }
- return (cp);
-}
-
-void
-__p_query(msg)
- const u_char *msg;
-{
- __fp_query(msg, stdout);
-}
-
-#ifdef ultrix
-/* ultrix 4.0's packaging has some icky packaging. alias for it here.
- * there is more junk of this kind over in res_comp.c.
- */
-void
-p_query(msg)
- const u_char *msg;
-{
- __p_query(msg);
-}
-#endif
-
-/*
- * Print the current options.
- * This is intended to be primarily a debugging routine.
- */
-void
-__fp_resstat(statp, file)
- struct __res_state *statp;
- FILE *file;
-{
- register u_long mask;
-
- fprintf(file, ";; res options:");
- if (!statp)
- statp = &_res;
- for (mask = 1; mask != 0; mask <<= 1)
- if (statp->options & mask)
- fprintf(file, " %s", p_option(mask));
- putc('\n', file);
-}
-
-/*
- * Print the contents of a query.
- * This is intended to be primarily a debugging routine.
- */
-void
-__fp_nquery(msg, len, file)
- const u_char *msg;
- int len;
- FILE *file;
-{
- register const u_char *cp, *endMark;
- register const HEADER *hp;
- register int n;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1)
- return;
-
-#define TruncTest(x) if (x >= endMark) goto trunc
-#define ErrorTest(x) if (x == NULL) goto error
-
- /*
- * Print header fields.
- */
- hp = (HEADER *)msg;
- cp = msg + HFIXEDSZ;
- endMark = cp + len;
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || hp->rcode) {
- fprintf(file, ";; ->>HEADER<<- opcode: %s, status: %s, id: %d",
- _res_opcodes[hp->opcode],
- _res_resultcodes[hp->rcode],
- ntohs(hp->id));
- putc('\n', file);
- }
- putc(';', file);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {
- fprintf(file, "; flags:");
- if (hp->qr)
- fprintf(file, " qr");
- if (hp->aa)
- fprintf(file, " aa");
- if (hp->tc)
- fprintf(file, " tc");
- if (hp->rd)
- fprintf(file, " rd");
- if (hp->ra)
- fprintf(file, " ra");
- }
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {
- fprintf(file, "; Ques: %d", ntohs(hp->qdcount));
- fprintf(file, ", Ans: %d", ntohs(hp->ancount));
- fprintf(file, ", Auth: %d", ntohs(hp->nscount));
- fprintf(file, ", Addit: %d", ntohs(hp->arcount));
- }
- if ((!_res.pfcode) || (_res.pfcode &
- (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
- putc('\n',file);
- }
- /*
- * Print question records.
- */
- if ((n = ntohs(hp->qdcount))) {
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ";; QUESTIONS:\n");
- while (--n >= 0) {
- fprintf(file, ";;\t");
- TruncTest(cp);
- cp = p_cdnname(cp, msg, len, file);
- ErrorTest(cp);
- TruncTest(cp);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ", type = %s",
- __p_type(_getshort((u_char*)cp)));
- cp += INT16SZ;
- TruncTest(cp);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_QUES))
- fprintf(file, ", class = %s\n",
- __p_class(_getshort((u_char*)cp)));
- cp += INT16SZ;
- putc('\n', file);
- }
- }
- /*
- * Print authoritative answer records
- */
- TruncTest(cp);
- cp = do_rrset(msg, len, cp, hp->ancount, RES_PRF_ANS, file,
- ";; ANSWERS:\n");
- ErrorTest(cp);
-
- /*
- * print name server records
- */
- TruncTest(cp);
- cp = do_rrset(msg, len, cp, hp->nscount, RES_PRF_AUTH, file,
- ";; AUTHORITY RECORDS:\n");
- ErrorTest(cp);
-
- TruncTest(cp);
- /*
- * print additional records
- */
- cp = do_rrset(msg, len, cp, hp->arcount, RES_PRF_ADD, file,
- ";; ADDITIONAL RECORDS:\n");
- ErrorTest(cp);
- return;
- trunc:
- fprintf(file, "\n;; ...truncated\n");
- return;
- error:
- fprintf(file, "\n;; ...malformed\n");
-}
-
-void
-__fp_query(msg, file)
- const u_char *msg;
- FILE *file;
-{
- fp_nquery(msg, PACKETSZ, file);
-}
-
-const u_char *
-__p_cdnname(cp, msg, len, file)
- const u_char *cp, *msg;
- int len;
- FILE *file;
-{
- char name[MAXDNAME];
- int n;
-
- if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0)
- return (NULL);
- if (name[0] == '\0')
- putc('.', file);
- else
- fputs(name, file);
- return (cp + n);
-}
-
-const u_char *
-__p_cdname(cp, msg, file)
- const u_char *cp, *msg;
- FILE *file;
-{
- return (p_cdnname(cp, msg, PACKETSZ, file));
-}
-
-/* XXX: the rest of these functions need to become length-limited, too. (vix)
- */
-
-const u_char *
-__p_fqname(cp, msg, file)
- const u_char *cp, *msg;
- FILE *file;
-{
- char name[MAXDNAME];
- int n;
-
- if ((n = dn_expand(msg, cp + MAXCDNAME, cp, name, sizeof name)) < 0)
- return (NULL);
- if (name[0] == '\0') {
- putc('.', file);
- } else {
- fputs(name, file);
- if (name[strlen(name) - 1] != '.')
- putc('.', file);
- }
- return (cp + n);
-}
-
-/*
- * Print resource record fields in human readable form.
- */
-const u_char *
-__p_rr(cp, msg, file)
- const u_char *cp, *msg;
- FILE *file;
-{
- int type, class, n, c;
- int dlen;
- struct in_addr inaddr;
- const u_char *cp1, *cp2;
- u_int32_t tmpttl, t;
- int lcnt;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
- return (NULL);
- }
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL); /* compression error */
- type = _getshort((u_char*)cp);
- cp += INT16SZ;
- class = _getshort((u_char*)cp);
- cp += INT16SZ;
- tmpttl = _getlong((u_char*)cp);
- cp += INT32SZ;
- dlen = _getshort((u_char*)cp);
- cp += INT16SZ;
- cp1 = cp;
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_TTLID))
- fprintf(file, "\t%lu", (u_long)tmpttl);
- if ((!_res.pfcode) || (_res.pfcode & RES_PRF_CLASS))
- fprintf(file, "\t%s", __p_class(class));
- fprintf(file, "\t%s", __p_type(type));
- /*
- * Print type specific data, if appropriate
- */
- switch (type) {
- case T_A:
- switch (class) {
- case C_IN:
- case C_HS:
- bcopy(cp, (char *)&inaddr, INADDRSZ);
- if (dlen == 4) {
- fprintf(file, "\t%s", inet_ntoa(inaddr));
- cp += dlen;
- } else if (dlen == 7) {
- char *address;
- u_char protocol;
- u_short port;
-
- address = inet_ntoa(inaddr);
- cp += INADDRSZ;
- protocol = *(u_char*)cp;
- cp += sizeof(u_char);
- port = _getshort((u_char*)cp);
- cp += INT16SZ;
- fprintf(file, "\t%s\t; proto %d, port %d",
- address, protocol, port);
- }
- break;
- default:
- cp += dlen;
- }
- break;
- case T_CNAME:
- case T_MB:
- case T_MG:
- case T_MR:
- case T_NS:
- case T_PTR:
- putc('\t', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- break;
-
- case T_HINFO:
- case T_ISDN:
- cp2 = cp + dlen;
- if ((n = *cp++)) {
- fprintf(file, "\t%.*s", n, cp);
- cp += n;
- }
- if ((cp < cp2) && (n = *cp++)) {
- fprintf(file, "\t%.*s", n, cp);
- cp += n;
- } else if (type == T_HINFO)
- fprintf(file, "\n;; *** Warning *** OS-type missing");
- break;
-
- case T_SOA:
- putc('\t', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- putc(' ', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- fputs(" (\n", file);
- t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; serial\n", (u_long)t);
- t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; refresh (%s)\n",
- (u_long)t, __p_time(t));
- t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; retry (%s)\n",
- (u_long)t, __p_time(t));
- t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu\t; expire (%s)\n",
- (u_long)t, __p_time(t));
- t = _getlong((u_char*)cp); cp += INT32SZ;
- fprintf(file, "\t\t\t%lu )\t; minimum (%s)",
- (u_long)t, __p_time(t));
- break;
-
- case T_MX:
- case T_AFSDB:
- case T_RT:
- fprintf(file, "\t%d ", _getshort((u_char*)cp));
- cp += INT16SZ;
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- break;
-
- case T_PX:
- fprintf(file, "\t%d ", _getshort((u_char*)cp));
- cp += INT16SZ;
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- putc(' ', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- break;
-
- case T_TXT:
- case T_X25:
- (void) fputs("\t\"", file);
- cp2 = cp1 + dlen;
- while (cp < cp2) {
- if ((n = (unsigned char) *cp++)) {
- for (c = n; c > 0 && cp < cp2; c--)
- if ((*cp == '\n') || (*cp == '"')) {
- (void) putc('\\', file);
- (void) putc(*cp++, file);
- } else
- (void) putc(*cp++, file);
- }
- }
- putc('"', file);
- break;
-
- case T_NSAP:
- (void) fprintf(file, "\t%s", inet_nsap_ntoa(dlen, cp, NULL));
- cp += dlen;
- break;
-
- case T_MINFO:
- case T_RP:
- putc('\t', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- putc(' ', file);
- if ((cp = p_fqname(cp, msg, file)) == NULL)
- return (NULL);
- break;
-
- case T_UINFO:
- putc('\t', file);
- fputs((char *)cp, file);
- cp += dlen;
- break;
-
- case T_UID:
- case T_GID:
- if (dlen == 4) {
- fprintf(file, "\t%u", _getlong((u_char*)cp));
- cp += INT32SZ;
- }
- break;
-
- case T_WKS:
- if (dlen < INT32SZ + 1)
- break;
- bcopy(cp, (char *)&inaddr, INADDRSZ);
- cp += INT32SZ;
- fprintf(file, "\t%s %s ( ",
- inet_ntoa(inaddr),
- deproto((int) *cp));
- cp += sizeof(u_char);
- n = 0;
- lcnt = 0;
- while (cp < cp1 + dlen) {
- c = *cp++;
- do {
- if (c & 0200) {
- if (lcnt == 0) {
- fputs("\n\t\t\t", file);
- lcnt = 5;
- }
- fputs(dewks(n), file);
- putc(' ', file);
- lcnt--;
- }
- c <<= 1;
- } while (++n & 07);
- }
- putc(')', file);
- break;
-
-#ifdef ALLOW_T_UNSPEC
- case T_UNSPEC:
- {
- int NumBytes = 8;
- u_char *DataPtr;
- int i;
-
- if (dlen < NumBytes) NumBytes = dlen;
- fprintf(file, "\tFirst %d bytes of hex data:",
- NumBytes);
- for (i = 0, DataPtr = cp; i < NumBytes; i++, DataPtr++)
- fprintf(file, " %x", *DataPtr);
- cp += dlen;
- }
- break;
-#endif /* ALLOW_T_UNSPEC */
-
- default:
- fprintf(file, "\t?%d?", type);
- cp += dlen;
- }
-#if 0
- fprintf(file, "\t; dlen=%d, ttl %s\n", dlen, __p_time(tmpttl));
-#else
- putc('\n', file);
-#endif
- if (cp - cp1 != dlen) {
-#ifdef __LP64__
- fprintf(file, ";; packet size error (found %ld, dlen was %d)\n", cp - cp1, dlen);
-#else
- fprintf(file, ";; packet size error (found %d, dlen was %d)\n", cp - cp1, dlen);
-#endif
- cp = NULL;
- }
- return (cp);
-}
-
-/*
- * Return a string for the type
- */
-const char *
-__p_type(type)
- int type;
-{
- static char nbuf[20];
-
- switch (type) {
- case T_A: return "A";
- case T_NS: return "NS";
- case T_CNAME: return "CNAME";
- case T_SOA: return "SOA";
- case T_MB: return "MB";
- case T_MG: return "MG";
- case T_MR: return "MR";
- case T_NULL: return "NULL";
- case T_WKS: return "WKS";
- case T_PTR: return "PTR";
- case T_HINFO: return "HINFO";
- case T_MINFO: return "MINFO";
- case T_MX: return "MX";
- case T_TXT: return "TXT";
- case T_RP: return "RP";
- case T_AFSDB: return "AFSDB";
- case T_X25: return "X25";
- case T_ISDN: return "ISDN";
- case T_RT: return "RT";
- case T_NSAP: return "NSAP";
- case T_NSAP_PTR: return "NSAP_PTR";
- case T_SIG: return "SIG";
- case T_KEY: return "KEY";
- case T_PX: return "PX";
- case T_GPOS: return "GPOS";
- case T_AAAA: return "AAAA";
- case T_LOC: return "LOC";
- case T_AXFR: return "AXFR";
- case T_MAILB: return "MAILB";
- case T_MAILA: return "MAILA";
- case T_ANY: return "ANY";
- case T_UINFO: return "UINFO";
- case T_UID: return "UID";
- case T_GID: return "GID";
-#ifdef ALLOW_T_UNSPEC
- case T_UNSPEC: return "UNSPEC";
-#endif /* ALLOW_T_UNSPEC */
- default: (void)sprintf(nbuf, "%d", type); return (nbuf);
- }
-}
-
-/*
- * Return a mnemonic for class
- */
-const char *
-__p_class(class)
- int class;
-{
- static char nbuf[20];
-
- switch (class) {
- case C_IN: return "IN";
- case C_HS: return "HS";
- case C_ANY: return "ANY";
- default: (void)sprintf(nbuf, "%d", class); return (nbuf);
- }
-}
-
-/*
- * Return a mnemonic for an option
- */
-const char *
-__p_option(option)
- u_long option;
-{
- static char nbuf[40];
-
- switch (option) {
- case RES_INIT: return "init";
- case RES_DEBUG: return "debug";
- case RES_AAONLY: return "aaonly(unimpl)";
- case RES_USEVC: return "usevc";
- case RES_PRIMARY: return "primry(unimpl)";
- case RES_IGNTC: return "igntc";
- case RES_RECURSE: return "recurs";
- case RES_DEFNAMES: return "defnam";
- case RES_STAYOPEN: return "styopn";
- case RES_DNSRCH: return "dnsrch";
- case RES_INSECURE1: return "insecure1";
- case RES_INSECURE2: return "insecure2";
- default: sprintf(nbuf, "?0x%lx?", (u_long)option);
- return (nbuf);
- }
-}
-
-/*
- * Return a mnemonic for a time to live
- */
-char *
-__p_time(value)
- u_int32_t value;
-{
- static char nbuf[40];
- int secs, mins, hours, days;
- register char *p;
-
- if (value == 0) {
- strcpy(nbuf, "0 secs");
- return (nbuf);
- }
-
- secs = value % 60;
- value /= 60;
- mins = value % 60;
- value /= 60;
- hours = value % 24;
- value /= 24;
- days = value;
- value = 0;
-
-#define PLURALIZE(x) x, (x == 1) ? "" : "s"
- p = nbuf;
- if (days) {
- (void)sprintf(p, "%d day%s", PLURALIZE(days));
- while (*++p);
- }
- if (hours) {
- if (days)
- *p++ = ' ';
- (void)sprintf(p, "%d hour%s", PLURALIZE(hours));
- while (*++p);
- }
- if (mins) {
- if (days || hours)
- *p++ = ' ';
- (void)sprintf(p, "%d min%s", PLURALIZE(mins));
- while (*++p);
- }
- if (secs || ! (days || hours || mins)) {
- if (days || hours || mins)
- *p++ = ' ';
- (void)sprintf(p, "%d sec%s", PLURALIZE(secs));
- }
- return (nbuf);
-}
+++ /dev/null
-/*
- * 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++ 1985, 1989, 1993
- * -
- * Copyright (c) 1985, 1989, 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--
- */
-
-#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.8 2003/02/18 17:29:24 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#if defined(BSD) && (BSD >= 199103)
-# include <unistd.h>
-# include <stdlib.h>
-# include <string.h>
-#else
-# include "portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "options.h"
-#endif
-
-static void res_setoptions __P((char *, char *));
-
-#ifdef RESOLVSORT
-static const char sort_mask[] = "/&";
-#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
-static u_int32_t net_mask __P((struct in_addr));
-#endif
-
-#if !defined(isascii) /* XXX - could be a function */
-# define isascii(c) (!(c & 0200))
-#endif
-
-/*
- * Resolver state default settings.
- */
-
-#if defined(__APPLE__)
-extern
-#endif /* NeXT */
-struct __res_state _res;
-
-/*
- * Set up default settings. If the configuration file exist, the values
- * there will have precedence. Otherwise, the server address is set to
- * INADDR_ANY and the default domain name comes from the gethostname().
- *
- * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
- * rather than INADDR_ANY ("0.0.0.0") as the default name server address
- * since it was noted that INADDR_ANY actually meant ``the first interface
- * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
- * it had to be "up" in order for you to reach your own name server. It
- * was later decided that since the recommended practice is to always
- * install local static routes through 127.0.0.1 for all your network
- * interfaces, that we could solve this problem without a code change.
- *
- * The configuration file should always be used, since it is the only way
- * to specify a default domain. If you are running a server on your local
- * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1"
- * in the configuration file.
- *
- * Return 0 if completes successfully, -1 on error
- */
-int
-res_init()
-{
- register FILE *fp;
- register char *cp, **pp;
- register int n;
- char buf[BUFSIZ];
- int nserv = 0; /* number of nameserver records read from file */
- int haveenv = 0;
- int havesearch = 0;
-#ifdef RESOLVSORT
- int nsort = 0;
- char *net;
-#endif
-#ifndef RFC1535
- int dots;
-#endif
-
- /*
- * These three fields used to be statically initialized. This made
- * it hard to use this code in a shared library. It is necessary,
- * now that we're doing dynamic initialization here, that we preserve
- * the old semantics: if an application modifies one of these three
- * fields of _res before res_init() is called, res_init() will not
- * alter them. Of course, if an application is setting them to
- * _zero_ before calling res_init(), hoping to override what used
- * to be the static default, we can't detect it and unexpected results
- * will follow. Zero for any of these fields would make no sense,
- * so one can safely assume that the applications were already getting
- * unexpected results.
- *
- * _res.options is tricky since some apps were known to diddle the bits
- * before res_init() was first called. We can't replicate that semantic
- * with dynamic initialization (they may have turned bits off that are
- * set in RES_DEFAULT). Our solution is to declare such applications
- * "broken". They could fool us by setting RES_INIT but none do (yet).
- */
- if (!_res.retrans)
- _res.retrans = RES_TIMEOUT;
- if (!_res.retry)
- _res.retry = 4;
- if (!(_res.options & RES_INIT))
- _res.options = RES_DEFAULT;
-
- /*
- * This one used to initialize implicitly to zero, so unless the app
- * has set it to something in particular, we can randomize it now.
- */
- if (!_res.id)
- _res.id = res_randomid();
-
-#ifdef USELOOPBACK
- _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
-#else
- _res.nsaddr.sin_addr.s_addr = INADDR_ANY;
-#endif
- _res.nsaddr.sin_family = AF_INET;
- _res.nsaddr.sin_port = htons(NAMESERVER_PORT);
- _res.nscount = 1;
- _res.ndots = 1;
- _res.pfcode = 0;
-
- /* Allow user to override the local domain definition */
- if ((cp = getenv("LOCALDOMAIN")) != NULL) {
- (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- haveenv++;
-
- /*
- * Set search list to be blank-separated strings
- * from rest of env value. Permits users of LOCALDOMAIN
- * to still have a search list, and anyone to set the
- * one that they want to use as an individual (even more
- * important now that the rfc1535 stuff restricts searches)
- */
- cp = _res.defdname;
- pp = _res.dnsrch;
- *pp++ = cp;
- for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
- if (*cp == '\n') /* silly backwards compat */
- break;
- else if (*cp == ' ' || *cp == '\t') {
- *cp = 0;
- n = 1;
- } else if (n) {
- *pp++ = cp;
- n = 0;
- havesearch = 1;
- }
- }
- /* null terminate last domain if there are excess */
- while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
- cp++;
- *cp = '\0';
- *pp++ = 0;
- }
-
-#define MATCH(line, name) \
- (!strncmp(line, name, sizeof(name) - 1) && \
- (line[sizeof(name) - 1] == ' ' || \
- line[sizeof(name) - 1] == '\t'))
-
- if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
- /* read the config file */
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- /* skip comments */
- if (*buf == ';' || *buf == '#')
- continue;
- /* read default domain name */
- if (MATCH(buf, "domain")) {
- if (haveenv) /* skip if have from environ */
- continue;
- cp = buf + sizeof("domain") - 1;
- while (*cp == ' ' || *cp == '\t')
- cp++;
- if ((*cp == '\0') || (*cp == '\n'))
- continue;
- strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
- *cp = '\0';
- havesearch = 0;
- continue;
- }
- /* set search list */
- if (MATCH(buf, "search")) {
- if (haveenv) /* skip if have from environ */
- continue;
- cp = buf + sizeof("search") - 1;
- while (*cp == ' ' || *cp == '\t')
- cp++;
- if ((*cp == '\0') || (*cp == '\n'))
- continue;
- strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
- if ((cp = strchr(_res.defdname, '\n')) != NULL)
- *cp = '\0';
- /*
- * Set search list to be blank-separated strings
- * on rest of line.
- */
- cp = _res.defdname;
- pp = _res.dnsrch;
- *pp++ = cp;
- for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
- if (*cp == ' ' || *cp == '\t') {
- *cp = 0;
- n = 1;
- } else if (n) {
- *pp++ = cp;
- n = 0;
- }
- }
- /* null terminate last domain if there are excess */
- while (*cp != '\0' && *cp != ' ' && *cp != '\t')
- cp++;
- *cp = '\0';
- *pp++ = 0;
- havesearch = 1;
- continue;
- }
- /* read nameservers to query */
- if (MATCH(buf, "nameserver") && nserv < MAXNS) {
- struct in_addr a;
-
- cp = buf + sizeof("nameserver") - 1;
- while (*cp == ' ' || *cp == '\t')
- cp++;
- if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) {
- _res.nsaddr_list[nserv].sin_addr = a;
- _res.nsaddr_list[nserv].sin_family = AF_INET;
- _res.nsaddr_list[nserv].sin_port =
- htons(NAMESERVER_PORT);
- nserv++;
- }
- continue;
- }
-#ifdef RESOLVSORT
- if (MATCH(buf, "sortlist")) {
- struct in_addr a;
-
- cp = buf + sizeof("sortlist") - 1;
- while (nsort < MAXRESOLVSORT) {
- while (*cp == ' ' || *cp == '\t')
- cp++;
- if (*cp == '\0' || *cp == '\n' || *cp == ';')
- break;
- net = cp;
- while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
- isascii(*cp) && !isspace(*cp))
- cp++;
- n = *cp;
- *cp = 0;
- if (inet_aton(net, &a)) {
- _res.sort_list[nsort].addr = a;
- if (ISSORTMASK(n)) {
- *cp++ = n;
- net = cp;
- while (*cp && *cp != ';' &&
- isascii(*cp) && !isspace(*cp))
- cp++;
- n = *cp;
- *cp = 0;
- if (inet_aton(net, &a)) {
- _res.sort_list[nsort].mask = a.s_addr;
- } else {
- _res.sort_list[nsort].mask =
- net_mask(_res.sort_list[nsort].addr);
- }
- } else {
- _res.sort_list[nsort].mask =
- net_mask(_res.sort_list[nsort].addr);
- }
- nsort++;
- }
- *cp = n;
- }
- continue;
- }
-#endif
- if (MATCH(buf, "options")) {
- res_setoptions(buf + sizeof("options") - 1, "conf");
- continue;
- }
- }
- if (nserv > 1)
- _res.nscount = nserv;
-#ifdef RESOLVSORT
- _res.nsort = nsort;
-#endif
- (void) fclose(fp);
- }
-
- if (_res.defdname[0] == 0 &&
- gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
- (cp = strchr(buf, '.')) != NULL)
- strcpy(_res.defdname, cp + 1);
-
- /* find components of local domain that might be searched */
- if (havesearch == 0) {
- pp = _res.dnsrch;
- *pp++ = _res.defdname;
- *pp = NULL;
-
-#ifndef RFC1535
- dots = 0;
- for (cp = _res.defdname; *cp; cp++)
- dots += (*cp == '.');
-
- cp = _res.defdname;
- while (pp < _res.dnsrch + MAXDFLSRCH) {
- if (dots < LOCALDOMAINPARTS)
- break;
- cp = strchr(cp, '.') + 1; /* we know there is one */
- *pp++ = cp;
- dots--;
- }
- *pp = NULL;
-#ifdef DEBUG
- if (_res.options & RES_DEBUG) {
- printf(";; res_init()... default dnsrch list:\n");
- for (pp = _res.dnsrch; *pp; pp++)
- printf(";;\t%s\n", *pp);
- printf(";;\t..END..\n");
- }
-#endif /* DEBUG */
-#endif /* !RFC1535 */
- }
-
- if ((cp = getenv("RES_OPTIONS")) != NULL)
- res_setoptions(cp, "env");
- _res.options |= RES_INIT;
- return (0);
-}
-
-static void
-res_setoptions(options, source)
- char *options, *source;
-{
- char *cp = options;
- int i;
-
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_setoptions(\"%s\", \"%s\")...\n",
- options, source);
-#endif
- while (*cp) {
- /* skip leading and inner runs of spaces */
- while (*cp == ' ' || *cp == '\t')
- cp++;
- /* search for and process individual options */
- if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) {
- i = atoi(cp + sizeof("ndots:") - 1);
- if (i <= RES_MAXNDOTS)
- _res.ndots = i;
- else
- _res.ndots = RES_MAXNDOTS;
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";;\tndots=%d\n", _res.ndots);
-#endif
- } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
-#ifdef DEBUG
- if (!(_res.options & RES_DEBUG)) {
- printf(";; res_setoptions(\"%s\", \"%s\")..\n",
- options, source);
- _res.options |= RES_DEBUG;
- }
- printf(";;\tdebug\n");
-#endif
- } else {
- /* XXX - print a warning here? */
- }
- /* skip to next run of spaces */
- while (*cp && *cp != ' ' && *cp != '\t')
- cp++;
- }
-}
-
-#ifdef RESOLVSORT
-/* XXX - should really support CIDR which means explicit masks always. */
-static u_int32_t
-net_mask(in) /* XXX - should really use system's version of this */
- struct in_addr in;
-{
- register u_int32_t i = ntohl(in.s_addr);
-
- if (IN_CLASSA(i))
- return (htonl(IN_CLASSA_NET));
- else if (IN_CLASSB(i))
- return (htonl(IN_CLASSB_NET));
- return (htonl(IN_CLASSC_NET));
-}
-#endif
-
-u_int16_t
-res_randomid()
-{
- struct timeval now;
-
- gettimeofday(&now, NULL);
- return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
-}
+++ /dev/null
-/*
- * 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++ 1985, 1993
- * -
- * Copyright (c) 1985, 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--
- */
-
-#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.3 2003/02/18 17:29:24 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <netinet/in.h>
-
-#include <stdio.h>
-#include <netdb.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#if defined(BSD) && (BSD >= 199103)
-# include <string.h>
-#else
-# include "portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "options.h"
-#endif
-
-/*
- * Form all types of queries.
- * Returns the size of the result or -1.
- */
-int
-res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
- int op; /* opcode of query */
- const char *dname; /* domain name */
- int class, type; /* class and type of query */
- const u_char *data; /* resource record data */
- int datalen; /* length of data */
- const u_char *newrr_in; /* new rr for modify or append */
- u_char *buf; /* buffer to put query */
- int buflen; /* size of buffer */
-{
- register HEADER *hp;
- register u_char *cp;
- register int n;
-#ifdef ALLOW_UPDATES
- struct rrec *newrr = (struct rrec *) newrr_in;
-#endif
- u_char *dnptrs[20], **dpp, **lastdnptr;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
- return (-1);
- }
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_mkquery(%d, %s, %d, %d)\n",
- op, dname, class, type);
-#endif
- /*
- * Initialize header fields.
- */
- if ((buf == NULL) || (buflen < HFIXEDSZ))
- return (-1);
- bzero(buf, HFIXEDSZ);
- hp = (HEADER *) buf;
- hp->id = htons(++_res.id);
- hp->opcode = op;
- hp->rd = (_res.options & RES_RECURSE) != 0;
- hp->rcode = NOERROR;
- cp = buf + HFIXEDSZ;
- buflen -= HFIXEDSZ;
- dpp = dnptrs;
- *dpp++ = buf;
- *dpp++ = NULL;
- lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
- /*
- * perform opcode specific processing
- */
- switch (op) {
- case QUERY: /*FALLTHROUGH*/
- case NS_NOTIFY_OP:
- if ((buflen -= QFIXEDSZ) < 0)
- return (-1);
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
- return (-1);
- cp += n;
- buflen -= n;
- __putshort(type, cp);
- cp += INT16SZ;
- __putshort(class, cp);
- cp += INT16SZ;
- hp->qdcount = htons(1);
- if (op == QUERY || data == NULL)
- break;
- /*
- * Make an additional record for completion domain.
- */
- buflen -= RRFIXEDSZ;
- n = dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr);
- if (n < 0)
- return (-1);
- cp += n;
- buflen -= n;
- __putshort(T_NULL, cp);
- cp += INT16SZ;
- __putshort(class, cp);
- cp += INT16SZ;
- __putlong(0, cp);
- cp += INT32SZ;
- __putshort(0, cp);
- cp += INT16SZ;
- hp->arcount = htons(1);
- break;
-
- case IQUERY:
- /*
- * Initialize answer section
- */
- if (buflen < 1 + RRFIXEDSZ + datalen)
- return (-1);
- *cp++ = '\0'; /* no domain name */
- __putshort(type, cp);
- cp += INT16SZ;
- __putshort(class, cp);
- cp += INT16SZ;
- __putlong(0, cp);
- cp += INT32SZ;
- __putshort(datalen, cp);
- cp += INT16SZ;
- if (datalen) {
- bcopy(data, cp, datalen);
- cp += datalen;
- }
- hp->ancount = htons(1);
- break;
-
-#ifdef ALLOW_UPDATES
- /*
- * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA
- * (Record to be modified is followed by its replacement in msg.)
- */
- case UPDATEM:
- case UPDATEMA:
-
- case UPDATED:
- /*
- * The res code for UPDATED and UPDATEDA is the same; user
- * calls them differently: specifies data for UPDATED; server
- * ignores data if specified for UPDATEDA.
- */
- case UPDATEDA:
- buflen -= RRFIXEDSZ + datalen;
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
- return (-1);
- cp += n;
- __putshort(type, cp);
- cp += INT16SZ;
- __putshort(class, cp);
- cp += INT16SZ;
- __putlong(0, cp);
- cp += INT32SZ;
- __putshort(datalen, cp);
- cp += INT16SZ;
- if (datalen) {
- bcopy(data, cp, datalen);
- cp += datalen;
- }
- if ( (op == UPDATED) || (op == UPDATEDA) ) {
- hp->ancount = htons(0);
- break;
- }
- /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */
-
- case UPDATEA: /* Add new resource record */
- buflen -= RRFIXEDSZ + datalen;
- if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
- return (-1);
- cp += n;
- __putshort(newrr->r_type, cp);
- cp += INT16SZ;
- __putshort(newrr->r_class, cp);
- cp += INT16SZ;
- __putlong(0, cp);
- cp += INT32SZ;
- __putshort(newrr->r_size, cp);
- cp += INT16SZ;
- if (newrr->r_size) {
- bcopy(newrr->r_data, cp, newrr->r_size);
- cp += newrr->r_size;
- }
- hp->ancount = htons(0);
- break;
-#endif /* ALLOW_UPDATES */
- default:
- return (-1);
- }
- return (cp - buf);
-}
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999, 2012 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* 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++ 1988, 1993
- * -
- * Copyright (c) 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--
- */
-#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.3 2003/02/18 17:29:24 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <ctype.h>
+#include <dns_sd.h>
#include <errno.h>
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
+#include <arpa/nameser_compat.h>
+#include <nameser.h>
-#if defined(BSD) && (BSD >= 199306)
-# include <stdlib.h>
-# include <string.h>
-#else
-# include "portability.h"
-#endif
+#include "si_module.h"
-#if defined(USE_OPTIONS_H)
-# include "options.h"
-#endif
+extern int h_errno;
-#if PACKETSZ > 1024
-#define MAXPACKET PACKETSZ
+// Storage for the global struct __res_9_state.
+// The BIND9 libresolv.dylib shares the same storage for this structure as the
+// legacy BIND8 libsystem_info.dylib. This implementation does not require the
+// _res structure but libresolv.dylib does and many 3rd-party applications
+// access this global symbol directly so we preserve it here.
+#ifdef __LP64__
+#define RES_9_STATE_SIZE 552
#else
-#define MAXPACKET 1024
-#endif
-
-char *__hostalias __P((const char *));
-#if defined(__APPLE__)
-extern
+#define RES_9_STATE_SIZE 512
#endif
-int h_errno;
+char _res[RES_9_STATE_SIZE] = {0};
-/*
- * Formulate a normal query, send, and await answer.
- * Returned answer is placed in supplied buffer "answer".
- * Perform preliminary check of answer, returning success only
- * if no error is indicated and the answer count is nonzero.
- * Return the size of the response on success, -1 on error.
- * Error number is left in h_errno.
- *
- * Caller must parse answer and determine whether it answers the question.
- */
int
-res_query(name, class, type, answer, anslen)
- const char *name; /* domain name */
- int class, type; /* class and type of query */
- u_char *answer; /* buffer to put answer */
- int anslen; /* size of answer buffer */
+res_init(void)
{
- u_char buf[MAXPACKET];
- register HEADER *hp = (HEADER *) answer;
- int n;
-
- hp->rcode = NOERROR; /* default */
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
- return (-1);
- }
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_query(%s, %d, %d)\n", name, class, type);
-#endif
-
- n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
- buf, sizeof(buf));
- if (n <= 0) {
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_query: mkquery failed\n");
-#endif
- h_errno = NO_RECOVERY;
- return (n);
- }
- n = res_send(buf, n, answer, anslen);
- if (n < 0) {
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_query: send error\n");
-#endif
- h_errno = TRY_AGAIN;
- return (n);
- }
-
- if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; rcode = %d, ancount=%d\n", hp->rcode,
- ntohs(hp->ancount));
-#endif
- switch (hp->rcode) {
- case NXDOMAIN:
- h_errno = HOST_NOT_FOUND;
- break;
- case SERVFAIL:
- h_errno = TRY_AGAIN;
- break;
- case NOERROR:
- h_errno = NO_DATA;
- break;
- case FORMERR:
- case NOTIMP:
- case REFUSED:
- default:
- h_errno = NO_RECOVERY;
- break;
- }
- return (-1);
- }
- return (n);
+ // For compatibility only.
+ return 0;
}
-/*
- * Formulate a normal query, send, and retrieve answer in supplied buffer.
- * Return the size of the response on success, -1 on error.
- * If enabled, implement search rules until answer or unrecoverable failure
- * is detected. Error code, if any, is left in h_errno.
- */
-int
-res_search(name, class, type, answer, anslen)
- const char *name; /* domain name */
- int class, type; /* class and type of query */
- u_char *answer; /* buffer to put answer */
- int anslen; /* size of answer */
+// Perform a DNS query. Returned DNS response is placed in the answer buffer.
+// A preliminary check of the answer is performed and success is returned only
+// if no error is indicated in the answer and the answer count is nonzero.
+// Returns the size of the response on success, or -1 with h_errno set.
+static int
+_mdns_query(int call, const char *name, int class, int type, u_char *answer, int anslen)
{
- register const char *cp, * const *domain;
- HEADER *hp = (HEADER *) answer;
- u_int dots;
- int trailing_dot, ret, saved_herrno;
- int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
- return (-1);
+ int res = -1;
+ si_item_t *item;
+ uint32_t err;
+
+ si_mod_t *dns = si_module_with_name("mdns");
+ if (dns == NULL) {
+ h_errno = NO_RECOVERY;
+ return -1;
}
- errno = 0;
- h_errno = HOST_NOT_FOUND; /* default, if we never query */
- dots = 0;
- for (cp = name; *cp; cp++)
- dots += (*cp == '.');
- trailing_dot = 0;
- if (cp > name && *--cp == '.')
- trailing_dot++;
-
- /*
- * if there aren't any dots, it could be a user-level alias
- */
- if (!dots && (cp = __hostalias(name)) != NULL)
- return (res_query(cp, class, type, answer, anslen));
-
- /*
- * If there are dots in the name already, let's just give it a try
- * 'as is'. The threshold can be set with the "ndots" option.
- */
- saved_herrno = -1;
- if (dots >= _res.ndots) {
- ret = res_querydomain(name, NULL, class, type, answer, anslen);
- if (ret > 0)
- return (ret);
- saved_herrno = h_errno;
- tried_as_is++;
+
+ item = dns->vtable->sim_item_call(dns, call, name, NULL, NULL, class, type, &err);
+
+ if (item != NULL) {
+ si_dnspacket_t *p;
+
+ p = (si_dnspacket_t *)((uintptr_t)item + sizeof(si_item_t));
+
+ res = p->dns_packet_len;
+
+ // Truncate to destination buffer size.
+ memcpy(answer, p->dns_packet, MIN(res, anslen));
+
+ si_item_release(item);
+ } else {
+ h_errno = HOST_NOT_FOUND;
+ res = -1;
}
- /*
- * We do at least one level of search if
- * - there is no dot and RES_DEFNAME is set, or
- * - there is at least one dot, there is no trailing dot,
- * and RES_DNSRCH is set.
- */
- if ((!dots && (_res.options & RES_DEFNAMES)) ||
- (dots && !trailing_dot && (_res.options & RES_DNSRCH))) {
- int done = 0;
-
- for (domain = (const char * const *)_res.dnsrch;
- *domain && !done;
- domain++) {
-
- ret = res_querydomain(name, *domain, class, type,
- answer, anslen);
- if (ret > 0)
- return (ret);
-
- /*
- * If no server present, give up.
- * If name isn't found in this domain,
- * keep trying higher domains in the search list
- * (if that's enabled).
- * On a NO_DATA error, keep trying, otherwise
- * a wildcard entry of another type could keep us
- * from finding this entry higher in the domain.
- * If we get some other error (negative answer or
- * server failure), then stop searching up,
- * but try the input name below in case it's
- * fully-qualified.
- */
- if (errno == ECONNREFUSED) {
+ if (MIN(res, anslen) >= sizeof(HEADER)) {
+ HEADER *hp = (HEADER *)answer;
+ switch (hp->rcode) {
+ case NXDOMAIN:
+ h_errno = HOST_NOT_FOUND;
+ res = -1;
+ break;
+ case SERVFAIL:
h_errno = TRY_AGAIN;
- return (-1);
- }
-
- switch (h_errno) {
- case NO_DATA:
- got_nodata++;
- /* FALLTHROUGH */
- case HOST_NOT_FOUND:
- /* keep trying */
+ res = -1;
break;
- case TRY_AGAIN:
- if (hp->rcode == SERVFAIL) {
- /* try next search element, if any */
- got_servfail++;
- break;
+ case NOERROR:
+ if (ntohs(hp->ancount) == 0) {
+ h_errno = NO_DATA;
+ res = -1;
}
- /* FALLTHROUGH */
+ break;
+ case FORMERR:
+ case NOTIMP:
+ case REFUSED:
default:
- /* anything else implies that we're done */
- done++;
- }
-
- /* if we got here for some reason other than DNSRCH,
- * we only wanted one iteration of the loop, so stop.
- */
- if (!(_res.options & RES_DNSRCH))
- done++;
+ h_errno = NO_RECOVERY;
+ res = -1;
+ break;
}
}
- /* if we have not already tried the name "as is", do that now.
- * note that we do this regardless of how many dots were in the
- * name or whether it ends with a dot.
- */
- if (!tried_as_is) {
- ret = res_querydomain(name, NULL, class, type, answer, anslen);
- if (ret > 0)
- return (ret);
- }
-
- /* if we got here, we didn't satisfy the search.
- * if we did an initial full query, return that query's h_errno
- * (note that we wouldn't be here if that query had succeeded).
- * else if we ever got a nodata, send that back as the reason.
- * else send back meaningless h_errno, that being the one from
- * the last DNSRCH we did.
- */
- if (saved_herrno != -1)
- h_errno = saved_herrno;
- else if (got_nodata)
- h_errno = NO_DATA;
- else if (got_servfail)
- h_errno = TRY_AGAIN;
- return (-1);
+ si_module_release(dns);
+ return res;
}
-/*
- * Perform a call on res_query on the concatenation of name and domain,
- * removing a trailing dot from name if domain is NULL.
- */
int
-res_querydomain(name, domain, class, type, answer, anslen)
- const char *name, *domain;
- int class, type; /* class and type of query */
- u_char *answer; /* buffer to put answer */
- int anslen; /* size of answer */
+res_query(const char *name, int class, int type, u_char *answer, int anslen)
{
- char nbuf[2*MAXDNAME+2];
- const char *longname = nbuf;
- int n;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
- return (-1);
- }
-#ifdef DEBUG
- if (_res.options & RES_DEBUG)
- printf(";; res_querydomain(%s, %s, %d, %d)\n",
- name, domain?domain:"<Nil>", class, type);
-#endif
- if (domain == NULL) {
- /*
- * Check for trailing '.';
- * copy without '.' if present.
- */
- n = strlen(name) - 1;
- if (n != (0 - 1) && name[n] == '.' && n < sizeof(nbuf) - 1) {
- bcopy(name, nbuf, n);
- nbuf[n] = '\0';
- } else
- longname = name;
- } else
- sprintf(nbuf, "%.*s.%.*s", MAXDNAME, name, MAXDNAME, domain);
-
- return (res_query(longname, class, type, answer, anslen));
+ return _mdns_query(SI_CALL_DNS_QUERY, name, class, type, answer, anslen);
}
-char *
-__hostalias(name)
- register const char *name;
+int
+res_search(const char *name, int class, int type, u_char *answer, int anslen)
{
- register char *cp1, *cp2;
- FILE *fp;
- char *file;
- char buf[BUFSIZ];
- static char abuf[MAXDNAME];
-
- if (_res.options & RES_NOALIASES)
- return (NULL);
- file = getenv("HOSTALIASES");
- if (file == NULL || (fp = fopen(file, "r")) == NULL)
- return (NULL);
- setbuf(fp, NULL);
- buf[sizeof(buf) - 1] = '\0';
- while (fgets(buf, sizeof(buf), fp)) {
- for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1)
- ;
- if (!*cp1)
- break;
- *cp1 = '\0';
- if (!strcasecmp(buf, name)) {
- while (isspace(*++cp1))
- ;
- if (!*cp1)
- break;
- for (cp2 = cp1 + 1; *cp2 && !isspace(*cp2); ++cp2)
- ;
- abuf[sizeof(abuf) - 1] = *cp2 = '\0';
- strncpy(abuf, cp1, sizeof(abuf) - 1);
- fclose(fp);
- return (abuf);
- }
- }
- fclose(fp);
- return (NULL);
+ return _mdns_query(SI_CALL_DNS_SEARCH, name, class, type, answer, anslen);
}
+++ /dev/null
-/*
- * 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@
- */
-/**
- ** res_running.c
- **
- ** A little shortie to tell us if the resolver has been initialized or not.
- **
- ** Copyright (c) 1995, NeXT Computer, Inc. All Rights Reserved.
- **/
-
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-int
-_res_running()
-{
- return (_res.options & RES_INIT);
-}
+++ /dev/null
-/*
- * 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++ 1985, 1989, 1993
- * -
- * Copyright (c) 1985, 1989, 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--
- */
-
-#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.6 2003/02/18 17:29:25 majka Exp $";
-#endif /* LIBC_SCCS and not lint */
-
- /* change this to "0"
- * if you talk to a lot
- * of multi-homed SunOS
- * ("broken") name servers.
- */
-#define CHECK_SRVR_ADDR 1 /* XXX - should be in options.h */
-
-/*
- * Send query to name server and wait for reply.
- */
-
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <net/if.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <errno.h>
-
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#if defined(BSD) && (BSD >= 199306)
-# include <stdlib.h>
-# include <string.h>
-# include <unistd.h>
-#else
-# include "portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "options.h"
-#endif
-
-void _res_close __P((void));
-
-static int s = -1; /* socket used for communications */
-static int connected = 0; /* is the socket connected */
-static int vc = 0; /* is the socket a virtual ciruit? */
-
-#ifndef FD_SET
-/* XXX - should be in portability.h */
-#define NFDBITS 32
-#define FD_SETSIZE 32
-#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
-#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
-#endif
-
-/* XXX - this should be done in portability.h */
-#if (defined(BSD) && (BSD >= 199103)) || defined(linux)
-# define CAN_RECONNECT 1
-#else
-# define CAN_RECONNECT 0
-#endif
-
-#ifndef DEBUG
-# define Dprint(cond, args) /*empty*/
-# define DprintQ(cond, args, query, size) /*empty*/
-# define Aerror(file, string, error, address) /*empty*/
-# define Perror(file, string, error) /*empty*/
-#else
-# define Dprint(cond, args) if (cond) {fprintf args;} else {}
-# define DprintQ(cond, args, query, size) if (cond) {\
- fprintf args;\
- __fp_nquery(query, size, stdout);\
- } else {}
- static void
- Aerror(file, string, error, address)
- FILE *file;
- char *string;
- int error;
- struct sockaddr_in address;
- {
- int save = errno;
-
- if (_res.options & RES_DEBUG) {
- fprintf(file, "res_send: %s ([%s].%u): %s\n",
- string,
- inet_ntoa(address.sin_addr),
- ntohs(address.sin_port),
- strerror(error));
- }
- errno = save;
- }
- static void
- Perror(file, string, error)
- FILE *file;
- char *string;
- int error;
- {
- int save = errno;
-
- if (_res.options & RES_DEBUG) {
- fprintf(file, "res_send: %s: %s\n",
- string, strerror(error));
- }
- errno = save;
- }
-#endif
-
-static res_send_qhook Qhook = NULL;
-static res_send_rhook Rhook = NULL;
-
-void
-res_send_setqhook(hook)
- res_send_qhook hook;
-{
-
- Qhook = hook;
-}
-
-void
-res_send_setrhook(hook)
- res_send_rhook hook;
-{
-
- Rhook = hook;
-}
-
-/* int
- * res_isourserver(ina)
- * looks up "ina" in _res.ns_addr_list[]
- * returns:
- * 0 : not found
- * >0 : found
- * author:
- * paul vixie, 29may94
- */
-int
-res_isourserver(inp)
- const struct sockaddr_in *inp;
-{
- struct sockaddr_in ina;
- register int ns, ret;
-
- ina = *inp;
- ret = 0;
- for (ns = 0; ns < _res.nscount; ns++) {
- register const struct sockaddr_in *srv = &_res.nsaddr_list[ns];
-
- if (srv->sin_family == ina.sin_family &&
- srv->sin_port == ina.sin_port &&
- (srv->sin_addr.s_addr == INADDR_ANY ||
- srv->sin_addr.s_addr == ina.sin_addr.s_addr)) {
- ret++;
- break;
- }
- }
- return (ret);
-}
-
-/* int
- * res_nameinquery(name, type, class, buf, eom)
- * look for (name,type,class) in the query section of packet (buf,eom)
- * returns:
- * -1 : format error
- * 0 : not found
- * >0 : found
- * author:
- * paul vixie, 29may94
- */
-int
-res_nameinquery(name, type, class, buf, eom)
- const char *name;
- register int type, class;
- const u_char *buf, *eom;
-{
- register const u_char *cp = buf + HFIXEDSZ;
- int qdcount = ntohs(((HEADER*)buf)->qdcount);
-
- while (qdcount-- > 0) {
- char tname[MAXDNAME+1];
- register int n, ttype, tclass;
-
- n = dn_expand(buf, eom, cp, tname, sizeof tname);
- if (n < 0)
- return (-1);
- cp += n;
- ttype = _getshort(cp); cp += INT16SZ;
- tclass = _getshort(cp); cp += INT16SZ;
- if (ttype == type &&
- tclass == class &&
- strcasecmp(tname, name) == 0)
- return (1);
- }
- return (0);
-}
-
-/* int
- * res_queriesmatch(buf1, eom1, buf2, eom2)
- * is there a 1:1 mapping of (name,type,class)
- * in (buf1,eom1) and (buf2,eom2)?
- * returns:
- * -1 : format error
- * 0 : not a 1:1 mapping
- * >0 : is a 1:1 mapping
- * author:
- * paul vixie, 29may94
- */
-int
-res_queriesmatch(buf1, eom1, buf2, eom2)
- const u_char *buf1, *eom1;
- const u_char *buf2, *eom2;
-{
- register const u_char *cp = buf1 + HFIXEDSZ;
- int qdcount = ntohs(((HEADER*)buf1)->qdcount);
-
- if (qdcount != ntohs(((HEADER*)buf2)->qdcount))
- return (0);
- while (qdcount-- > 0) {
- char tname[MAXDNAME+1];
- register int n, ttype, tclass;
-
- n = dn_expand(buf1, eom1, cp, tname, sizeof tname);
- if (n < 0)
- return (-1);
- cp += n;
- ttype = _getshort(cp); cp += INT16SZ;
- tclass = _getshort(cp); cp += INT16SZ;
- if (!res_nameinquery(tname, ttype, tclass, buf2, eom2))
- 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)
-{
- const u_int8_t *d0 = NULL; // Top-Level Domain
- 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 || *name == 0) return 0;
-
- while (*name)
- {
- d3 = d2;
- d2 = d1;
- d1 = d0;
- d0 = name;
- name += 1 + *name;
- }
-
- // "local" domains need to be resolved with multicast
- // "local."
- if (d0[0] == 5 && strncasecmp((char *)d0+1, "local", 5) == 0) return 1;
-
- // "local.arpa."
- if (d1 && d1[0] == 5 && strncasecmp((char *)d1+1, "local", 5) == 0 &&
- d0[0] == 4 && strncasecmp((char *)d0+1, "arpa", 4) == 0) return 1;
-
- // "local.int."
- if (d1 && d1[0] == 5 && strncasecmp((char *)d1+1, "local", 5) == 0 &&
- d0[0] == 3 && strncasecmp((char *)d0+1, "int", 3) == 0) return 1;
-
- // The network 169.254/16 is defined to be link-local,
- // so lookups in 254.169.in-addr.arpa. also need to be resolved with local multicast
- if (d3 && d3[0] == 3 && strncasecmp((char *)d3+1, "254", 3) == 0 &&
- d2 && d2[0] == 3 && strncasecmp((char *)d2+1, "169", 3) == 0 &&
- d1 && d1[0] == 7 && strncasecmp((char *)d1+1, "in-addr", 7) == 0 &&
- d0[0] == 4 && strncasecmp((char *)d0+1, "arpa", 4) == 0) return 1;
-
- return 0;
-}
-
-#define DNS_LOCAL_DOMAIN_SERVICE_PORT 5353
-#define DNS_HEADER_SIZE 12
-
-static const struct sockaddr_in mDNS_addr =
-{
- sizeof(mDNS_addr),
- AF_INET,
- htons(DNS_LOCAL_DOMAIN_SERVICE_PORT),
- {htonl(0xE00000FB)} /* 224.0.0.251 */
-};
-
-int
-res_send(buf, buflen, ans, anssiz)
- const u_char *buf;
- int buflen;
- u_char *ans;
- int anssiz;
-{
- HEADER *hp = (HEADER *) buf;
- HEADER *anhp = (HEADER *) ans;
- int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns;
- register int n;
- u_int badns; /* XXX NSMAX can't exceed #/bits in this var */
- int multicast;
-
- if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- /* errno should have been set by res_init() in this case. */
- return (-1);
- }
- DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY),
- (stdout, ";; res_send()\n"), buf, buflen);
- v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
- gotsomewhere = 0;
- connreset = 0;
- terrno = ETIMEDOUT;
- badns = 0;
-
- if (dns_is_local_name((u_int8_t*)(buf + DNS_HEADER_SIZE))) {
- multicast = 1;
- v_circuit = 0;
- } else {
- multicast = 0;
- }
-
-
- /*
- * Send request, RETRY times, or until successful
- */
- for (try = 0; try < _res.retry; try++) {
- for (ns = 0; (multicast == 0 && ns < _res.nscount) ||
- (multicast == 1 && ns < 1) ; ns++) {
- struct sockaddr_in *nsap;
- if (multicast == 0)
- nsap = &_res.nsaddr_list[ns];
- else
- nsap = (struct sockaddr_in*)&mDNS_addr; /* const cast */
- same_ns:
- if (badns & (1 << ns)) {
- _res_close();
- goto next_ns;
- }
-
- if (Qhook) {
- int done = 0, loops = 0;
-
- do {
- res_sendhookact act;
-
- act = (*Qhook)(&nsap, &buf, &buflen,
- ans, anssiz, &resplen);
- switch (act) {
- case res_goahead:
- done = 1;
- break;
- case res_nextns:
- _res_close();
- goto next_ns;
- case res_done:
- return (resplen);
- case res_modified:
- /* give the hook another try */
- if (++loops < 42) /*doug adams*/
- break;
- /*FALLTHROUGH*/
- case res_error:
- /*FALLTHROUGH*/
- default:
- return (-1);
- }
- } while (!done);
- }
-
- Dprint(_res.options & RES_DEBUG,
- (stdout, ";; Querying server (# %d) address = %s\n",
- ns + 1, inet_ntoa(nsap->sin_addr)));
-
- if (v_circuit) {
- int truncated;
- struct iovec iov[2];
- u_short len;
- u_char *cp;
-
- /*
- * Use virtual circuit;
- * at most one attempt per server.
- */
- try = _res.retry;
- truncated = 0;
- if ((s < 0) || (!vc)) {
- if (s >= 0)
- _res_close();
-
- s = socket(PF_INET, SOCK_STREAM, 0);
- if (s < 0) {
- terrno = errno;
- Perror(stderr, "socket(vc)", errno);
- return (-1);
- }
- errno = 0;
- if (connect(s, (struct sockaddr *)nsap,
- sizeof(struct sockaddr)) < 0) {
- terrno = errno;
- Aerror(stderr, "connect/vc",
- errno, *nsap);
- badns |= (1 << ns);
- _res_close();
- goto next_ns;
- }
- vc = 1;
- }
- /*
- * Send length & message
- */
- putshort((u_short)buflen, (u_char*)&len);
- iov[0].iov_base = (caddr_t)&len;
- iov[0].iov_len = INT16SZ;
- iov[1].iov_base = (caddr_t)buf;
- iov[1].iov_len = buflen;
- if (writev(s, iov, 2) != (INT16SZ + buflen)) {
- terrno = errno;
- Perror(stderr, "write failed", errno);
- badns |= (1 << ns);
- _res_close();
- goto next_ns;
- }
- /*
- * Receive length & response
- */
- cp = ans;
- len = INT16SZ;
- while ((n = read(s, (char *)cp, (int)len)) > 0) {
- cp += n;
- if ((len -= n) <= 0)
- break;
- }
- if (n <= 0) {
- terrno = errno;
- Perror(stderr, "read failed", errno);
- _res_close();
- /*
- * A long running process might get its TCP
- * connection reset if the remote server was
- * restarted. Requery the server instead of
- * trying a new one. When there is only one
- * server, this means that a query might work
- * instead of failing. We only allow one reset
- * per query to prevent looping.
- */
- if (terrno == ECONNRESET && !connreset) {
- connreset = 1;
- _res_close();
- goto same_ns;
- }
- _res_close();
- goto next_ns;
- }
- resplen = _getshort(ans);
- if (resplen > anssiz) {
- Dprint(_res.options & RES_DEBUG,
- (stdout, ";; response truncated\n")
- );
- truncated = 1;
- len = anssiz;
- } else
- len = resplen;
- cp = ans;
- while (len != 0 &&
- (n = read(s, (char *)cp, (int)len)) > 0) {
- cp += n;
- len -= n;
- }
- if (n <= 0) {
- terrno = errno;
- Perror(stderr, "read(vc)", errno);
- _res_close();
- goto next_ns;
- }
- if (truncated) {
- /*
- * Flush rest of answer
- * so connection stays in synch.
- */
- anhp->tc = 1;
- len = resplen - anssiz;
- while (len != 0) {
- char junk[PACKETSZ];
-
- n = (len > sizeof(junk)
- ? sizeof(junk)
- : len);
- if ((n = read(s, junk, n)) > 0)
- len -= n;
- else
- break;
- }
- }
- } else {
- /*
- * Use datagrams.
- */
- struct timeval timeout;
- fd_set dsmask;
- struct sockaddr_in from;
- unsigned int fromlen;
-
- if ((s < 0) || vc) {
- if (vc)
- _res_close();
- s = socket(PF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
-#if !CAN_RECONNECT
- bad_dg_sock:
-#endif
- terrno = errno;
- Perror(stderr, "socket(dg)", errno);
- return (-1);
- }
- connected = 0;
- }
- /*
- * On a 4.3BSD+ machine (client and server,
- * actually), sending to a nameserver datagram
- * port with no nameserver will cause an
- * ICMP port unreachable message to be returned.
- * If our datagram socket is "connected" to the
- * server, we get an ECONNREFUSED error on the next
- * socket operation, and select returns if the
- * error message is received. We can thus detect
- * the absence of a nameserver without timing out.
- * If we have sent queries to at least two servers,
- * however, we don't want to remain connected,
- * as we wish to receive answers from the first
- * server to respond.
- */
- if ((_res.nscount == 1 || (try == 0 && ns == 0)) && multicast == 0) {
- /*
- * Connect only if we are sure we won't
- * receive a response from another server.
- */
- if (!connected) {
- if (connect(s, (struct sockaddr *)nsap,
- sizeof(struct sockaddr)
- ) < 0) {
- Aerror(stderr,
- "connect(dg)",
- errno, *nsap);
- badns |= (1 << ns);
- _res_close();
- goto next_ns;
- }
- connected = 1;
- }
- if (send(s, (char*)buf, buflen, 0) != buflen) {
- Perror(stderr, "send", errno);
- badns |= (1 << ns);
- _res_close();
- goto next_ns;
- }
- } else {
- /*
- * Disconnect if we want to listen
- * for responses from more than one server.
- */
- if (connected) {
-#if CAN_RECONNECT
- struct sockaddr_in no_addr;
-
- no_addr.sin_family = AF_INET;
- no_addr.sin_addr.s_addr = INADDR_ANY;
- no_addr.sin_port = 0;
- (void) connect(s,
- (struct sockaddr *)
- &no_addr,
- sizeof(no_addr));
-#else
- int s1 = socket(PF_INET, SOCK_DGRAM,0);
- if (s1 < 0)
- goto bad_dg_sock;
- (void) dup2(s1, s);
- (void) close(s1);
- Dprint(_res.options & RES_DEBUG,
- (stdout, ";; new DG socket\n"))
-#endif
- connected = 0;
- errno = 0;
- }
-
- if (multicast) {
- struct ifaddrs* addrs;
- struct ifaddrs* curAddr;
- const int twofivefive = 255;
-
- // multicast packets with TTL 255
- if(setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL, &twofivefive, sizeof(twofivefive))) {
- Perror(stderr, "setsocketopt - IP_MULTICAST_TTL", errno);
- _res_close();
- return (0);
- }
-
- if (getifaddrs(&addrs) != 0)
- {
- Perror(stderr, "getifaddrs", errno);
- _res_close();
- return (0);
- }
-
- /* multicast should send request on all multicast capable interfaces */
- for (curAddr = addrs; curAddr != NULL; curAddr = curAddr->ifa_next) {
- if ((curAddr->ifa_addr->sa_family) == AF_INET &&
- (curAddr->ifa_flags & IFF_MULTICAST) != 0 &&
- (curAddr->ifa_flags & IFF_POINTOPOINT) == 0) {
- struct in_addr* if_ip_addr = &((struct sockaddr_in*)curAddr->ifa_addr)->sin_addr;
-
- if (setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF,
- if_ip_addr, sizeof(*if_ip_addr)) != 0) {
- freeifaddrs(addrs);
- Perror(stderr, "setsocketopt - IP_MULTICAST_IF", errno);
- _res_close();
- return (0);
- }
-
- if (sendto(s, (char*)buf, buflen, 0,
- (struct sockaddr *)nsap, sizeof *nsap) != buflen)
- {
- freeifaddrs(addrs);
- Aerror(stderr, "sendto", errno, *nsap);
- _res_close();
- return (0);
- }
- }
- }
-
- freeifaddrs(addrs);
- } else {
- if (sendto(s, (char*)buf, buflen, 0,
- (struct sockaddr *)nsap,
- sizeof(struct sockaddr))
- != buflen) {
- Aerror(stderr, "sendto", errno, *nsap);
- badns |= (1 << ns);
- _res_close();
- goto next_ns;
- }
- }
- }
-
- /*
- * Wait for reply
- */
- timeout.tv_sec = (_res.retrans << try);
- if (try > 0)
- timeout.tv_sec /= _res.nscount;
- if ((long) timeout.tv_sec <= 0 || multicast)
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
- wait:
- FD_ZERO(&dsmask);
- FD_SET(s, &dsmask);
- n = select(s+1, &dsmask, (fd_set *)NULL,
- (fd_set *)NULL, &timeout);
- if (n < 0) {
- Perror(stderr, "select", errno);
- _res_close();
- goto next_ns;
- }
- if (n == 0) {
- /*
- * timeout
- */
- Dprint(_res.options & RES_DEBUG,
- (stdout, ";; timeout\n"));
- gotsomewhere = 1;
- _res_close();
- goto next_ns;
- }
- errno = 0;
- fromlen = sizeof(struct sockaddr_in);
- resplen = recvfrom(s, (char*)ans, anssiz, 0,
- (struct sockaddr *)&from, &fromlen);
- if (resplen <= 0) {
- Perror(stderr, "recvfrom", errno);
- _res_close();
- goto next_ns;
- }
- gotsomewhere = 1;
- if (hp->id != anhp->id) {
- /*
- * response from old query, ignore it.
- * XXX - potential security hazard could
- * be detected here.
- */
- DprintQ((_res.options & RES_DEBUG) ||
- (_res.pfcode & RES_PRF_REPLY),
- (stdout, ";; old answer:\n"),
- ans, resplen);
- goto wait;
- }
-#if CHECK_SRVR_ADDR
- if (!(_res.options & RES_INSECURE1) &&
- multicast == 0 && !res_isourserver(&from)) {
- /*
- * response from wrong server? ignore it.
- * XXX - potential security hazard could
- * be detected here.
- */
- DprintQ((_res.options & RES_DEBUG) ||
- (_res.pfcode & RES_PRF_REPLY),
- (stdout, ";; not our server:\n"),
- ans, resplen);
- goto wait;
- }
-#endif
- if (!(_res.options & RES_INSECURE2) &&
- !res_queriesmatch(buf, buf + buflen,
- ans, ans + anssiz)) {
- /*
- * response contains wrong query? ignore it.
- * XXX - potential security hazard could
- * be detected here.
- */
- DprintQ((_res.options & RES_DEBUG) ||
- (_res.pfcode & RES_PRF_REPLY),
- (stdout, ";; wrong query name:\n"),
- ans, resplen);
- goto wait;
- }
- if (anhp->rcode == SERVFAIL ||
- anhp->rcode == NOTIMP ||
- anhp->rcode == REFUSED) {
- DprintQ(_res.options & RES_DEBUG,
- (stdout, "server rejected query:\n"),
- ans, resplen);
- badns |= (1 << ns);
- _res_close();
- /* don't retry if called from dig */
- if (!_res.pfcode)
- goto next_ns;
- }
- if (!(_res.options & RES_IGNTC) && anhp->tc) {
- /*
- * get rest of answer;
- * use TCP with same server.
- */
- Dprint(_res.options & RES_DEBUG,
- (stdout, ";; truncated answer\n"));
- v_circuit = 1;
- _res_close();
- goto same_ns;
- }
- } /*if vc/dg*/
- DprintQ((_res.options & RES_DEBUG) ||
- (_res.pfcode & RES_PRF_REPLY),
- (stdout, ";; got answer:\n"),
- ans, resplen);
- /*
- * If using virtual circuits, we assume that the first server
- * is preferred over the rest (i.e. it is on the local
- * machine) and only keep that one open.
- * If we have temporarily opened a virtual circuit,
- * or if we haven't been asked to keep a socket open,
- * close the socket.
- */
- if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) ||
- !(_res.options & RES_STAYOPEN)) {
- _res_close();
- }
- if (Rhook) {
- int done = 0, loops = 0;
-
- do {
- res_sendhookact act;
-
- act = (*Rhook)(nsap, buf, buflen,
- ans, anssiz, &resplen);
- switch (act) {
- case res_goahead:
- case res_done:
- done = 1;
- break;
- case res_nextns:
- _res_close();
- goto next_ns;
- case res_modified:
- /* give the hook another try */
- if (++loops < 42) /*doug adams*/
- break;
- /*FALLTHROUGH*/
- case res_error:
- /*FALLTHROUGH*/
- default:
- return (-1);
- }
- } while (!done);
-
- }
- return (resplen);
- next_ns: ;
- } /*foreach ns*/
- } /*foreach retry*/
- _res_close();
- if (!v_circuit)
- if (!gotsomewhere)
- errno = ECONNREFUSED; /* no nameservers found */
- else
- errno = ETIMEDOUT; /* no answer obtained */
- else
- errno = terrno;
- return (-1);
-}
-
-/*
- * This routine is for closing the socket if a virtual circuit is used and
- * the program wants to close it. This provides support for endhostent()
- * which expects to close the socket.
- *
- * This routine is not expected to be user visible.
- */
-void
-_res_close()
-{
- if (s >= 0) {
- (void) close(s);
- s = -1;
- connected = 0;
- vc = 0;
- }
-}
+++ /dev/null
-/*
- * 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++ 1983, 1987, 1989, 1993
- * -
- * Copyright (c) 1983, 1987, 1989, 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--
- */
-
-/*
- * @(#)resolv.h 8.1 (Berkeley) 6/2/93
- * $Id: resolv8_compat.h,v 1.3 2004/10/28 21:58:14 emoy Exp $
- */
-
-#ifndef _RESOLV_H_
-#define _RESOLV_H_
-
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-#include <stdio.h>
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __RES 19950621
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
-#endif
-
-/*
- * Global defines and variables for resolver stub.
- */
-#define MAXNS 3 /* max # name servers we'll track */
-#define MAXDFLSRCH 3 /* # default domain levels to try */
-#define MAXDNSRCH 6 /* max # domains in search path */
-#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
-
-#define RES_TIMEOUT 5 /* min. seconds between retries */
-#define MAXRESOLVSORT 10 /* number of net to sort on */
-#define RES_MAXNDOTS 15 /* should reflect bit field size */
-
-struct __res_state {
- int retrans; /* retransmition time interval */
- int retry; /* number of times to retransmit */
- unsigned long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in
- nsaddr_list[MAXNS]; /* address of name server */
-#define nsaddr nsaddr_list[0] /* for backward compatibility */
- unsigned short id; /* current packet id */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
- char defdname[MAXDNAME]; /* default domain */
- unsigned long pfcode; /* RES_PRF_ flags - see below. */
- unsigned ndots:4; /* threshold for initial abs. query */
- unsigned nsort:4; /* number of elements in sort_list[] */
- char unused[3];
- struct {
- struct in_addr addr;
- u_int32_t mask;
- } sort_list[MAXRESOLVSORT];
-};
-
-/*
- * Resolver options (keep these in synch with res_debug.c, please)
- */
-#define RES_INIT 0x00000001 /* address initialized */
-#define RES_DEBUG 0x00000002 /* print debug messages */
-#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
-#define RES_USEVC 0x00000008 /* use virtual circuit */
-#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
-#define RES_IGNTC 0x00000020 /* ignore trucation errors */
-#define RES_RECURSE 0x00000040 /* recursion desired */
-#define RES_DEFNAMES 0x00000080 /* use default domain name */
-#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
-#define RES_DNSRCH 0x00000200 /* search up local domain tree */
-#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
-#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
-#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
-
-#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-/*
- * Resolver "pfcode" values. Used by dig.
- */
-#define RES_PRF_STATS 0x00000001
-/* 0x00000002 */
-#define RES_PRF_CLASS 0x00000004
-#define RES_PRF_CMD 0x00000008
-#define RES_PRF_QUES 0x00000010
-#define RES_PRF_ANS 0x00000020
-#define RES_PRF_AUTH 0x00000040
-#define RES_PRF_ADD 0x00000080
-#define RES_PRF_HEAD1 0x00000100
-#define RES_PRF_HEAD2 0x00000200
-#define RES_PRF_TTLID 0x00000400
-#define RES_PRF_HEADX 0x00000800
-#define RES_PRF_QUERY 0x00001000
-#define RES_PRF_REPLY 0x00002000
-#define RES_PRF_INIT 0x00004000
-/* 0x00008000 */
-
-/* hooks are still experimental as of 4.9.2 */
-typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
- res_sendhookact;
-
-typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
- const unsigned char **query,
- int *querylen,
- unsigned char *ans,
- int anssiz,
- int *resplen));
-
-typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
- const unsigned char *query,
- int querylen,
- unsigned char *ans,
- int anssiz,
- int *resplen));
-
-extern struct __res_state _res;
-
-/* Private routines shared between libc/net, named, nslookup and others. */
-#define dn_skipname __dn_skipname
-#define fp_query __fp_query
-#define fp_nquery __fp_nquery
-#define hostalias __hostalias
-#define putlong __putlong
-#define putshort __putshort
-#define p_class __p_class
-#define p_time __p_time
-#define p_type __p_type
-#define p_cdnname __p_cdnname
-#define p_cdname __p_cdname
-#define p_fqname __p_fqname
-#define p_rr __p_rr
-#define p_option __p_option
-#define res_randomid __res_randomid
-#define res_isourserver __res_isourserver
-#define res_nameinquery __res_nameinquery
-#define res_queriesmatch __res_queriesmatch
-__BEGIN_DECLS
-int __dn_skipname __P((const unsigned char *, const unsigned char *));
-void __fp_resstat __P((struct __res_state *, FILE *));
-void __fp_query __P((const unsigned char *, FILE *));
-void __fp_nquery __P((const unsigned char *, int, FILE *));
-char *__hostalias __P((const char *));
-void __putlong __P((u_int32_t, unsigned char *));
-void __putshort __P((u_int16_t, unsigned char *));
-char *__p_time __P((u_int32_t));
-void __p_query __P((const unsigned char *));
-const unsigned char *__p_cdnname __P((const unsigned char *, const unsigned char *, int, FILE *));
-const unsigned char *__p_cdname __P((const unsigned char *, const unsigned char *, FILE *));
-const unsigned char *__p_fqname __P((const unsigned char *, const unsigned char *, FILE *));
-const unsigned char *__p_rr __P((const unsigned char *, const unsigned char *, FILE *));
-const char *__p_type __P((int));
-const char *__p_class __P((int));
-const char *__p_option __P((unsigned long option));
-int dn_comp __P((const char *, unsigned char *, int, unsigned char **, unsigned char **));
-int dn_expand __P((const unsigned char *, const unsigned char *, const unsigned char *,
- char *, int));
-int res_init __P((void));
-u_int16_t res_randomid __P((void));
-int res_query __P((const char *, int, int, unsigned char *, int));
-int res_search __P((const char *, int, int, unsigned char *, int));
-int res_querydomain __P((const char *, const char *, int, int,
- unsigned char *, int));
-int res_mkquery __P((int, const char *, int, int, const unsigned char *, int,
- const unsigned char *, unsigned char *, int));
-int res_send __P((const unsigned char *, int, unsigned char *, int));
-int res_isourserver __P((const struct sockaddr_in *));
-int res_nameinquery __P((const char *, int, int,
- const unsigned char *, const unsigned char *));
-int res_queriesmatch __P((const unsigned char *, const unsigned char *,
- const unsigned char *, const unsigned char *));
-__END_DECLS
-
-#endif /* !_RESOLV_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2012 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This 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 <stdlib.h>
+#include <string.h>
+#include <xpc/private.h>
+#include <sys/stat.h>
+#include <TargetConditionals.h>
+#include "configuration_profile.h"
+
+#define NOTIFY_PATH_SERVICE "com.apple.system.notify.service.path:0x87:"
+#define CPROF_PATH "/Library/Managed Preferences/mobile"
+
+char *
+configuration_profile_create_notification_key(const char *ident)
+{
+ char *out = NULL;
+
+ if (ident == NULL) return NULL;
+
+ if (ident[0] == '/')
+ {
+ asprintf(&out, "%s%s", NOTIFY_PATH_SERVICE, ident);
+ return out;
+ }
+
+#if TARGET_OS_EMBEDDED
+ if (strchr(ident + 1, '/') != NULL) return NULL;
+ asprintf(&out, "%s%s/%s.plist", NOTIFY_PATH_SERVICE, CPROF_PATH, ident);
+#endif
+
+ return out;
+}
+
+xpc_object_t
+configuration_profile_copy_property_list(const char *ident)
+{
+ char path[MAXPATHLEN];
+ void *data;
+ int fd;
+ struct stat sb;
+ xpc_object_t out = NULL;
+
+ if (ident == NULL) return NULL;
+
+ path[0] = '\0';
+ if (ident[0] == '/')
+ {
+ snprintf(path, sizeof(path), "%s", ident);
+ }
+#if TARGET_OS_EMBEDDED
+ else
+ {
+ if (strchr(ident + 1, '/') != NULL) return NULL;
+ snprintf(path, sizeof(path), "%s/%s.plist", CPROF_PATH, ident);
+ }
+#endif
+
+ if (path[0] == '\0') return NULL;
+
+ fd = open(path, O_RDONLY, 0);
+ if (fd < 0) return NULL;
+
+ memset(&sb, 0, sizeof(struct stat));
+ if (fstat(fd, &sb) < 0)
+ {
+ close(fd);
+ return NULL;
+ }
+
+ data = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (data != NULL) out = xpc_create_from_plist(data, sb.st_size);
+
+ munmap(data, sb.st_size);
+ close(fd);
+
+ return out;
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Apple Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * This 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 __CONFIGURATION_PROFILE_H__
+#define __CONFIGURATION_PROFILE_H__
+
+#include <xpc/xpc.h>
+#include <Availability.h>
+
+char *configuration_profile_create_notification_key(const char *ident) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
+xpc_object_t configuration_profile_copy_property_list(const char *ident) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
+
+#endif /* __CONFIGURATION_PROFILE_H__ */
+++ /dev/null
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/socket.h>
-
-void __res_close()
-{
-}
-
-#define MAX_V4_ADDR_LEN 16
-#define MAX_V6_ADDR_LEN 64
-
-static const char *hexchars = "0123456789abcdef";
-
-const char *
-inet_ntop6(const struct in6_addr *addr, char *dst, socklen_t size)
-{
- char hexa[8][5], tmp[MAX_V6_ADDR_LEN];
- int zr[8];
- socklen_t len;
- int32_t i, j, k, skip;
- uint8_t x8, hx8;
- uint16_t x16;
- struct in_addr a4;
-
- if (addr == NULL)
- {
- errno = EAFNOSUPPORT;
- return NULL;
- }
-
- if (dst == NULL)
- {
- errno = ENOSPC;
- 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)
- {
- errno = ENOSPC;
- 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)
- {
- errno = ENOSPC;
- return NULL;
- }
-
- memcpy(dst, tmp, len);
- return dst;
-}
-
-const char *
-inet_ntop4(const struct in_addr *addr, char *dst, socklen_t size)
-{
- char tmp[MAX_V4_ADDR_LEN], *p;
- const u_int8_t *ap = (u_int8_t *)&addr->s_addr;
- int i, ql, len;
-
- if (addr == NULL)
- {
- errno = EAFNOSUPPORT;
- return NULL;
- }
-
- if (dst == NULL)
- {
- errno = ENOSPC;
- return NULL;
- }
-
- memset(tmp, 0, MAX_V4_ADDR_LEN);
-
- /* 3 dots, trailing nul */
- len = 4;
-
- p = tmp;
-
- for (i = 0; i < 4; i++, ap++)
- {
- snprintf(p, 4, "%d", *ap);
- ql = strlen(p);
- len += ql;
- p += ql;
- if (i < 3) *p++ = '.';
- }
-
- if (len > size)
- {
- errno = ENOSPC;
- return NULL;
- }
-
- memcpy(dst, tmp, len);
- return dst;
-}
-
-const char *
-inet_ntop(int af, const void *addr, char *buf, socklen_t len)
-{
- if (af == AF_INET6) return inet_ntop6(addr, buf, len);
- if (af == AF_INET) return inet_ntop4(addr, buf, len);
-
- errno = EAFNOSUPPORT;
- return NULL;
-}
+++ /dev/null
-/*
- * Copyright (c) 1996,1999 by Internet Software Consortium.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-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
-#include <config.h>
-#endif
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <arpa/nameser.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#define IN6ADDRSZ 16
-
-#if 0
-#ifndef HAVE_PORTABLE_PROTOTYPE
-#include "cdecl_ext.h"
-#endif
-
-#ifndef HAVE_U_INT16_T
-#include "bittypes.h"
-#endif
-#if !(defined(HAVE_INADDRSZ) && defined(HAVE_IN6ADDRSZ))
-#include "addrsize.h"
-#endif
-#endif
-#ifndef NS_INADDRSZ
-#define NS_INADDRSZ INADDRSZ
-#endif
-#ifndef NS_IN6ADDRSZ
-#define NS_IN6ADDRSZ IN6ADDRSZ
-#endif
-#ifndef NS_INT16SZ
-#define NS_INT16SZ sizeof(u_int16_t)
-#endif
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static int inet_pton4 __P((const char *src, u_char *dst));
-#ifdef INET6
-static int inet_pton6 __P((const char *src, u_char *dst));
-#endif
-
-/* int
- * inet_pton(af, src, dst)
- * convert from presentation format (which usually means ASCII printable)
- * to network format (which is usually some kind of binary format).
- * return:
- * 1 if the address was valid for the specified address family
- * 0 if the address wasn't valid (`dst' is untouched in this case)
- * -1 if some other error occurred (`dst' is untouched in this case, too)
- * author:
- * Paul Vixie, 1996.
- */
-int
-inet_pton(int af, const char *src, void *dst)
-{
- int status;
- unsigned short ifnum;
- char *p, *s;
-
- switch (af)
- {
- case AF_INET:
- {
- return (inet_pton4(src, dst));
- }
-
-#ifdef INET6
- case AF_INET6:
- {
- ifnum = 0;
- p = NULL;
- s = (char *)src;
-
- if (src != NULL) p = strrchr(src, '%');
- if (p != NULL)
- {
- s = strdup(src);
- if (s == NULL)
- {
- errno = ENOMEM;
- return -1;
- }
-
- s[p - src] = '\0';
- }
-
- status = inet_pton6(s, dst);
- if (p != NULL) free(s);
- if (status != 1) return status;
-
- if ((p != NULL) && IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)dst))
- {
- ifnum = if_nametoindex(++p);
- ifnum = htons(ifnum);
- ((struct in6_addr *)dst)->__u6_addr.__u6_addr16[1] = ifnum;
- }
-
- return 1;
- }
-#endif
-
- default:
- {
- errno = EAFNOSUPPORT;
- return -1;
- }
- }
-
- /* NOTREACHED */
- return -1;
-}
-
-/* int
- * inet_pton4(src, dst)
- * like inet_aton() but without all the hexadecimal and shorthand.
- * return:
- * 1 if `src' is a valid dotted quad, else 0.
- * notice:
- * does not touch `dst' unless it's returning 1.
- * author:
- * Paul Vixie, 1996.
- */
-static int
-inet_pton4(const char *src, u_char *dst)
-{
- static const char digits[] = "0123456789";
- int saw_digit, octets, ch;
- u_char tmp[NS_INADDRSZ], *tp;
-
- saw_digit = 0;
- octets = 0;
- *(tp = tmp) = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr(digits, ch)) != NULL) {
- u_int new = *tp * 10 + (pch - digits);
-
- if (new > 255)
- return (0);
- *tp = new;
- if (! saw_digit) {
- if (++octets > 4)
- return (0);
- saw_digit = 1;
- }
- } else if (ch == '.' && saw_digit) {
- if (octets == 4)
- return (0);
- *++tp = 0;
- saw_digit = 0;
- } else
- return (0);
- }
- if (octets < 4)
- return (0);
- memcpy(dst, tmp, NS_INADDRSZ);
- return (1);
-}
-
-#ifdef INET6
-/* int
- * inet_pton6(src, dst)
- * convert presentation level address to network order binary form.
- * return:
- * 1 if `src' is a valid [RFC1884 2.2] address, else 0.
- * notice:
- * (1) does not touch `dst' unless it's returning 1.
- * (2) :: in a full address is silently ignored.
- * credit:
- * inspired by Mark Andrews.
- * author:
- * Paul Vixie, 1996.
- */
-static int
-inet_pton6(const char *src, u_char *dst)
-{
- static const char xdigits_l[] = "0123456789abcdef",
- xdigits_u[] = "0123456789ABCDEF";
- u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
- const char *xdigits, *curtok;
- int ch, saw_xdigit;
- u_int val;
-
- memset((tp = tmp), '\0', NS_IN6ADDRSZ);
- endp = tp + NS_IN6ADDRSZ;
- colonp = NULL;
- /* Leading :: requires some special handling. */
- if (*src == ':')
- if (*++src != ':')
- return (0);
- curtok = src;
- saw_xdigit = 0;
- val = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
-
- if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
- pch = strchr((xdigits = xdigits_u), ch);
- if (pch != NULL) {
- val <<= 4;
- val |= (pch - xdigits);
- if (val > 0xffff)
- return (0);
- saw_xdigit = 1;
- continue;
- }
- if (ch == ':') {
- curtok = src;
- if (!saw_xdigit) {
- if (colonp)
- return (0);
- colonp = tp;
- continue;
- } else if (*src == '\0') {
- return (0);
- }
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- saw_xdigit = 0;
- val = 0;
- continue;
- }
- if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
- inet_pton4(curtok, tp) > 0) {
- tp += NS_INADDRSZ;
- saw_xdigit = 0;
- break; /* '\0' was seen by inet_pton4(). */
- }
- return (0);
- }
- if (saw_xdigit) {
- if (tp + NS_INT16SZ > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
- }
- if (colonp != NULL) {
- /*
- * Since some memmove()'s erroneously fail to handle
- * overlapping regions, we'll do the shift by hand.
- */
- const int n = tp - colonp;
- int i;
-
- if (tp == endp)
- return (0);
- for (i = 1; i <= n; i++) {
- endp[- i] = colonp[n - i];
- colonp[n - i] = 0;
- }
- tp = endp;
- }
- if (tp != endp)
- return (0);
- memcpy(dst, tmp, NS_IN6ADDRSZ);
- return (1);
-}
-#endif /*INET6*/
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <arpa/nameser_compat.h>
+#include <nameser.h>
+
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <ctype.h>
#include <syslog.h>
-#include "nameser8_compat.h"
-#include "resolv8_compat.h"
-
-#define IN6ADDRSZ 16
typedef union {
int32_t al;
char ac;
#include <arpa/inet.h>
#include <sys/stat.h>
#include <ils.h>
+#include <pthread.h>
#include <libkern/OSAtomic.h>
#include <dispatch/dispatch.h>
typedef struct
{
- /* XXX should be mutex */
- OSSpinLock lock;
+ pthread_mutex_t mutex;
int head;
si_item_t *item[CACHE_MAX];
si_list_t *list;
pp = (cache_si_private_t *)si->private;
if (pp == NULL) return NULL;
- OSSpinLockLock(&(pp->cache_store[cat].lock));
+ pthread_mutex_lock(&pp->cache_store[cat].mutex);
for (i = 0; i < CACHE_MAX; i++)
{
}
}
- OSSpinLockUnlock(&(pp->cache_store[cat].lock));
+ pthread_mutex_unlock(&(pp->cache_store[cat].mutex));
return item;
}
pp = (cache_si_private_t *)si->private;
if (pp == NULL) return NULL;
- OSSpinLockLock(&(pp->cache_store[cat].lock));
+ pthread_mutex_lock(&(pp->cache_store[cat].mutex));
list = cache_validate_list(pp, cat);
- OSSpinLockUnlock(&(pp->cache_store[cat].lock));
+ pthread_mutex_unlock(&(pp->cache_store[cat].mutex));
return list;
}
si_item_release(pp->cache_store[i].item[j]);
pp->cache_store[i].item[j] = NULL;
}
+
+ pthread_mutex_destroy(&(pp->cache_store[i].mutex));
}
free(pp);
static dispatch_once_t once;
dispatch_once(&once, ^{
+ cache_si_private_t *cache;
+ int i, j;
+
+ cache = calloc(1, sizeof(cache_si_private_t));
si.name = strdup("cache");
- si.private = calloc(1, sizeof(cache_si_private_t));
+ si.private = cache;
+
+ for (i = 0; i < CACHE_COUNT; i++) {
+ for (j = 0; j < CACHE_MAX; j++) {
+ pthread_mutex_init(&(cache->cache_store[i].mutex), NULL);
+ }
+ }
});
return &si;
pp = (cache_si_private_t *)si->private;
if (pp == NULL) return;
- OSSpinLockLock(&(pp->cache_store[cat].lock));
+ pthread_mutex_lock(&(pp->cache_store[cat].mutex));
head = pp->cache_store[item->type].head;
if (head >= CACHE_MAX) head = 0;
pp->cache_store[item->type].head = head;
- OSSpinLockUnlock(&(pp->cache_store[cat].lock));
+ pthread_mutex_unlock(&(pp->cache_store[cat].mutex));
}
void
pp = (cache_si_private_t *)si->private;
if (pp == NULL) return;
- OSSpinLockLock(&(pp->cache_store[cat].lock));
+ pthread_mutex_lock(&(pp->cache_store[cat].mutex));
si_list_release(pp->cache_store[item->type].list);
pp->cache_store[item->type].list = si_list_retain(list);
- OSSpinLockUnlock(&(pp->cache_store[cat].lock));
+ pthread_mutex_unlock(&(pp->cache_store[cat].mutex));
}
* Copyright (c) 2008-2011 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
+ *
* This ds 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 ds 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
* ds.
- *
+ *
* 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,
* 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 <asl.h>
#endif
-#ifdef __i386__
-/* <rdar://problem/10675978> */
-__attribute__((weak_import))
-void xpc_dictionary_get_audit_token(xpc_object_t xdict, audit_token_t *token);
-
-__attribute__((weak_import))
-xpc_pipe_t xpc_pipe_create(const char *name, uint64_t flags);
-
-__attribute__((weak_import))
-void xpc_pipe_invalidate(xpc_pipe_t pipe);
-
-__attribute__((weak_import))
-int xpc_pipe_routine(xpc_pipe_t pipe, xpc_object_t message, xpc_object_t *reply);
-#endif
-
#define IPV6_ADDR_LEN 16
#define IPV4_ADDR_LEN 4
{
// re-enable opendirectory interaction since we forked
_si_opendirectory_disabled = 0;
-
+
if (__od_pipe != NULL) {
xpc_pipe_invalidate(__od_pipe);
/* disable release due to 10649340, it will cause a minor leak for each fork without exec */
{
static dispatch_once_t once;
xpc_pipe_t result = NULL;
-
-#ifdef __i386__
- if (xpc_pipe_create == NULL) {
- _si_disable_opendirectory();
- return NULL;
- }
-#endif
-
+
dispatch_once(&once, ^(void) {
- char *rc_xbs;
-
+ char *xbs_disable;
+
/* if this is a build environment we ignore opendirectoryd */
- rc_xbs = getenv("RC_XBS");
- if ((issetugid() == 0) && (rc_xbs != NULL) && (strcmp(rc_xbs, "YES") == 0)) {
+ xbs_disable = getenv("XBS_DISABLE_LIBINFO");
+ if ((issetugid() == 0) && (xbs_disable != NULL) && (strcmp(xbs_disable, "YES") == 0)) {
_si_opendirectory_disabled = 1;
return;
}
pthread_atfork(_od_fork_prepare, _od_fork_parent, _od_fork_child);
});
-
+
if (_si_opendirectory_disabled == 1) {
return NULL;
}
-
+
pthread_mutex_lock(&mutex);
if (resetPipe) {
xpc_release(__od_pipe);
__od_pipe = NULL;
}
-
+
if (__od_pipe == NULL) {
if (!issetugid() && getenv("OD_DEBUG_MODE") != NULL) {
__od_pipe = xpc_pipe_create(kODMachLibinfoPortNameDebug, 0);
__od_pipe = xpc_pipe_create(kODMachLibinfoPortName, XPC_PIPE_FLAG_PRIVILEGED);
}
}
-
+
if (__od_pipe != NULL) result = xpc_retain(__od_pipe);
pthread_mutex_unlock(&mutex);
-
+
return result;
}
_valid_token(xpc_object_t reply)
{
audit_token_t token;
-
+
/*
* This should really call audit_token_to_au32,
* but that's in libbsm, not in a Libsystem library.
*/
xpc_dictionary_get_audit_token(reply, &token);
-
+
return ((uid_t) token.val[1] == 0);
}
}
XPC_RETURNS_RETAINED
-__private_extern__ xpc_object_t
+__private_extern__ xpc_object_t
_od_rpc_call(const char *procname, xpc_object_t payload, xpc_pipe_t (*get_pipe)(bool))
{
xpc_object_t result = NULL;
xpc_object_t reply;
xpc_pipe_t od_pipe;
int retries, rc;
-
+
od_pipe = get_pipe(false);
if (od_pipe == NULL) return NULL;
-
+
if (payload == NULL) {
payload = xpc_dictionary_create(NULL, NULL, 0);
}
-
+
// we nest it for backward compatibility so we can do independent submissions
xpc_dictionary_set_string(payload, OD_RPC_NAME, procname);
xpc_dictionary_set_int64(payload, OD_RPC_VERSION, 2);
-
+
for (retries = 0; od_pipe != NULL && retries < 2; retries++) {
rc = xpc_pipe_routine(od_pipe, payload, &reply);
switch (rc) {
xpc_release(od_pipe);
od_pipe = get_pipe(true);
break;
-
+
case EAGAIN:
/* just loop and try to send again */
break;
-
+
case 0:
if (_valid_token(reply) == true) {
result = reply;
}
/* fall through since we got a valid response */
-
+
default:
/* release and NULL the pipe it'll break the loop */
xpc_release(od_pipe);
break;
}
}
-
+
if (od_pipe != NULL) {
xpc_release(od_pipe);
}
if (procname == NULL) return NULL;
_ds_get_validation(si, &va, &vb, cat);
-
+
list = NULL;
reply = _od_rpc_call(procname, NULL, _od_xpc_pipe);
if (reply != NULL) {
si_item_t *item = extract(si, value, extra, va, vb);
list = si_list_add(list, item);
si_item_release(item);
-
+
return true;
});
}
-
+
xpc_release(reply);
}
xpc_object_t result;
uint64_t va, vb;
si_item_t *item = NULL;
-
+
if (procname == NULL) return NULL;
result = _od_rpc_call(procname, payload, _od_xpc_pipe);
if (xpc_dictionary_get_int64(result, OD_RPC_ERROR) == 0) {
item = extract(si, result, extra, va, vb);
}
-
+
xpc_release(result);
}
-
+
return item;
}
ds_si_private_t *pp;
int status;
uint32_t oldval, newval;
-
+
if (si == NULL) return 0;
if (item == NULL) return 0;
if (si->name == NULL) return 0;
if (item->src == NULL) return 0;
-
+
pp = (ds_si_private_t *)si->private;
if (pp == NULL) return 0;
-
+
src = (si_mod_t *)item->src;
-
+
if (src->name == NULL) return 0;
if (string_not_equal(si->name, src->name)) return 0;
-
+
/* check global invalidation */
oldval = item->validation_a;
newval = -1;
status = notify_peek(pp->notify_token_global, &newval);
if (status != NOTIFY_STATUS_OK) return 0;
-
+
newval = ntohl(newval);
if (oldval != newval) return 0;
-
+
oldval = item->validation_b;
newval = -1;
if (item->type == CATEGORY_USER) status = notify_peek(pp->notify_token_user, &newval);
else if (item->type == CATEGORY_GROUP) status = notify_peek(pp->notify_token_group, &newval);
else if (item->type == CATEGORY_SERVICE) status = notify_peek(pp->notify_token_service, &newval);
else return 0;
-
+
if (status != NOTIFY_STATUS_OK) return 0;
-
+
newval = ntohl(newval);
if (oldval != newval) return 0;
-
+
return 1;
}
}
/* map ipv4 addresses and append to v6 list */
-static int
+static int
_map_v4(char ***v6, uint32_t n6, char **v4, uint32_t n4)
{
struct in6_addr a6;
_xpc_query_key_string(const char *key, const char *value)
{
xpc_object_t payload;
-
+
if (value == NULL) return NULL;
-
+
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_string(payload, key, value);
-
+
return payload;
}
_xpc_query_key_id(const char *key, id_t idValue)
{
xpc_object_t payload;
-
+
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_int64(payload, key, idValue);
-
+
return payload;
}
_xpc_query_key_uuid(const char *key, uuid_t uu)
{
xpc_object_t payload;
-
+
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_uuid(payload, key, uu);
-
+
return payload;
}
_xpc_query_key_int(const char *key, int64_t intValue)
{
xpc_object_t payload;
-
+
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_int64(payload, key, intValue);
-
+
return payload;
}
#pragma mark -
-static char **
-_extract_array(xpc_object_t reply, const char *key, unsigned int *len)
+static int
+_extract_string_from_xpc_array_index(xpc_object_t reply, int index, const char **str)
{
- xpc_object_t xpc_array;
- char **result;
-
- xpc_array = xpc_dictionary_get_value(reply, key);
- if (xpc_array == NULL || xpc_get_type(xpc_array) != XPC_TYPE_ARRAY) {
- return calloc(1, sizeof(*result));
+ xpc_object_t value;
+
+ if (xpc_array_get_count(reply) < index) return -1;
+
+ value = xpc_array_get_value(reply, index);
+ if (xpc_get_type(value) != XPC_TYPE_STRING) return -1;
+
+ *str = xpc_string_get_string_ptr(value);
+ return 0;
+}
+
+static int
+_extract_string_from_xpc_object(xpc_object_t value, const char **str)
+{
+ if (value == NULL) return -1;
+ else if (xpc_get_type(value) == XPC_TYPE_STRING)
+ {
+ *str = xpc_string_get_string_ptr(value);
+ return 0;
}
-
- result = calloc(xpc_array_get_count(xpc_array) + 1, sizeof(*result));
- if (result == NULL) {
- return NULL;
+ else if (xpc_get_type(value) == XPC_TYPE_ARRAY)
+ {
+ return _extract_string_from_xpc_array_index(value, 0, str);
}
-
- if (len != NULL) {
- /* include trailing NULL */
- (*len) = xpc_array_get_count(xpc_array) + 1;
+
+ return -1;
+}
+
+static int
+_extract_uint32_from_xpc_object(xpc_object_t value, uint32_t *val32)
+{
+ xpc_type_t type;
+
+ if (value == NULL) return -1;
+ type = xpc_get_type(value);
+
+ if (type == XPC_TYPE_STRING)
+ {
+ *val32 = atoi(xpc_string_get_string_ptr(value));
+ return 0;
}
-
- xpc_array_apply(xpc_array, ^_Bool(size_t idx, xpc_object_t value) {
- result[idx] = (char *) xpc_string_get_string_ptr(value);
+ else if (type == XPC_TYPE_INT64)
+ {
+ *val32 = (uint32_t)xpc_int64_get_value(value);
+ return 0;
+ }
+ else if (type == XPC_TYPE_BOOL)
+ {
+ *val32 = (uint32_t)xpc_bool_get_value(value);
+ return 0;
+ }
+ else if (type == XPC_TYPE_ARRAY)
+ {
+ if (xpc_array_get_count(value) == 0) return -1;
+ return _extract_uint32_from_xpc_object(xpc_array_get_value(value, 0), val32);
+ }
+
+ return -1;
+}
+
+static int
+_extract_string_list_from_xpc_array_index(xpc_object_t reply, int index, unsigned int *len, char ***list)
+{
+ char **result;
+ xpc_object_t xpc_array = xpc_array_get_value(reply, index);
+
+ if ((xpc_array == NULL) || (xpc_get_type(xpc_array) != XPC_TYPE_ARRAY)) return -1;
+
+ result = calloc(xpc_array_get_count(xpc_array) + 1, sizeof(*result));
+ if (result == NULL) return -1;
+
+ /* include trailing NULL */
+ if (len != NULL) (*len) = xpc_array_get_count(xpc_array) + 1;
+
+ xpc_array_apply(xpc_array, ^bool(size_t idx, xpc_object_t value) {
+ result[idx] = (char *)xpc_string_get_string_ptr(value);
return true;
});
-
- return result;
+
+ *list = result;
+ return 0;
+}
+
+static int
+_extract_uint32_from_xpc_array_index(xpc_object_t reply, int index, uint32_t *val32)
+{
+ xpc_object_t value = xpc_array_get_value(reply, index);
+ return _extract_uint32_from_xpc_object(value, val32);
+}
+
+static int
+_extract_string_list_from_xpc_array(xpc_object_t xpc_array, unsigned int *len, char ***list)
+{
+ char **result;
+
+ if ((xpc_array == NULL) || (xpc_get_type(xpc_array) != XPC_TYPE_ARRAY)) return -1;
+
+ result = calloc(xpc_array_get_count(xpc_array) + 1, sizeof(*result));
+ if (result == NULL) return -1;
+
+ /* include trailing NULL */
+ if (len != NULL) (*len) = xpc_array_get_count(xpc_array) + 1;
+
+ xpc_array_apply(xpc_array, ^bool(size_t idx, xpc_object_t value) {
+ result[idx] = (char *)xpc_string_get_string_ptr(value);
+ return true;
+ });
+
+ *list = result;
+ return 0;
}
-static const char *
-_extract_string(xpc_object_t reply, const char *key)
+static int
+_extract_string_from_xpc_dict(xpc_object_t reply, const char *key, const char **str)
+{
+ xpc_object_t value = xpc_dictionary_get_value(reply, key);
+ const char *result;
+
+ if (value == NULL) return -1;
+
+ if (xpc_get_type(value) != XPC_TYPE_STRING) return -1;
+
+ result = xpc_string_get_string_ptr(value);
+ if (result == NULL) return -1;
+
+ *str = result;
+ return 0;
+}
+
+static int
+_extract_uint32_from_xpc_dict(xpc_object_t reply, const char *key, uint32_t *val32)
{
xpc_object_t value = xpc_dictionary_get_value(reply, key);
+ return _extract_uint32_from_xpc_object(value, val32);
+}
+
+#pragma mark -
+
+/*
+ * user schema
+ *
+ * name : string
+ * passwd : string
+ * uid : uint32
+ * gid : uint32
+ * gecos : string
+ * dir : string
+ * shell : string
+ */
+
+static si_item_t *
+_extract_user_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ struct passwd tmp;
+ int i = 0;
+
+ if (xpc_array_get_count(reply) < 7) return NULL;
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.pw_name)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.pw_passwd)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.pw_uid)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.pw_gid)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.pw_gecos)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.pw_dir)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.pw_shell)) return NULL;
+
+ /* default values */
+ tmp.pw_change = (time_t)0;
+ tmp.pw_expire = (time_t)0;
+ tmp.pw_class = (char *)"";
+
+ return (si_item_t *)LI_ils_create("L4488ss44LssssL", (unsigned long)si, CATEGORY_USER, 1, valid_global, valid_cat, tmp.pw_name, tmp.pw_passwd, tmp.pw_uid, tmp.pw_gid, tmp.pw_change, tmp.pw_class, tmp.pw_gecos, tmp.pw_dir, tmp.pw_shell, tmp.pw_expire);
+}
+
+static si_item_t *
+_extract_user_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ __block struct passwd tmp;
+ __block int status = 0;
+ __block int parts = 3;
+
+ tmp.pw_name = (char *)"";
+ tmp.pw_passwd = (char *)"*";
+ tmp.pw_uid = (uid_t)0;
+ tmp.pw_gid = (gid_t)0;
+ tmp.pw_change = (time_t)0;
+ tmp.pw_expire = (time_t)0;
+ tmp.pw_class = (char *)"";
+ tmp.pw_gecos = (char *)"";
+ tmp.pw_dir = (char *)"/var/empty";
+ tmp.pw_shell = (char *)"/usr/bin/false";
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "pw_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "pw_passwd"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_passwd);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_uid"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.pw_uid);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "pw_gid"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.pw_gid);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "pw_change"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.pw_change);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_expire"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.pw_expire);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_class"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_class);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_gecos"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_gecos);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_dir"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_dir);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "pw_shell"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.pw_shell);
+ /* no parts check - this value is optional */
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0)) return NULL;
+
+ return (si_item_t *)LI_ils_create("L4488ss44LssssL", (unsigned long)si, CATEGORY_USER, 1, valid_global, valid_cat, tmp.pw_name, tmp.pw_passwd, tmp.pw_uid, tmp.pw_gid, tmp.pw_change, tmp.pw_class, tmp.pw_gecos, tmp.pw_dir, tmp.pw_shell, tmp.pw_expire);
+}
+
+static si_item_t *
+_extract_user(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+{
xpc_type_t type;
- const char *result = NULL;
-
- if (value == NULL) {
- return "";
- }
-
- type = xpc_get_type(value);
- if (type == XPC_TYPE_STRING) {
- result = xpc_string_get_string_ptr(value);
- } else if (type == XPC_TYPE_ARRAY && xpc_array_get_count(value) != 0) {
- result = xpc_array_get_string(value, 0);
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ type = xpc_get_type(reply);
+
+ if (type == XPC_TYPE_ARRAY) return _extract_user_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_user_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * group schema
+ *
+ * name : string
+ * gid : uint32
+ * optional members : array of string
+ *
+ */
+
+static si_item_t *
+_extract_group_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ struct group tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
+
+ if ((arraycount < 2) || (arraycount > 3)) return NULL;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.gr_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.gr_gid)) return NULL;
+
+ if (arraycount == 3)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.gr_mem)) return NULL;
}
-
- if (result == NULL) {
- result = "";
+
+ /* default value */
+ tmp.gr_passwd = (char *)"*";
+
+ item = (si_item_t *) LI_ils_create("L4488ss4*", (unsigned long)si, CATEGORY_GROUP, 1, valid_global, valid_cat, tmp.gr_name, tmp.gr_passwd, tmp.gr_gid, tmp.gr_mem);
+
+ free(tmp.gr_mem);
+
+ return item;
+}
+
+static si_item_t *
+_extract_group_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ __block struct group tmp;
+ __block int status = 0;
+ __block int parts = 2;
+
+ tmp.gr_name = (char *)"";
+ tmp.gr_passwd = (char *)"*";
+ tmp.gr_gid = (gid_t)0;
+ tmp.gr_mem = NULL;
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "gr_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.gr_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "gr_passwd"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.gr_passwd);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "gr_gid"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.gr_gid);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "gr_mem"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, NULL, (char ***)&tmp.gr_mem);
+ /* no parts check - this value is optional */
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.gr_mem);
+ return NULL;
}
-
- return result;
+
+ item = (si_item_t *) LI_ils_create("L4488ss4*", (unsigned long)si, CATEGORY_GROUP, 1, valid_global, valid_cat, tmp.gr_name, tmp.gr_passwd, tmp.gr_gid, tmp.gr_mem);
+
+ free(tmp.gr_mem);
+
+ return item;
}
-static uint32_t
-_extract_uint32(xpc_object_t reply, const char *key)
+static si_item_t *
+_extract_group(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
{
- xpc_object_t value = xpc_dictionary_get_value(reply, key);
xpc_type_t type;
- uint32_t result;
-
- if (value == NULL) {
- return 0;
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_group_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_group_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * netgroup schema
+ *
+ * host : string
+ * user : string
+ * domain : string
+ *
+ */
+static si_item_t *
+_extract_netgroup_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ const char *host, *user, *domain;
+ int i = 0;
+
+ if (xpc_array_get_count(reply) != 3) return NULL;
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&host)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&user)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&domain)) return NULL;
+
+ return (si_item_t *)LI_ils_create("L4488sss", (unsigned long)si, CATEGORY_NETGROUP, 1, valid_global, valid_cat, host, user, domain);
+}
+
+static si_item_t *
+_extract_netgroup_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ __block const char *host = "";
+ __block const char *user = "";
+ __block const char *domain = "";
+ __block int status = 0;
+ __block int parts = 3;
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "host"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&host);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "user"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&user);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "domain"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&domain);
+ if (status == 0) parts--;
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0)) return NULL;
+
+ return (si_item_t *)LI_ils_create("L4488sss", (unsigned long)si, CATEGORY_NETGROUP, 1, valid_global, valid_cat, host, user, domain);
+}
+
+static si_item_t *
+_extract_netgroup(si_mod_t *si, xpc_object_t reply, const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+{
+ xpc_type_t type;
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_netgroup_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_netgroup_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * alias schema
+ *
+ * name : string
+ * local : uint32
+ * optional members : array of string
+ *
+ */
+
+static si_item_t *
+_extract_alias_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ struct aliasent tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
+
+ if ((arraycount < 2) || (arraycount > 3)) return NULL;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.alias_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.alias_local)) return NULL;
+
+ if (arraycount == 3)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.alias_members)) return NULL;
}
-
- type = xpc_get_type(value);
- if (type == XPC_TYPE_ARRAY && xpc_array_get_count(value) != 0) {
- value = xpc_array_get_value(value, 0);
- type = xpc_get_type(value);
+
+ item = (si_item_t *)LI_ils_create("L4488s4*4", (unsigned long)si, CATEGORY_ALIAS, 1, valid_global, valid_cat, tmp.alias_name, tmp.alias_members_len, tmp.alias_members, tmp.alias_local);
+
+ free(tmp.alias_members);
+
+ return item;
+}
+
+static si_item_t *
+_extract_alias_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ __block struct aliasent tmp;
+ __block int status = 0;
+ __block int parts = 2;
+
+ tmp.alias_name = (char *)"";
+ tmp.alias_local = 0;
+ tmp.alias_members = NULL;
+ tmp.alias_members_len = 0;
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "alias_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.alias_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "alias_local"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.alias_local);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "alias_members"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, &tmp.alias_members_len, (char ***)&tmp.alias_members);
+ /* no parts check - this value is optional */
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.alias_members);
+ return NULL;
}
-
- if (type == XPC_TYPE_STRING) {
- result = (int) strtol(xpc_string_get_string_ptr(value), NULL, 10);
- } else if (type == XPC_TYPE_INT64) {
- result = (uint32_t) xpc_int64_get_value(value);
- } else if (type == XPC_TYPE_BOOL) {
- result = xpc_bool_get_value(value);
- } else {
- result = 0;
+
+ item = (si_item_t *)LI_ils_create("L4488s4*4", (unsigned long)si, CATEGORY_ALIAS, 1, valid_global, valid_cat, tmp.alias_name, tmp.alias_members_len, tmp.alias_members, tmp.alias_local);
+
+ free(tmp.alias_members);
+
+ return item;
+}
+
+static si_item_t *
+_extract_alias(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+{
+ xpc_type_t type;
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_alias_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_alias_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * network schema
+ *
+ * name : string
+ * net : uint32
+ * optional aliases : array of string
+ *
+ */
+
+static si_item_t *
+_extract_network_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ struct netent tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
+
+ if ((arraycount < 2) || (arraycount > 3)) return NULL;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.n_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.n_net)) return NULL;
+
+ if (arraycount == 3)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.n_aliases)) return NULL;
}
-
- return result;
+
+ /* default value */
+ tmp.n_addrtype = AF_INET;
+
+ item = (si_item_t *)LI_ils_create("L4488s*44", (unsigned long)si, CATEGORY_NETWORK, 1, valid_global, valid_cat, tmp.n_name, tmp.n_aliases, tmp.n_addrtype, tmp.n_net);
+
+ free(tmp.n_aliases);
+
+ return item;
}
-static si_item_t *
-_extract_user(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
-{
- struct passwd tmp;
-
- if (si == NULL) return NULL;
- if (reply == NULL) return NULL;
-
- tmp.pw_name = (char *) _extract_string(reply, "pw_name");
- tmp.pw_passwd = (char *) _extract_string(reply, "pw_passwd");
- tmp.pw_uid = (uid_t) _extract_uint32(reply, "pw_uid");
- tmp.pw_gid = (gid_t) _extract_uint32(reply, "pw_gid");
- tmp.pw_change = (time_t) _extract_uint32(reply, "pw_change");
- tmp.pw_expire = (time_t) _extract_uint32(reply, "pw_expire");
- tmp.pw_class = (char *) _extract_string(reply, "pw_class");
- tmp.pw_gecos = (char *) _extract_string(reply, "pw_gecos");
- tmp.pw_dir = (char *) _extract_string(reply, "pw_dir");
- tmp.pw_shell = (char *) _extract_string(reply, "pw_shell");
-
- return (si_item_t *)LI_ils_create("L4488ss44LssssL", (unsigned long)si, CATEGORY_USER, 1, valid_global, valid_cat, tmp.pw_name, tmp.pw_passwd, tmp.pw_uid, tmp.pw_gid, tmp.pw_change, tmp.pw_class, tmp.pw_gecos, tmp.pw_dir, tmp.pw_shell, tmp.pw_expire);
+static si_item_t *
+_extract_network_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ __block struct netent tmp;
+ __block int status = 0;
+ __block int parts = 2;
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ tmp.n_name = (char *)"";
+ tmp.n_aliases = NULL;
+ tmp.n_net = 0;
+
+ /* default value */
+ tmp.n_addrtype = AF_INET;
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "n_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.n_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "n_aliases"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, NULL, (char ***)&tmp.n_aliases);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "n_net"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.n_net);
+ if (status == 0) parts--;
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.n_aliases);
+ return NULL;
+ }
+
+ item = (si_item_t *)LI_ils_create("L4488s*44", (unsigned long)si, CATEGORY_NETWORK, 1, valid_global, valid_cat, tmp.n_name, tmp.n_aliases, tmp.n_addrtype, tmp.n_net);
+
+ free(tmp.n_aliases);
+
+ return item;
+}
+
+static si_item_t *
+_extract_network(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+{
+ xpc_type_t type;
+
+ if (si == NULL) return NULL;
+ if (reply == NULL) return NULL;
+
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_network_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_network_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * service schema
+ *
+ * name : string
+ * port : uint32
+ * proto : string
+ * optional aliases : array of string
+ *
+ */
+
+static si_item_t *
+_extract_service_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ struct servent tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
+
+ if ((arraycount < 3) || (arraycount > 4)) return NULL;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.s_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.s_port)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.s_proto)) return NULL;
+
+ if (arraycount == 4)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.s_aliases)) return NULL;
+ }
+
+ item = (si_item_t *)LI_ils_create("L4488s*4s", (unsigned long)si, CATEGORY_SERVICE, 1, valid_global, valid_cat, tmp.s_name, tmp.s_aliases, tmp.s_port, tmp.s_proto);
+
+ free(tmp.s_aliases);
+
+ return item;
}
static si_item_t *
-_extract_group(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_service_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
{
si_item_t *item;
- struct group tmp;
-
+ __block struct servent tmp;
+ __block int status = 0;
+ __block int parts = 3;
+
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
-
- tmp.gr_name = (char *) _extract_string(reply, "gr_name");
- tmp.gr_passwd = (char *) _extract_string(reply, "gr_passwd");
- tmp.gr_gid = (gid_t) _extract_uint32(reply, "gr_gid");
- tmp.gr_mem = _extract_array(reply, "gr_mem", NULL);
- item = (si_item_t *) LI_ils_create("L4488ss4*", (unsigned long)si, CATEGORY_GROUP, 1, valid_global, valid_cat, tmp.gr_name, tmp.gr_passwd, tmp.gr_gid, tmp.gr_mem);
-
- if (tmp.gr_mem != NULL) {
- free(tmp.gr_mem); /* have to free because it's allocated */
+ tmp.s_name = (char *)"";
+ tmp.s_aliases = NULL;
+ tmp.s_port = 0;
+ tmp.s_proto = (char *)"";
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "s_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.s_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "s_aliases"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, NULL, (char ***)&tmp.s_aliases);
+ /* no parts check - this value is optional */
+ }
+ else if (!strcmp(key, "s_port"))
+ {
+ uint32_t v32;
+ status |= _extract_uint32_from_xpc_object(value, &v32);
+ if (status == 0)
+ {
+ tmp.s_port = (unsigned int)htons(v32); // ugh
+ parts--;
+ }
+ }
+ else if (!strcmp(key, "s_proto"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.s_proto);
+ if (status == 0) parts--;
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.s_aliases);
+ return NULL;
}
-
+
+ item = (si_item_t *)LI_ils_create("L4488s*4s", (unsigned long)si, CATEGORY_SERVICE, 1, valid_global, valid_cat, tmp.s_name, tmp.s_aliases, tmp.s_port, tmp.s_proto);
+
+ free(tmp.s_aliases);
+
return item;
}
static si_item_t *
-_extract_netgroup(si_mod_t *si, xpc_object_t reply, const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_service(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
{
- const char *host, *user, *domain;
+ xpc_type_t type;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
- host = _extract_string(reply, "host");
- user = _extract_string(reply, "user");
- domain = _extract_string(reply, "domain");
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_service_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_service_dict(si, reply, valid_global, valid_cat);
- return (si_item_t *)LI_ils_create("L4488sss", (unsigned long)si, CATEGORY_NETGROUP, 1, valid_global, valid_cat, host, user, domain);
+ return NULL;
}
+/*
+ * protocol schema
+ *
+ * name : string
+ * proto : uint32
+ * optional aliases : array of string
+ *
+ */
static si_item_t *
-_extract_alias(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_protocol_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
{
- struct aliasent tmp;
si_item_t *item;
+ struct protoent tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
- if (si == NULL) return NULL;
- if (reply == NULL) return NULL;
-
- tmp.alias_name = (char *) _extract_string(reply, "alias_name");
- tmp.alias_local = _extract_uint32(reply, "alias_local");
- tmp.alias_members = _extract_array(reply, "alias_members", &tmp.alias_members_len);
+ if ((arraycount < 2) || (arraycount > 3)) return NULL;
- item = (si_item_t *)LI_ils_create("L4488s4*4", (unsigned long)si, CATEGORY_ALIAS, 1, valid_global, valid_cat, tmp.alias_name, tmp.alias_members_len, tmp.alias_members, tmp.alias_local);
-
- if (tmp.alias_members != NULL) {
- free(tmp.alias_members);
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.p_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.p_proto)) return NULL;
+
+ if (arraycount == 3)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.p_aliases)) return NULL;
}
-
+
+ item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_PROTOCOL, 1, valid_global, valid_cat, tmp.p_name, tmp.p_aliases, tmp.p_proto);
+
+ free(tmp.p_aliases);
+
return item;
}
static si_item_t *
-_extract_network(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_protocol_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
{
- struct netent tmp;
si_item_t *item;
+ __block struct protoent tmp;
+ __block int status = 0;
+ __block int parts = 2;
- if (si == NULL) return NULL;
- if (reply == NULL) return NULL;
+ tmp.p_name = (char *)"";
+ tmp.p_proto = 0;
+ tmp.p_aliases = NULL;
- tmp.n_name = (char *) _extract_string(reply, "n_name");
- tmp.n_aliases = _extract_array(reply, "n_aliases", NULL);
- tmp.n_net = _extract_uint32(reply, "n_net");
- tmp.n_addrtype = AF_INET; /* opendirectoryd doesn't return this value, only AF_INET is supported */
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "p_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.p_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "p_proto"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.p_proto);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "p_aliases"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, NULL, (char ***)&tmp.p_aliases);
+ /* no parts check - this value is optional */
+ }
+ return true;
+ });
- item = (si_item_t *)LI_ils_create("L4488s*44", (unsigned long)si, CATEGORY_NETWORK, 1, valid_global, valid_cat, tmp.n_name, tmp.n_aliases, tmp.n_addrtype, tmp.n_net);
-
- if (tmp.n_aliases != NULL) {
- free(tmp.n_aliases);
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.p_aliases);
+ return NULL;
}
-
+
+ item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_PROTOCOL, 1, valid_global, valid_cat, tmp.p_name, tmp.p_aliases, tmp.p_proto);
+
+ free(tmp.p_aliases);
+
return item;
}
static si_item_t *
-_extract_service(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_protocol(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
{
- struct servent tmp;
- si_item_t *item;
+ xpc_type_t type;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
-
- tmp.s_name = (char *) _extract_string(reply, "s_name");
- tmp.s_aliases = _extract_array(reply, "s_aliases", NULL);
- tmp.s_port = (unsigned int) htons(_extract_uint32(reply, "s_port"));
- tmp.s_proto = (char *) _extract_string(reply, "s_proto");
- item = (si_item_t *)LI_ils_create("L4488s*4s", (unsigned long)si, CATEGORY_SERVICE, 1, valid_global, valid_cat, tmp.s_name, tmp.s_aliases, tmp.s_port, tmp.s_proto);
-
- if (tmp.s_aliases != NULL) {
- free(tmp.s_aliases);
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_protocol_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_protocol_dict(si, reply, valid_global, valid_cat);
+
+ return NULL;
+}
+
+/*
+ * rpc schema
+ *
+ * name : string
+ * number : uint32
+ * optional aliases : array of string
+ *
+ */
+
+static si_item_t *
+_extract_rpc_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ si_item_t *item;
+ struct rpcent tmp;
+ int i = 0;
+ int arraycount = xpc_array_get_count(reply);
+
+ if ((arraycount < 2) || (arraycount > 3)) return NULL;
+
+ memset(&tmp, 0, sizeof(tmp));
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.r_name)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.r_number)) return NULL;
+
+ if (arraycount == 3)
+ {
+ if (0 != _extract_string_list_from_xpc_array_index(reply, i++, NULL, (char ***)&tmp.r_aliases)) return NULL;
}
-
+
+ item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_RPC, 1, valid_global, valid_cat, tmp.r_name, tmp.r_aliases, tmp.r_number);
+
+ free(tmp.r_aliases);
+
return item;
}
static si_item_t *
-_extract_protocol(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
+_extract_rpc_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
{
- struct protoent tmp;
si_item_t *item;
+ __block struct rpcent tmp;
+ __block int status = 0;
+ __block int parts = 2;
- if (si == NULL) return NULL;
- if (reply == NULL) return NULL;
+ tmp.r_name = (char *)"";
+ tmp.r_number = 0;
+ tmp.r_aliases = NULL;
- tmp.p_name = (char *) _extract_string(reply, "p_name");
- tmp.p_proto = (int) _extract_uint32(reply, "p_proto");
- tmp.p_aliases = _extract_array(reply, "p_aliases", NULL);
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "r_name"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.r_name);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "r_number"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.r_number);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "r_aliases"))
+ {
+ status |= _extract_string_list_from_xpc_array(value, NULL, (char ***)&tmp.r_aliases);
+ /* no parts check - this value is optional */
+ }
+ return true;
+ });
- item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_PROTOCOL, 1, valid_global, valid_cat, tmp.p_name, tmp.p_aliases, tmp.p_proto);
- if (tmp.p_aliases != NULL) {
- free(tmp.p_aliases);
+ if ((status != 0) || (parts != 0))
+ {
+ free(tmp.r_aliases);
+ return NULL;
}
-
+
+ item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_RPC, 1, valid_global, valid_cat, tmp.r_name, tmp.r_aliases, tmp.r_number);
+
+ free(tmp.r_aliases);
+
return item;
}
static si_item_t *
_extract_rpc(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
{
- struct rpcent tmp;
- si_item_t *item;
+ xpc_type_t type;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
- tmp.r_name = (char *) _extract_string(reply, "r_name");
- tmp.r_number = (int) _extract_uint32(reply, "r_number");
- tmp.r_aliases = _extract_array(reply, "r_aliases", NULL);
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_rpc_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_rpc_dict(si, reply, valid_global, valid_cat);
- item = (si_item_t *)LI_ils_create("L4488s*4", (unsigned long)si, CATEGORY_RPC, 1, valid_global, valid_cat, tmp.r_name, tmp.r_aliases, tmp.r_number);
- if (tmp.r_aliases != NULL) {
- free(tmp.r_aliases);
- }
-
- return item;
+ return NULL;
+}
+
+/*
+ * fstab schema
+ *
+ * file : string
+ * spec : string
+ * freq : uint32
+ * passno : uint32
+ * mntopts : string
+ * type : string
+ * vfstype : string
+ */
+
+static si_item_t *
+_extract_fstab_array(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ __block struct fstab tmp;
+ int i = 0;
+
+ if (xpc_array_get_count(reply) != 7) return NULL;
+
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.fs_file)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.fs_spec)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.fs_freq)) return NULL;
+ if (0 != _extract_uint32_from_xpc_array_index(reply, i++, (uint32_t *)&tmp.fs_passno)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.fs_mntops)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.fs_type)) return NULL;
+ if (0 != _extract_string_from_xpc_array_index(reply, i++, (const char **)&tmp.fs_vfstype)) return NULL;
+
+ return (si_item_t *)LI_ils_create("L4488sssss44", (unsigned long)si, CATEGORY_FS, 1, valid_global, valid_cat, tmp.fs_spec, tmp.fs_file, tmp.fs_vfstype, tmp.fs_mntops, tmp.fs_type, tmp.fs_freq, tmp.fs_passno);
+}
+
+static si_item_t *
+_extract_fstab_dict(si_mod_t *si, xpc_object_t reply, uint64_t valid_global, uint64_t valid_cat)
+{
+ __block struct fstab tmp;
+ __block int status = 0;
+ __block int parts = 7;
+
+ tmp.fs_file = NULL;
+ tmp.fs_spec = (char *)"";
+ tmp.fs_freq = 0;
+ tmp.fs_passno = 0;
+ tmp.fs_mntops = (char *)"";
+ tmp.fs_type = (char *)"";
+ tmp.fs_vfstype = (char *)"";
+
+ xpc_dictionary_apply(reply, ^bool(const char *key, xpc_object_t value) {
+ if (key == NULL) return true;
+ else if (!strcmp(key, "fs_file"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.fs_file);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_spec"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.fs_spec);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_freq"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.fs_freq);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_passno"))
+ {
+ status |= _extract_uint32_from_xpc_object(value, (uint32_t *)&tmp.fs_passno);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_mntops"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.fs_mntops);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_type"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.fs_type);
+ if (status == 0) parts--;
+ }
+ else if (!strcmp(key, "fs_vfstype"))
+ {
+ status |= _extract_string_from_xpc_object(value, (const char **)&tmp.fs_vfstype);
+ if (status == 0) parts--;
+ }
+ return true;
+ });
+
+ if ((status != 0) || (parts != 0)) return NULL;
+
+ return (si_item_t *)LI_ils_create("L4488sssss44", (unsigned long)si, CATEGORY_FS, 1, valid_global, valid_cat, tmp.fs_spec, tmp.fs_file, tmp.fs_vfstype, tmp.fs_mntops, tmp.fs_type, tmp.fs_freq, tmp.fs_passno);
}
static si_item_t *
_extract_fstab(si_mod_t *si, xpc_object_t reply, __unused const void *ignored, uint64_t valid_global, uint64_t valid_cat)
{
- struct fstab tmp;
+ xpc_type_t type;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
- tmp.fs_file = (char *) _extract_string(reply, "fs_file");
- if (tmp.fs_file == NULL) return NULL;
-
- tmp.fs_spec = (char *) _extract_string(reply, "fs_spec");
- tmp.fs_freq = _extract_uint32(reply, "fs_freq");
- tmp.fs_passno = _extract_uint32(reply, "fs_passno");
- tmp.fs_mntops = (char *) _extract_string(reply, "fs_mntops");
- tmp.fs_type = (char *) _extract_string(reply, "fs_type");
- tmp.fs_vfstype = (char *) _extract_string(reply, "fs_vfstype");
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY) return _extract_fstab_array(si, reply, valid_global, valid_cat);
+ else if (type == XPC_TYPE_DICTIONARY) return _extract_fstab_dict(si, reply, valid_global, valid_cat);
- return (si_item_t *)LI_ils_create("L4488sssss44", (unsigned long)si, CATEGORY_FS, 1, valid_global, valid_cat, tmp.fs_spec, tmp.fs_file, tmp.fs_vfstype, tmp.fs_mntops, tmp.fs_type, tmp.fs_freq, tmp.fs_passno);
+ return NULL;
}
static si_item_t *
_extract_mac_mac(si_mod_t *si, xpc_object_t reply, const void *extra, uint64_t valid_global, uint64_t valid_cat)
{
- const char *value;
+ xpc_type_t type;
char *cmac;
+ const char *value = NULL;
si_item_t *out;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
if (extra == NULL) return NULL;
- value = _extract_string(reply, "mac");
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY)
+ {
+ if (xpc_array_get_count(reply) >= 1)
+ {
+ if (0 != _extract_string_from_xpc_array_index(reply, 0, (const char **)&value)) return NULL;
+ }
+ }
+ else if (type == XPC_TYPE_DICTIONARY)
+ {
+ if (0 != _extract_string_from_xpc_dict(reply, "mac", &value)) return NULL;
+ }
+
if (value == NULL || value[0] == '\0') return NULL;
-
+
cmac = si_standardize_mac_address(value);
if (cmac == NULL) return NULL;
out = (si_item_t *)LI_ils_create("L4488ss", (unsigned long)si, CATEGORY_MAC, 1, valid_global, valid_cat, extra, cmac);
-
+
free(cmac);
-
+
return out;
}
static si_item_t *
_extract_mac_name(si_mod_t *si, xpc_object_t reply, const void *extra, uint64_t valid_global, uint64_t valid_cat)
{
- const char *name;
+ xpc_type_t type;
+ const char *name = NULL;
si_item_t *out;
if (si == NULL) return NULL;
if (reply == NULL) return NULL;
if (extra == NULL) return NULL;
- name = _extract_string(reply, "name");
+ type = xpc_get_type(reply);
+ if (type == XPC_TYPE_ARRAY)
+ {
+ if (xpc_array_get_count(reply) >= 1)
+ {
+ if (0 != _extract_string_from_xpc_array_index(reply, 0, (const char **)&name )) return NULL;
+ }
+ }
+ else if (type == XPC_TYPE_DICTIONARY)
+ {
+ if (0 != _extract_string_from_xpc_dict(reply, "name", &name)) return NULL;
+ }
+
+ if (name == NULL) return NULL;
out = (si_item_t *)LI_ils_create("L4488ss", (unsigned long)si, CATEGORY_MAC, 1, valid_global, valid_cat, name, extra);
+
return out;
}
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_id("gid", gid);
if (payload == NULL) return NULL;
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_uuid("uuid", uuid);
if (payload == NULL) return NULL;
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_string(payload, "name", name);
xpc_dictionary_set_int64(payload, "ngroups", ngroups);
-
+
reply = _od_rpc_call("getgrouplist", payload, _od_xpc_pipe);
if (reply != NULL) {
size_t gidptrsz;
const gid_t *gidptr = xpc_dictionary_get_data(reply, "groups", &gidptrsz);
- int32_t count;
+ uint32_t count = 0;
uint64_t va, vb;
-
+
_ds_get_validation(si, &va, &vb, CATEGORY_GROUPLIST);
/* see what we were sent */
- count = _extract_uint32(reply, "count");
- if (count != 0) {
- item = (si_item_t *)LI_ils_create("L4488s4@", (unsigned long)si, CATEGORY_GROUPLIST, 1, va, vb, name, count,
- gidptrsz, gidptr);
+ if (0 == _extract_uint32_from_xpc_dict(reply, "count", &count))
+ {
+ if (count != 0)
+ {
+ item = (si_item_t *)LI_ils_create("L4488s4@", (unsigned long)si, CATEGORY_GROUPLIST, 1, va, vb, name, count,
+ gidptrsz, gidptr);
+ }
}
-
+
xpc_release(reply);
}
-
+
xpc_release(payload);
-
+
return item;
}
int is_innetgr;
if (!_od_running()) return 0;
-
+
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return 0;
-
+
xpc_dictionary_set_string(payload, "netgroup", (group ? group : ""));
xpc_dictionary_set_string(payload, "host", (host ? host : ""));
xpc_dictionary_set_string(payload, "user", (user ? user : ""));
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_string("name", name);
if (payload == NULL) return NULL;
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_string("name", name);
if (payload == NULL) return NULL;
si_item_t *item;
if (!_od_running()) return NULL;
-
+
f1 = addr & 0xff;
addr >>= 8;
f2 = addr & 0xff;
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
xpc_dictionary_set_string(payload, "name", name);
xpc_dictionary_set_string(payload, "proto", proto);
-
+
item = _ds_item(si, CATEGORY_SERVICE, "getservbyname", NULL, _extract_service, payload);
xpc_release(payload);
-
+
return item;
}
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
/* swap to native order, API passes network order */
xpc_dictionary_set_int64(payload, "port", ntohs(port));
xpc_dictionary_set_string(payload, "proto", (proto ? proto : ""));
item = _ds_item(si, CATEGORY_SERVICE, "getservbyport", NULL, _extract_service, payload);
xpc_release(payload);
-
+
return item;
}
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_string("name", name);
if (payload == NULL) return NULL;
si_item_t *item;
if (!_od_running()) return NULL;
-
+
payload = _xpc_query_key_string("name", name);
if (payload == NULL) return NULL;
xpc_object_t payload;
si_item_t *item;
char *cmac;
-
+
if (!_od_running()) return NULL;
cmac = si_standardize_mac_address(mac);
payload = xpc_dictionary_create(NULL, NULL, 0);
if (payload == NULL) return NULL;
-
+
payload = _xpc_query_key_string("mac", cmac);
item = _ds_item(si, CATEGORY_MAC, "gethostbymac", cmac, _extract_mac_name, payload);
free(cmac);
xpc_release(payload);
-
+
return item;
}
{
/*
* Errors in registering for cache invalidation notifications are ignored.
- * If there are failures, the tokens remain set to -1 which just causes
+ * If there are failures, the tokens remain set to -1 which just causes
* cached items to be invalidated.
*/
notify_register_check(kNotifyDSCacheInvalidation, &(pp->notify_token_global));
len = strlen(s) + 1;
t = malloc(len);
+ if (t == NULL) return NULL;
+
bcopy(s, t, len);
return t;
}
.Fn getpwuid "uid_t uid"
.Ft int
.Fn getpwuid_r "uid_t uid" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result"
-.Ft int
+.Ft struct passwd *
.Fn getpwuuid "uuid_t uuid"
.Ft int
.Fn getpwuuid_r "uuid_t uuid" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result"
.Dt AuthenticationAuthority
attribute contains the value
.Ql ;basic; .
+.Pp
+Note that
+.Xr opendirectoryd 8
+allows user records from some sources which may not include all the component
+fields present in a passwd structure.
+Only the name, uid, and gid of a user record are required.
+Default values will be supplied as follows:
+.Bd -literal -offset indent
+pw_passwd = "*"
+pw_change = 0
+pw_class = ""
+pw_gecos = ""
+pw_dir = "/var/empty"
+pw_shell = "/usr/bin/false"
+pw_expire = 0
+.Ed
.Sh RETURN VALUES
The functions
.Fn getpwent ,
#define _GRP_H_
#include <_types.h>
-
-#ifndef _GID_T
-typedef __darwin_gid_t gid_t; /* [XBD] */
-#define _GID_T
-#endif
-
-/*
- * Although the definition of size_t is not mandated by [TSF], the function
- * prototypes defined by [TSF] for the thread reentrant functions include
- * it as a type for their 4th arguments, so we define it here.
- */
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef __darwin_size_t size_t; /* [???] */
-#endif
+#include <sys/_types/_gid_t.h> /* [XBD] */
+#include <sys/_types/_size_t.h> /* SUSv4 */
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define _PATH_GROUP "/etc/group"
/*
- * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2013 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <sys/kauth.h>
#include "netdb_async.h"
#include <dispatch/dispatch.h>
+#include <mach-o/dyld_priv.h>
#define SOCK_UNSPEC 0
#define IPPROTO_UNSPEC 0
#define IPV6_ADDR_LEN 16
#define IPV4_ADDR_LEN 4
-/* The kernel's initgroups call */
+/* kernel syscalls */
extern int __initgroups(u_int gidsetsize, gid_t *gidset, int gmuid);
/* SPI from long ago */
_check_groups(const char *function, int32_t ngroups)
{
static dispatch_once_t once;
-
+
if (ngroups > 0 && ngroups < NGROUPS_MAX) {
return;
}
-
+
/* only log once per process */
dispatch_once(&once, ^(void) {
const char *proc_name = getprogname();
if (strcmp(proc_name, "id") != 0 && strcmp(proc_name, "smbd") != 0 && strcmp(proc_name, "rpcsvchost") != 0) {
aslmsg msg = asl_new(ASL_TYPE_MSG);
char buffer[256];
-
+
snprintf(buffer, sizeof(buffer), "%d", (ngroups == 0 ? INT_MAX : ngroups));
asl_set(msg, "com.apple.message.value", buffer);
-
+
asl_set(msg, "com.apple.message.domain", "com.apple.system.libinfo");
asl_set(msg, "com.apple.message.result", "noop");
asl_set(msg, "com.apple.message.signature", function);
-
+
asl_log(NULL, msg, ASL_LEVEL_NOTICE, "%s called triggering group enumeration", function);
-
+
asl_free(msg);
}
});
groups[0] = basegid;
*ngroups = 1;
-
+
item = si_grouplist(si_search(), name, max);
LI_set_thread_item(CATEGORY_GROUPLIST, item);
if (item == NULL) return 0;
if (item == NULL) return -1;
gl = (si_grouplist_t *) ((uintptr_t) item + sizeof(si_item_t));
-
+
/*
* we can allocate enough up-front, we'll only use what we need
* we add one to the count that was found in case the basegid is not there
merge_gid(gids, gl->gl_gid[i], &count);
}
}
-
+
(*groups) = gids;
-
+
return count;
}
* Caller must free the list.
* Returns the number of gids in the list or -1 on failure.
*/
-
+
#ifdef CALL_TRACE
fprintf(stderr, "-> %s %s %d\n", __func__, name, basegid);
#endif
-
+
if (name == NULL) return 0;
if (groups == NULL) return 0;
-
+
#if DS_AVAILABLE
_check_groups("getgrouplist_2", INT_MAX);
#endif
-
+
return _getgrouplist_2_internal(name, basegid, groups);
}
/*
* Ignore status.
- * A failure either means that user belongs to more than NGROUPS groups
+ * A failure either means that user belongs to more than NGROUPS groups
* or no groups at all.
*/
-
+
(void) getgrouplist_internal(name, basegid, groups, &ngroups);
status = __initgroups(ngroups, groups, uid);
si_item_t *item;
struct group *g;
int status;
-
+
#ifdef CALL_TRACE
uuid_string_t uuidstr;
uuid_unparse_upper(uuid, uuidstr);
if (result != NULL) *result = NULL;
if ((grp == NULL) || (buffer == NULL) || (result == NULL) || (bufsize == 0)) return ERANGE;
-
+
item = si_group_byuuid(si_search(), uuid);
if (item == NULL) return 0;
-
+
g = (struct group *)((uintptr_t)item + sizeof(si_item_t));
-
+
status = copy_group_r(g, grp, buffer, bufsize);
si_item_release(item);
-
+
if (status != 0) return ERANGE;
-
+
*result = grp;
return 0;
}
else if (type == ns_t_aaaa) ctx->host = reply->h6;
else if (type == ns_t_ptr && reply->h4) ctx->host = reply->h4;
else if (type == ns_t_ptr && reply->h6) ctx->host = reply->h6;
- else if (type != ns_t_srv && type != ns_t_cname) abort();
+ else if (type != ns_t_srv && type != ns_t_cname) return -1;
}
uint32_t iface = 0;
}
break;
default:
- abort();
+ return 0;
}
return 0;
}
#define _NETDB_H_
#include <_types.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_socklen_t.h>
+
#include <stdint.h>
#include <netinet/in.h> /* IPPORT_RESERVED */
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef __darwin_size_t size_t;
-#endif
-
-#ifndef _SOCKLEN_T
-#define _SOCKLEN_T
-typedef __darwin_socklen_t socklen_t;
-#endif
-
#ifndef _PATH_HEQUIV
# define _PATH_HEQUIV "/etc/hosts.equiv"
#endif
#define _PWD_H_
#include <_types.h>
-
-#ifndef _GID_T
-typedef __darwin_gid_t gid_t;
-#define _GID_T
-#endif
-
-#ifndef _SIZE_T
-#define _SIZE_T
-typedef __darwin_size_t size_t;
-#endif
-
-#ifndef _UID_T
-typedef __darwin_uid_t uid_t;
-#define _UID_T
-#endif
+#include <sys/_types/_gid_t.h>
+#include <sys/_types/_size_t.h>
+#include <sys/_types/_uid_t.h>
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
#define _PATH_PWD "/etc"
net_v6_count++;
}
}
+ freeifaddrs(ifa);
}
- freeifaddrs(ifa);
}
if (inet4 != NULL) *inet4 = net_v4_count;
#include <xpc/private.h>
#include <opendirectory/odipc.h>
#include <pthread.h>
-
-#ifdef __i386__
-/* <rdar://problem/10675978> */
-__attribute__((weak_import))
-xpc_pipe_t xpc_pipe_create(const char *name, uint64_t flags);
-
-__attribute__((weak_import))
-void xpc_pipe_invalidate(xpc_pipe_t pipe);
-
-__attribute__((weak_import))
-int xpc_pipe_routine(xpc_pipe_t pipe, xpc_object_t message, xpc_object_t *reply);
-#endif /* __i386__ */
-#endif /* DS_AVAILABLE */
+#include <mach-o/dyld_priv.h>
+#endif
static const uuid_t _user_compat_prefix = {0xff, 0xff, 0xee, 0xee, 0xdd, 0xdd, 0xcc, 0xcc, 0xbb, 0xbb, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00};
static const uuid_t _group_compat_prefix = {0xab, 0xcd, 0xef, 0xab, 0xcd, 0xef, 0xab, 0xcd, 0xef, 0xab, 0xcd, 0xef, 0x00, 0x00, 0x00, 0x00};
{
static dispatch_once_t once;
xpc_pipe_t pipe = NULL;
-
-#ifdef __i386__
- if (xpc_pipe_create == NULL) {
- _si_opendirectory_disabled = 1;
- return NULL;
- }
-#endif
-
+
dispatch_once(&once, ^(void) {
- char *rc_xbs;
+ char *xbs_disable;
/* if this is a build environment we ignore opendirectoryd */
- rc_xbs = getenv("RC_XBS");
- if (rc_xbs != NULL && strcmp(rc_xbs, "YES") == 0) {
+ xbs_disable = getenv("XBS_DISABLE_LIBINFO");
+ if (xbs_disable != NULL && strcmp(xbs_disable, "YES") == 0) {
_si_opendirectory_disabled = 1;
return;
}
}
if (__mbr_pipe == NULL) {
- if (!issetugid() && getenv("OD_DEBUG_MODE") != NULL) {
+ if (!dyld_process_is_restricted() && getenv("OD_DEBUG_MODE") != NULL) {
__mbr_pipe = xpc_pipe_create(kODMachMembershipPortNameDebug, 0);
} else {
__mbr_pipe = xpc_pipe_create(kODMachMembershipPortName, XPC_PIPE_FLAG_PRIVILEGED);
/* only supported by mbr_identifier_translate for target type */
#define ID_TYPE_UID_OR_GID 30
#define ID_TYPE_NAME 31
+#define ID_TYPE_WINDOWS_FQN 32
__BEGIN_DECLS
+++ /dev/null
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-
-#define NI_FAILED 9999
-#define RPC_FAILED 16
-
-typedef struct
-{
- int a;
- int b;
-} stub_type_0;
-
-typedef struct
-{
- int a;
- void *b;
-} stub_type_1;
-
-typedef struct
-{
- void *a;
- stub_type_1 b;
-} stub_type_2;
-
-static stub_type_1 empty_stub_type_1()
-{
- stub_type_1 a;
-
- memset(&a, 0, sizeof(stub_type_1));
- return a;
-}
-
-static stub_type_2 empty_stub_type_2()
-{
- stub_type_2 a;
-
- memset(&a, 0, sizeof(stub_type_2));
- return a;
-}
-
-static int debug_log(const char *func)
-{
- syslog(LOG_ERR, "NetInfo stub: %s", func);
- return NI_FAILED;
-}
-
-const char *ni_error(int a) { return "Communication failure"; }
-int multi_call(int a, void *b, int c, int d, int e, void *f, void *g, int h, void *i, void *j, int (*k)(void *, void *, int), int l) { return RPC_FAILED; }
-stub_type_2 ni_prop_dup(stub_type_2 a) { return empty_stub_type_2(); }
-int ni_name_match(void *a, void *b) { return 0; }
-void *ni_name_dup(void *a) { return NULL; }
-
-stub_type_1 ni_idlist_dup(stub_type_1 a) { return empty_stub_type_1(); }
-stub_type_1 ni_proplist_dup(stub_type_1 a) { return empty_stub_type_1(); }
-stub_type_1 ni_namelist_dup(stub_type_1 a) { return empty_stub_type_1(); }
-
-int ni_idlist_delete(void *a, int b) { return -1; }
-int ni_proplist_match(stub_type_1 a, void *b, void *c) { return -1; }
-int ni_namelist_match(stub_type_1 a, void *b) { return -1; }
-
-void ni_idlist_insert(void *a, int b, int c) {}
-void ni_idlist_free(void *a) {}
-void ni_proplist_insert(void *a, stub_type_2 b, int c) {}
-void ni_proplist_delete(void *a, int b) {}
-void ni_proplist_free(void *a) {}
-void ni_proplist_list_free(void *a) {}
-void ni_prop_free(void *a) {}
-void ni_name_free(void *a) {}
-void ni_namelist_free(void *a) {}
-void ni_namelist_insert(void *a, void *b, int c) {}
-void ni_namelist_delete(void *a, int b) {}
-void ni_entrylist_insert(void *a, stub_type_1 b) {}
-void ni_entrylist_delete(void *a, int b) {}
-void ni_entrylist_free(void *a) {}
-void ni_parse_url(void *a, void *b, void *c, void *d, void *e, void *f) {}
-void ni_setabort(void *a, int b) {}
-void ni_setwritetimeout(void *a, int b) {}
-void ni_setreadtimeout(void *a, int b) {}
-void ni_needwrite(void *a, int b) {}
-void ni_free(void *a) {}
-
-int ni_find(void *a, void *b, void *c, int d) { return debug_log(__FUNCTION__); }
-int ni_open(void *a, void *b, void *c) { return debug_log(__FUNCTION__); }
-int ni_fancyopen(void *a, void *b, void *c, void *d) { return debug_log(__FUNCTION__); }
-int ni_host_domain(void *a, void *b, void *c) { return debug_log(__FUNCTION__); }
-int ni_url(void *a, void *b, void *c) { return debug_log(__FUNCTION__); }
-
-void *_ni_dup(void *a) { debug_log(__FUNCTION__); return NULL; }
-void *ni_connect(void *a, void *b) { debug_log(__FUNCTION__); return NULL; }
-void *ni_new(void *a, void *b) { debug_log(__FUNCTION__); return NULL; }
-
-int ni_lookupprop(void *a, void *b, void *c, void *d) { return NI_FAILED; }
-int ni_search(void *a, void *b, void *c, void *d, int e, void *f) { return NI_FAILED; }
-int ni_pathsearch(void *a, void *b, void *c) { return NI_FAILED; }
-int ni_pwdomain(void *a, void *b) { return NI_FAILED; }
-int ni_addrtag(void *a, void *b, void *c) { return NI_FAILED; }
-int ni_statistics(void *q, void *b) { return NI_FAILED; }
-int ni_root(void *a, void *b) { return NI_FAILED; }
-int ni_self(void *a, void *b) { return NI_FAILED; }
-int ni_parent(void *q, void *b, void *c) { return NI_FAILED; }
-int ni_children(void *q, void *b, void *c) { return NI_FAILED; }
-int ni_create(void *a, void *b, stub_type_1 c, void *d, int e) { return NI_FAILED; }
-int ni_destroy(void *a, void *b, stub_type_0 c) { return NI_FAILED; }
-int ni_write(void *a, void *b, stub_type_1 c) { return NI_FAILED; }
-int ni_read(void *a, void *b, void *c) { return NI_FAILED; }
-int ni_lookup(void *a, void *b, void *c, void *d, void *e) { return NI_FAILED; }
-int ni_lookupread(void *a, void *b, void *c, void *d, void *e) { return NI_FAILED; }
-int ni_list(void *a, void *b, void *c, void *d) { return NI_FAILED; }
-int ni_listall(void *a, void *b, void *c) { return NI_FAILED; }
-int ni_readprop(void *a, void *b, int c, void *d) { return NI_FAILED; }
-int ni_writeprop(void *a, void *b, int c, stub_type_1 d) { return NI_FAILED; }
-int ni_listprops(void *a, void *b, void *c) { return NI_FAILED; }
-int ni_createprop(void *a, void *b, stub_type_2 c, int d) { return NI_FAILED; }
-int ni_destroyprop(void *a, void *b, int c) { return NI_FAILED; }
-int ni_renameprop(void *a, void *b, int c, void *d) { return NI_FAILED; }
-int ni_createname(void *a, void *b, int c, void *d, int e) { return NI_FAILED; }
-int ni_destroyname(void *a, void *b, int c, int d) { return NI_FAILED; }
-int ni_writename(void *a, void *b, int c, int d, void *e) { return NI_FAILED; }
-int ni_readname(void *a, void *b, int c, int d, void *e) { return NI_FAILED; }
-int ni_resync(void *a) { return NI_FAILED; }
-int ni_setuser(void *a, void *b) { return NI_FAILED; }
-int ni_setpassword(void *a, void *b) { return NI_FAILED; }
-
-int xdr_ni_id(void *a, void *b) { return 0; }
-int xdr_ni_name(void *a, void *b) { return 0; }
-int xdr_ni_namelist(void *a, void *b) { return 0; }
-int xdr_ni_property(void *a, void *b) { return 0; }
-int xdr_ni_proplist(void *a, void *b) { return 0; }
-int xdr_ni_idlist(void *a, void *b) { return 0; }
-int xdr_ni_object(void *a, void *b) { return 0; }
-int xdr_ni_status(void *a, void *b) { return 0; }
-int xdr_ni_id_res(void *a, void *b) { return 0; }
-int xdr_ni_parent_stuff(void *a, void *b) { return 0; }
-int xdr_ni_parent_res(void *a, void *b) { return 0; }
-int xdr_ni_children_stuff(void *a, void *b) { return 0; }
-int xdr_ni_children_res(void *a, void *b) { return 0; }
-int xdr_ni_entry(void *a, void *b) { return 0; }
-int xdr_ni_entrylist(void *a, void *b) { return 0; }
-int xdr_ni_list_stuff(void *a, void *b) { return 0; }
-int xdr_ni_list_res(void *a, void *b) { return 0; }
-int xdr_ni_proplist_stuff(void *a, void *b) { return 0; }
-int xdr_ni_create_args(void *a, void *b) { return 0; }
-int xdr_ni_proplist_res(void *a, void *b) { return 0; }
-int xdr_ni_create_stuff(void *a, void *b) { return 0; }
-int xdr_ni_create_res(void *a, void *b) { return 0; }
-int xdr_ni_destroy_args(void *a, void *b) { return 0; }
-int xdr_ni_lookup_args(void *a, void *b) { return 0; }
-int xdr_ni_lookup_stuff(void *a, void *b) { return 0; }
-int xdr_ni_lookup_res(void *a, void *b) { return 0; }
-int xdr_ni_name_args(void *a, void *b) { return 0; }
-int xdr_ni_createprop_args(void *a, void *b) { return 0; }
-int xdr_ni_writeprop_args(void *a, void *b) { return 0; }
-int xdr_ni_prop_args(void *a, void *b) { return 0; }
-int xdr_ni_namelist_stuff(void *a, void *b) { return 0; }
-int xdr_ni_namelist_res(void *a, void *b) { return 0; }
-int xdr_ni_propname_args(void *a, void *b) { return 0; }
-int xdr_ni_createname_args(void *a, void *b) { return 0; }
-int xdr_ni_nameindex_args(void *a, void *b) { return 0; }
-int xdr_ni_writename_args(void *a, void *b) { return 0; }
-int xdr_ni_readname_stuff(void *a, void *b) { return 0; }
-int xdr_ni_readname_res(void *a, void *b) { return 0; }
-int xdr_ni_binding(void *a, void *b) { return 0; }
-int xdr_ni_rparent_res(void *a, void *b) { return 0; }
-int xdr_ni_object_list(void *a, void *b) { return 0; }
-int xdr_ni_object_node(void *a, void *b) { return 0; }
-int xdr_ni_readall_stuff(void *a, void *b) { return 0; }
-int xdr_ni_readall_res(void *a, void *b) { return 0; }
-int xdr_ni_proplist_list(void *a, void *b) { return 0; }
-int xdr_ni_listall_stuff(void *a, void *b) { return 0; }
-int xdr_ni_listall_res(void *a, void *b) { return 0; }
if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
(! XDR_PUTLONG(xdrs, (int *)&proc)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
- (! (*xargs)(xdrs, argsp))) return (RPC_CANTENCODEARGS);
+ (! (*xargs)(xdrs, argsp, 0))) return (RPC_CANTENCODEARGS);
#else
if ((! XDR_PUTBYTES(xdrs, clp->mashl_callmsg, clp->mcnt)) ||
(! XDR_PUTLONG(xdrs, (long *)&proc)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
- (! (*xargs)(xdrs, argsp))) return (RPC_CANTENCODEARGS);
+ (! (*xargs)(xdrs, argsp, 0))) return (RPC_CANTENCODEARGS);
#endif
(void)XDR_GETPOS(xdrs); /* called just to cause overhead */
return (rval);
}
xdrs->x_op = XDR_FREE;
- return ((*xdr_res)(xdrs, res_ptr));
+ return ((*xdr_res)(xdrs, res_ptr, 0));
}
static void
if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
(! XDR_PUTLONG(xdrs, (int *)&proc)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
- (! (*xdr_args)(xdrs, args_ptr)))
+ (! (*xdr_args)(xdrs, args_ptr, 0)))
#else
if ((! XDR_PUTBYTES(xdrs, ct->ct_mcall, ct->ct_mpos)) ||
(! XDR_PUTLONG(xdrs, (long *)&proc)) ||
(! AUTH_MARSHALL(h->cl_auth, xdrs)) ||
- (! (*xdr_args)(xdrs, args_ptr)))
+ (! (*xdr_args)(xdrs, args_ptr, 0)))
#endif
{
if (ct->ct_error.re_status == RPC_SUCCESS)
if (! AUTH_VALIDATE(h->cl_auth, &reply_msg.acpted_rply.ar_verf)) {
ct->ct_error.re_status = RPC_AUTHERROR;
ct->ct_error.re_why = AUTH_INVALIDRESP;
- } else if (! (*xdr_results)(xdrs, results_ptr)) {
+ } else if (! (*xdr_results)(xdrs, results_ptr, 0)) {
if (ct->ct_error.re_status == RPC_SUCCESS)
ct->ct_error.re_status = RPC_CANTDECODERES;
}
register XDR *xdrs = &(ct->ct_xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_res)(xdrs, res_ptr));
+ return ((*xdr_res)(xdrs, res_ptr, 0));
}
static void
#ifdef __LP64__
if ((! XDR_PUTLONG(xdrs, (int *)&proc)) ||
(! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
- (! (*xargs)(xdrs, argsp)))
+ (! (*xargs)(xdrs, argsp, 0)))
return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
#else
if ((! XDR_PUTLONG(xdrs, (long *)&proc)) ||
(! AUTH_MARSHALL(cl->cl_auth, xdrs)) ||
- (! (*xargs)(xdrs, argsp)))
+ (! (*xargs)(xdrs, argsp, 0)))
return (cu->cu_error.re_status = RPC_CANTENCODEARGS);
#endif
outlen = (int)XDR_GETPOS(xdrs);
register XDR *xdrs = &(cu->cu_outxdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_res)(xdrs, res_ptr));
+ return ((*xdr_res)(xdrs, res_ptr, 0));
}
static void
if (! xdr_u_long(xdrs, &(cap->arglen)))
return (FALSE);
argposition = XDR_GETPOS(xdrs);
- if (! (*(cap->xdr_args))(xdrs, cap->args_ptr))
+ if (! (*(cap->xdr_args))(xdrs, cap->args_ptr, 0))
return (FALSE);
position = XDR_GETPOS(xdrs);
#ifdef __LP64__
#ifdef __LP64__
if (xdr_reference(xdrs, &port_ptr, sizeof (uint32_t), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
crp->port_ptr = (unsigned int *)port_ptr;
- return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
+ return ((*(crp->xdr_results))(xdrs, crp->results_ptr, 0));
}
#else
if (xdr_reference(xdrs, &port_ptr, sizeof (u_long), (xdrproc_t)xdr_u_long) && xdr_u_long(xdrs, &crp->resultslen)) {
crp->port_ptr = (unsigned long *)port_ptr;
- return ((*(crp->xdr_results))(xdrs, crp->results_ptr));
+ return ((*(crp->xdr_results))(xdrs, crp->results_ptr, 0));
}
#endif
return (FALSE);
xdrs->x_op = XDR_FREE;
msg.acpted_rply.ar_results.proc = (xdrproc_t)xdr_void;
(void)xdr_replymsg(xdrs, &msg);
- (void)(*xresults)(xdrs, resultsp);
+ (void)(*xresults)(xdrs, resultsp, 0);
xdr_destroy(xdrs);
if (done) {
stat = RPC_SUCCESS;
switch (ar->ar_stat) {
case SUCCESS:
- return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
+ return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where, 0));
case PROG_MISMATCH:
if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
if (srp == 0)
return (FALSE);
- return ((*xdr_args)(&srp->xdr_stream, args_ptr));
+ return ((*xdr_args)(&srp->xdr_stream, args_ptr, 0));
}
static bool_t
return (FALSE);
xdrs = &srp->xdr_stream;
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return ((*xdr_args)(xdrs, args_ptr, 0));
}
static void
caddr_t args_ptr;
{
- return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr));
+ return ((*xdr_args)(&(((struct tcp_conn *)(xprt->xp_p1))->xdrs), args_ptr, 0));
}
static bool_t
&(((struct tcp_conn *)(xprt->xp_p1))->xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return ((*xdr_args)(xdrs, args_ptr, 0));
}
static bool_t
caddr_t args_ptr;
{
- return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr));
+ return ((*xdr_args)(&(su_data(xprt)->su_xdrs), args_ptr, 0));
}
static bool_t
register XDR *xdrs = &(su_data(xprt)->su_xdrs);
xdrs->x_op = XDR_FREE;
- return ((*xdr_args)(xdrs, args_ptr));
+ return ((*xdr_args)(xdrs, args_ptr, 0));
}
static void
XDR x;
x.x_op = XDR_FREE;
- (*proc)(&x, objp);
+ (*proc)(&x, objp, 0);
}
/*
*/
for (; choices->proc != NULL_xdrproc_t; choices++) {
if (choices->value == dscm)
- return ((*(choices->proc))(xdrs, unp));
+ return ((*(choices->proc))(xdrs, unp, 0));
}
/*
* no match - execute the default xdr routine if there is one
*/
return ((dfault == NULL_xdrproc_t) ? FALSE :
- (*dfault)(xdrs, unp));
+ (*dfault)(xdrs, unp, 0));
}
* The opaque pointer generally points to a structure of the data type
* to be decoded. If this pointer is 0, then the type routines should
* allocate dynamic storage of the appropriate size and return it.
+ *
+ *
+ * IMPORTANT NOTE: Apple iOS and OS X
+ *
+ * Previous versions of this header file defined the xdrproc_t prototype as
+ * typedef bool_t (*xdrproc_t)(XDR *, ...);
+ *
+ * This prototype is incorrect. One may not use a varargs function pointer
+ * in place of pointer to a function with positional parameters.
+ * This mistake has been masked by the fact that clients of this API would
+ * generally cast their xdr functions as (xdrproc_t), and thus silence compiler
+ * warnings. The code worked because the ABI for varargs routines that pass a
+ * small number of arguments has been the same as the ABI for routines with a
+ * few positional parameters. However, if the ABI differs this will cause the
+ * compiled code to fail.
+ *
+ * Historically, some client xdr routines expected three parameters. This
+ * does not seem to be the case in more recent code, but we have decided to
+ * retain this definition in the XDR library in case some legacy code still
+ * expects three parameters. The library will pass zero as the third
+ * parameter. Routines that expect two parameters will work correctly.
+ *
+ * If your client-side xdr routine is of the form:
+ * bool_t xdr_my_datatype(XDR *, void *);
+ * and you pass your function pointer to routines like xdr_pointer or
+ * xdr_reference using "(xdrproc_t)xdr_my_datatype", then your code will
+ * compile and run correctly. If your code invokes an xdrproc_t callback,
+ * it must be modified to pass a third parameter, which may simply be zero.
*/
-#ifdef _KERNEL
typedef bool_t (*xdrproc_t)(XDR *, void *, unsigned int);
-#else
-/*
- * XXX can't actually prototype it, because some take three args!!!
- */
-typedef bool_t (*xdrproc_t)(XDR *, ...);
-#endif
/*
* Operations defined on a XDR handle
* now we xdr each element of array
*/
for (i = 0; (i < c) && stat; i++) {
- stat = (*elproc)(xdrs, target);
+ stat = (*elproc)(xdrs, target, 0);
target += elsize;
}
elptr = basep;
for (i = 0; i < nelem; i++) {
- if (!(*xdr_elem)(xdrs, elptr)) {
+ if (!(*xdr_elem)(xdrs, elptr, 0)) {
return(FALSE);
}
elptr += elemsize;
break;
}
- stat = (*proc)(xdrs, loc);
+ stat = (*proc)(xdrs, loc, 0);
if (xdrs->x_op == XDR_FREE) {
mem_free(loc, size);
x.x_private = (caddr_t) NULL;
x.x_base = (caddr_t) 0;
- stat = func(&x, data);
+ stat = func(&x, data, 0);
if (x.x_private)
free(x.x_private);
return (stat == TRUE ? (unsigned) x.x_handy: 0);
+++ /dev/null
-/*
- * 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@
- */
-
-int
-putpwpasswd(char *login, char *old_passwd, char *new_passwd)
-{
- return 0;
-}
#include <rpcsvc/ypclnt.h>
#endif
-#include "nameser8_compat.h"
+#include <arpa/nameser_compat.h>
+#include <nameser.h>
/* wrapper for KAME-special getnameinfo() */
#ifndef NI_WITHSCOPEID
+++ /dev/null
-/*
- * 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@
- */
-/* $OpenBSD: rcmdsh.c,v 1.4 1997/07/23 16:59:37 millert Exp $ */
-
-/*
- * This is an rcmd() replacement originally by
- * Chris Siebenmann <cks@utcc.utoronto.ca>.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: rcmdsh.c,v 1.4 1997/07/23 16:59:37 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <pwd.h>
-#include <paths.h>
-#include <unistd.h>
-/*
- * This is a replacement rcmd() function that uses the rsh(1)
- * program in place of a direct rcmd(3) function call so as to
- * avoid having to be root. Note that rport is ignored.
- */
-/* ARGSUSED */
-int
-rcmdsh(ahost, rport, locuser, remuser, cmd, rshprog)
- char **ahost;
- int rport;
- const char *locuser, *remuser, *cmd;
- char *rshprog;
-{
- struct hostent *hp;
- int cpid, sp[2];
- char *p;
- struct passwd *pw;
-
- /* What rsh/shell to use. */
- if (rshprog == NULL)
- rshprog = _PATH_RSH;
-
- /* locuser must exist on this host. */
- if ((pw = getpwnam(locuser)) == NULL) {
- (void) fprintf(stderr, "rcmdsh: unknown user: %s\n", locuser);
- return(-1);
- }
-
- /* Validate remote hostname. */
- if (strcmp(*ahost, "localhost") != 0) {
- if ((hp = gethostbyname(*ahost)) == NULL) {
- herror(*ahost);
- return(-1);
- }
- *ahost = hp->h_name;
- }
-
- /* Get a socketpair we'll use for stdin and stdout. */
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) < 0) {
- perror("rcmdsh: socketpair");
- return(-1);
- }
-
- cpid = fork();
- if (cpid < 0) {
- perror("rcmdsh: fork failed");
- return(-1);
- } else if (cpid == 0) {
- /*
- * Child. We use sp[1] to be stdin/stdout, and close sp[0].
- */
- (void) close(sp[0]);
- if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) {
- perror("rcmdsh: dup2 failed");
- _exit(255);
- }
- /* Fork again to lose parent. */
- cpid = fork();
- if (cpid < 0) {
- perror("rcmdsh: fork to lose parent failed");
- _exit(255);
- }
- if (cpid > 0)
- _exit(0);
-
- /* In grandchild here. Become local user for rshprog. */
- if (setuid(pw->pw_uid)) {
- (void) fprintf(stderr, "rcmdsh: setuid(%u): %s\n",
- pw->pw_uid, strerror(errno));
- _exit(255);
- }
-
- /*
- * If remote host is "localhost" and local and remote user
- * are the same, avoid running remote shell for efficiency.
- */
- if (!strcmp(*ahost, "localhost") && !strcmp(locuser, remuser)) {
- if (pw->pw_shell[0] == '\0')
- rshprog = _PATH_BSHELL;
- else
- rshprog = pw->pw_shell;
- p = strrchr(rshprog, '/');
- execlp(rshprog, p ? p+1 : rshprog, "-c", cmd,
- (char *) NULL);
- } else {
- p = strrchr(rshprog, '/');
- execlp(rshprog, p ? p+1 : rshprog, *ahost, "-l",
- remuser, cmd, (char *) NULL);
- }
- (void) fprintf(stderr, "rcmdsh: execlp %s failed: %s\n",
- rshprog, strerror(errno));
- _exit(255);
- } else {
- /* Parent. close sp[1], return sp[0]. */
- (void) close(sp[1]);
- /* Reap child. */
- (void) wait(NULL);
- }
- return(sp[0]);
-}
membership.subproj/membership.h \
membership.subproj/ntsid.h
-# lookup.subproj is not installed for the simulator, but its API is provided
-# by Interposition_Sim. To be cautious, we only want to provide headers for
-# the SPI *used* by other simulator projects. We should work to keep this
-# SPI as backwards-compatible as possible and use Interposition_Sim to
-# translate where that cannot be achieved.
-if [ "${RC_ProjectName%_Sim}" == "${RC_ProjectName}" ] ; then
- InstallHeaders /usr/local/include \
- lookup.subproj/ils.h \
- lookup.subproj/kvbuf.h \
- lookup.subproj/libinfo.h \
- lookup.subproj/si_data.h \
- lookup.subproj/si_module.h \
- lookup.subproj/thread_data.h
-fi
+InstallHeaders /usr/local/include \
+ gen.subproj/configuration_profile.h \
+ lookup.subproj/ils.h \
+ lookup.subproj/kvbuf.h \
+ lookup.subproj/libinfo.h \
+ lookup.subproj/si_data.h \
+ lookup.subproj/si_module.h \
+ lookup.subproj/thread_data.h
InstallHeaders /usr/local/include \
lookup.subproj/netdb_async.h \
membership.subproj/membershipPriv.h
-InstallHeaders /usr/include/arpa \
- dns.subproj/inet.h
-
InstallHeaders /usr/include/rpc \
rpc.subproj/auth.h \
rpc.subproj/auth_unix.h \
LinkManPages getpwent.3 \
endpwent.3 getpwnam.3 getpwnam_r.3 getpwuid.3 \
- getpwuid_r.3 setpassent.3 setpwent.3 setpwfile.3
+ getpwuid_r.3 setpassent.3 setpwent.3 setpwfile.3 \
+ getpwuuid.3 getpwuuid_r.3
LinkManPages mbr_uid_to_uuid.3 \
mbr_gid_to_uuid.3 mbr_sid_to_uuid.3 mbr_uuid_to_id.3 mbr_uuid_to_sid.3 \