rcmd.c (141920) | rcmd.c (146187) |
---|---|
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> | 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 141920 2005-02-14 17:51:45Z stefanf $"); | 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 | 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 |
66/* wrapper for KAME-special getnameinfo() */ 67#ifndef NI_WITHSCOPEID 68#define NI_WITHSCOPEID 0 69#endif 70 | |
71extern int innetgr( const char *, const char *, const char *, const char * ); 72 73#define max(a, b) ((a > b) ? a : b) 74 75int __ivaliduser(FILE *, u_int32_t, const char *, const char *); 76int __ivaliduser_af(FILE *,const void *, const char *, const char *, int, int); 77int __ivaliduser_sa(FILE *, const struct sockaddr *, socklen_t, const char *, 78 const char *); --- 113 unchanged lines hidden (view full) --- 192 freeaddrinfo(res); 193 _sigprocmask(SIG_SETMASK, (const sigset_t *)&oldmask, 194 NULL); 195 return (-1); 196 } 197 if (nres > 1) { 198 int oerrno = errno; 199 | 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 |
200 getnameinfo(ai->ai_addr, ai->ai_addrlen, 201 paddr, sizeof(paddr), 202 NULL, 0, 203 NI_NUMERICHOST|NI_WITHSCOPEID); | 195 getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, 196 sizeof(paddr), NULL, 0, NI_NUMERICHOST); |
204 (void)fprintf(stderr, "connect to address %s: ", 205 paddr); 206 errno = oerrno; 207 perror(0); 208 } 209 if ((ai = ai->ai_next) == NULL) { 210 /* refused && timo <= 16 */ 211 struct timespec time_to_sleep, time_remaining; 212 213 time_to_sleep.tv_sec = timo; 214 time_to_sleep.tv_nsec = 0; 215 (void)_nanosleep(&time_to_sleep, &time_remaining); 216 timo *= 2; 217 ai = res; 218 refused = 0; 219 } 220 if (nres > 1) { | 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) { |
221 getnameinfo(ai->ai_addr, ai->ai_addrlen, 222 paddr, sizeof(paddr), 223 NULL, 0, 224 NI_NUMERICHOST|NI_WITHSCOPEID); | 214 getnameinfo(ai->ai_addr, ai->ai_addrlen, paddr, 215 sizeof(paddr), NULL, 0, NI_NUMERICHOST); |
225 fprintf(stderr, "Trying %s...\n", paddr); 226 } 227 } 228 lport--; 229 if (fd2p == 0) { 230 _write(s, "", 1); 231 lport = 0; 232 } else { --- 479 unchanged lines hidden (view full) --- 712 if (hostok && userok) 713 return(0); 714 } 715 return (-1); 716} 717 718/* 719 * Returns "true" if match, 0 if no match. | 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. |
720 * 721 * NI_WITHSCOPEID is useful for comparing sin6_scope_id portion 722 * if af == AF_INET6. | |
723 */ 724static int 725__icheckhost(raddr, salen, lhost) 726 const struct sockaddr *raddr; 727 socklen_t salen; 728 const char *lhost; 729{ 730 struct sockaddr_in sin; --- 12 unchanged lines hidden (view full) --- 743 sizeof(sin.sin_addr)); 744 raddr = (struct sockaddr *)&sin; 745 salen = sin.sin_len; 746 } 747 } 748 749 h1[0] = '\0'; 750 if (getnameinfo(raddr, salen, h1, sizeof(h1), NULL, 0, | 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, |
751 NI_NUMERICHOST | NI_WITHSCOPEID) != 0) | 739 NI_NUMERICHOST) != 0) |
752 return (0); 753 754 /* Resolve laddr into sockaddr */ 755 memset(&hints, 0, sizeof(hints)); 756 hints.ai_family = raddr->sa_family; 757 hints.ai_socktype = SOCK_DGRAM; /*XXX dummy*/ 758 res = NULL; 759 error = getaddrinfo(lhost, "0", &hints, &res); 760 if (error) 761 return (0); 762 763 for (r = res; r ; r = r->ai_next) { 764 h2[0] = '\0'; 765 if (getnameinfo(r->ai_addr, r->ai_addrlen, h2, sizeof(h2), | 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), |
766 NULL, 0, NI_NUMERICHOST | NI_WITHSCOPEID) != 0) | 754 NULL, 0, NI_NUMERICHOST) != 0) |
767 continue; 768 if (strcmp(h1, h2) == 0) { 769 freeaddrinfo(res); 770 return (1); 771 } 772 } 773 774 /* No match. */ 775 freeaddrinfo(res); 776 return (0); 777} | 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} |