Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Howto: Pop-before-SMTP authentication with the vmail guide

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
24 posts • Page 1 of 1
Author
Message
Oopsz
Guru
Guru
Posts: 340
Joined: Tue Oct 08, 2002 3:05 pm

Howto: Pop-before-SMTP authentication with the vmail guide

  • Quote

Post by Oopsz » Sun Mar 21, 2004 4:59 am

So, you've followed this guide to the letter, and you've got a fully functional mail server. But you want people to be able to send mail without their ip address listed explicitly in your postfix main.cf? A solution to this is to use Pop-Before-SMTP authentication. Anytime someone checks their pop3/imap email, their IP address is authenticated for outgoing email for 5 minutes, after which it expires. Your SMTP server is secure against spammers, but still usable.

For this howto, we'll be using DRAC, and a utility called drac-add. It's assumed you're running postfix and courier-imap as described in the virtual mail howto.

1) Install DRAC.

Code: Select all

$ emerge drac
deceptively simple. ;)

2) Install drac-add:

First, download and decompress it.

Code: Select all

$ wget http://venus.tripadelic.com/ebuilds/sources/drac-add.c.gz
$ gunzip drac-add.c.gz
Browse the source if you'd like. It's very straightforward. The default drac_update_host() variable should work fine for you, if you're updating a remote drac server, you probably know what you're doing and don't need this howto.

Once you have that file ready, we need to compile it.

Code: Select all

$ gcc -o drac-add drac-add.c -L/usr/sbin/drac -ldrac -mcpu=i686 -march=i686 -Os -fomit-frame-pointer -fstack-protector -pipe
$ strip drac-add
If it compiles cleanly, copy the drac-add program to courier's authlib directory.

Code: Select all

$ cp drac-add /usr/lib/courier-imap/authlib/
Now, we need to set up courier-imap to call drac-add, so that whenever anyone checks their email, the database will be updated properly.

First, the pop3 server.

Code: Select all

$ nano -w /etc/courier/pop3d
Change the following line:

Code: Select all

AUTHMODULES="authdaemon"
TO

Code: Select all

AUTHMODULES="authdaemon drac-add"
Then, imap.

Code: Select all

$ nano -w /etc/courier/imapd
Change the following line:

Code: Select all

AUTHMODULES="authdaemon"
TO

Code: Select all

AUTHMODULES="authdaemon drac-add"
Okay, now we just have to make postfix check the drac database when it wants to authenticate users. This requires a quick configuration tweak.

Code: Select all

$ nano -w /etc/postfix/main.cf
Add these lines (or edit the existing lines, as appropriate)

Code: Select all

smtpd_recipient_restrictions =
   permit_mynetworks,reject_non_fqdn_recipient,
   check_client_access btree:/var/lib/drac/drac,
   reject_unauth_destination

mynetworks = 127.0.0.0/8, your.ip.address, btree:/var/lib/drac/drac
REPLACE your.ip.address WITH YOUR PUBLIC NUMERIC IP ADDRESS!!

There, we're done! Let's get the servers up.

First, if you're running portsentry, stop it. It plays havoc with new daemons.

Code: Select all

$ /etc/init.d/portsentry stop
Now, start up drac.

Code: Select all

$ /etc/init.d/dracd start
Restart courier:

Code: Select all

$ /etc/init.d/authdaemond restart
And reload postfix

Code: Select all

$ /etc/init.d/postfix reload
You're done! Rock out! Test that it works using your favourite mail client, and check that its secure by using an open relay test. Once you're sure its working, you can clean up:

Code: Select all

$ rc-update add portmap default
$ rc-update add dracd default
And start up portsentry again, if you are so inclined. :)
Last edited by Oopsz on Thu Apr 08, 2004 7:46 pm, edited 2 times in total.
Pop-before-SMTP with the Gentoo Virtual Mailhosting Guide
Top
BobOki
n00b
n00b
User avatar
Posts: 67
Joined: Mon Feb 23, 2004 2:46 pm
Location: Svannah, Ga
Contact:
Contact BobOki
Website

  • Quote

Post by BobOki » Tue Mar 23, 2004 2:42 pm

Now if someone can make this for qmail, I would be rocking!
We the willing lead by the unknowing have done so much for so long with so little, we are now capable of doing everything with nothing.
Top
chrisyu
Apprentice
Apprentice
User avatar
Posts: 207
Joined: Thu Apr 10, 2003 1:36 am
Location: China

  • Quote

Post by chrisyu » Wed Apr 28, 2004 10:48 am

Yeah!

Worked well for me(postfix). :D
Thank you very much!

BTW
In my case /etc/courier is /etc/courier-imap. :)
Top
Oopsz
Guru
Guru
Posts: 340
Joined: Tue Oct 08, 2002 3:05 pm

  • Quote

Post by Oopsz » Thu Apr 29, 2004 1:19 am

Yay, someone used my guide! I feel all warm and fuzzy..
Pop-before-SMTP with the Gentoo Virtual Mailhosting Guide
Top
atac
Apprentice
Apprentice
User avatar
Posts: 234
Joined: Sat Jan 04, 2003 1:18 am
Location: haninge, swe
Contact:
Contact atac
Website

  • Quote

Post by atac » Tue Sep 21, 2004 5:01 pm

just what i needed! thanks :D
1 + 1 + 1 = 11
Top
lectrix
n00b
n00b
Posts: 17
Joined: Thu Apr 03, 2003 1:25 pm
Location: austria
Contact:
Contact lectrix
Website

  • Quote

Post by lectrix » Tue Oct 26, 2004 5:20 pm

hi!

this howto helped me some time ago - thanks for that.
in the meantime, after some major updates and different config changes, i noticed this in syslog:

Code: Select all

Oct 26 19:09:52 igor drac-add: dracauth() Error "127.0.0.1: RPC: Program not registered " for user $REMOTEIP
whereas $REMOTEIP is some non-local ip.
this is repeated very often, each time dracd is called?

what does this mean?

rpcinfo -p says this:

Code: Select all

   program vers proto   port
    100000    2   tcp    111  portmapper
    100000    2   udp    111  portmapper
    391002    2   tcp   1017  sgi_fam
/etc/postfix/main.cf contains

Code: Select all

mynetworks = 62.99.149.26, 127.0.0.0/8, btree:/var/lib/drac/drac
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_non_fqdn_recipient,
    check_client_access btree:/var/lib/drac/drac,
    reject_unauth_destination
/etc/courier-imap/pop3d contains

Code: Select all

AUTHMODULES="authdaemon drac-add"
AUTHMODULES_ORIG="authdaemon"
/etc/courier-imap/imapd contains

Code: Select all

AUTHMODULES="authdaemon drac-add"
AUTHMODULES_ORIG="authdaemon"
thanks for helping...

stefan.
huh, was that me?!
Top
ministry
n00b
n00b
User avatar
Posts: 5
Joined: Wed Sep 29, 2004 1:38 pm
Contact:
Contact ministry
Website

Thanks a Bunch!

  • Quote

Post by ministry » Mon Dec 06, 2004 8:31 pm

Just wanted to thank you for your work around solution.
I'd been messing with smtp-auth for like 4 days.
And everything seemed to be authenticating but it wouldn't pass any outoing smtp traffic!

I think it is really important that people who post howtos make sure they work.
And should also specify what system the howto is for and update them everytime a new version of any of the packages involved comes out.

I found that 80% of of the stuff out there on postfix+cryus-sasl+smtp-auth was not even close to complete and working.

In fact most of the guides I found on it that looked pretty good were in japanese or german.

Anyway gentoo is great! and I'm sticking to my guns with regards to using it in the corporate environment.

Ministry
Top
meulie
l33t
l33t
User avatar
Posts: 845
Joined: Tue Jun 17, 2003 12:07 pm
Location: a Dutchman living in Norway
Contact:
Contact meulie
Website

  • Quote

Post by meulie » Tue Jan 04, 2005 9:44 am

I just implemented this guide as well, and so far it seems to be working great! 8)
Greetz,
Evert Meulie
Top
Oopsz
Guru
Guru
Posts: 340
Joined: Tue Oct 08, 2002 3:05 pm

  • Quote

Post by Oopsz » Mon Mar 28, 2005 3:39 pm

The guy that was having trouble with weird syslog entries: try recompiling the drac-add utility, might be a stale link..

I'm sorry I can't support this howto much anymore, I switched to dbmail as my backend, and it has native support for pop-before-smtp by storing IPs and timestamps in an sql table, ridiculously easy to get postfix to auth from using "mysql:/".
Pop-before-SMTP with the Gentoo Virtual Mailhosting Guide
Top
sander85
n00b
n00b
Posts: 1
Joined: Thu Apr 21, 2005 12:50 pm

Still working ?

  • Quote

Post by sander85 » Thu Apr 21, 2005 12:58 pm

It worked great. Only am I right that courier now uses courier-authlib ?

Since an update to this newer version of courier Drac won't work anymore.

Does someone else has also troubles with this ?
Top
Oopsz
Guru
Guru
Posts: 340
Joined: Tue Oct 08, 2002 3:05 pm

  • Quote

Post by Oopsz » Thu Apr 21, 2005 1:09 pm

I'm sorry if it doesn't work; as I said before I've switched my mailstore from postfix+courier-imap+maildirs to postfix+dbmail+mysql, so I can't support this howto anymore. :( It worked great for the better part of a year though.. not too shabby.
Pop-before-SMTP with the Gentoo Virtual Mailhosting Guide
Top
dschein
Tux's lil' helper
Tux's lil' helper
Posts: 121
Joined: Sun Aug 10, 2003 1:49 am

  • Quote

Post by dschein » Mon Jun 27, 2005 5:15 pm

I'm trying to implement this but I dont seem to have an AUTHMODULES entry in my imapd-ssl file, or any of the other courier config files....any ideas?
Top
hurricane
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 107
Joined: Thu Jul 15, 2004 12:06 am

  • Quote

Post by hurricane » Mon Sep 26, 2005 5:17 am

dschein wrote:I'm trying to implement this but I dont seem to have an AUTHMODULES entry in my imapd-ssl file, or any of the other courier config files....any ideas?
Same problem here...

Looking at the locations of courier's files, it seems that someone changed stuff for courier... And now??

Does anyone know what happened?
Top
hurricane
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 107
Joined: Thu Jul 15, 2004 12:06 am

Not working anymore!

  • Quote

Post by hurricane » Mon Sep 26, 2005 6:56 am

So AUTHMODULES does not work anymore, because now the modules are compiled straight into the daemon! (How fucking stupid! then why are they modules?? [No. Security is no excuse!])

But we're lucky, because now there exists a solution!
Top
zomps
n00b
n00b
User avatar
Posts: 59
Joined: Wed Dec 08, 2004 7:35 pm

  • Quote

Post by zomps » Wed Nov 09, 2005 7:37 pm

The solution:
change drac-add.c line

from

Code: Select all

if (getenv("AUTHUSER") && getenv("AUTHARGV0") && getenv("AUTHENTICATED")) {
to

Code: Select all

if (getenv("AUTHENTICATED")) {
add line end to /etc/courier-imap/imapd and /etc/courier-imap/pop3d

Code: Select all

LOGINRUN="/usr/local/bin/drac-add"
and no more need to change AUTHMODULES parameter

net-libs/courier-authlib-0.57-r1
net-mail/courier-imap-4.0.4
Top
TheCarNinja
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Tue Sep 16, 2003 2:33 am
Location: New York

  • Quote

Post by TheCarNinja » Tue Nov 15, 2005 4:05 am

Nice solution, everything compiles, but i have a problem.
After implementing everything (I don't have my IP addy in mynetworks because that would defeat the purpose) I still get relay access denied.

mail.log (relevant)

Code: Select all

 >>> START Recipient address RESTRICTIONS <<<
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: generic_checks: name=permit_mynetworks
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: permit_mynetworks: cpe-24-90-103-234.nyc.res.rr.com 24.90.103.234
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostname: cpe-24-90-103-234.nyc.res.rr.com ~? <serverip>
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostaddr: 24.90.103.234 ~? <serverip>
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostname: cpe-24-90-103-234.nyc.res.rr.com ~? 127.0.0.1
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostaddr: 24.90.103.234 ~? 127.0.0.1
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostname: cpe-24-90-103-234.nyc.res.rr.com ~? btree:/var/lib/drac/drac(0,100)
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_hostaddr: 24.90.103.234 ~? btree:/var/lib/drac/drac(0,100)
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_list_match: cpe-24-90-103-234.nyc.res.rr.com: no match
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: match_list_match: 24.90.103.234: no match
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: generic_checks: name=permit_mynetworks status=0
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: generic_checks: name=reject_unauth_destination
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: reject_unauth_destination: thecarninja@gmail.com
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: permit_auth_destination: thecarninja@gmail.com
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: ctable_locate: leave existing entry key thecarninja@gmail.com
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: NOQUEUE: reject: RCPT from cpe-24-90-103-234.nyc.res.rr.com[24.90.103.234]: 554 <thecarninja@gmail
.com>: Relay access denied; from=<dummymail@<serverip>> to=<thecarninja@gmail.com> proto=ESMTP helo=<[10.0.0.5]>
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: generic_checks: name=reject_unauth_destination status=2
Nov 14 22:53:13 Diehard postfix/smtpd[15539]: > cpe-24-90-103-234.nyc.res.rr.com[24.90.103.234]: 554 <thecarninja@gmail.com>: Relay access denied
An ls -l of /var/lib/drac/drac.db shows that the modified date is not when i tried logging in, so that means that either courier isn't calling drac-add or that it doesn't have proper permissions (which im sure it does since i changed them as well as no error message). I can't find any reference anywhere to drac-add being called other than the line i added into the courier files.
TheCarNinja
--
~Adopt an unanswered post today!~
Life is more fun sideways.
Top
zomps
n00b
n00b
User avatar
Posts: 59
Joined: Wed Dec 08, 2004 7:35 pm

  • Quote

Post by zomps » Tue Nov 15, 2005 12:42 pm

hmm i saw drac-add messages in /var/log/messages log file
Top
TheCarNinja
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Tue Sep 16, 2003 2:33 am
Location: New York

  • Quote

Post by TheCarNinja » Tue Nov 15, 2005 2:50 pm

zomps wrote:The solution:
add line end to /etc/courier-imap/imapd and /etc/courier-imap/pop3d

Code: Select all

LOGINRUN="/usr/local/bin/drac-add"
This means that i add that line to the end of /etc/courier-imap/pop3d and imapd right?
Also, /var/log/messages hasn't been modified recently at all. Nor is there any drac related activity in there.
TheCarNinja
--
~Adopt an unanswered post today!~
Life is more fun sideways.
Top
TheCarNinja
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 124
Joined: Tue Sep 16, 2003 2:33 am
Location: New York

  • Quote

Post by TheCarNinja » Wed Nov 16, 2005 5:50 pm

*bump*
TheCarNinja
--
~Adopt an unanswered post today!~
Life is more fun sideways.
Top
zomps
n00b
n00b
User avatar
Posts: 59
Joined: Wed Dec 08, 2004 7:35 pm

  • Quote

Post by zomps » Wed Nov 16, 2005 7:07 pm

what happens when you call drac-add command

Code: Select all

TCPREMOTEIP="127.0.0.1" AUTHENTICATED="username" drac-add
and without parameters, does there appear any log or change /var/lib/drac/drac time/size
Top
poco
n00b
n00b
Posts: 11
Joined: Thu Jan 06, 2005 1:39 pm
Location: Nice, France
Contact:
Contact poco
Website

drac-add not called

  • Quote

Post by poco » Tue Dec 20, 2005 1:53 pm

Same problem here, I added the line "LOGINRUN="/usr/local/bin/drac-add"" to the /etc/courier-imap/pop3d file, I think it is the correct one since I have lines like "source /etc/courier-imap/pop3d" in my /etc/init.d/courier-pop3d init script.

I added some syslog to see if drac-add its called when I'm logging into the server, but it isn't :'( I can call it by hand (for example with 'TCPREMOTEIP="192.168.0.7" AUTHENTICATED="plouf" drac-add') and syslog is notified (and the db file modified).

Any help would be welcome.
Top
JackPo
n00b
n00b
Posts: 19
Joined: Fri Jan 23, 2004 1:21 am

  • Quote

Post by JackPo » Wed Jan 04, 2006 2:44 am

anyone have any idea how to fix this?

I have reached the same stage as the previous poster.. but can progress no further...
Top
JackPo
n00b
n00b
Posts: 19
Joined: Fri Jan 23, 2004 1:21 am

  • Quote

Post by JackPo » Wed Jan 04, 2006 5:08 am

nevermind...

I think the route to go is now to use

pop-before-smtp

emerge pop-before-smtp.. and then follow the instructions from the QUICKSTART
Top
poco
n00b
n00b
Posts: 11
Joined: Thu Jan 06, 2005 1:39 pm
Location: Nice, France
Contact:
Contact poco
Website

  • Quote

Post by poco » Wed Jan 04, 2006 3:08 pm

And if anyone is interested i used, for pop-before-smtp with postfix and courier-imap, the following regex :

Code: Select all

$pat = '^(... .. ..:..:..) \[(?:courier)?(?:pop3|imap)(?:login|d|d-ssl)\] LOGIN, user=\S+, ip=\[[:f]*(\d+\.\d+\.\d+\.\d+)\]';
and I changed one variable

Code: Select all

$file_tail{'name'} = '/var/log/mail/current';
Thanks, JackPo, now it rox :)
Top
Post Reply

24 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic