Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 199428 - mail-filter/dspam new patches
Summary: mail-filter/dspam new patches
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Alin Năstac (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-17 11:40 UTC by steveb
Modified: 2007-11-25 14:59 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
mail-filter/dspam/dspam-3.8.0-r8.ebuild (dspam-3.8.0-r8.ebuild,19.98 KB, text/plain)
2007-11-17 11:43 UTC, steveb
Details
files/dspam-3.8.0-blocklist.patch (dspam-3.8.0-blocklist.patch,389 bytes, patch)
2007-11-17 11:43 UTC, steveb
Details | Diff
files/dspam-3.8.0-dspam_train.patch (dspam-3.8.0-dspam_train.patch,3.77 KB, patch)
2007-11-17 11:43 UTC, steveb
Details | Diff
files/dspam-3.8.0-eol.patch (dspam-3.8.0-eol.patch,1.22 KB, patch)
2007-11-17 11:44 UTC, steveb
Details | Diff
files/dspam-3.8.0-mysql_reconnect.patch (dspam-3.8.0-mysql_reconnect.patch,598 bytes, patch)
2007-11-17 11:44 UTC, steveb
Details | Diff
files/dspam-3.8.0-nosuchuser.patch (dspam-3.8.0-nosuchuser.patch,2.33 KB, patch)
2007-11-17 11:44 UTC, steveb
Details | Diff
files/dspam-3.8.0-notification_path.patch (dspam-3.8.0-notification_path.patch,1.01 KB, patch)
2007-11-17 11:45 UTC, steveb
Details | Diff
files/dspam-3.8.0-src_client.c.patch (dspam-3.8.0-src_client.c.patch,782 bytes, patch)
2007-11-17 11:45 UTC, steveb
Details | Diff
files/dspam-3.8.0-src_dspam.c.patch (dspam-3.8.0-src_dspam.c.patch,1.06 KB, patch)
2007-11-17 11:45 UTC, steveb
Details | Diff
files/dspam-3.8.0-better_error_handling.patch (dspam-3.8.0-better_error_handling.patch,1.83 KB, patch)
2007-11-18 19:53 UTC, steveb
Details | Diff
files/dspam-3.8.0-mysql_reconnect.patch (dspam-3.8.0-mysql_reconnect.patch,2.17 KB, patch)
2007-11-18 19:54 UTC, steveb
Details | Diff
files/dspam-3.8.0-better_error_handling.patch (dspam-3.8.0-better_error_handling.patch,1.35 KB, patch)
2007-11-21 11:54 UTC, steveb
Details | Diff
files/dspam-3.8.0-group_member_matching.patch (dspam-3.8.0-group_member_matching.patch,575 bytes, patch)
2007-11-21 12:14 UTC, steveb
Details | Diff
files/dspam-3.8.0-linking_against_libdspam.patch (dspam-3.8.0-linking_against_libdspam.patch,2.16 KB, patch)
2007-11-22 06:24 UTC, steveb
Details | Diff
files/dspam-3.8.0-use_libdspam.patch (dspam-3.8.0-use_libdspam.patch,2.00 KB, patch)
2007-11-22 06:31 UTC, steveb
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description steveb 2007-11-17 11:40:22 UTC
New patches to make DSPAM work better with newer editions of MySQL and QMail.

Reproducible: Always
Comment 1 steveb 2007-11-17 11:43:07 UTC
Created attachment 136141 [details]
mail-filter/dspam/dspam-3.8.0-r8.ebuild

New DSPAM ebuild with following changes:
--- dspam-3.8.0-r8.ebuild       2007-11-17 10:49:15.788190750 +0100
+++ /usr/portage/mail-filter/dspam/dspam-3.8.0-r7.ebuild        2007-11-05 18:06:18.000000000 +0100
@@ -1,6 +1,6 @@
 # Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: Exp $
+# $Header: /var/cvsroot/gentoo-x86/mail-filter/dspam/dspam-3.8.0-r7.ebuild,v 1.6 2007/11/05 16:57:04 armin76 Exp $

 WANT_AUTOCONF="latest"
 WANT_AUTOMAKE="latest"
@@ -66,26 +66,6 @@
        EPATCH_SUFFIX="patch"
        epatch "${WORKDIR}"/patches

-       # Add MySQLReconnect option
-       epatch "${FILESDIR}"/${PN}-${PV}-mysql_reconnect.patch
-
-       # Fix domain blocklisting
-       epatch "${FILESDIR}"/${PN}-${PV}-blocklist.patch
-
-       # Fix non existent path for notification
-       epatch "${FILESDIR}"/${PN}-${PV}-notification_path.patch
-
-       # Fix dspam_train
-       epatch "${FILESDIR}"/${PN}-${PV}-dspam_train.patch
-
-       # Fix various problems with QMail
-       epatch "${FILESDIR}"/${PN}-${PV}-eol.patch
-       epatch "${FILESDIR}"/${PN}-${PV}-src_client.c.patch
-       epatch "${FILESDIR}"/${PN}-${PV}-src_dspam.c.patch
-
-       # Fix problem with unknown users
-       epatch "${FILESDIR}"/${PN}-${PV}-nosuchuser.patch
-
        # Fix Lazy bindings
        append-flags $(bindnow-flags)

@@ -280,12 +260,6 @@
                        -i "${D}/${DSPAM_CONFDIR}"/dspam.conf
        fi

-       # Add MySQLReconnect option after MySQLCompress
-       if ! ( grep -iqe "^#*MySQLReconnect[[:space:]]" "${D}"/${CONFDIR}/dspam.conf ) ; then
-               sed -e "s:^\(\(#*\)MySQLCompress[\t ].*\):\1\n\2MySQLReconnect\t\ttrue:" \
-                       -i "${D}"/${DSPAM_CONFDIR}/dspam.conf
-       fi
-
        # installs the notification messages
        # -> The documentation is wrong! The files need to be in ./txt
        echo "Scanned and tagged as SPAM with DSPAM ${PV} by Your ISP.com">"${T}"/msgtag.spam
Comment 2 steveb 2007-11-17 11:43:43 UTC
Created attachment 136143 [details, diff]
files/dspam-3.8.0-blocklist.patch
Comment 3 steveb 2007-11-17 11:43:58 UTC
Created attachment 136145 [details, diff]
files/dspam-3.8.0-dspam_train.patch
Comment 4 steveb 2007-11-17 11:44:11 UTC
Created attachment 136146 [details, diff]
files/dspam-3.8.0-eol.patch
Comment 5 steveb 2007-11-17 11:44:46 UTC
Created attachment 136147 [details, diff]
files/dspam-3.8.0-mysql_reconnect.patch
Comment 6 steveb 2007-11-17 11:44:59 UTC
Created attachment 136149 [details, diff]
files/dspam-3.8.0-nosuchuser.patch
Comment 7 steveb 2007-11-17 11:45:11 UTC
Created attachment 136150 [details, diff]
files/dspam-3.8.0-notification_path.patch
Comment 8 steveb 2007-11-17 11:45:28 UTC
Created attachment 136151 [details, diff]
files/dspam-3.8.0-src_client.c.patch
Comment 9 steveb 2007-11-17 11:45:38 UTC
Created attachment 136153 [details, diff]
files/dspam-3.8.0-src_dspam.c.patch
Comment 10 Alin Năstac (RETIRED) gentoo-dev 2007-11-18 09:45:38 UTC
Because we need to apply a large number of patches, I've made a tarball with these patches.

In order to incorporate these new patches into the tarball, they must have a proper name. Names like "src_client.c.patch" aren't proper, so please rename them so I could understand easily what purpose do they serve.
Comment 11 steveb 2007-11-18 17:47:08 UTC
(In reply to comment #10)
> Because we need to apply a large number of patches, I've made a tarball with
> these patches.
>
I know.

 
> In order to incorporate these new patches into the tarball, they must have a
> proper name. Names like "src_client.c.patch" aren't proper, so please rename
> them so I could understand easily what purpose do they serve.
> 
Okay. Will fix that. Give me time to finish cooking my Fondue and eat it. After that I will fix the issue with the patch naming convention.
Comment 12 steveb 2007-11-18 19:53:43 UTC
Created attachment 136318 [details, diff]
files/dspam-3.8.0-better_error_handling.patch
Comment 13 steveb 2007-11-18 19:54:14 UTC
Created attachment 136320 [details, diff]
files/dspam-3.8.0-mysql_reconnect.patch
Comment 14 steveb 2007-11-18 19:55:14 UTC
Comment on attachment 136141 [details]
mail-filter/dspam/dspam-3.8.0-r8.ebuild

Not needed any more.
Comment 15 steveb 2007-11-18 20:00:13 UTC
Okay. Fixed the naming of the patches and moved some stuff into a patch instead of using GNU sed to modify dspam.conf. Now no changes are needed to the structure of the ebuild. Just add the patches into the archive and reference the new patch-archive and all is done :)

I am running since months on those patches. They work all fine on my installation (but I am in no way a reference for all DSPAM users out there).

Most of the patches do fix stuff or enhance the way DSPAM handles error conditions. None of the patches do remove functionality or change fundamentally how DSPAM works.
Comment 16 Alin Năstac (RETIRED) gentoo-dev 2007-11-20 22:21:15 UTC
All patches looks OK by me, except  the better_error_handling.patch. I think the last hunk should be:
+            if (!strcmp (user, username) || !strncmp(user, "*") ||
+               (!strncmp(user, "*@", 2) && !strcmp(user+1, strchr(username,'@'))))

Am I right? 
Comment 17 steveb 2007-11-20 23:27:06 UTC
(In reply to comment #16)
> All patches looks OK by me, except  the better_error_handling.patch. I think
> the last hunk should be:
> +            if (!strcmp (user, username) || !strncmp(user, "*") ||
> +               (!strncmp(user, "*@", 2) && !strcmp(user+1,
> strchr(username,'@'))))
> 
> Am I right? 
> 
I don't think so. The second strncmp will trigger under unwanted conditions. The original one is more narrow.
Comment 18 steveb 2007-11-20 23:29:22 UTC
(In reply to comment #17)
> (In reply to comment #16)
> > All patches looks OK by me, except  the better_error_handling.patch. I think
> > the last hunk should be:
> > +            if (!strcmp (user, username) || !strncmp(user, "*") ||
> > +               (!strncmp(user, "*@", 2) && !strcmp(user+1,
> > strchr(username,'@'))))
> > 
> > Am I right? 
> > 
> I don't think so. The second strncmp will trigger under unwanted conditions.
> The original one is more narrow.
> 
btw: If this is last hunk is a problem, then leave it out. It is not so ultra important.
Comment 19 Alin Năstac (RETIRED) gentoo-dev 2007-11-21 06:03:51 UTC
I cannot remove the hunk entirely because the original version have problems. 

IMO the condition that author wanted to implement was this:
  user == username || user == "*" || user == "*@domain_part_of_the_username"
You say that second condition should be user == "*anything_else_as_long_as_it_doesn_t_start_with_@", which doesn't make sense to me.
Comment 20 steveb 2007-11-21 11:29:38 UTC
(In reply to comment #19)
> I cannot remove the hunk entirely because the original version have problems. 
> 
> IMO the condition that author wanted to implement was this:
>   user == username || user == "*" || user == "*@domain_part_of_the_username"
> You say that second condition should be user ==
> "*anything_else_as_long_as_it_doesn_t_start_with_@", which doesn't make sense
> to me.
> 
You are right! It does not make sense. The patched code is handling groups and username is passed as a parameter to the function and it holds the real username (aka: user@domain.tld). While variable user holds the parsed users from a group. user can be "*" (matching all users) and it could be "*@domain.tld" (matching all users from one domain).

I can't remember why I have added this code to the group handling. The only thing I can remember was that on the DSPAM mailing list a user had problems with wrong username handling with groups. The patch resulted from this problem. But I really can not remember now why this stupid handling. Especially since the variable "user" is the parsed result from reading the group file.
Comment 21 steveb 2007-11-21 11:42:03 UTC
Okay. Now I see the problem. Here a small c code for testing:
netbox cdadmin # cat dspam-test.c
int main(int argc, char *argv[]){
        if( argc < 3 ) {
                printf("USAGE: %s <username> <user>\n", argv[0]);
                return 1;
        }
        char *username = argv[1];
        char *user = argv[2];

        printf("Username: %s\n", username);
        printf("User: %s\n\n", user);

        if (!strcmp (user, username) || user[0] == '*' ||
           (!strncmp(user, "*@", 2) && !strcmp(user+2, strchr(username,'@'))))
        {
                printf("Matching original code\n");
        }
        if (!strcmp (user, username) || (user[0] == '*' && strncmp(user, "*@", 2)) ||
           (!strncmp(user, "*@", 2) && !strcmp(user+1, strchr(username,'@'))))
        {
                printf("Matching new code\n");
        }
}
netbox cdadmin # gcc dspam-test.c -o dspam-test
netbox cdadmin # ./dspam-test user@domain.tld "*@"
Username: user@domain.tld
User: *@

Matching original code
netbox cdadmin # ./dspam-test user@domain.tld "*@domain.tld"
Username: user@domain.tld
User: *@domain.tld

Matching original code
Matching new code
netbox cdadmin # ./dspam-test user@domain.tld "*whatever@domain.tld"
Username: user@domain.tld
User: *whatever@domain.tld

Matching original code
Matching new code
netbox cdadmin #


The patch is not good at all. I need to go back and fix this. Sorry.

The reason why the original DSPAM code is not okay is because you can add "*@domain.tld" into a group definition (according to the documentation). The original code will not honor that because it will match against "user[0] == '*'" and not evaluate the other conditions.

btw: Your code needs an additional argument for "strncmp".
Comment 22 Alin Năstac (RETIRED) gentoo-dev 2007-11-21 11:46:12 UTC
(In reply to comment #21)
> btw: Your code needs an additional argument for "strncmp".

Ah, I intended to use strcmp, not strncmp. The second condition must be:
  !strcmp(user, "*") 
Comment 23 steveb 2007-11-21 11:54:54 UTC
Created attachment 136599 [details, diff]
files/dspam-3.8.0-better_error_handling.patch

Removed the patch for group handling. I need time to look at that issue. If there should be any patching to the way groups are handled, then it sure does not belong into a patch named "better_error_handling".
Comment 24 steveb 2007-11-21 12:02:32 UTC
(In reply to comment #22)
> (In reply to comment #21)
> > btw: Your code needs an additional argument for "strncmp".
> 
> Ah, I intended to use strcmp, not strncmp. The second condition must be:
>   !strcmp(user, "*") 
> 
Yes! Using strcmp(user, "*") would be the best approach. If adding any patch for that issue, then the patch should be:
@@ -2321,8 +2321,8 @@
   
           while (user != NULL)
           {
-            if (!strcmp (user, username) || user[0] == '*' ||
-               (!strncmp(user, "*@", 2) && !strcmp(user+2, strchr(username,'@'))))
+            if (!strcmp (user, username) || !strncmp(user, "*") ||
+               (!strncmp(user, "*@", 2) && !strcmp(user+1, strchr(username,'@'))))
             {
   
               /* If we're reporting a spam, report it as a spam to all other



I leave it up to you to add that patch. It would be better to separate it into another patch file and not misuse the better_error_handling patch.

Thanks for looking into that.

// Steve
Comment 25 steveb 2007-11-21 12:05:57 UTC
(In reply to comment #24)
> (In reply to comment #22)
> > (In reply to comment #21)
> > > btw: Your code needs an additional argument for "strncmp".
> > 
> > Ah, I intended to use strcmp, not strncmp. The second condition must be:
> >   !strcmp(user, "*") 
> > 
> Yes! Using strcmp(user, "*") would be the best approach. If adding any patch
> for that issue, then the patch should be:
> @@ -2321,8 +2321,8 @@
> 
>            while (user != NULL)
>            {
> -            if (!strcmp (user, username) || user[0] == '*' ||
> -               (!strncmp(user, "*@", 2) && !strcmp(user+2,
> strchr(username,'@'))))
> +            if (!strcmp (user, username) || !strncmp(user, "*") ||
> +               (!strncmp(user, "*@", 2) && !strcmp(user+1,
> strchr(username,'@'))))
>              {
> 
>                /* If we're reporting a spam, report it as a spam to all other
> 
> 
> 
> I leave it up to you to add that patch. It would be better to separate it into
> another patch file and not misuse the better_error_handling patch.
> 
> Thanks for looking into that.
> 
> // Steve
> 
Shit! Used wrongly strncmp instead of strcmp. But you probably spotted it already :)
Comment 26 steveb 2007-11-21 12:14:12 UTC
Created attachment 136602 [details, diff]
files/dspam-3.8.0-group_member_matching.patch

Alin's code for better group member matching.
Comment 27 steveb 2007-11-21 18:14:48 UTC
@Alin: I have two other patches sitting around here. One of them adds read_config support to libdpsam and the other makes dspam linking against the shared libdspam library (making the dspam binary in my installation some kilo byte smaller).

Should I post them as well?
Comment 28 Alin Năstac (RETIRED) gentoo-dev 2007-11-22 06:02:40 UTC
Yes, please.
Comment 29 steveb 2007-11-22 06:24:21 UTC
Created attachment 136649 [details, diff]
files/dspam-3.8.0-linking_against_libdspam.patch

This is the patch to make the drivers link against libdspam. The patch needs a patched DSPAM on the stage of 3.8.0-r7.
Comment 30 steveb 2007-11-22 06:31:16 UTC
Created attachment 136650 [details, diff]
files/dspam-3.8.0-use_libdspam.patch

This patch makes the dspam binary link against libdspam.
This patch allows libdspam to use the function read_config.
The patch needs a patched DSPAM on the stage of 3.8.0-r7.
Comment 31 steveb 2007-11-22 06:32:45 UTC
(In reply to comment #28)
> Yes, please.
> 
The last two patches (dspam-3.8.0-linking_against_libdspam.patch and dspam-3.8.0-use_libdspam.patch) are the one making the dspam binary smaller.
Comment 32 Alin Năstac (RETIRED) gentoo-dev 2007-11-22 14:30:42 UTC
Committed in cvs as dspam-3.8.0-r8.
Thanks!
Comment 33 steveb 2007-11-22 16:15:25 UTC
(In reply to comment #32)
> Committed in cvs as dspam-3.8.0-r8.
> Thanks!
> 
@Alin: Often I see people complaining about Gentoo developers and maintainers. Well... I have to say that you are always very responsive and open minded. Thank you for that!

Steve
Comment 34 Seemant Kulleen (RETIRED) gentoo-dev 2007-11-23 14:50:55 UTC
Alin, Stevb,

Has either of you sent these patches upstream?

Thanks!

Seemant
Comment 35 Alin Năstac (RETIRED) gentoo-dev 2007-11-23 15:00:40 UTC
I didn't sent anything to upstream (more exactly I don't remember doing such thing), mostly because some patches are not original work (for example, some patches have been derived from Debian counterparts).
Comment 36 steveb 2007-11-23 21:41:07 UTC
(In reply to comment #34)
> Alin, Stevb,
> 
> Has either of you sent these patches upstream?
> 
> Thanks!
> 
> Seemant
> 
Hallo Seemant

There is no "upstream" any more. Okay. Sensory Networks is responsible for development. See this link here: http://mailing-list.nuclearelephant.com/6257.html

But sending them mails or patches is pointless. They don't respond.

Probably soon or later DSPAM will be forked. Currently a lot of people on the mailing list are thinking about this move.

// SteveB
Comment 37 Seemant Kulleen (RETIRED) gentoo-dev 2007-11-25 14:59:15 UTC
Ahh, I see! Thanks guys!  Sorry for the bugspam.