diff options
author | Ian C <ianc@noddybox.co.uk> | 2004-06-05 01:09:58 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2004-06-05 01:09:58 +0000 |
commit | 4a6391ce910b5f71574e20b31f1e9429d756b96d (patch) | |
tree | e6866cc37946ca2ca69d9719cd5f8e30311fe2dc /src/dbase.c | |
parent | c378e8f900d85d59a8a616bf0b8b14e426d898e1 (diff) |
Fixed checking of trusted users. Tweaks to compile under FreeBSD 4.10. Added
debug output option.
Diffstat (limited to 'src/dbase.c')
-rw-r--r-- | src/dbase.c | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/src/dbase.c b/src/dbase.c index e1caa04..563de25 100644 --- a/src/dbase.c +++ b/src/dbase.c @@ -35,6 +35,7 @@ static const char id[]="$Id$"; #include "dbase.h" #include "dstring.h" #include "config.h" +#include "debug.h" #include "util.h" static const char header_id[]=KBS_DBASE_H; @@ -77,17 +78,27 @@ static DString reason=NULL; /* ---------------------------------------- PRVIVATE FUNCTIONS */ -static int IsTrustedUser(const char *username) +static int IsTrustedUser(const char *username, const char *domain) { + char *p; int f; + int res=FALSE; - for(f=0;f<no_trusted_users;f++) + p=CopyStr(username); + p=CatStr(p,"@"); + p=CatStr(p,domain); + + for(f=0;f<no_trusted_users && !res;f++) { - if (strcasecmp(username,trusted_user[f])==0) - return TRUE; + if (strcasecmp(p,trusted_user[f])==0) + { + res=TRUE; + } } - return FALSE; + free(p); + + return res; } @@ -252,6 +263,14 @@ int DBBlockMessage(const POP3Message *msg) int f; int show; + KBSDEBUG(("msg.id=%d\n",msg->id)); + KBSDEBUG(("msg.to='%s'\n",msg->to)); + KBSDEBUG(("msg.from='%s'\n",msg->from)); + KBSDEBUG(("msg.from_uname='%s'\n",msg->from_uname)); + KBSDEBUG(("msg.from_domain='%s'\n",msg->from_domain)); + KBSDEBUG(("msg.subject='%s'\n",msg->subject)); + KBSDEBUG(("msg.content_type='%s'\n",msg->content_type)); + show=ConfigInt(CONFIG_SHOWMATCH); reason=DSReset(reason); @@ -259,7 +278,7 @@ int DBBlockMessage(const POP3Message *msg) if (IsTrustedDomain(msg->from_domain)) return FALSE; - if (IsTrustedUser(msg->from_uname)) + if (IsTrustedUser(msg->from_uname,msg->from_domain)) return FALSE; if (ConfigInt(CONFIG_BLOCKHTML) && @@ -428,7 +447,7 @@ void DBClose(void) free(t->allow); - for(f=0;f<t->no_allow;f++) + for(f=0;f<t->no_allow_to;f++) REFree(t->allow_to[f]); free(t->allow_to); @@ -445,4 +464,46 @@ void DBClose(void) } +void DBDump(void) +{ + Domain *d; + int f; + + for(f=0;f<no_trusted_domains;f++) + KBSDEBUG(("trusted_domain[%d]='%s'\n",f,trusted_domain[f])); + + for(f=0;f<no_trusted_users;f++) + KBSDEBUG(("trusted_user[%d]='%s'\n",f,trusted_user[f])); + + for(f=0;f<no_blacklist;f++) + KBSDEBUG(("blacklist[%d]='%s'\n",f,blacklist[f])); + + d=head; + + while(d) + { + KBSDEBUG(("DOMAIN '%s' default:%s\n", + d->name,d->def_block ? "block":"allow")); + + for(f=0;f<d->no_user;f++) + KBSDEBUG((" user[%d]='%s'\n", + f,d->user[f])); + + for(f=0;f<d->no_block;f++) + KBSDEBUG((" block[%d]='%s'\n", + f,REGetExpression(d->block[f]))); + + for(f=0;f<d->no_allow;f++) + KBSDEBUG((" allow[%d]='%s'\n", + f,REGetExpression(d->allow[f]))); + + for(f=0;f<d->no_allow_to;f++) + KBSDEBUG((" allow_to[%d]='%s'\n", + f,REGetExpression(d->allow_to[f]))); + + d=d->next; + } +} + + /* END OF FILE */ |