Thanksgiving Break

Well, it was really good.  I was again at the Stevenson’s.  I read two and a half books, watched some movies, and made the mistake of participating in the annual Black Friday shopping trip.  Once was enough.  I don’t plan on doing that again.

For work I’m trying to figure out how to make our Samba domain controller authenticate off an LDAP server, without totally disrupting every ones work.  This could take some time.  The up side is I’m going to have a lot of that this winter.  Hansen’s and Bree are leaving this Thursday, so things are going to get even quieter here at camp (if you don’t know who these people are that’s ok).  Since I can’t think of anything else to say I’ll stop.

John 20:31 But these are written, that ye might believe that Jesus is the Christ, the Son of God; and that believing ye might have life through his name.

Quick Update

So I seem to be spacing these posts out. I suppose that’s because not much new has been happening. A quick update on me. I’m doing well. I’ve been keeping busy at work. Last week I set up my own DHCP/DNS server (I’ve been using the one built into IPCop). That was cool. I’ve got the DHCP server dynamically updating the DNS server so that all my names and IP’s stay synced.  Other than that not much is new.

Oh, I did slide off the road and into the ditch today.  As accidents go it was really quite nice.  I was in the ditch and then out again in about 10 minutes.  I slid in, got stuck, and this guy showed up with his truck and a tow strap.  Like I said, in and out.  No one got hurt, my car is fine, and my ego is slowing recovering.
John 18:8-9 Jesus answered, I have told you that I am he; if therefore ye seek me, let these go their way: That the saying might be fulfilled, which he spake, Of them which thou gavest me have I lost none.

I always assumed when I read that Jesus was referring to salvation. This makes it look more like he was referring to their physical well being.

John 18:11 Then said Jesus unto Peter, Put up thy sword into the sheath: the cup which my Father hath given me, shall I not drink it?

Again and again I am blown away at Christ’s complete and utter submission.

gmail Clone

Something I need to make absolutely clear from the start.  This post is NOT about setting up an actual email server.  This server sits on our local network, behind our router/firewall.  It does not have direct access to the Internet.  As such I was not focusing on security and will not vouch for it (this setup) being secure.

Ok, now that that is done, I need to give a little background.  Here at BMCR we have satellite Internet.  This means we have very limited bandwidth.  In order to stay under our cap, I limit bandwidth per day by IP address.  Once you hit your daily limit you can’t get to the Internet till the next day.  That is all well and good, but if you hit your limit you can’t check your email.  This was starting to be a problem.

Enter in these three programs postfix, dovecot, and offlineimap.  With this setup, our server syncs itself with our Google Apps email accounts, and then we check and send our email on/from the local server.  This way, even if you hit your bandwidth limit for the day, you can still do email (it also means that if for some strange reason all of Google’s servers die you have a local backup copy of all your emails).  I installed this on Ubuntu server 10.04 (the 32bit version).

I offer no guarantees that any of this will work for you, nor do I guarantee that it wont completely destroy your system if you try it.

Sources:

Postfix install and configuration: Techienote.com

Postfix setup for multiple smtp servers: Cyberciti.biz (I don’t actually talk about this in this post, but I did set it up.)

Dovecot install and configuration: Webmonkey.com

Offlineimap: Offlineimap.org

 

Postfix

Install

sudo apt-get install postfix -y

The “-y” matters, but I’m not sure why.  At the configuration screen select “No Configuration”

sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf

Configuration

sudo vi /etc/postfix/main.cf

This is my main.cf:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/sll/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client

myhostname = repository.bmcr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost = [smtp.gmail.com]:submission
mynetworks = 192.168.1.0/24, 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
default_transport = smtp
relay_transport = smtp
inet_protocols = all
home_mailbox = email/
mailbox_command = 

# SASL Settings
smtp_use_tls=yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtp_generic_maps = hash:/etc/postfix/generic

Just a note, the “home_mailbox” parameter.  On our server every ones email is in a folder called “email” in their home directory.  You can call that folder whatever you want.

sudo echo "myfully.qualifieddomain.name" > /etc/mailname

sudo vi /etc/postfix/sasl_passwd

This opens the postfix password file.  One username and password per line.

For example:

#Per-sender authentication
username@Repository.BMCR username@bmcrministries.org:password
#Default login
[smtp.gmail.com]:587 username@bmcrministries.org:password

I’ll try and explain the following commands, but the sources links will have better explanations (owing to the fact they know what they are doing).

This secures the password file (the passwords are stored in it plain text):

sudo chmod 400 /etc/postfix/sasl_passwd

Postfix keeps some kind of a database hash of the postfix password file and the mailname file.  These update the databases after a change (these must be run whenever you modify there respective files):

sudo postmap /etc/postfix/sasl_passwd
sudo newaliases (this is for the /etc/mailname file… I think)

Setup the CA certificate.  This is a self-signed certificate, so most email clients/browsers will throw up a warning.  Remember this is running on our local network and isn’t accessible from outside.

sudo touch /etc/postfix/cacert.pem

sudo cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem >> /etc/postfix/cacert.pem

Now restart postfix.

sudo /etc/init.d/postfix restart

To test postfix:

sudo apt-get install mailutils This will let you send an email from the command line.
echo “We rolling, yo” | mail -s “Sent from Repository” someone@somewhere.com

If you’ve got everything configured properly this should send an email.  The subject line will be the text following the “-s” and the body will be the text following “echo”.  The address is that of the recipient.

A couple of notes:

I had ‘inet_interfaces’ explicitly stated in my main.cf. For some reason that didn’t work. I removed the line and it defaulted properly. Once that was done I started getting alias.db errors, which were fixed by ‘sudo newaliases’. That was some how tied to ‘mynetworks’. That should default to the local subnet and local host, however I had to explicitly put that in. Once these things were figured out I could send email using Thunderbird.

Dovecot (IMAP server)

 Install

sudo apt-get install dovecot-imapd

Configuration

sudo nano /etc/dovecot/dovecot.conf

Find “protocols” and set it to “protocols = imap imaps”

Find “mail_location” and set that to “mail_location = maildir:/home/%u/email:LAYOUT=fs” (if you are using a different folder name make sure to use that instead)

Offlineimap

Install

For whatever reason I couldn’t get the Offlineimap in the Ubuntu repositories to work, so I installed from a different repository.

In order to add a ppa run this command:

sudo apt-get install python-software-properties

Then add the ppa:

sudo add-apt-repository ppa:pomeo/offlineimap

Then of course:

sudo apt-get update
sudo apt-get install offlineimap

Offlineimap is configured on a per user basis.  Each user will have an .offlineimaprc file in their home directory. OfflineIMAP is very picky about the configuration file. If you are getting errors open the file up again and double check your settings. For example if you have a space before “ui = TTY.TTYUI” it will error out.

My offlineimaprc:

[general]
accounts = BMCR

ui = TTY.TTYUI

[Account BMCR]
#Profile for local mail
localrepository = localrep
#Profile for remote mail
remoterepository = remoterep

[Repository localrep]
type = Maildir
localfolders = ~/email/

[Repository remoterep]
type = IMAP
remotehost = imap.gmail.com
ssl = yes
remoteuser = someone@somewhere.com
remotepass = password
nametrans = lambda folder: re.sub('.*Drafts$', 'Drafts', re.sub('.*Sent Mail$', 'Sent_Mail', re.sub('.*Trash$', 'Trash', folder)))
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail','[Gmail]/Spam','[Gmail]/Starred','[Gmail]/Important']
maxconnections = 2

I would also chmod this to 400 when your done as it also contains a plain text password.  The documentation at offlineimap.org should walk you through all the options I’ve used.

I hope this was useful.  If something is un-clear, or simply wrong please let me know and I’ll try and fix it.