Search
j0ke.net Open Build Service
>
Projects
>
server:ftp
>
pure-ftpd
> pureftpd-geoip.diff
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File pureftpd-geoip.diff of Package pure-ftpd (Revision 16)
Currently displaying revision
16
,
show latest
diff -ur pure-ftpd-1.0.21/src/Makefile.am pure-ftpd-1.0.21-geoip/src/Makefile.am --- pure-ftpd-1.0.21/src/Makefile.am Thu May 19 09:36:52 2005 +++ pure-ftpd-1.0.21-geoip/src/Makefile.am Tue Aug 26 00:02:05 2008 @@ -16,7 +16,7 @@ pure_ftpd_LDADD = \ ../puredb/src/libpuredb_read.a \ - @LDAP_SSL_LIBS@ @GETLOADAVG_LIBS@ @BONJOUR_LDADD@ + @LDAP_SSL_LIBS@ @GETLOADAVG_LIBS@ @BONJOUR_LDADD@ -lGeoIP pure_ftpd_CFLAGS = -DINCLUDE_IO_WRAPPERS=1 diff -ur pure-ftpd-1.0.21/src/Makefile.in pure-ftpd-1.0.21-geoip/src/Makefile.in --- pure-ftpd-1.0.21/src/Makefile.in Sun Feb 19 15:33:04 2006 +++ pure-ftpd-1.0.21-geoip/src/Makefile.in Tue Aug 26 00:02:18 2008 @@ -222,7 +222,7 @@ target_alias = @target_alias@ pure_ftpd_LDADD = \ ../puredb/src/libpuredb_read.a \ - @LDAP_SSL_LIBS@ @GETLOADAVG_LIBS@ @BONJOUR_LDADD@ + @LDAP_SSL_LIBS@ @GETLOADAVG_LIBS@ @BONJOUR_LDADD@ -lGeoIP pure_ftpd_CFLAGS = -DINCLUDE_IO_WRAPPERS=1 pure_ftpd_SOURCES = \ diff -ur pure-ftpd-1.0.21/src/ftpd.c pure-ftpd-1.0.21-geoip/src/ftpd.c --- pure-ftpd-1.0.21/src/ftpd.c Tue Feb 21 14:14:49 2006 +++ pure-ftpd-1.0.21-geoip/src/ftpd.c Tue Aug 26 00:24:16 2008 @@ -33,6 +33,7 @@ #ifdef WITH_OSX_BONJOUR # include "osx-extensions.h" #endif +#include "GeoIP.h" #ifdef WITH_DMALLOC # include <dmalloc.h> @@ -4449,9 +4450,10 @@ die(421, LOG_ERR, MSG_GETPEERNAME ": %s" , strerror(errno)); } fourinsix(&peer); - if (checkvalidaddr(&peer) == 0) { + if (checkvalidaddr(&peer) == 0 || STORAGE_FAMILY(ctrlconn) != AF_INET) { die(425, LOG_ERR, MSG_INVALID_IP); } + resolve_hostnames = 0; #ifndef DONT_LOG_IP for (;;) { int eai; @@ -4485,6 +4487,37 @@ *host = '?'; host[1] = 0; #endif + do { + char line[LINE_MAX]; + GeoIP *gi; + const char *country; + char *sep; + int found = 0; + FILE *fp; + + gi = GeoIP_new(GEOIP_STANDARD); + country = GeoIP_country_code_by_name(gi, host); + if (country == NULL || *country == 0 || + !(fp = fopen(CONFDIR "/pureftpd-restricted-countries.txt", "r"))) { + break; + } + while (fgets(line, sizeof line, fp) != NULL) { + if (*line == '#') { + continue; + } + if ((sep = strchr(line, '\n')) != NULL) { + *sep = 0; + } + if (strcasecmp(line, country) == 0) { + found++; + break; + } + } + fclose(fp); + if (found == 0) { + die(425, LOG_ERR, MSG_INVALID_IP); + } + } while(0); iptropize(&peer); logfile(LOG_INFO, MSG_NEW_CONNECTION, host);