summaryrefslogtreecommitdiff
path: root/nss
Commit message (Collapse)AuthorAgeFilesLines
* Minimize inclusion of netinet/in.h from public headers.Zack Weinberg2020-01-083-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As with sys/socket.h and struct sockaddr, most of the files including netinet/in.h just want struct sockaddr_in or a related type, so introduce bits/types headers for these. POSIX specifically allows arpa/inet.h to include netinet/in.h and I think it makes sense to preserve that. The definition of struct sockaddr_in had a dependence on the definition of struct sockaddr; to avoid that, bits/sockaddr.h grows a new macro, __SOCKADDR_DATA_SIZE, which is the declared size of struct sockaddr.sa_data. On Linux, some kernel headers (notably linux/in.h and linux/in6.h) attempt to cooperate with a C library’s headers in defining types such as struct sockaddr_in. There is a set of macros whose names begin with __UAPI_DEF_ that indicate that a type has already been defined. This mechanism doesn’t actually work with the kernel headers as they are in 5.0, as far as I can tell, but it could be made to work with straightforward changes, so it makes sense for us to support it to the extent we can. To do this sensibly I need to introduce a new bits header called bits/uapi-compat.h, with a trivial definition for non-Linux. This replaces the existing __USE_KERNEL_IPV6_DEFS macro. * bits/sockaddr.h (__SOCKADDR_DATA_SIZE): New macro. * sysdeps/unix/bsd/bits/sockaddr.h: Likewise. * sysdeps/unix/sysv/linux/m68k/bits/sockaddr.h: Likewise. * socket/bits/types/struct_sockaddr.h: Use __SOCKADDR_DATA_SIZE as array length of sa_data. * bits/in.h: Add multiple inclusion guard. (__USE_KERNEL_IPV6_DEFS): Don’t define. * sysdeps/unix/sysv/linux/bits/in.h: Similarly. (IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP): Define when not already defined, not conditional on __USE_KERNEL_IPV6_DEFS. * bits/uapi-compat.h: New file, trivial generic version. * sysdeps/unix/sysv/linux/bits/uapi-compat.h: New file, Linux-specific version which recognizes kernel header guard macros and defines __UAPI_DEF_* macros as appropriate. * misc/Makefile: Install bits/uapi-compat.h. * include/bits/types/in_addr_t.h, include/bits/types/in_port_t.h * include/bits/types/struct_in_addr.h * include/bits/types/struct_in6_addr.h * include/bits/types/struct_sockaddr_in.h * include/bits/types/struct_sockaddr_in6.h: New wrapper headers. * inet/bits/types/in_addr_t.h, inet/bits/types/in_port_t.h * inet/bits/types/struct_in_addr.h * inet/bits/types/struct_in6_addr.h * inet/bits/types/struct_sockaddr_in.h * inet/bits/types/struct_sockaddr_in6.h New single-type headers, factored out of inet/netinet/in.h. Add __UAPI_DEF_* conditionals where appropriate, and verify that all conditionalized definitions agree with the relevant OS-supplied header. Use __SOCKADDR_DATA_SIZE to set size of sin_zero. * inet/Makefile: Install the new single-type headers. * inet/netinet/in.h: Include bits/uapi-compat.h. Define in_addr_t, in_port_t, struct in_addr, struct in6_addr, struct sockaddr_in, and struct sockaddr_in6 by including the above single-type headers, not directly. Replace all __USE_KERNEL_IPV6_DEFS conditionals with appropriate __UAPI_DEF_* conditionals. Add appropriate __UAPI_DEF_* conditionals around the definitions of the IPPROTO_* constants, the IN_CLASS macros, and struct ip_mreq. Import IN_LOOPBACK macro from Linux 5.0 linux/in.h and verify all other conditionalized definitions agree with the relevant linux/ header. Define IPPORT_RESERVED only if not already defined, and make it a macro so we can tell. * inet/netinet/igmp.h, inet/netinet/ip.h, inet/netinet/ip_icmp.h: Include bits/types/struct_in_addr.h, not netinet/in.h. * inet/netinet/ip_icmp.h: Hoist all #includes to the top of the file. * inet/netinet/icmp6.h, inet/netinet/ip6.h * sysdeps/unix/sysv/linux/net/route.h: Include bits/types/struct_in6_addr.h, not netinet/in.h. * sysdeps/mach/hurd/net/route.h: Include bits/types.h and bits/types/struct_in6_addr.h, not netinet/in.h. Use __uint16_t and __uint32_t instead of uint16_t and uint32_t. * resolv/bits/types/res_state.h: Include bits/types/struct_in_addr.h and bits/types/struct_sockaddr_in.h. Forward declare struct sockaddr_in6. Don’t include netinet/in.h. * resolv/netdb.h: Don’t include netinet/in.h. Use socklen_t instead of __socklen_t. Define IPPORT_RESERVED only if not already defined, with definition matching netinet/in.h. When __USE_MISC, include bits/sockaddr.h. * resolv/resolv.h: Don’t include netinet/in.h. * inet/tst-getni1.c, inet/tst-getni2.c * nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c * nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo2.c * resolv/tst-bug18665-tcp.c, resolv/tst-resolv-ai_idn-common.c * resolv/tst-resolv-canonname.c, resolv/tst-resolv-edns.c * resolv/tst-resolv-network.c, resolv/tst-resolv-nondecimal.c * resolv/tst-resolv-search.c, support/tst-support-namespace.c: Include netinet/in.h. * support/resolv_test.h: Include stdint.h, not sys/cdefs.h. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update.
* Don’t include sys/socket.h from public headers.Zack Weinberg2020-01-086-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No standard public header is required to include sys/socket.h, although some are allowed to. Several public headers need the definitions of socklen_t, struct sockaddr, and/or struct sockaddr_storage, but nothing else from sys/socket.h. We already have a single-type header for socklen_t, so this patch adds single-type headers for struct sockaddr and struct sockaddr_storage. The definition of struct sockaddr_storage is subtly different on Linux than on the Hurd; in order to not need two copies of bits/types/struct_sockaddr_storage.h, bits/sockaddr.h is now responsible for defining __ss_aligntype if ‘unsigned long int’ is not the correct definition. I also added a single-type header for struct linger, even though only sys/socket.h is expected to define that, just because all three copies of bits/socket.h were defining it exactly the same way. There would also be a case for defining it directly in sys/socket.h but this seemed tidier. I did *not* create single-type headers for struct msghdr and struct cmsghdr, because those and their helper macros are not consistent among the three copies of bits/socket.h, and, again, only sys/socket.h is expected to define them. The large number of .c files that add an `#include <sys/socket.h>` might make this look like it’s not worth doing. However, after this change, only half of the files in the glibc source tree that include netinet/in.h also need to include sys/socket.h, and only a third of the files that include netdb.h need to include sys/socket.h. Before, all of the files in both groups were getting sys/socket.h. That seems like enough justification to me. While I was at it I noticed that sys/socketvar.h is yet another backward compatibility header that does nothing but include some other header (sys/socket.h, in this case) and also doesn’t need to be system-dependent. * socket/bits/types/struct_linger.h * socket/bits/types/struct_sockaddr.h * socket/bits/types/struct_sockaddr_storage.h: New single-type headers, factored out of the various bits/socket.h headers. * include/bits/types/struct_linger.h * include/bits/types/struct_sockaddr.h * include/bits/types/struct_sockaddr_storage.h: New wrappers. * socket/Makefile (headers): Add bits/types/struct_linger.h, bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h. Alphabetize the list. * bits/socket.h, sysdeps/mach/hurd/bits/socket.h * sysdeps/unix/sysv/linux/bits/socket.h: Don’t define struct sockaddr, struct sockaddr_storage, __ss_aligntype, or struct linger here. Minimize inclusions. * sysdeps/unix/bsd/bits/sockaddr.h: Define __ss_aligntype here. * socket/sys/socket.h: Include bits/types/struct_linger.h, bits/sockaddr.h, bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h. Move inclusion of bits/socket.h below forward declaration of struct timespec, and update commentary. * inet/ifaddrs.h, socket/net/if.h * sysdeps/mach/hurd/net/if_arp.h * sysdeps/mach/hurd/net/route.h * sysdeps/unix/sysv/linux/errqueue.h * sysdeps/unix/sysv/linux/net/if_arp.h * sysdeps/unix/sysv/linux/net/route.h: Include bits/types/struct_sockaddr.h and possibly also bits/types.h, not sys/socket.h or sys/types.h. * sysdeps/unix/sysv/linux/errqueue.h: * sysdeps/unix/sysv/linux/net/route.h: Use __uint8_t and __uint32_t instead of uint8_t and uint32_t. * inet/arpa/inet.h: Include bits/types/size_t.h. * inet/netinet/in.h: Include bits/sockaddr.h, bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h, not sys/socket.h. Use __socklen_t instead of socklen_t. * inet/netinet/tcp.h: Include bits/types.h and bits/types/struct_sockaddr_storage.h, not sys/socket.h or bits/stdint-uintn.h. Use __uint8_t, __uint16_t, and __uint32_t instead of uint8_t, uint16_t and uint32_t. * inet/protocols/routed.h: Include features.h and bits/types/struct_sockaddr.h, not sys/socket.h. * resolv/netdb.h: Include bits/types/socklen_t.h. * sysdeps/unix/sysv/linux/netatalk/at.h: Don’t include sys/socket.h. * include/ifaddrs.h: Include stddef.h for size_t. * include/netdb.h: Use __socklen_t instead of socklen_t. * inet/check_pf.c, inet/gethstbynm.c, inet/gethstbynm_r.c * inet/getsourcefilter.c, inet/inet6_opt.c, inet/inet6_option.c * inet/inet6_rth.c, inet/setsourcefilter.c, inet/test-ifaddrs.c * inet/test-inet6_opt.c, inet/tst-inet6_rth.c * inet/tst-inet6_scopeid_pton.c, nis/nss_nis/nis-hosts.c * nis/nss_nisplus/nisplus-hosts.c, nscd/aicache.c, nscd/cache.c * nscd/hstcache.c, nscd/initgrcache.c, nscd/netgroupcache.c * nscd/nscd_gethst_r.c, nscd/servicescache.c, nss/digits_dots.c * nss/nss_files/files-hosts.c, nss/nss_files/files-network.c * nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c * nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo3.c * resolv/nss_dns/dns-network.c, resolv/resolv_conf.c * resolv/tst-bug18665-tcp.c, resolv/tst-bug18665.c * resolv/tst-inet_ntop.c, resolv/tst-inet_pton.c * resolv/tst-resolv-ai_idn-common.c, resolv/tst-resolv-basic.c * resolv/tst-resolv-edns.c, resolv/tst-resolv-network.c * resolv/tst-resolv-nondecimal.c, resolv/tst-resolv-search.c * resolv/tst-resolv-threads.c, resolv/tst-resolv-trailing.c * sunrpc/rpc_gethostbyname.c * support/support_format_address_family.c * support/support_format_addrinfo.c * support/support_format_dns_packet.c * support/support_format_hostent.c, support/support_format_netent.c * sysdeps/mach/hurd/if_index.c * sysdeps/unix/sysv/linux/check_native.c: Include sys/socket.h. * resolv/tst-resolv-binary.c: Include sys/types.h. * sysdeps/generic/sys/socketvar.h: Move to socket/sys/socketvar.h. * include/sys/socketvar.h: New wrapper. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update.
* Minimize includes of unrelated public headers by networking headers.Zack Weinberg2020-01-084-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop including sys/param.h, sys/types.h, stdint.h, inttypes.h, stdio.h, and string.h from network-related headers. This is done separately from earlier patches because the network headers are extra messy, and are also more likely to contain quirks inherited verbatim from 4.xBSD than the bulk of our public headers. Rose and NetROM are based on AX.25 so it makes practical sense for netrose/rose.h and netrom/netrom.h to continue including netax25/ax25.h. The only copies of ip_icmp.h and udp.h in the source tree are moved from sysdeps/gnu to inet (after which there are no longer any netinet/ headers in sysdeps/gnu). Much as sys/un.h needs to duplicate the prototype for strlen, netinet/icmp6.h needs to duplicate the prototype for memset. I am open to better ideas on that front. * resolv/resolv.h: Include bits/types.h, bits/types/FILE.h, and bits/types/size_t.h; don’t include sys/param.h, sys/types.h, or stdio.h. Use __uint16_t and __uint32_t instead of uint16_t and uint32_t. * resolv/arpa/nameser.h: Include features.h, bits/types.h, and bits/types/size_t.h; don’t include sys/param.h, sys/types.h, or stdint.h. Use __uint16_t and __uint32_t instead of uint16_t and uint32_t. * resolv/arpa/nameser_compat.h: Include features.h. * sysdeps/mach/hurd/net/ethernet.h: Include bits/types.h; don’t include sys/types.h or stdint.h. Use __uint8_t and __uint16_t instead of uint8_t and uint16_t. * sysdeps/unix/sysv/linux/net/ethernet.h: Include features.h and bits/types.h; don’t include sys/types.h or stdint.h. Use __uint8_t and __uint16_t instead of uint8_t and uint16_t. * sysdeps/unix/sysv/linux/netinet/if_ether.h: Include features.h and bits/types.h. Use __uint8_t instead of uint8_t. * sysdeps/mach/hurd/net/if_arp.h: Don’t include sys/types.h or stdint.h. Use __uint32_t instead of uint32_t. * sysdeps/unix/sysv/linux/net/if_arp.h: Include features.h. Don’t include sys/types.h or stdint.h. Use __uint32_t instead of uint32_t. * sysdeps/mach/hurd/net/route.h: Don’t include sys/types.h. * sysdeps/unix/sysv/linux/net/route.h: Don’t include sys/types.h. * sysdeps/unix/sysv/linux/net/if_ppp.h: Include features.h and bits/types.h. Don’t include sys/types.h or stdint.h. Use __uint8_t and __uint32_t instead of uint8_t and uint32_t. * sysdeps/unix/sysv/linux/net/if_shaper.h: Include features.h and bits/types.h. Don’t include sys/types.h or stdint.h. Use __uint16_t and __uint32_t instead of uint16_t and uint32_t. * sysdeps/unix/sysv/linux/netatalk/at.h: Include features.h, bits/types.h, and sys/ioctl.h. Don’t include asm/types.h or linux/atalk.h. Copy over all user-appropriate definitions from linux/atalk.h with adjustments for glibc context. * grp/initgroups.c, nscd/initgrcache.c, nss/nss_db/db-XXX.c * resolv/ns_print.c, resolv/tst-ns_name_compress.c * resolv/tst-res_hnok.c, support/resolv_test.c: Include stdio.h. * nscd/initgrcache.c, nscd/netgroupcache.c * nss/nss_compat/compat-grp.c, nss/nss_compat/compat-pwd.c * nss/nss_compat/compat-spwd.c, resolv/ns_print.c: Include sys/param.h for MIN and/or MAX. * resolv/tst-resolv-res_init-skeleton.c: Include signal.h. * inet/protocols/rwhod.h: Include features.h and bits/types.h. Don’t include sys/types.h. Use __int32_t instead of int32_t. * inet/protocols/talkd.h: Include features.h and bits/types.h. Don’t include sys/types.h, sys/socket.h, or stdint.h. Use __int32_t and __uint32_t instead of int32_t and uint32_t. * inet/protocols/timed.h: Include features.h, bits/types.h, and bits/types/struct_timeval.h. Don’t include sys/types.h or sys/time.h. * sysdeps/unix/sysv/linux/netipx/ipx.h: Include features.h and bits/types.h. Don’t include sys/types.h or stdint.h. Use __uint16_t and __uint32_t instead of uint16_t and uint32_t. * sysdeps/unix/sysv/linux/netrose/rose.h: Include features.h. Don’t include sys/socket.h. * inet/netinet/icmp6.h: Include features.h, bits/endian.h, bits/types.h, and bits/types/size_t.h. Don’t include inttypes.h, string.h, or sys/types.h. Duplicate prototype of memset here. Use __uintN_t instead of uintN_t types. * inet/netinet/igmp.h: Include bits/types.h. Don’t include sys/types.h. Use __uintN_t instead of uintN_t types. * inet/netinet/ip.h: Include bits/types.h. Don’t include bits/stdint-uintn.h. Use __uintN_t instead of uintN_t types. * inet/netinet/ip6.h: Include features.h, bits/endian.h, and bits/types.h. Don’t include inttypes.h. Use __uintN_t instead of uintN_t types. * inet/netinet/ip_icmp.h: Include features.h and bits/types.h. Don’t include sys/types.h or stdint.h. Use __uintN_t instead of uintN_t types. * inet/netinet/udp.h: Likewise. * sysdeps/generic/netinet/if_ether.h: Likewise. * sysdeps/unix/sysv/linux/netinet/if_ether.h: Likewise. * sysdeps/unix/sysv/linux/netinet/if_fddi.h: Likewise. * sysdeps/unix/sysv/linux/netinet/if_tr.h: Likewise. * sysdeps/gnu/netinet/ip_icmp.h: Move to inet/netinet/ip_icmp.h. * sysdeps/gnu/netinet/udp.h: Move to inet/netinet/udp.h. * include/netinet/ip_icmp.h, include/netinet/udp.h: New wrappers. * sysdeps/gnu/Makefile: Remove $(subdir)==inet stanza. * inet/Makefile (headers): Add netinet/ip_icmp.h and netinet/udp.h. Don’t use $(wildcard *.h) for arpa and protocols headers. Sort list. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.
* Don’t include sys/types.h or stdint.h from most public headers.Zack Weinberg2020-01-082-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many public headers include sys/types.h and/or stdint.h when they only need and/or are supposed to define a small number of types from that header. This patch changes as many of them as practical to include only the single-type headers for the types they are actually specified to define, and use the impl-namespace aliases for any types they need but are not specified to define. In most cases, where a header has historically used uintN_t types, I changed it to use __uintN_t types; in a few cases I chose to have it continue to define the complete set of those types (using <bits/stdint-uintn.h>). After this patch, the public headers that still include sys/types.h are: stdlib.h and sys/param.h, where removal would risk breaking far too much; the inclusion of sys/types.h; regex.h, which is taken verbatim from gnulib and can't include features.h directly (I'm open to better ideas); sys/bitypes.h, which is an alternative name for sys/types.h; and the networking headers, which will be dealt with separately. The headers that still include stdint.h are: inttypes.h, as required by ISO C; elf.h and thread_db.h, see discussion of debugger interface headers below; and, again, the networking headers will be dealt with separately. While I was at it, I moved headers out of sysdeps where possible: If we have only a sysdeps/generic/something.h or sysdeps/gnu/something.h, no other sysdeps variants, it is not really system-dependent and can be moved to the directory that installs it. If we have both sysdeps/generic/ and gnu/something.h, the generic version is never used (since we support only GNUish systems these days) and can be deleted, and the gnu-version can be moved to the directory that installs it. If the only copy of a bits header is in the top-level bits directory, it is not system-dependent. For utmp.h and utmpx.h, I think we might be able to fold their respective bits headers into the primary headers and make them not system-dependent at all. The remaining variation is between s390*-*-linux* and everything else, and it appears to me that the s390 versions of the bits headers are actually the headers that everyone should be using. The only difference is that the s390 headers unconditionally use 64-bit quantities for lastlog.ll_time, utmp{,x}.ut_tv, and utmp{,x}.ut_session, whereas the generic headers use either 64- or 32-bit quantities depending on __WORDSIZE_TIME64_COMPAT32. I could be wrong, but I don’t think it makes sense for programs with 64-bit and 32-bit time_t to have different ideas of the layout of a structures that are copied directly to and from a shared file on disk. But fixing that doesn’t belong in this patch series. The conform tests expect utmpx.h to define time_t and suseconds_t. These are the public names for the types of the fields of struct timeval, and utmpx.h is required to define struct timeval, so this is a reasonable expectation even though POSIX doesn't _explicitly_ say it's also required to define time_t and suseconds_t. utmp.h is not a standard header but it makes sense for it to be as consistent with utmpx.h as possible, especially in our implementation where /var/log/utmp and /var/log/utmpx have the same format. I thought I was going to need to change all of the arch-specific bits/epoll.h headers as well as sys/epoll.h, but it turned out not to be necessary. I still took the opportunity to give them all multiple inclusion guards. I suspect we do not need as many copies of bits/fcntl.h and bits/sem.h as we have, but that’s complicated enough that it deserves its own patchset. The debugger interface headers are a mess and I only have so much patience for them. This does the bare minimum required for thread_db.h, sys/procfs.h, and sys/user.h, which are at least nominally cross-platform interfaces, to avoid including sys/types.h, sys/time.h, and/or signal.h. Exposure of sys/ucontext.h is reduced but not eliminated. Cross-architecture consistency should be improved. It would be desirable to stop including stdint.h from elf.h and thread_db.h as well, but that would involve touching dozens more bits headers and I ran out of patience. Git does not understand “remove file X and then rename file Y over the top of it” very well, so the diff looks bigger than it should. This is another partial fix for Hurd-specific bug 23088. The headers that are still affected by that bug are aio.h, mqueue.h, regex.h, signal.h, stdlib.h, and sys/types.h. * io/ftw.h: Don't include sys/types.h. * misc/sys/uio.h: Don't include sys/types.h. Include bits/types.h, bits/types/size_t.h, and bits/types/ssize_t.h. * posix/spawn.h: Don't include sys/types.h. Include bits/types.h, bits/types/mode_t.h, and bits/types/pid_t.h. * rt/aio.h: Don't include sys/types.h. Include bits/types.h, bits/pthreadtypes.h, bits/types/size_t.h, and bits/types/ssize_t.h. * sysdeps/pthread/semaphore.h: Don't include sys/types.h. * sysdeps/unix/sysv/linux/bits/uio-ext.h: Use __pid_t, not pid_t. * sysdeps/generic/netinet/in_systm.h: Rename to inet/netinet/in_systm.h. Include bits/stdint-uintn.h, not sys/types.h or stdint.h. * sysdeps/generic/netinet/ip.h: Rename to inet/netinet/ip.h. Include bits/stdint-uintn.h and bits/endian.h, not sys/types.h. * sysdeps/gnu/netinet/tcp.h: Rename to inet/netinet/tcp.h. Include bits/stdint-uintn.h and bits/endian.h, not sys/types.h or stdint.h. * sydeps/gnu/net/if.h: Rename to socket/net/if.h. Don’t include sys/types.h. * include/net/if.h: Include socket/net/if.h, rather than whatever the next net/if.h on the include path is. * include/netinet/in_systm.h, include/netinet/ip.h * include/netinet/tcp.h: New trivial wrappers. * sysdeps/generic/net/if.h: Delete, never used. * sysdeps/generic/netinet/tcp.h: Delete, never used. * bits/utmp.h: Delete file. * sysdeps/gnu/bits/utmp.h: Move to bits/utmp.h. Add multiple include guard. Don’t include paths.h, sys/time.h, or sys/types.h. Don’t use struct timeval. Use __intN_t for consistency with bits/utmpx.h. * sysdeps/unix/sysv/linux/s390/bits/utmp.h: Add multiple include guard. Don’t include paths.h, sys/time.h, sys/types.h, or bits/wordsize.h. Don’t use struct timeval. Use __intN_t for consistency with bits/utmpx.h. Use __time64_t unconditionally for lastlog.ll_time. Use __int64_t unconditionally for utmp.ut_session. Adjust indentation and blank lines to match bits/utmp.h. * sysdeps/gnu/bits/utmpx.h: Move to bits/utmpx.h. Add multiple include guard. Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h. Don’t define _PATH_UTMPX or _PATH_WTMPX. Don’t use struct timeval. Use pid_t for consistency with bits/utmp.h. * sysdeps/unix/sysv/linux/s390/bits/utmpx.h: Add multiple include guard. Don’t define _PATH_UTMPX or _PATH_WTMPX. Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h. Don’t define _PATH_UTMPX or _PATH_WTMPX. Don’t use struct timeval. Use pid_t for consistency with bits/utmp.h. Use __int64_t unconditionally for utmpx.ut_session. * login/utmp.h: Don’t include sys/types.h. Do include paths.h, bits/types.h, bits/types/pid_t.h, bits/types/suseconds_t, bits/types/time_t.h, and bits/types/struct_timeval.h. Move __BEGIN_DECLS to enclose only prototypes. * sysdeps/gnu/utmpx.h: Move to login/utmpx.h. Don’t include sys/time.h. Do include bits/types.h, bits/types/suseconds_t, bits/types/time_t.h, and bits/types/struct_timeval.h. When __USE_GNU, include paths.h and define _PATH_UTMPX and _PATH_WTMPX. * login/Makefile (headers): Add utmpx.h and bits/utmpx.h. (routines): Add endutxent, getutmp, getutmpx, getutxent, getutxid, getutxline, pututxline, setutxent, updwtmpx, and utmpxname. Reorganize. * sysdeps/gnu/Makefile: Do not add anything to sysdep_routines or sysdep_headers when subdir == login. * sysdeps/gnu/sys/mtio.h: Move to misc/sys/mtio.h. Don't include sys/types.h. * sysdeps/gnu/Makefile: Don't add anything to sysdep_headers for the misc directory. * misc/Makefile (headers): Add sys/mtio.h. * include/sys/mtio.h: New wrapper. * elf/link.h, inet/aliases.h, misc/sys/xattr.h: Don't include sys/types.h. Include bits/types/size_t.h. * gmon/sys/gmon.h: Don't include sys/types.h. * gmon/sys/profil.h: Don't include sys/types.h. Include bits/types/size_t.h and bits/types/struct_timeval.h. * io/fts.h: Don't include sys/types.h. Include bits/types/dev_t.h, bits/types/ino_t.h, bits/types/ino64_t.h, and bits/types/nlink_t.h. * io/sys/sendfile.h: Don't include sys/types.h. Include bits/types.h, bits/types/off_t.h, bits/types/size_t.h, and bits/types/ssize_t.h. * stdlib/sys/random.h: Don't include sys/types.h. Include bits/types/size_t.h and bits/types/ssize_t.h. * gmon/tst-sprofil.h: Include sys/time.h. * sysdeps/mach/hurd/sendfile.c: Include sys/types.h. * sysdeps/unix/sysv/linux/sys/epoll.h: Don’t include stdint.h or sys/types.h. Do include features.h and bits/types.h. (union epoll_data, struct epoll_event): Use __uint32_t and __uint64_t for field types. * sysdeps/unix/sysv/linux/alpha/bits/epoll.h * sysdeps/unix/sysv/linux/bits/epoll.h * sysdeps/unix/sysv/linux/hppa/bits/epoll.h * sysdeps/unix/sysv/linux/mips/bits/epoll.h * sysdeps/unix/sysv/linux/sparc/bits/epoll.h * sysdeps/unix/sysv/linux/x86/bits/epoll.h: Add multiple inclusion guard. * sysdeps/unix/sysv/linux/alpha/sys/acct.h: Style fix. * sysdeps/unix/sysv/linux/sys/acct.h: Include features.h and bits/stdint-uintn.h. Don't include sys/types.h, stdint.h, or bits/types/time_t.h. * sysdeps/unix/sysv/linux/sys/fsuid.h * sysdeps/unix/sysv/linux/sys/quota.h Include bits/types.h, not sys/types.h. * sysdeps/nptl/sys/procfs.h: Include features.h and bits/types.h, not sys/types.h. * sysdeps/nptl/thread_db.h: Don’t include sys/types.h. * sysdeps/nptl/proc_service.h: Include bits/types/pid_t.h and bits/types/size_t.h. * sysdeps/unix/sysv/linux/sys/procfs.h: Include bits/types.h and bits/types/struct_timeval.h, not sys/time.h or sys/types.h. * sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Add multiple inclusion guard. Include bits/types.h. Correct a comment. * sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h: Add multiple inclusion guard. Include sys/ucontext.h. * sysdeps/unix/sysv/linux/alpha/bits/procfs.h * sysdeps/unix/sysv/linux/sparc/bits/procfs.h Add multiple inclusion guard. Don’t include signal.h or sys/ucontext.h. * sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Add multiple inclusion guard. Include sys/ucontext.h, not signal.h. * sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Add multiple inclusion guard. Don’t include signal.h or sys/ucontext.h. Include bits/wordsize.h and asm/elf.h. Adjust conditional for whether to provide various fallback definitions. * sysdeps/unix/sysv/linux/arm/bits/procfs.h * sysdeps/unix/sysv/linux/csky/bits/procfs.h * sysdeps/unix/sysv/linux/hppa/bits/procfs.h * sysdeps/unix/sysv/linux/m68k/bits/procfs.h * sysdeps/unix/sysv/linux/microblaze/bits/procfs.h * sysdeps/unix/sysv/linux/mips/bits/procfs.h * sysdeps/unix/sysv/linux/nios2/bits/procfs.h * sysdeps/unix/sysv/linux/riscv/bits/procfs.h * sysdeps/unix/sysv/linux/s390/bits/procfs.h * sysdeps/unix/sysv/linux/sh/bits/procfs.h * sysdeps/unix/sysv/linux/x86/bits/procfs.h: Add multiple inclusion guard. Improve commentary. * sysdeps/posix/dl-fileid.h (r_file_id): Use __dev_t and __ino64_t for field types. * nss/nss.h * sysdeps/powerpc/sys/platform/ppc.h * sysdeps/unix/sysv/linux/sys/eventfd.h * sysdeps/unix/sysv/linux/sys/fanotify.h * sysdeps/unix/sysv/linux/sys/inotify.h * sysdeps/unix/sysv/linux/sys/raw.h * sysdeps/unix/sysv/linux/sys/signalfd.h: Include bits/types.h, not stdint.h. Include features.h where not already doing so. Use __(u)intN_t types instead of (u)intN_t types in all declarations. * sysdeps/unix/sysv/linux/powerpc/bits/powerpc.h: Use __uint64_t instead of uint64_t. * nss/tst-nss-test4.c: Include stdint.h. * bits/fcntl.h: Add multiple include guard. Hoist inclusion of bits/types.h to top of file. * sysdeps/mach/hurd/bits/fcntl.h: Add multiple include guard. Include bits/types.h, not sys/types.h; remove redundant inclusion of bits/types.h in middle of file. * bits/sem.h: Add multiple include guard. Include bits/types.h, not sys/types.h. * sysdeps/gnu/bits/sem.h: Likewise. * sysdeps/unix/sysv/linux/bits/sem.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise. * sysvipc/sys/sem.h: Include bits/types/pid_t.h and bits/types/time_t.h. * resolv/bits/types/res_state.h: Include bits/types.h, not sys/types.h. Use __uint32_t and __uint16_t, not uint32_t and uint16_t. * sysdeps/mach/hurd/bits/socket.h: Include bits/types.h, not sys/types.h. * sysdeps/unix/sysv/linux/bits/socket.h: Likewise. Use __pid_t, __uid_t, and __gid_t, not pid_t, uid_t, and gid_t. * socket/sys/socket.h: Include bits/types.h, bits/types/ssize_t.h, and bits/types/socklen_t.h. * inet/htonl.c, include/htons.c: Include endian.h. * include/netinet/ether.h: Include bits/types/size_t.h. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update. * sysdeps/mach/hurd/i386/Makefile: Update list of xfails for bug 23088.
* Update copyright dates not handled by scripts/update-copyrights.Joseph Myers2020-01-012-2/+2
| | | | | | | | | | | | | | | I've updated copyright dates in glibc for 2020. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. As well as the usual annual updates, mainly dates in --version output (minus libc.texinfo which previously had to be handled manually but is now successfully updated by update-copyrights), there is a fix to sysdeps/unix/sysv/linux/powerpc/bits/termios-c_lflag.h where a typo in the copyright notice meant it failed to be updated automatically. Please remember to include 2020 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them).
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-0186-86/+86
|
* Comment out initgroups from example nsswitch.conf (Bug 25146)Carlos O'Donell2019-10-291-1/+2
| | | | | | | | | | In commit 4b7c74179c8928d971d370e1137d202f891a4cf5 the nsswitch.conf file was harmonized with downstream distributions, but this change included adding "initgroups: files". We should not add initgroups by default, we can have it, but it should be commented out to allow it to inherit the settings for group. The problem is principally that downstream authconfig won't update initgroups and it will get out of sync with the setting for group.
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-0786-86/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* nss: Make nsswitch.conf more distribution friendly.Carlos O'Donell2019-08-191-16/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current default nsswitch.conf file provided by glibc is not very distribution friendly. The file contains some minimal directives that no real distribution uses. This update aims to provide a rich set of comments which are useful for all distributions, and a broader set of service defines which should work for all distributions. Tested defaults on x86_64 and they work. The nsswitch.conf file more closely matches what we have in Fedora now, and I'll adjust Fedora to use this version with minor changes to enable Fedora-specific service providers. v2 - Add missing databases to manual. - Add link to manual from default nsswitch.conf. - Sort nsswitch.conf according to most used database first. v3 - Only mention implemented services in 'NSS Basics.' - Mention 'automount' in 'Services in the NSS configuration.' - Sort services in alphabetical order. v4 - Project name is 'Samba'. v5 - Fix typo in manual/nss.texi. v6 - Fix another typo in manual/nss.texi. Ran spell checker this time.
* nss_db: fix endent wrt NULL mappings [BZ #24695] [BZ #24696]DJ Delorie2019-07-107-2/+134
| | | | | | | | | | | | | nss_db allows for getpwent et al to be called without a set*ent, but it only works once. After the last get*ent a set*ent is required to restart, because the end*ent did not properly reset the module. Resetting it to NULL allows for a proper restart. If the database doesn't exist, however, end*ent erroniously called munmap which set errno. The test case runs "makedb" inside the testroot, so needs selinux DSOs installed.
* Fix gcc 9 build errors for make xcheck. [BZ #24556]Stefan Liebler2019-06-191-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the following gcc 9 warnings for "make xcheck" / "make bench": -string/tst-strcasestr.c: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -argp/argp-test.c: argp-test.c:130:20: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Werror=format-overflow=] argp-test.c:130:19: note: directive argument in the range [-2147483648, 122] argp-test.c:130:5: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 10 -nss/tst-field.c: tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -benchtests/bench-strstr.c: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -benchtests/bench-malloc-simple.c: bench-malloc-simple.c:93:16: error: iteration 3 invokes undefined behavior [-Werror=aggressive-loop-optimizations] ChangeLog: [BZ #24556] * string/test-strcasestr.c (check_result): Add NULL check. * nss/tst-field.c (check_rewrite): Likewise. * benchtests/bench-strstr.c (do_one_test): Likewise. * string/test-strstr.c (check_result): Likewise. * argp/argp-test.c (popt): Increase size of buf to 12. * benchtests/bench-malloc-simple.c (bench): Do not initialize tests array out of bounds.
* nss_files: Remove RES_USE_INET6 from hosts processingFlorian Weimer2019-05-161-27/+11
| | | | | | Since commit 3f8b44be0a658266adff5ece1e4bc3ce097a5dbe ("resolv: Remove support for RES_USE_INET6 and the inet6 option"), res_use_inet6 () always evaluates to false.
* nss: Turn __nss_database_lookup into a compatibility symbolFlorian Weimer2019-05-159-29/+49
| | | | | | | | | | | | | The function uses the internal service_user type, so it is not really usable from the outside of glibc. Rename the function to __nss_database_lookup2 for internal use, and change __nss_database_lookup to always indicate failure to the caller. __nss_next already was a compatibility symbol. The new implementation always fails and no longer calls __nss_next2. unscd, the alternative nscd implementation, does not use __nss_database_lookup, so it is not affected by this change.
* nss/tst-nss-files-alias-leak: add missing opening quote in printfAndreas K. Hüttel2019-03-251-1/+1
|
* nss: Fix tst-nss-files-alias-truncated for default --as-needed linkingFlorian Weimer2019-03-142-3/+7
| | | | | | | Linking to the NSS module directly does not work if the linker defaults to --as-needed because it will remove the apparently unused DSO reference and not generate a DT_NEEDED entry. Use an explicit dlopen call, like in the other chroot tests involving NSS modules.
* Add some spaces before '('.Joseph Myers2019-02-272-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes various places where a space should have been present before '(' in accordance with the GNU Coding Standards. Most but not all of the fixes in this patch are for calls to sizeof (but it's not exhaustive regarding such calls that should be fixed). Tested for x86_64, and with build-many-glibcs.py. * benchtests/bench-strcpy.c (do_test): Use space before '('. * benchtests/bench-string.h (cmdline_process_function): Likewise. * benchtests/bench-strlen.c (do_test): Likewise. (test_main): Likewise. * catgets/gencat.c (read_old): Likewise. * elf/cache.c (load_aux_cache): Likewise. * iconvdata/bug-iconv8.c (do_test): Likewise. * math/test-tgmath-ret.c (do_test): Likewise. * nis/nis_call.c (rec_dirsearch): Likewise. * nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise. * nptl/tst-audit-threads.c (do_test): Likewise. * nptl/tst-cancel4-common.h (set_socket_buffer): Likewise. * nss/nss_test1.c (init): Likewise. * nss/test-netdb.c (test_hosts): Likewise. * posix/execvpe.c (maybe_script_execute): Likewise. * stdio-common/tst-fmemopen4.c (do_test): Likewise. * stdio-common/tst-printf.c (do_test): Likewise. * stdio-common/vfscanf-internal.c (__vfscanf_internal): Likewise. * stdlib/fmtmsg.c (NKEYWORDS): Likewise. * stdlib/qsort.c (STACK_SIZE): Likewise. * stdlib/test-canon.c (do_test): Likewise. * stdlib/tst-swapcontext1.c (do_test): Likewise. * string/memcmp.c (OPSIZ): Likewise. * string/test-strcpy.c (do_test): Likewise. (do_random_tests): Likewise. * string/test-strlen.c (do_test): Likewise. (test_main): Likewise. * string/test-strrchr.c (do_test): Likewise. (do_random_tests): Likewise. * string/tester.c (test_memrchr): Likewise. (test_memchr): Likewise. * sysdeps/generic/memcopy.h (OPSIZ): Likewise. * sysdeps/generic/unwind-dw2.c (execute_stack_op): Likewise. * sysdeps/generic/unwind-pe.h (read_sleb128): Likewise. (read_encoded_value_with_base): Likewise. * sysdeps/hppa/dl-machine.h (elf_machine_runtime_setup): Likewise. * sysdeps/hppa/fpu/feupdateenv.c (__feupdateenv): Likewise. * sysdeps/ia64/fpu/sfp-machine.h (TI_BITS): Likewise. * sysdeps/mach/hurd/spawni.c (__spawni): Likewise. * sysdeps/posix/spawni.c (maybe_script_execute): Likewise. * sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (query_auxv): Likewise. * sysdeps/unix/sysv/linux/aarch64/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/arm/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/arm/ioperm.c (init_iosys): Likewise. * sysdeps/unix/sysv/linux/csky/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/m68k/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/nios2/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute): Likewise. * sysdeps/unix/sysv/linux/x86/bits/procfs.h (ELF_NGREG): Likewise. * sysdeps/unix/sysv/linux/x86/bits/sigcontext.h (FP_XSTATE_MAGIC2_SIZE): Likewise. * sysdeps/x86/fpu/sfp-machine.h (TI_BITS): Likewise. * time/test_time.c (main): Likewise.
* Break more lines before not after operators.Joseph Myers2019-02-254-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes further coding style fixes where code was breaking lines after an operator, contrary to the GNU Coding Standards. As with the previous patch, it is limited to files following a reasonable approximation to GNU style already, and is not exhaustive; more such issues remain to be fixed. Tested for x86_64, and with build-many-glibcs.py. * dirent/dirent.h [!_DIRENT_HAVE_D_NAMLEN && _DIRENT_HAVE_D_RECLEN] (_D_ALLOC_NAMLEN): Break lines before rather than after operators. * elf/cache.c (print_cache): Likewise. * gshadow/fgetsgent_r.c (__fgetsgent_r): Likewise. * htl/pt-getattr.c (__pthread_getattr_np): Likewise. * hurd/hurdinit.c (_hurd_setproc): Likewise. * hurd/hurdkill.c (_hurd_sig_post): Likewise. * hurd/hurdlookup.c (__file_name_lookup_under): Likewise. * hurd/hurdsig.c (_hurd_internal_post_signal): Likewise. (reauth_proc): Likewise. * hurd/lookup-at.c (__file_name_lookup_at): Likewise. (__file_name_split_at): Likewise. (__directory_name_split_at): Likewise. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise. * hurd/port2fd.c (_hurd_port2fd): Likewise. * iconv/gconv_dl.c (do_print): Likewise. * inet/netinet/in.h (struct sockaddr_in): Likewise. * libio/wstrops.c (_IO_wstr_seekoff): Likewise. * locale/setlocale.c (new_composite_name): Likewise. * malloc/memusagestat.c (main): Likewise. * misc/fstab.c (fstab_convert): Likewise. * nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt): Likewise. * nss/nss_compat/compat-grp.c (getgrent_next_nss): Likewise. (getgrent_next_file): Likewise. (internal_getgrnam_r): Likewise. (internal_getgrgid_r): Likewise. * nss/nss_compat/compat-initgroups.c (getgrent_next_nss): Likewise. (internal_getgrent_r): Likewise. * nss/nss_compat/compat-pwd.c (getpwent_next_nss_netgr): Likewise. (getpwent_next_nss): Likewise. (getpwent_next_file): Likewise. (internal_getpwnam_r): Likewise. (internal_getpwuid_r): Likewise. * nss/nss_compat/compat-spwd.c (getspent_next_nss_netgr): Likewise. (getspent_next_nss): Likewise. (internal_getspnam_r): Likewise. * pwd/fgetpwent_r.c (__fgetpwent_r): Likewise. * shadow/fgetspent_r.c (__fgetspent_r): Likewise. * string/strchr.c (STRCHR): Likewise. * string/strchrnul.c (STRCHRNUL): Likewise. * sysdeps/aarch64/fpu/fpu_control.h (_FPU_FPCR_IEEE): Likewise. * sysdeps/aarch64/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/csky/dl-machine.h (elf_machine_rela): Likewise. * sysdeps/generic/memcopy.h (PAGE_COPY_FWD_MAYBE): Likewise. * sysdeps/generic/symbol-hacks.h (__stack_chk_fail_local): Likewise. * sysdeps/gnu/netinet/ip_icmp.h (ICMP_INFOTYPE): Likewise. * sysdeps/gnu/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/gnu/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/hppa/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Likewise. * sysdeps/mach/hurd/bits/stat.h (S_ISPARE): Likewise. * sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Likewise. (open_file): Likewise. * sysdeps/mach/hurd/htl/pt-mutexattr-setprotocol.c (pthread_mutexattr_setprotocol): Likewise. * sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise. * sysdeps/mach/hurd/mmap.c (__mmap): Likewise. * sysdeps/mach/hurd/ptrace.c (ptrace): Likewise. * sysdeps/mach/hurd/spawni.c (__spawni): Likewise. * sysdeps/microblaze/dl-machine.h (elf_machine_type_class): Likewise. (elf_machine_rela): Likewise. * sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise. * sysdeps/mips/sys/asm.h (multiple #if conditionals): Likewise. * sysdeps/posix/rename.c (rename): Likewise. * sysdeps/powerpc/novmx-sigjmp.c (__novmx__sigjmp_save): Likewise. * sysdeps/powerpc/sigjmp.c (__vmx__sigjmp_save): Likewise. * sysdeps/s390/fpu/fenv_libc.h (FPC_VALID_MASK): Likewise. * sysdeps/s390/utf8-utf16-z9.c (gconv_end): Likewise. * sysdeps/unix/grantpt.c (grantpt): Likewise. * sysdeps/unix/sysv/linux/a.out.h (N_TXTOFF): Likewise. * sysdeps/unix/sysv/linux/updwtmp.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/unix/sysv/linux/utmp_file.c (TRANSFORM_UTMP_FILE_NAME): Likewise. * sysdeps/x86/cpu-features.c (get_common_indices): Likewise. * time/tzfile.c (__tzfile_compute): Likewise.
* Break some lines before not after operators.Joseph Myers2019-02-222-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The GNU Coding Standards specify that line breaks in expressions should go before an operator, not after one. This patch fixes various code to do this. It only changes code that appears to be mostly following GNU style anyway, not files and directories with substantially different formatting. It is not exhaustive even for files using GNU style (for example, changes to sysdeps files are deferred for subsequent cleanups). Some files changed are shared with gnulib, but most are specific to glibc. Changes were made manually, with places to change found by grep (so some cases, e.g. where the operator was followed by a comment at end of line, are particularly liable to have been missed by grep, but I did include cases where the operator was followed by backslash-newline). This patch generally does not attempt to address other coding style issues in the expressions changed (for example, missing spaces before '(', or lack of parentheses to ensure indentation of continuation lines properly reflects operator precedence). Tested for x86_64, and with build-many-glibcs.py. * benchtests/bench-memmem.c (simple_memmem): Break lines before rather than after operators. * benchtests/bench-skeleton.c (TIMESPEC_AFTER): Likewise. * crypt/md5.c (md5_finish_ctx): Likewise. * crypt/sha256.c (__sha256_finish_ctx): Likewise. * crypt/sha512.c (__sha512_finish_ctx): Likewise. * elf/cache.c (load_aux_cache): Likewise. * elf/dl-load.c (open_verify): Likewise. * elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise. * elf/readelflib.c (process_elf_file): Likewise. * elf/rtld.c (dl_main): Likewise. * elf/sprof.c (generate_call_graph): Likewise. * hurd/ctty-input.c (_hurd_ctty_input): Likewise. * hurd/ctty-output.c (_hurd_ctty_output): Likewise. * hurd/dtable.c (reauth_dtable): Likewise. * hurd/getdport.c (__getdport): Likewise. * hurd/hurd/signal.h (_hurd_interrupted_rpc_timeout): Likewise. * hurd/hurd/sigpreempt.h (HURD_PREEMPT_SIGNAL_P): Likewise. * hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise): Likewise. * hurd/hurdioctl.c (fioctl): Likewise. * hurd/hurdselect.c (_hurd_select): Likewise. * hurd/hurdsig.c (_hurdsig_abort_rpcs): Likewise. (STOPSIGS): Likewise. * hurd/hurdstartup.c (_hurd_startup): Likewise. * hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Likewise. * hurd/lookup-retry.c (__hurd_file_name_lookup_retry): Likewise. * hurd/msgportdemux.c (msgport_server): Likewise. * hurd/setauth.c (_hurd_setauth): Likewise. * include/features.h (__GLIBC_USE_DEPRECATED_SCANF): Likewise. * libio/libioP.h [IO_DEBUG] (CHECK_FILE): Likewise. * locale/programs/ld-ctype.c (set_class_defaults): Likewise. * localedata/tests-mbwc/tst_swscanf.c (tst_swscanf): Likewise. * login/tst-utmp.c (do_check): Likewise. (simulate_login): Likewise. * mach/lowlevellock.h (lll_lock): Likewise. (lll_trylock): Likewise. * math/test-fenv.c (ALL_EXC): Likewise. * math/test-fenvinline.c (ALL_EXC): Likewise. * misc/sys/cdefs.h (__attribute_deprecated_msg__): Likewise. * nis/nis_call.c (__do_niscall3): Likewise. * nis/nis_callback.c (cb_prog_1): Likewise. * nis/nis_defaults.c (searchaccess): Likewise. * nis/nis_findserv.c (__nis_findfastest_with_timeout): Likewise. * nis/nis_ismember.c (internal_ismember): Likewise. * nis/nis_local_names.c (nis_local_principal): Likewise. * nis/nss_nis/nis-rpc.c (_nss_nis_getrpcbyname_r): Likewise. * nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_getnetgrent_r): Likewise. * nis/ypclnt.c (yp_match): Likewise. (yp_first): Likewise. (yp_next): Likewise. (yp_master): Likewise. (yp_order): Likewise. * nscd/hstcache.c (cache_addhst): Likewise. * nscd/initgrcache.c (addinitgroupsX): Likewise. * nss/nss_compat/compat-pwd.c (copy_pwd_changes): Likewise. (internal_getpwuid_r): Likewise. * nss/nss_compat/compat-spwd.c (copy_spwd_changes): Likewise. * posix/glob.h (__GLOB_FLAGS): Likewise. * posix/regcomp.c (peek_token): Likewise. (peek_token_bracket): Likewise. (parse_expression): Likewise. * posix/regexec.c (sift_states_iter_mb): Likewise. (check_node_accept_bytes): Likewise. * posix/tst-spawn3.c (do_test): Likewise. * posix/wordexp-test.c (testit): Likewise. * posix/wordexp.c (parse_tilde): Likewise. (exec_comm): Likewise. * posix/wordexp.h (__WRDE_FLAGS): Likewise. * resource/vtimes.c (TIMEVAL_TO_VTIMES): Likewise. * setjmp/sigjmp.c (__sigjmp_save): Likewise. * stdio-common/printf_fp.c (__printf_fp_l): Likewise. * stdio-common/tst-fileno.c (do_test): Likewise. * stdio-common/vfprintf-internal.c (vfprintf): Likewise. * stdlib/strfmon_l.c (__vstrfmon_l_internal): Likewise. * stdlib/strtod_l.c (round_and_return): Likewise. (____STRTOF_INTERNAL): Likewise. * stdlib/tst-strfrom.h (TEST_STRFROM): Likewise. * string/strcspn.c (STRCSPN): Likewise. * string/test-memmem.c (simple_memmem): Likewise. * termios/tcsetattr.c (tcsetattr): Likewise. * time/alt_digit.c (_nl_parse_alt_digit): Likewise. * time/asctime.c (asctime_internal): Likewise. * time/strptime_l.c (__strptime_internal): Likewise. * time/sys/time.h (timercmp): Likewise. * time/tzfile.c (__tzfile_compute): Likewise.
* nss: tst-nss-files-hosts-long: Add host.conf [BZ #21915]Patsy Franklin2019-02-211-0/+1
| | | | | | | | Add /etc/host.conf file with 'multi on' to tst-nss-files-hosts-long.root. Ensures the entire file, and all long lines, need to be parsed for the test. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nss: getent: Print IPv6 scope ID for ahosts/ahostsv6 if availableFlorian Weimer2019-02-121-8/+28
| | | | | This information is sometimes useful and actually required for link-local addresses.
* nss: Add tst-nss-files-hosts-long test [BZ #21915]Patsy Franklin2019-02-083-1/+55
| | | | | | | | | When the /etc/hosts file has a line longer than 1028 characters getent ahostsv4 and ahostsv6 will fail. This test performs a getent call on a /etc/hosts file that contains a very long line (greater than 1028) using the test-in-container framework.
* nss_files: Fix /etc/aliases null pointer dereference [BZ #24059]Florian Weimer2019-01-313-0/+78
| | | | | | | | If /etc/aliases ends with a continuation line (a line that starts with whitespace) which does not have a trailing newline character, the file parser would crash due to a null pointer dereference. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* CVE-2016-10739: getaddrinfo: Fully parse IPv4 address strings [BZ #20018]Florian Weimer2019-01-211-2/+1
| | | | | | | | | | | | | | | | The IPv4 address parser in the getaddrinfo function is changed so that it does not ignore trailing whitespace and all characters after it. For backwards compatibility, the getaddrinfo function still recognizes legacy name syntax, such as 192.000.002.010 interpreted as 192.0.2.8 (octal). This commit does not change the behavior of inet_addr and inet_aton. gethostbyname already had additional sanity checks (but is switched over to the new __inet_aton_exact function for completeness as well). To avoid sending the problematic query names over DNS, commit 6ca53a2453598804a2559a548a08424fca96434a ("resolv: Do not send queries for non-host-names in nss_dns [BZ #24112]") is needed.
* Update copyright dates not handled by scripts/update-copyrights.Joseph Myers2019-01-012-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've updated copyright dates in glibc for 2019. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. Please remember to include 2019 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them). * NEWS: Update copyright dates. * catgets/gencat.c (print_version): Likewise. * csu/version.c (banner): Likewise. * debug/catchsegv.sh: Likewise. * debug/pcprofiledump.c (print_version): Likewise. * debug/xtrace.sh (do_version): Likewise. * elf/ldconfig.c (print_version): Likewise. * elf/ldd.bash.in: Likewise. * elf/pldd.c (print_version): Likewise. * elf/sotruss.sh: Likewise. * elf/sprof.c (print_version): Likewise. * iconv/iconv_prog.c (print_version): Likewise. * iconv/iconvconfig.c (print_version): Likewise. * locale/programs/locale.c (print_version): Likewise. * locale/programs/localedef.c (print_version): Likewise. * login/programs/pt_chown.c (print_version): Likewise. * malloc/memusage.sh (do_version): Likewise. * malloc/memusagestat.c (print_version): Likewise. * malloc/mtrace.pl: Likewise. * manual/libc.texinfo: Likewise. * nptl/version.c (banner): Likewise. * nscd/nscd.c (print_version): Likewise. * nss/getent.c (print_version): Likewise. * nss/makedb.c (print_version): Likewise. * posix/getconf.c (main): Likewise. * scripts/test-installation.pl: Likewise. * sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-0182-82/+82
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Add missing libnss_testX.so requirement for tst-nss-test3.Stefan Liebler2018-12-141-1/+1
| | | | | | | | | | | | | | | Sometimes tst-nss-test3 fails with: error: test-container.c:386: unable to open .../nss/libnss_test1.so for reading The test tst-nss-test3 which runs in a container needs libnss_test[12].so. (see e.g. tst-nss-test3.script). Before this test was moved from tests to tests-container variable, the requirement was met. Thus this patch adds this requirement also for tests in tests-container. ChangeLog: * nss/Makefile (tst-nss-test3.out): New rule.
* Increase timeout of nss/tst-nss-files-hosts-multiSzabolcs Nagy2018-10-091-0/+1
| | | | | | | | | | | | | | | | | | | Increase timeout from the default 20s to 40s. This test makes close to 2 million syscalls with distribution: 1180249 connect 297952 getsockname 144040 lseek 143734 read 14466 close ... connect can be slow, so the default timeout was not enough on slow systems. Reviewed-by: Carlos O'Donell <carlos@redhat.com> * nss/tst-nss-files-hosts-multi.c (TIMEOUT): Define.
* [BZ #20271] Add newlines in __libc_fatal calls.Paul Pluzhnikov2018-08-311-1/+1
|
* Add test-in-container infrastructure.DJ Delorie2018-08-224-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (testroot.pristine): New rules to initialize the test-in-container "testroot". * Makerules (all-testsuite): Add tests-container. * Rules (tests-expected): Add tests-container. (binaries-all-tests): Likewise. (tests-container): New, run these tests in the testroot container. * support/Makefile (others): Add *-container, support_paths.c, xmkdirp, and links-dso-program. * support/links-dso-program-c.c: New. * support/links-dso-program.cc: New. * support/test-container.c: New. * support/shell-container.c: New. * support/echo-container.c: New. * support/true-container.c: New. * support/xmkdirp.c: New. * support/xsymlink.c: New. * support/support_paths.c: New. * support/support.h: Add support paths prototypes. * support/xunistd.h: Add xmkdirp () and xsymlink (). * nss/tst-nss-test3.c: Convert to test-in-container. * nss/tst-nss-test3.root/: New.
* nss_files: Fix file stream leak in aliases lookup [BZ #23521]Florian Weimer2018-08-143-0/+249
| | | | | In order to get a clean test case, it was necessary to fix partially fixed bug 23522 as well.
* Fix copyright years in recent commitsFlorian Weimer2018-07-101-1/+1
|
* nss_files: Fix re-reading of long lines [BZ #18991]Florian Weimer2018-07-063-71/+328
| | | | | Use the new __libc_readline_unlocked function to pick up reading at the same line in case the buffer needs to be enlarged.
* nss_files: Use struct scratch_buffer instead of extend_alloca [BZ #18023]Florian Weimer2018-06-251-22/+10
|
* getent: Use dynarray in initgroups_keys [BZ #18023]Florian Weimer2018-06-251-10/+30
|
* getgrent_next_nss (compat-initgroups): Remove alloca fallback [BZ #18023]Florian Weimer2018-06-251-25/+21
| | | | | | | | | | If the caller-supplied buffer is not large enough, fall back directly malloc. The previous __libc_use_alloca check was incorrect because it did not take into account that extend_alloca may fail to merge allocations, so it would underestimate the stack space being used by roughly a factor of two.
* Fix multiple definitions of __nss_*_database (bug 22918)Andreas Schwab2018-03-032-5/+5
|
* Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for feof_unlocked. The usual approach is followed of adding __feof_unlocked (inlined when feof_unlocked is), making calls use it when required for namespace reasons, and using libc_hidden_proto / libc_hidden_weak for the feof_unlocked weak alias when only localplt but not namespace issues are involved. In the case of getaddrinfo.c, use of __feof_unlocked needs to be conditional since that code is also used in nscd (where __feof_unlocked is not available). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and define as weak alias of __feof_unlocked. Use libc_hidden_weak. * include/stdio.h (feof_unlocked): Use libc_hidden_proto. (__feof_unlocked): New declaration, and inline function if [__USE_EXTERN_INLINES]. * iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked instead of feof_unlocked. * intl/localealias.c [_LIBC] (FEOF): Likewise. * nss/nsswitch.c (nss_parse_file): Likewise. * sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area): Likewise. * time/getdate.c (__getdate_r): Likewise. * sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked): Define as macro to call __feof_unlocked.
* nss: Adjust tests to use nss_files onlyFlorian Weimer2018-01-302-0/+6
|
* Update copyright dates not handled by scripts/update-copyrights.Joseph Myers2018-01-012-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've updated copyright dates in glibc for 2018. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. Please remember to include 2018 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them). * NEWS: Update copyright dates. * catgets/gencat.c (print_version): Likewise. * csu/version.c (banner): Likewise. * debug/catchsegv.sh: Likewise. * debug/pcprofiledump.c (print_version): Likewise. * debug/xtrace.sh (do_version): Likewise. * elf/ldconfig.c (print_version): Likewise. * elf/ldd.bash.in: Likewise. * elf/pldd.c (print_version): Likewise. * elf/sotruss.sh: Likewise. * elf/sprof.c (print_version): Likewise. * iconv/iconv_prog.c (print_version): Likewise. * iconv/iconvconfig.c (print_version): Likewise. * locale/programs/locale.c (print_version): Likewise. * locale/programs/localedef.c (print_version): Likewise. * login/programs/pt_chown.c (print_version): Likewise. * malloc/memusage.sh (do_version): Likewise. * malloc/memusagestat.c (print_version): Likewise. * malloc/mtrace.pl: Likewise. * manual/libc.texinfo: Likewise. * nptl/version.c (banner): Likewise. * nscd/nscd.c (print_version): Likewise. * nss/getent.c (print_version): Likewise. * nss/makedb.c (print_version): Likewise. * posix/getconf.c (main): Likewise. * scripts/test-installation.pl: Likewise. * sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-0180-80/+80
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* nss: Export nscd hash function as __nss_hash [BZ #22459]Florian Weimer2017-11-233-1/+81
|
* nss_files: Avoid large buffers with many host addresses [BZ #22078]Florian Weimer2017-10-113-96/+462
| | | | | The previous implementation had at least a quadratic space requirement in the number of host addresses and aliases.
* nss_files: Use struct scratch_buffer for gethostbyname [BZ #18023]Florian Weimer2017-10-111-156/+138
|
* nss_files: Refactor gethostbyname3 multi case into separate functionFlorian Weimer2017-10-101-193/+202
| | | | This is in preparation of further cleanup work.
* Move nss_compat from nis to nss subdir and install it unconditionallyAndreas Schwab2017-10-048-1/+3339
| | | | | | This has been tested that local lookup still works with and without an installed libnss_nis, and that NIS lookup works when libnss_nis is available.
* Mark internal getXXXbyYYY functions with attribute_hidden [BZ #18822]H.J. Lu2017-10-011-1/+2
| | | | | | | | | | | | | | | | | | | | | Mark internal getXXXbyYYY functions with attribute_hidden to allow direct access within libc.so and libc.a without using GOT nor PLT. [BZ #18822] * include/aliases.h (__getaliasbyname_r): Add attribute_hidden. * include/netdb.h (__gethostbyaddr_r): Likewise. (__gethostbyname_r): Likewise. (__gethostbyname2_r): Likewise. (__getnetbyaddr_r): Likewise. (__getnetbyname_r): Likewise. (__getservbyname_r): Likewise. (__getservbyport_r): Likewise. (__getprotobyname_r): Likewise. (__getprotobynumber_r): Likewise. (__getnetgrent_r): Likewise. * include/rpc/netdb.h (__getrpcbyname_r): Likewise. (__getrpcbynumber_r): Likewise. * nss/getXXbyYY.c (INTERNAL (REENTRANT_NAME)): Likewise.
* Remove compat from DEFAULT_CONFIG lookup stringsSteve Ellcey2017-09-124-7/+33
| | | | | | | | | | | | | | | * grp/initgroups.c: Include config.h. (DEFAULT_CONFIG): New macro. (internal_getgrouplist): Use DEFAULT_CONFIG. * nscd/initgrcache.c (addinitgroupsX): Likewise. * nss/nsswitch.c (__nss_disable_nscd): Likewise. (DEFAULT_DEFCONFIG): New macro. (__nss_database_lookup): Use DEFAULT_DEFCONFIG. * nss/grp-lookup.c: Include config.h (DEFAULT_CONFIG): Set definition based on LINK_OBSOLETE_NSL. * nss/pwd-lookup.c (DEFAULT_CONFIG): Likewise. * nss/spwd-lookup.c (DEFAULT_CONFIG): Likewise. * manual/nss.texi: Update default values section.
* getaddrinfo: Fix error handling in gethosts [BZ #21915] [BZ #21922]Florian Weimer2017-09-012-0/+116
| | | | | | The old code uses errno as the primary indicator for success or failure. This is wrong because errno is only set for specific combinations of the status return value and the h_errno variable.
* NSS: Remove internal_function function attributeFlorian Weimer2017-08-314-12/+4
|
* Don't compile non-lib modules as lib modules [BZ #21864]H.J. Lu2017-08-211-0/+1
| | | | | | | | | | | | | Some programs have more than one source files. These non-lib modules should not be compiled with -DMODULE_NAME=libc. This patch puts these non-lib modules in $(others-extras) and adds $(others-extras) to all-nonlib. [BZ #21864] * Makerules (all-nonlib): Add $(others-extras). * catgets/Makefile (others-extras): New. * elf/Makefile (others-extras): Likewise. * nss/Makefile (others-extras): Likewise.