ftpd.c (60929) | ftpd.c (62100) |
---|---|
1/* 2 * Copyright (c) 1985, 1988, 1990, 1992, 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 --- 30 unchanged lines hidden (view full) --- 39#endif /* not lint */ 40#endif 41 42#ifndef lint 43#if 0 44static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; 45#endif 46static const char rcsid[] = | 1/* 2 * Copyright (c) 1985, 1988, 1990, 1992, 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 --- 30 unchanged lines hidden (view full) --- 39#endif /* not lint */ 40#endif 41 42#ifndef lint 43#if 0 44static char sccsid[] = "@(#)ftpd.c 8.4 (Berkeley) 4/16/94"; 45#endif 46static const char rcsid[] = |
47 "$FreeBSD: head/libexec/ftpd/ftpd.c 60929 2000-05-25 19:30:18Z nsayer $"; | 47 "$FreeBSD: head/libexec/ftpd/ftpd.c 62100 2000-06-26 05:36:09Z davidn $"; |
48#endif /* not lint */ 49 50/* 51 * FTP server. 52 */ 53#include <sys/param.h> 54#include <sys/stat.h> 55#include <sys/ioctl.h> --- 582 unchanged lines hidden (view full) --- 638 hrp->hostinfo = res; 639 hrp->statfile = _PATH_FTPDSTATFILE; 640 hrp->welcome = _PATH_FTPWELCOME; 641 hrp->loginmsg = _PATH_FTPLOGINMESG; 642 hrp->anonuser = "ftp"; 643 hrp->next = NULL; 644 thishost = firsthost = lhrp = hrp; 645 if ((fp = fopen(_PATH_FTPHOSTS, "r")) != NULL) { | 48#endif /* not lint */ 49 50/* 51 * FTP server. 52 */ 53#include <sys/param.h> 54#include <sys/stat.h> 55#include <sys/ioctl.h> --- 582 unchanged lines hidden (view full) --- 638 hrp->hostinfo = res; 639 hrp->statfile = _PATH_FTPDSTATFILE; 640 hrp->welcome = _PATH_FTPWELCOME; 641 hrp->loginmsg = _PATH_FTPLOGINMESG; 642 hrp->anonuser = "ftp"; 643 hrp->next = NULL; 644 thishost = firsthost = lhrp = hrp; 645 if ((fp = fopen(_PATH_FTPHOSTS, "r")) != NULL) { |
646 int addrsize, error; | 646 int addrsize, error, gothost; |
647 void *addr; 648 struct hostent *hp; 649 650 while (fgets(line, sizeof(line), fp) != NULL) { 651 int i, hp_error; 652 653 if ((cp = strchr(line, '\n')) == NULL) { 654 /* ignore long lines */ --- 10 unchanged lines hidden (view full) --- 665 666 hints.ai_flags = 0; 667 hints.ai_family = AF_UNSPEC; 668 hints.ai_flags = AI_PASSIVE; 669 error = getaddrinfo(cp, NULL, &hints, &res); 670 if (error != NULL) 671 continue; 672 for (ai = res; ai != NULL && ai->ai_addr != NULL; | 647 void *addr; 648 struct hostent *hp; 649 650 while (fgets(line, sizeof(line), fp) != NULL) { 651 int i, hp_error; 652 653 if ((cp = strchr(line, '\n')) == NULL) { 654 /* ignore long lines */ --- 10 unchanged lines hidden (view full) --- 665 666 hints.ai_flags = 0; 667 hints.ai_family = AF_UNSPEC; 668 hints.ai_flags = AI_PASSIVE; 669 error = getaddrinfo(cp, NULL, &hints, &res); 670 if (error != NULL) 671 continue; 672 for (ai = res; ai != NULL && ai->ai_addr != NULL; |
673 ai = ai->ai_next) 674 { | 673 ai = ai->ai_next) { |
675 | 674 |
675 gothost = 0; |
|
676 for (hrp = firsthost; hrp != NULL; hrp = hrp->next) { 677 struct addrinfo *hi; 678 679 for (hi = hrp->hostinfo; hi != NULL; 680 hi = hi->ai_next) 681 if (hi->ai_addrlen == ai->ai_addrlen && 682 memcmp(hi->ai_addr, 683 ai->ai_addr, | 676 for (hrp = firsthost; hrp != NULL; hrp = hrp->next) { 677 struct addrinfo *hi; 678 679 for (hi = hrp->hostinfo; hi != NULL; 680 hi = hi->ai_next) 681 if (hi->ai_addrlen == ai->ai_addrlen && 682 memcmp(hi->ai_addr, 683 ai->ai_addr, |
684 ai->ai_addr->sa_len) == 0) | 684 ai->ai_addr->sa_len) == 0) { 685 gothost++; |
685 break; | 686 break; |
687 } 688 if (gothost) 689 break; |
|
686 } 687 if (hrp == NULL) { 688 if ((hrp = malloc(sizeof(struct ftphost))) == NULL) 689 continue; 690 /* defaults */ 691 hrp->statfile = _PATH_FTPDSTATFILE; 692 hrp->welcome = _PATH_FTPWELCOME; 693 hrp->loginmsg = _PATH_FTPLOGINMESG; --- 94 unchanged lines hidden (view full) --- 788 IN6_IS_ADDR_V4MAPPED(&su->su_sin6.sin6_addr)) 789 mapped_in6 = &su->su_sin6.sin6_addr; 790#endif 791 792 hrp = thishost = firsthost; /* default */ 793 port = su->su_port; 794 su->su_port = 0; 795 while (hrp != NULL) { | 690 } 691 if (hrp == NULL) { 692 if ((hrp = malloc(sizeof(struct ftphost))) == NULL) 693 continue; 694 /* defaults */ 695 hrp->statfile = _PATH_FTPDSTATFILE; 696 hrp->welcome = _PATH_FTPWELCOME; 697 hrp->loginmsg = _PATH_FTPLOGINMESG; --- 94 unchanged lines hidden (view full) --- 792 IN6_IS_ADDR_V4MAPPED(&su->su_sin6.sin6_addr)) 793 mapped_in6 = &su->su_sin6.sin6_addr; 794#endif 795 796 hrp = thishost = firsthost; /* default */ 797 port = su->su_port; 798 su->su_port = 0; 799 while (hrp != NULL) { |
796 for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next) 797 { | 800 for (hi = hrp->hostinfo; hi != NULL; hi = hi->ai_next) { |
798 if (memcmp(su, hi->ai_addr, hi->ai_addrlen) == 0) { 799 thishost = hrp; 800 break; 801 } 802#ifdef INET6 803 /* XXX IPv4 mapped IPv6 addr consideraton */ 804 if (hi->ai_addr->sa_family == AF_INET && mapped_in6 != NULL && 805 (memcmp(&mapped_in6->s6_addr[12], 806 &((struct sockaddr_in *)hi->ai_addr)->sin_addr, 807 sizeof(struct in_addr)) == 0)) { 808 thishost = hrp; 809 break; 810 } 811#endif | 801 if (memcmp(su, hi->ai_addr, hi->ai_addrlen) == 0) { 802 thishost = hrp; 803 break; 804 } 805#ifdef INET6 806 /* XXX IPv4 mapped IPv6 addr consideraton */ 807 if (hi->ai_addr->sa_family == AF_INET && mapped_in6 != NULL && 808 (memcmp(&mapped_in6->s6_addr[12], 809 &((struct sockaddr_in *)hi->ai_addr)->sin_addr, 810 sizeof(struct in_addr)) == 0)) { 811 thishost = hrp; 812 break; 813 } 814#endif |
812 } 813 hrp = hrp->next; | 815 } 816 hrp = hrp->next; |
814 } 815 su->su_port = port; 816 /* setup static variables as appropriate */ 817 hostname = thishost->hostname; 818 ftpuser = thishost->anonuser; 819} 820#endif 821 --- 1963 unchanged lines hidden --- | 817 } 818 su->su_port = port; 819 /* setup static variables as appropriate */ 820 hostname = thishost->hostname; 821 ftpuser = thishost->anonuser; 822} 823#endif 824 --- 1963 unchanged lines hidden --- |