Article View: es.comp.os.linux.programacion
Article #15574Re: Problema con regcomp y regexec...
From: Santiago Romero
Date: Mon, 12 Jun 2000 00:00
Date: Mon, 12 Jun 2000 00:00
201 lines
8653 bytes
8653 bytes
El Sun, 14 May 2000 11:49:05 +0200, Santiago Romero escribi๏ฟฝ:
>
> Enas...
> no consigo tirar para adelante los filtros de mi checkmail,
> el caso es que no me tiran las regexp con regcomp y regexec.
> Si alguien quiere echar una mano, le puedo pasar el codigo
> (son 17Kb), aunque lo principal es esto:
en fin, eso ya es historia porque ya funciona (espero que bien)
mi popmail. Lo podeis probar en
http://web.jet.es/s.romero/prog/popmail.html
Os pego una cosa (un fichero HOW-TO-TEST) que en ese rpm/tar.gz no
viene pero que ira en la proxima version de popmail:
(sorry por el tochete, pero si alguien lo va a probar es mejor que
lea esto :-)
____ __ __ _ _
| _ \ ___ _ __ | \/ | __ _(_) |
| |_) / _ \| '_ \| |\/| |/ _` | | |
| __/ (_) | |_) | | | | (_| | | |
|_| \___/| .__/|_| |_|\__,_|_|_|
|_|
Copyright (c) 2000
Santiago Romero Iglesias - sromero@unix-shells.com
HOW TO TEST THIS PROGRAM
=======================================================================
Although being version lower than 1.0, popmail is fully functional.
The 0.3-0.4 version is a very low number, This is NOT because
the program is dangerous or something like that, I just wanted to
implement all the features in 0.1, 0.2, and 0.3 and start making it
very very very stable (stable to fails, to timeouts, and so on),
translate it to more languages, etc. from 0.3 to 1.0.
I'll repeat it: POPMail is not dangerous: I've tested it and it
works perfectly, but still needs testing, in order to find and correct
any bug it could have. Of course, this is GPL'ed softwate, so this
program is distributed without any warranty: if you put a filter
such as Deny: .*$ and you delete all your messages, it's your fault.
Of course, I've tested it enough to see that filters are working
and "Deny: ^From:.*spammer@spammer.com" will only filter that email
address (read the second section on this file for more info) and
no more addresses.
If you want to help me finding bugs, or if you just don't trust me
about POPMail it's not dangerous, you can test it into your localhost
(with your local mailbox) instead than testing it with your personal
email. To do this, you need a POP3 server installed on your machine.
I use QPOPPER (http://www.eudora.com/qpopper). Download version 3.x,
untar it, and do "./configure; make; make install". You can also go
to RPMFIND (rpmfind.net) enter into de RPM DATABASE, select SORT BY
NAME, enter into the 'Q' and download the QPopper RPM package.
After installing qpopper, edit /etc/inetd.conf and add this line:
pop3 stream tcp nowait root /usr/sbin/tcpd in.qpopper
The spaces are tabs. Edit /etc/services and add this line too:
pop3 110/tcp # POP version 3
Now restart the inet service (or the computer :-). In Redhat you
will write:
/etc/rc.d/init.d/inet restart
Ok, you now have a POP3 server on you machine. Now you can specify
localhost (or your IP/hostname) as popserver in .popmailrc and
POPMail will connect your machine and do it's job with the messages
of any user.
Create a new user or use a user that has no new mail into his
mailbox (ls -l /var/spool/mail/user). Now we're going to insert
some email there (to do testing):
cat Mail/email_file_from_mutt_or_similar >> /var/spool/mail/user
In my case I use:
cat Mail/valux-linux-spanish.list >> /var/spool/mail/user
Then I get new mail in my mailbox:
[localuser@compiler localuser]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/localuser": 7 messages
> 1 Majordomo@valux.org 32/1296 "Majordomo results: au"
2 Majordomo@valux.org 56/2167 "Welcome to valux-list"
3 Majordomo@valux.org 52/1965 "Confirmation for subs"
4 Majordomo@valux.org 56/2255 "Majordomo results: su"
5 compiler@imame.com 90/3901 "Me presento a la list"
6 luisauertes@remmmmil 63/2480 "Benaguasil P@rty 2000"
7 mana@europa2.com 56/2301 "RE: no os lo perdais"
&
Nice, we have now messages for testing. You can delete them in
any moment by just running mail and using the d (delete) option
followed by the message number to delete (exs: d 1 or d 1-7).
Now we create a .popmailrc file:
popservers 1
server localhost
user localuser
password passwd
port 110
maxsize 10000000
filterfile /home/localuser/.filterfile
Finally we create a .filterfile to test filters:
# my filter file. It will delete (I hope) 4 messages...
deny ^From:.*Majordomo@valux.org
Now we're going to test popmail:
[localuser@compiler localuser]$ popmail
POPMail - (c) 2000 Santiago Romero - Published under the GNU License.
- The user localuser in localhost has 7 message(s) (16429 bytes).
Message 1 deleted: Deny ^From:.*Majordomo@valux.org .
Message 2 deleted: Deny ^From:.*Majordomo@valux.org .
Message 3 deleted: Deny ^From:.*Majordomo@valux.org .
Message 4 deleted: Deny ^From:.*Majordomo@valux.org .
[localuser@compiler localuser]$ mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/localuser": 3 messages
> 1 compiler@imame.com 90/3901 "Me presento a la list"
2 luiafuertes@remmmmil 63/2480 "Benaguasil P@rty 2000"
3 mana@europa2.com 56/2301 "RE: no os lo perdais"
So it works!!! but ... maybe while testing in your mailbox you
found a bug... a timeout produced a segfault... this kind of nice
bugs that the coder never finds and the user always gets ... :-)
In that case email me... this is the way I want to convert 0.3 o
1.0 and make it 100% stable and usable. Once you've seen that
popmail works you can use it with a remote POP3 server and report
any bug you can find.
SOME RULES ABOUT FILTERING
=======================================================================
Remember that the Deny filters are regular expressions (regexp).
Do "man regexp" to learn about them... I'll try to give you some
guidelines there.
o Using simple expresions such as the following is no dangerous:
Deny ^From:.*name@domain.com
Deny ^From:.*@domain.com
Deny ^From:.*name@
Deny ^Subject:.*WIN.*MONEY
Deny ^Subject:.*FREE.*SEX
Feel free to use lots of these expressions (maybe you could
escape the . character, such as explained in the next advice).
In fact, my filter file is 99% plenty of expressions like the
above, so the danger of losing messages by a failure when
writing new filters reduces to nothing.
o Escape all special characters. If you want to filter something
like ^Subject:.*[eya-list].*$ (all the messages that have in
the subject the string [eya-list]), DON'T DO THE FOLLOWING:
Deny ^Subject:.*[eya-list].*$
THAT'S WRONG: [ and ] are special characters to regexps... they
mean "any of the characters between them". If you use the above
regexp as filter, you will delete all the messages that contains
an 'e', an 'y', an 'a, an 'l', ... or any 't' in the subject...
Almost all the Subjects will have 'a' or 'e', so you will delete
all the messages. The RIGHT WAY IS THIS:
Deny ^Subject:.*\[eya-list\].*$
With \ you escape the special characters and treat it as normal
ones. Do the same with the . (means: any character), *, ^ and
so on. Or just do man regexp and learn the nice world of regexp.
:-)
Santiago Romero AkA NoP/Compiler.
sromero@unix-shells.com
--
Don't compare Linux to Windows 2000. There's no colour (except BLUE)
_-----------------------------------------------------_
| NoP / Compiler -- sromero@unix-shells.com |
|-------------------------------------------------------|
| POWERED BY - Linux RedHat 6.0 - Reg. User #74.821 |
| http://web.jet.es/s.romero |
~-----------------------------------------------------~
Technical Details
Message-ID:
<slrn8kan8v.re.sromero@compiler.linux.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<slrn8hstkh.sq.nop@compiler.linux.es>Show Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: f86c8,2dfb3ec83ff2a1bc X-Google-Attributes: gidf86c8,public From: sromero@unix-shells.com (Santiago Romero) Subject: Re: Problema con regcomp y regexec... Date: 2000/06/12 Message-ID: <slrn8kan8v.re.sromero@compiler.linux.es> X-Deja-AN: 633732759 Content-Transfer-Encoding: 8bit References: <slrn8hstkh.sq.nop@compiler.linux.es> Content-Type: text/plain; charset=iso-8859-1 Organization: Telefonica Transmision de Datos Mime-Version: 1.0 User-Agent: slrn/0.9.6.2 (Linux) Reply-To: sromero@unix-shells.com Newsgroups: es.comp.os.linux.programacion