version 1.6 | | version 1.7 |
---|
| | |
/* | | /* |
* static char *rcsid_ban_c = | | * static char *rcsid_ban_c = |
* "$Id: ban.c,v 1.6 2002/09/07 22:08:07 mwedel Exp $"; | | * "$Id: ban.c,v 1.7 2003/07/26 02:10:40 temitchell Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
char *indexpos; | | char *indexpos; |
int num1; | | int num1; |
int Hits=0; /* Hits==2 means we're banned */ | | int Hits=0; /* Hits==2 means we're banned */ |
| | int loop=0; |
| | |
| | while (loop < 2) { /* have to check both ban files now */ |
| | |
| | /* First time through look for BANFILE */ |
| | |
| | if (loop == 0){ |
sprintf (buf, "%s/%s", settings.confdir, BANFILE); | | sprintf (buf, "%s/%s", settings.confdir, BANFILE); |
if ((bannedfile = fopen(buf, "r")) == NULL) { | | if ((bannedfile = fopen(buf, "r")) == NULL) { |
LOG (llevDebug, "Could not find file Banned file.\n"); | | LOG (llevDebug, "Could not find file Banned file\n"); |
| | loop++; |
| | } |
| | } |
| | |
| | /* Second time through look for BANISHFILE */ |
| | |
| | if (loop == 1){ |
| | sprintf (buf, "%s/%s", settings.localdir, BANISHFILE); |
| | if ((bannedfile = fopen(buf, "r")) == NULL) { |
| | LOG (llevDebug, "Could not find file Banish file\n"); |
return(0); | | return(0); |
} | | } |
| | } |
| | |
| | /* Do the actual work here checking for banned IPs */ |
| | |
while(fgets(line_buf, 160, bannedfile) != NULL) { | | while(fgets(line_buf, 160, bannedfile) != NULL) { |
/* Split line up */ | | /* Split line up */ |
if((*line_buf=='#')||(*line_buf=='\n')) | | if((*line_buf=='#')||(*line_buf=='\n')) |
| | |
fclose(bannedfile); | | fclose(bannedfile); |
if(Hits>=2) | | if(Hits>=2) |
return(1); | | return(1); |
else | | loop++; |
| | } |
return(0); | | return(0); |
} | | } |