1/* 2 * Copyright (c) 1983, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 21 unchanged lines hidden (view full) --- 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#if defined(LIBC_SCCS) && !defined(lint) 35static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; 36#endif /* LIBC_SCCS and not lint */ 37#include <sys/cdefs.h> |
38__FBSDID("$FreeBSD: head/lib/libc/net/rcmd.c 146187 2005-05-13 16:31:11Z ume $"); |
39 40#include "namespace.h" 41#include <sys/param.h> 42#include <sys/socket.h> 43#include <sys/stat.h> 44 45#include <netinet/in.h> 46#include <arpa/inet.h> --- 11 unchanged lines hidden (view full) --- 58#include <rpc/rpc.h> 59#ifdef YP 60#include <rpcsvc/yp_prot.h> 61#include <rpcsvc/ypclnt.h> 62#endif 63#include <arpa/nameser.h> 64#include "un-namespace.h" 65 |
66extern int innetgr( const char *, const char *, const char *, const char * ); 67 68#define max(a, b) ((a > b) ? a : b) 69 70int __ivaliduser(FILE *, u_int32_t, const char *, const char *); 71int __ivaliduser_af(FILE *,const void *, const char *, const char *, int, int); 72int __ivaliduser_sa(FILE *, const struct sockaddr *, socklen_t, const char *, 73 const char *); --- 113 unchanged lines hidden (view full) --- 187 freeaddrinfo(res); 188 _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, 189 NULL); 190 return (-1); 191 } 192 if (nres > 1) { 193 int oerrno = errno; 194 |
195 getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, 196 sizeof(paddr), NULL, 0, NI_NUMERICHOST); |
197 (void)fprintf(stderr, "connect to address %s: ", 198 paddr); 199 errno = oerrno; 200 perror(0); 201 } 202 if ((ai = ai->ai_next) == NULL) { 203 /* refused && timo <= 16 */ 204 struct timespec time_to_sleep, time_remaining; 205 206 time_to_sleep.tv_sec = timo; 207 time_to_sleep.tv_nsec = 0; 208 (void)_nanosleep(&time_to_sleep, &time_remaining); 209 timo *= 2; 210 ai = res; 211 refused = 0; 212 } 213 if (nres > 1) { |
214 getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, 215 sizeof(paddr), NULL, 0, NI_NUMERICHOST); |
216 fprintf(stderr, "Trying %s...\n", paddr); 217 } 218 } 219 lport--; 220 if (fd2p == 0) { 221 _write(s, "", 1); 222 lport = 0; 223 } else { --- 479 unchanged lines hidden (view full) --- 703 if (hostok && userok) 704 return(0); 705 } 706 return (-1); 707} 708 709/* 710 * Returns "true" if match, 0 if no match. |
711 */ 712static int 713__icheckhost(raddr, salen, lhost) 714 const struct sockaddr *raddr; 715 socklen_t salen; 716 const char *lhost; 717{ 718 struct sockaddr_in sin; --- 12 unchanged lines hidden (view full) --- 731 sizeof(sin.sin_addr)); 732 raddr = (struct sockaddr *)&sin; 733 salen = sin.sin_len; 734 } 735 } 736 737 h1[0] = '\0'; 738 if (getnameinfo(raddr, salen, h1, sizeof(h1), NULL, 0, |
739 NI_NUMERICHOST) != 0) |
740 return (0); 741 742 /* Resolve laddr into sockaddr */ 743 memset(&hints, 0, sizeof(hints)); 744 hints.ai_family = raddr->sa_family; 745 hints.ai_socktype = SOCK_DGRAM; /*XXX dummy*/ 746 res = NULL; 747 error = getaddrinfo(lhost, "0", &hints, &res); 748 if (error) 749 return (0); 750 751 for (r = res; r ; r = r->ai_next) { 752 h2[0] = '\0'; 753 if (getnameinfo(r->ai_addr, r->ai_addrlen, h2, sizeof(h2), |
754 NULL, 0, NI_NUMERICHOST) != 0) |
755 continue; 756 if (strcmp(h1, h2) == 0) { 757 freeaddrinfo(res); 758 return (1); 759 } 760 } 761 762 /* No match. */ 763 freeaddrinfo(res); 764 return (0); 765} |