Davide,

Your changes look like valid. But always test it!

You can also use following patch. It is simplier.
http://www.enderunix.org/qsheff/patches/patch-b16.diff

regards,

 
Baris Simsek
http://www.enderunix.org/simsek
http://www.endersys.com.tr
 

-----Original Message-----
From: Davide Bozzelli [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 05, 2008 5:04 PM
To: [email protected]
Subject: Re: [qsheff] Blocked attachment

Baris Simsek ha scritto:
> Hi,
>
> E-mails filtered by attachment filter are mostly viruses. Since return
> addresses are invalid, you dont need to response them.
>   
Your statement is true.

But consider the following scenario: smtp service for outbound mails 
(port 587) with smtp-auth .
If someone which was authenticated from the smtp service trying to send 
mails with invalid attachment ,
would be useful if he could be informed of the fact that it's attachment 
has been blocked .

This is the scenario that i'm testing .
Btw, i've made simple hacks on the code to let qsheff returns a custom 
message (like: you have an invalid attachment),
but, since i'm not a c programmer, i'm not sure if this modifications 
are safe and correct, also if they works .


---------------- START OF MY MODS 
----------------------------------------------------------------------------
---------------------------

My mods:

main.c:

I've rewritten "static int custom_msg_exit:" in this way:

static int custom_msg_exit(int module)
{
        char reject_message[254];

        memset(reject_message, 0, sizeof(reject_message));
        /* Custom message can be maximum 254 bytes. It shouldn't include 
newline (\n) */
        spam_word[32] = '\0';
        virname[32] = '\0';
        if(module == 5) {
                snprintf(reject_message, sizeof(reject_message),
                "D%s (%s) / %s", SPAMMSG, spam_word, custom_sign);
        }
        else if(module == 6) {
                snprintf(reject_message, sizeof(reject_message),
                "D%s (%s) / %s", VIRUSMSG, virname, custom_sign);
        }

       /*  JUST ADDED THIS CHECK */
        else if(module == 666) {
                snprintf(reject_message, sizeof(reject_message),
                "D%s (%s) / %s", ATTACHMSG, spam_word, custom_sign);
        }
       /* END OF ADDED CHECK */
        else {
                snprintf(reject_message, sizeof(reject_message),
                "D%s / %s", DEFAULTMSG, custom_sign);
        }
       
        /* Write custom message to qmail-smtpd fd. */
        write(4, reject_message, strlen(reject_message));
       
        _exit(EX_CUSTOM);
       
        return -1;
}
#endif

I also modify in main.c :


/**********************************
 ** Module 4: Attachment filter. **
 **********************************/

        memset(err_error, 0, sizeof(err_error));
               
        if(enable_attach_filter == 1) {
                #ifdef _DEBUG_
                printf("- attach\n");
                #endif
       
                if(load_attachlist() == -1) {
                        #ifdef _DEBUG_
                        printf("  . ret: -1\n");
                        #endif
                        clean_exit(EX_TEMPORARY, 4);
                }
        
                ret = attach_filter();

                #ifdef _DEBUG_
                printf("  . ret: %d\n", ret);
                #endif

                if(ret > 0) {
                        /* if we found a denied file as attached. */
                        clean_exit(EX_PERMANENT, 666); <<<<<< changed 
the code and the exit msg code
                }
                else if(ret == -1) {
                        clean_exit(EX_TEMPORARY, 666); <<<<<<< changed 
only the code
                }
        }


I've modify also the clean_exit func in main.c:

 if(status == EX_PERMANENT) {
                if ((enable_quarantine == 1) && (modno == 5)) {
                        backup(msgfile, "quarantine");
                }

                /* If SPAM check enable_spam_blackhole */
                if (((modno == 5) && (enable_spam_blackhole == 0)) || 
((modno == 6) && (enable_virus_blackhole == 0))) {
                        unlink(msgfile);
                        #ifdef CUSTOM_ERROR
                        /* This works only if the qmail-queue custom 
error patch is installed. */
                        custom_msg_exit(modno);
                        #else
                        _exit(EX_PERMANENT);
                        #endif
                }

                /*ADDED CHECK  == 666 */  <<<<<<<<<<
                 if ( ( modno == 666) && (enable_spam_blackhole == 0) ) {
                        unlink(msgfile);
                        #ifdef CUSTOM_ERROR
                        /* This works only if the qmail-queue custom 
error patch is installed. */
                        custom_msg_exit(modno);
                        #else
                        _exit(EX_PERMANENT);
                        #endif
                }
                /* END OF ADDED */  <<<<<<<<<<<<<<<<<<<<<<

                else {
                        status = 0;
                }
        }

finally:
added in main.h:

#define ATTACHMSG "Your email was rejected by qSheff because it 
contained a banned attachment"


---------------- END  OF MY MODS 
----------------------------------------------------------------------------
---------------------------

Again, i dunno if this code is safe , also if this works for me .


Thx for help.


Davide




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to