Skip to content

Commit

Permalink
vfilter modifications (#33)
Browse files Browse the repository at this point in the history
* vfilter modifications

1. vcfilter.c: allow both textual and numberical values for -c and -h option
2. vfilter_header.c: added function headerNumber() to convert textual filter
   name to filter number
3. vadddomain_handle.in: replace header, comparision numbers with textual
   names
4. vfilter.c, spam.c: replace fnmatch with matchregix from libqmail
5. configure.ac: Removed check for fnmatch
6. vfilter.c, vcfilter.c, variables.c, vfilter_insert.c: removed "Sender not
   in addressbook"

* updated RCS log

* updated vfilter

1. vdelivermail.c: prepend dot '.' to delivery folder if folder doesn't
   start with dot
2. vfilter_filterNo.c: start with filter no 1 for filter not matching
   'My ID not in To, Cc, Bcc'
3. vfilter_insert.c: handle negative header_num, empty keyword for
   'My ID not in To, Cc, Bcc'

* updated vfilter, vdelivermail

1. vdelivermail: Bounce mail if env variable BOUNCE_MAIL is set
2. vfilter.c: set BOUNCE_MAIL env variable to bounce mail using vdelivermail

* added vfilter tests

* removed duplicate tests
  • Loading branch information
mbhangui committed Sep 8, 2023
1 parent 96af794 commit 4768979
Show file tree
Hide file tree
Showing 17 changed files with 1,011 additions and 658 deletions.
4 changes: 2 additions & 2 deletions indimail-x/configure.ac
Expand Up @@ -90,7 +90,7 @@ CPPFLAGS=$saveCPPFLAGS
AC_CHECK_HEADERS([dirent.h limits.h sys/ioctl.h net/if.h linux/sockios.h sys/sockio.h])
AC_CHECK_HEADERS([openssl/evp.h sys/syscall.h sys/select.h sys/un.h])
AC_CHECK_HEADERS([crypt.h inttypes.h])
AC_CHECK_HEADERS([fnmatch.h udb.h elf.h magic.h a.out.h malloc.h sys/utsname.h sys/ipc.h asm/ioctls.h])
AC_CHECK_HEADERS([udb.h elf.h magic.h a.out.h malloc.h sys/utsname.h sys/ipc.h asm/ioctls.h])
AC_CHECK_HEADERS([gsasl.h])
AC_CHECK_HEADERS([sodium_random.h])

Expand All @@ -105,7 +105,7 @@ AC_TYPE_GETGROUPS

# Checks for library functions.
AC_FUNC_CHOWN
AC_CHECK_FUNCS(strsignal fdatasync sigaction sigprocmask fnmatch gethostname fchown getmntent getmntinfo setenv unsetenv rresvport)
AC_CHECK_FUNCS(strsignal fdatasync sigaction sigprocmask gethostname fchown getmntent getmntinfo setenv unsetenv rresvport)
defaultprefix="/usr"
if test x$prefix = xNONE
then
Expand Down
20 changes: 20 additions & 0 deletions indimail-x/doc/ChangeLog
Expand Up @@ -56,6 +56,26 @@ Release 3.4.5-1.1 Start 25/04/2023 End XX/XX/XXXX
28. parseAddress.c: handle address without domain component
29. storeHeader.c: return error if parseAddress is unsuccessful
30. vfilter.c: run vdelivermail if storeHeader is unsuccessful
05/09/2023
31. vcfilter.c: allow both textual and numberical values for -c and -h option
32. vfilter_header.c: added function headerNumber() to convert textual filter
name to filter number
33. vadddomain_handle.in: replace header, comparision numbers with textual
names
34. vfilter.c, spam.c: replace fnmatch with matchregex from libqmail
35. configure.ac: Removed check for fnmatch
36. vfilter.c, vcfilter.c, variables.c, vfilter_insert.c: removed "Sender not
in addressbook"
06/09/2023
37. vdelivermail.c: prepend dot '.' to delivery folder if folder doesn't start
with dot
38. vfilter_filterNo.c: start with filter no 1 for filter not matching 'My ID
not in To, Cc, Bcc'
39. vfilter_insert.c: handle negative header_num, empty keyword for 'My ID not
in To, Cc, Bcc'
07/09/2023
40. vdelivermail: Bounce mail if env variable BOUNCE_MAIL is set
41. vfilter.c: set BOUNCE_MAIL env variable to bounce mail using vdelivermail

* Sun Apr 23 2023 19:21:03 +0000 Manvendra Bhangui <indimail-virtualdomains@indimail.org> 3.4.4-1.1%{?dist}
Release 3.4.4-1.1 Start 26/03/2023 End 23/04/2023
Expand Down
6 changes: 5 additions & 1 deletion indimail-x/osh.c
@@ -1,5 +1,8 @@
/*
* $Log: osh.c,v $
* Revision 1.4 2023-09-05 21:47:22+05:30 Cprogrammer
* added return type for gethostname
*
* Revision 1.3 2022-10-20 11:58:04+05:30 Cprogrammer
* converted function prototype to ansic
*
Expand Down Expand Up @@ -33,7 +36,7 @@
*/

#ifndef lint
static char *rcsid = "@(#) $Id: osh.c,v 1.3 2022-10-20 11:58:04+05:30 Cprogrammer Exp mbhangui $";
static char *rcsid = "@(#) $Id: osh.c,v 1.4 2023-09-05 21:47:22+05:30 Cprogrammer Exp mbhangui $";
#endif

#ifdef HAVE_CONFIG_H
Expand Down Expand Up @@ -804,6 +807,7 @@ command(int *waitpid, int makepipe, int *pipepfd)
} /*- of command */

#ifndef HAVE_GETHOSTNAME
int
gethostname(char *host, int len)
{
struct utsname name;
Expand Down
39 changes: 6 additions & 33 deletions indimail-x/spam.c
@@ -1,5 +1,8 @@
/*
* $Log: spam.c,v $
* Revision 1.6 2023-09-05 21:47:40+05:30 Cprogrammer
* use matchregex from libqmail
*
* Revision 1.5 2023-03-20 10:18:16+05:30 Cprogrammer
* standardize getln handling
*
Expand Down Expand Up @@ -46,21 +49,20 @@
#include <error.h>
#include <subfd.h>
#include <getEnvConfig.h>
#include <matchregex.h>
#endif
#include "common.h"
#include "spam.h"
#include "wildmat.h"
#include "lowerit.h"

#ifndef lint
static char sccsid[] = "$Id: spam.c,v 1.5 2023-03-20 10:18:16+05:30 Cprogrammer Exp mbhangui $";
static char sccsid[] = "$Id: spam.c,v 1.6 2023-09-05 21:47:40+05:30 Cprogrammer Exp mbhangui $";
#endif

#define BADMAIL 1
#define BADRCPT 2
#define SPAMDB 3
#define REGCOMP(X,Y) regcomp(&X, Y, REG_EXTENDED|REG_ICASE)
#define REGEXEC(X,Y) regexec(&X, Y, (size_t)0, (regmatch_t *)0, (int)0)

static char *parseLine1(char *);
static char *parseLine2(char *);
Expand All @@ -70,35 +72,6 @@ static maddr **spammer_hash;
static maddr **ignored_hash;
static int bounce, maxaddr;

static int
matchregex(char *text, char *regex)
{
regex_t qreg;
char errbuf[512];
int retval = 0;

/*- build the regex */
if ((retval = REGCOMP(qreg, regex)) != 0) {
regerror(retval, &qreg, errbuf, sizeof(errbuf));
regfree(&qreg);
strerr_warn5(text, ": ", regex, ": ", errbuf, 0);
return (-retval);
}
/*- execute the regex */
if ((retval = REGEXEC(qreg, text)) != 0) {
/*- did we just not match anything? */
if (retval == REG_NOMATCH) {
regfree(&qreg);
return (0);
}
regfree(&qreg);
return (-retval);
}
/*- signal the match */
regfree(&qreg);
return (1);
}

static void
die_nomem()
{
Expand Down Expand Up @@ -497,7 +470,7 @@ isIgnored(char *email)
!stralloc_0(&pattern))
die_nomem();
}
if (matchregex(email, pattern.s) == 1)
if (matchregex(email, pattern.s, 0) == 1)
return (1);
} else {
if (*(p->mail) == '@')
Expand Down

0 comments on commit 4768979

Please sign in to comment.