diff options
Diffstat (limited to 'lib/libc/net')
-rw-r--r-- | lib/libc/net/getaddrinfo.c | 10 | ||||
-rw-r--r-- | lib/libc/net/gethostbyht.c | 1 | ||||
-rw-r--r-- | lib/libc/net/gethostnamadr.c | 3 | ||||
-rw-r--r-- | lib/libc/net/getifaddrs.c | 9 | ||||
-rw-r--r-- | lib/libc/net/getnetbydns.c | 1 | ||||
-rw-r--r-- | lib/libc/net/getnetnamadr.c | 1 | ||||
-rw-r--r-- | lib/libc/net/herror.c | 4 | ||||
-rw-r--r-- | lib/libc/net/map_v4v6.c | 1 | ||||
-rw-r--r-- | lib/libc/net/name6.c | 18 | ||||
-rw-r--r-- | lib/libc/net/rcmd.c | 32 | ||||
-rw-r--r-- | lib/libc/net/recv.c | 6 | ||||
-rw-r--r-- | lib/libc/net/res_mkupdate.c | 1 | ||||
-rw-r--r-- | lib/libc/net/res_send.c | 24 | ||||
-rw-r--r-- | lib/libc/net/res_update.c | 1 | ||||
-rw-r--r-- | lib/libc/net/send.c | 6 |
15 files changed, 66 insertions, 52 deletions
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c index 10ddd3a..9e498e5 100644 --- a/lib/libc/net/getaddrinfo.c +++ b/lib/libc/net/getaddrinfo.c @@ -86,6 +86,7 @@ * - classful IPv4 numeric (127.1) is allowed. */ +#include "namespace.h" #include <sys/types.h> #include <sys/param.h> #include <sys/socket.h> @@ -106,6 +107,7 @@ #include <syslog.h> #include <stdarg.h> #include <nsswitch.h> +#include "un-namespace.h" #if defined(__KAME__) && defined(INET6) # define FAITH @@ -665,7 +667,7 @@ explore_null(pai, servname, res) * filter out AFs that are not supported by the kernel * XXX errno? */ - s = socket(pai->ai_family, SOCK_DGRAM, 0); + s = _socket(pai->ai_family, SOCK_DGRAM, 0); if (s < 0) { if (errno != EMFILE) return 0; @@ -1059,18 +1061,18 @@ addrconfig(pai) */ af = pai->ai_family; if (af == AF_UNSPEC) { - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0) af = AF_INET; else { _close(s); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(AF_INET, SOCK_DGRAM, 0)) < 0) af = AF_INET6; else _close(s); } } if (af != AF_UNSPEC) { - if ((s = socket(af, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(af, SOCK_DGRAM, 0)) < 0) return 0; _close(s); } diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c index eeecd22..478d2d2 100644 --- a/lib/libc/net/gethostbyht.c +++ b/lib/libc/net/gethostbyht.c @@ -63,7 +63,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netdb.h> #include <stdio.h> #include <ctype.h> -#include <errno.h> #include <string.h> #include <stdarg.h> #include <nsswitch.h> diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index d5644a8..80e6637 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -35,7 +35,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netdb.h> #include <stdio.h> #include <ctype.h> -#include <errno.h> #include <string.h> #include <stdarg.h> #include <nsswitch.h> @@ -117,7 +116,6 @@ gethostbyaddr(const char *addr, int len, int type) return hp; } -#ifdef _THREAD_SAFE struct hostent_data; /* @@ -136,7 +134,6 @@ int gethostbyaddr_r(const char *addr, int len, int type, } return(ret); } -#endif void sethostent(stayopen) diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c index a0a034e..6b81196 100644 --- a/lib/libc/net/getifaddrs.c +++ b/lib/libc/net/getifaddrs.c @@ -28,6 +28,7 @@ * NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform * try-and-error for region size. */ +#include "namespace.h" #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -39,10 +40,10 @@ #include <net/if_dl.h> #endif -#include <errno.h> #include <ifaddrs.h> #include <stdlib.h> #include <string.h> +#include "un-namespace.h" #if !defined(AF_LINK) #define SA_LEN(sa) sizeof(struct sockaddr) @@ -194,10 +195,10 @@ getifaddrs(struct ifaddrs **pif) ifc.ifc_buf = buf; ifc.ifc_len = sizeof(buf); - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) + if ((sock = _socket(AF_INET, SOCK_STREAM, 0)) < 0) return (-1); - i = ioctl(sock, SIOCGIFCONF, (char *)&ifc); - close(sock); + i = _ioctl(sock, SIOCGIFCONF, (char *)&ifc); + _close(sock); if (i < 0) return (-1); diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c index 5827103..433b3b8 100644 --- a/lib/libc/net/getnetbydns.c +++ b/lib/libc/net/getnetbydns.c @@ -73,7 +73,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netdb.h> #include <resolv.h> #include <ctype.h> -#include <errno.h> #include <string.h> #include <unistd.h> #include <syslog.h> diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c index 6d9dbfa..2c5c918 100644 --- a/lib/libc/net/getnetnamadr.c +++ b/lib/libc/net/getnetnamadr.c @@ -34,7 +34,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netdb.h> #include <stdio.h> #include <ctype.h> -#include <errno.h> #include <string.h> #include <stdarg.h> #include <nsswitch.h> diff --git a/lib/libc/net/herror.c b/lib/libc/net/herror.c index 0ab7448..e42badf 100644 --- a/lib/libc/net/herror.c +++ b/lib/libc/net/herror.c @@ -53,11 +53,13 @@ static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; static char rcsid[] = "$FreeBSD$"; #endif /* LIBC_SCCS and not lint */ +#include "namespace.h" #include <sys/types.h> #include <sys/uio.h> #include <netdb.h> #include <string.h> #include <unistd.h> +#include "un-namespace.h" const char *h_errlist[] = { "Resolver Error 0 (no error)", @@ -94,7 +96,7 @@ herror(s) v++; v->iov_base = "\n"; v->iov_len = 1; - writev(STDERR_FILENO, iov, (v - iov) + 1); + _writev(STDERR_FILENO, iov, (v - iov) + 1); } const char * diff --git a/lib/libc/net/map_v4v6.c b/lib/libc/net/map_v4v6.c index ca5e553..cc6bb36 100644 --- a/lib/libc/net/map_v4v6.c +++ b/lib/libc/net/map_v4v6.c @@ -70,7 +70,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netdb.h> #include <resolv.h> #include <ctype.h> -#include <errno.h> #include <syslog.h> typedef union { diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 36df9a0..4ab24b3 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -94,6 +94,7 @@ * rewrite resolvers to be thread safe */ +#include "namespace.h" #include <sys/param.h> #include <sys/socket.h> #include <sys/time.h> @@ -112,6 +113,7 @@ #include <stdarg.h> #include <nsswitch.h> #include <unistd.h> +#include "un-namespace.h" #ifndef _PATH_HOSTS #define _PATH_HOSTS "/etc/hosts" @@ -255,11 +257,11 @@ _ghbyname(const char *name, int af, int flags, int *errp) * because addresses will be dynamically assigned or deleted. */ if (af == AF_UNSPEC) { - if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(AF_INET6, SOCK_DGRAM, 0)) < 0) af = AF_INET; else { _close(s); - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(AF_INET, SOCK_DGRAM, 0)) < 0) af = AF_INET6; else _close(s); @@ -267,7 +269,7 @@ _ghbyname(const char *name, int af, int flags, int *errp) } if (af != AF_UNSPEC) { - if ((s = socket(af, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(af, SOCK_DGRAM, 0)) < 0) return NULL; _close(s); } @@ -1699,11 +1701,11 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) msg.msg_controllen = (char *)cmsg - cbuf; } - if ((s = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) + if ((s = _socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) return NULL; - (void)setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, + (void)_setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, (char *)&filter, sizeof(filter)); - cc = sendmsg(s, &msg, 0); + cc = _sendmsg(s, &msg, 0); if (cc < 0) { _close(s); return NULL; @@ -1711,12 +1713,12 @@ _icmp_fqdn_query(const struct in6_addr *addr, int ifindex) FD_SET(s, &s_fds); for (;;) { fds = s_fds; - if (select(s + 1, &fds, NULL, NULL, &tout) <= 0) { + if (_select(s + 1, &fds, NULL, NULL, &tout) <= 0) { _close(s); return NULL; } len = sizeof(sin6); - cc = recvfrom(s, buf, sizeof(buf), 0, + cc = _recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr *)&sin6, &len); if (cc <= 0) { _close(s); diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c index 3392cd5..3fad8d6 100644 --- a/lib/libc/net/rcmd.c +++ b/lib/libc/net/rcmd.c @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #endif /* LIBC_SCCS and not lint */ +#include "namespace.h" #include <sys/param.h> #include <sys/socket.h> #include <sys/stat.h> @@ -59,6 +60,7 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include <rpcsvc/ypclnt.h> #endif #include <arpa/nameser.h> +#include "un-namespace.h" /* wrapper for KAME-special getnameinfo() */ #ifndef NI_WITHSCOPEID @@ -100,7 +102,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) struct addrinfo hints, *res, *ai; struct sockaddr_storage from; fd_set reads; - long oldmask; + sigset_t oldmask, newmask; pid_t pid; int s, aport, lport, timo, error; char c; @@ -136,7 +138,9 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) nres++; ai = res; refused = 0; - oldmask = sigblock(sigmask(SIGURG)); + sigemptyset(&newmask); + sigaddset(&newmask, SIGURG); + _sigprocmask(SIG_BLOCK, (const sigset_t *)&newmask, &oldmask); for (timo = 1, lport = IPPORT_RESERVED - 1;;) { s = rresvport_af(&lport, ai->ai_family); if (s < 0) { @@ -151,11 +155,12 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)fprintf(stderr, "rcmd: socket: %s\n", strerror(errno)); freeaddrinfo(res); - sigsetmask(oldmask); + _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, + NULL); return (-1); } _fcntl(s, F_SETOWN, pid); - if (connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) + if (_connect(s, ai->ai_addr, ai->ai_addrlen) >= 0) break; (void)_close(s); if (errno == EADDRINUSE) { @@ -168,7 +173,8 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) (void)fprintf(stderr, "%s: %s\n", *ahost, strerror(errno)); freeaddrinfo(res); - sigsetmask(oldmask); + _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, + NULL); return (-1); } if (nres > 1) { @@ -214,7 +220,7 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) if (s2 < 0) goto bad; - listen(s2, 1); + _listen(s2, 1); (void)snprintf(num, sizeof(num), "%d", lport); if (_write(s, num, strlen(num)+1) != strlen(num)+1) { (void)fprintf(stderr, @@ -234,7 +240,7 @@ again: FD_SET(s, &reads); FD_SET(s2, &reads); errno = 0; - if (select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){ + if (_select(nfds, &reads, 0, 0, 0) < 1 || !FD_ISSET(s2, &reads)){ if (errno != 0) (void)fprintf(stderr, "rcmd: select (setting up stderr): %s\n", @@ -245,7 +251,7 @@ again: (void)_close(s2); goto bad; } - s3 = accept(s2, (struct sockaddr *)&from, &len); + s3 = _accept(s2, (struct sockaddr *)&from, &len); switch (from.ss_family) { case AF_INET: aport = ntohs(((struct sockaddr_in *)&from)->sin_port); @@ -297,7 +303,7 @@ again: } goto bad2; } - sigsetmask(oldmask); + _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); freeaddrinfo(res); return (s); bad2: @@ -305,7 +311,7 @@ bad2: (void)_close(*fd2p); bad: (void)_close(s); - sigsetmask(oldmask); + _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, NULL); freeaddrinfo(res); return (-1); } @@ -345,12 +351,12 @@ rresvport_af(alport, family) return -1; } - s = socket(ss.ss_family, SOCK_STREAM, 0); + s = _socket(ss.ss_family, SOCK_STREAM, 0); if (s < 0) return (-1); #if 0 /* compat_exact_traditional_rresvport_semantics */ sin.sin_port = htons((u_short)*alport); - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) + if (_bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) return (s); if (errno != EADDRINUSE) { (void)_close(s); @@ -486,7 +492,7 @@ again: cp = ".rhosts lstat failed"; else if (!S_ISREG(sbuf.st_mode)) cp = ".rhosts not regular file"; - else if (fstat(fileno(hostf), &sbuf) < 0) + else if (_fstat(fileno(hostf), &sbuf) < 0) cp = ".rhosts fstat failed"; else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) cp = "bad .rhosts owner"; diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c index 65ec9d4..6d4ac0e 100644 --- a/lib/libc/net/recv.c +++ b/lib/libc/net/recv.c @@ -29,16 +29,20 @@ * 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. + * + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94"; #endif /* LIBC_SCCS and not lint */ +#include "namespace.h" #include <sys/types.h> #include <sys/socket.h> #include <stddef.h> +#include "un-namespace.h" ssize_t recv(s, buf, len, flags) @@ -46,5 +50,5 @@ recv(s, buf, len, flags) size_t len; void *buf; { - return (recvfrom(s, buf, len, flags, NULL, 0)); + return (_recvfrom(s, buf, len, flags, NULL, 0)); } diff --git a/lib/libc/net/res_mkupdate.c b/lib/libc/net/res_mkupdate.c index eb31bac..7344197 100644 --- a/lib/libc/net/res_mkupdate.c +++ b/lib/libc/net/res_mkupdate.c @@ -31,7 +31,6 @@ static char rcsid[] = "$FreeBSD$"; #include <arpa/nameser.h> #include <arpa/inet.h> -#include <errno.h> #include <limits.h> #include <netdb.h> #include <resolv.h> diff --git a/lib/libc/net/res_send.c b/lib/libc/net/res_send.c index cfcf815..4173f65 100644 --- a/lib/libc/net/res_send.c +++ b/lib/libc/net/res_send.c @@ -78,6 +78,7 @@ static char rcsid[] = "$FreeBSD$"; * Send query to name server and wait for reply. */ +#include "namespace.h" #include <sys/types.h> #include <sys/event.h> #include <sys/param.h> @@ -96,6 +97,7 @@ static char rcsid[] = "$FreeBSD$"; #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "un-namespace.h" #include "res_config.h" @@ -460,7 +462,7 @@ res_send(buf, buflen, ans, anssiz) res_close(); af = nsap->sa_family; - s = socket(af, SOCK_STREAM, 0); + s = _socket(af, SOCK_STREAM, 0); if (s < 0) { terrno = errno; Perror(stderr, "socket(vc)", errno); @@ -469,7 +471,7 @@ res_send(buf, buflen, ans, anssiz) goto next_ns; } errno = 0; - if (connect(s, nsap, salen) < 0) { + if (_connect(s, nsap, salen) < 0) { terrno = errno; Aerror(stderr, "connect/vc", errno, nsap); @@ -487,7 +489,7 @@ res_send(buf, buflen, ans, anssiz) iov[0].iov_len = INT16SZ; iov[1].iov_base = (caddr_t)buf; iov[1].iov_len = buflen; - if (writev(s, iov, 2) != (INT16SZ + buflen)) { + if (_writev(s, iov, 2) != (INT16SZ + buflen)) { terrno = errno; Perror(stderr, "write failed", errno); badns |= (1 << ns); @@ -604,7 +606,7 @@ read_len: if (vc) res_close(); af = nsap->sa_family; - s = socket(af, SOCK_DGRAM, 0); + s = _socket(af, SOCK_DGRAM, 0); if (s < 0) { #ifndef CAN_RECONNECT bad_dg_sock: @@ -639,7 +641,7 @@ read_len: * receive a response from another server. */ if (!connected) { - if (connect(s, nsap, salen) < 0) { + if (_connect(s, nsap, salen) < 0) { Aerror(stderr, "connect(dg)", errno, nsap); @@ -668,15 +670,15 @@ read_len: no_addr.sin_family = AF_INET; no_addr.sin_addr.s_addr = INADDR_ANY; no_addr.sin_port = 0; - (void) connect(s, + (void) _connect(s, (struct sockaddr *) &no_addr, sizeof no_addr); #else - int s1 = socket(af, SOCK_DGRAM,0); + int s1 = _socket(af, SOCK_DGRAM,0); if (s1 < 0) goto bad_dg_sock; - (void)dup2(s1, s); + (void)_dup2(s1, s); (void)_close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n")) @@ -685,7 +687,7 @@ read_len: errno = 0; } #endif /* !CANNOT_CONNECT_DGRAM */ - if (sendto(s, (char*)buf, buflen, 0, + if (_sendto(s, (char*)buf, buflen, 0, nsap, salen) != buflen) { Aerror(stderr, "sendto", errno, nsap); badns |= (1 << ns); @@ -717,7 +719,7 @@ read_len: kv.flags = EV_ADD | EV_ONESHOT; kv.filter = EVFILT_READ; - n = kevent(kq, &kv, 1, &kv, 1, &timeout); + n = _kevent(kq, &kv, 1, &kv, 1, &timeout); if (n < 0) { if (errno == EINTR) goto wait; @@ -738,7 +740,7 @@ read_len: } errno = 0; fromlen = sizeof(from); - resplen = recvfrom(s, (char*)ans, anssiz, 0, + resplen = _recvfrom(s, (char*)ans, anssiz, 0, (struct sockaddr *)&from, &fromlen); if (resplen <= 0) { Perror(stderr, "recvfrom", errno); diff --git a/lib/libc/net/res_update.c b/lib/libc/net/res_update.c index a877d4a..6622efd 100644 --- a/lib/libc/net/res_update.c +++ b/lib/libc/net/res_update.c @@ -30,7 +30,6 @@ static char rcsid[] = "$FreeBSD$"; #include <netinet/in.h> #include <arpa/inet.h> #include <arpa/nameser.h> -#include <errno.h> #include <limits.h> #include <netdb.h> #include <resolv.h> diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c index 81151c4..81ded52 100644 --- a/lib/libc/net/send.c +++ b/lib/libc/net/send.c @@ -29,16 +29,20 @@ * 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. + * + * $FreeBSD$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94"; #endif /* LIBC_SCCS and not lint */ +#include "namespace.h" #include <sys/types.h> #include <sys/socket.h> #include <stddef.h> +#include "un-namespace.h" ssize_t send(s, msg, len, flags) @@ -46,5 +50,5 @@ send(s, msg, len, flags) size_t len; const void *msg; { - return (sendto(s, msg, len, flags, NULL, 0)); + return (_sendto(s, msg, len, flags, NULL, 0)); } |