Archive for the 'open-xchange' Category

Open-Xchange problems with postgresql-jdbc

Monday, May 15th, 2006

A little hiccup for a Monday. Not quite sure what went wrong, but in the middle of the morning our Open-Xchange server went belly up. No warning, no updates applied since the start of last week - just refused to handle user logins and dropped all existing sessions.

Easy enough to track down - the Java servlet couldn’t create a connection to the Postgresql database. After a bit of head scratching trying to figure out, simply re-installing ‘postgresql-jdbc‘ did the trick:

yum remove postgresql-jdbc
yum install postgresql-jdbc

followed by a restart of Open-Xchange:

/etc/init.d/openexchange restart

Bit of a puzzler as to why it suddenly stopped, as the correct PATH locations were still set and there hadn’t been any Java updates applied since the server was installed a couple of months back, but at least everything’s back to normal now.

Just got to figure out how to install Debian onto our new HP DL-320 webserver when they (quite helpfully) don’t ship with a CD drive… A nice ploy by HP to get you to then purchase a hot-swapable drive for £70-odd maybe?

ClamAV + SpamAssassin with Amavisd/Postfix on Open-Xchange

Thursday, February 16th, 2006

With the our new Open-Xchange server ready to handle external e-mail once our service provider sets up the forwarding, it seemed like a good idea to set up virus scanning + spam filtering. As we’re not going to be handling a huge number of messages, this doesn’t really warrant a dedicated machine. So, after digging around pulling information from Gentoo, Debian + Fedora guides, here’s how to configure it on CentOS. This assumes you already have ‘apt‘ installed on your system, although the packages should be available through ‘yum‘ if you try, and the base system has come from my installing Open-Xchange on CentOS guide.

Install Packages
There are a number of dependencies that will be downloaded when installing Amavisd, ClamAV + SpamAssassin. Allow all the packages to download, as many are simply Perl libraries:

apt-get install amavisd-new spamassassin clamd

Configure Amavisd-new
First off, we need to set the permissions on our directories to allow amavisd-new to run correctly:

chown amavis:amavis /var/amavis/db
mkdir /var/amavis/quarantine
chown amavis:amavis /var/amavis/quarantine
chown amavis:amavis /var/amavis/tmp

The main configuration file for amavisd-new is located at ‘/etc/amavisd.conf‘ and contains a host of settings. Move through and change the following settings:

$daemon_user  = "amavis";
$daemon_group = "amavis";
 
$mydomain = 'domain.com'; # Set to your mail domain
 
$sa_tag_level_deflt  = undef; # 'undef' means spam status added to all headers - useful
$sa_tag2_level_deflt = 5.0; # A decent, rounded setting - the lower this value, the stricter
$sa_kill_level_deflt = $sa_tag2_level_deflt;
 
$virus_admin = "virusalert\@$mydomain";
$mailfrom_notify_admin = "virusalert\@$mydomain";
$mailfrom_notify_recip = "virusalert\@$mydomain";
$mailfrom_notify_spamadmin = "spam\@$mydomain";
 
$forward_method = 'smtp:[127.0.0.1]:10025';
$notify_method = $forward_method;

Note that this is not a full representation of the config file! Feel free to adjust any other settings as you wish, this is just the bear minimum. Also note that we set the scoring system for SpamAssassin in here - it’s important it’s done in the Amavisd config file rather than the SpamAssassin settings we’ll do later or they won’t take effect!

If you don’t wish to create mailboxes for ‘virusalert‘ and ‘spam‘, then edit ‘/etc/aliases‘ to point these two addresses through to another, already existing mailbox before reading in your updated aliases:

postalias /etc/aliases

The default settings will pick up the Clamd virus-scanner and scan for viruses - there are no settings to change for this. If you wish to use another virus scanner, move down the ‘amavisd.conf‘ file and uncomment the appropriate lines depending on which virus engine you wish to use.

Configure SpamAssassin
There’s not a great deal to do for SpamAssassin other than adjust the scoring within ‘/etc/amavisd.conf‘, however there are a couple of settings you may wish to insert into the config file located at ‘/etc/mail/spamassassin/local.cf‘ to allow the bayesian filtering to function:

bayes_auto_learn 1
bayes_auto_learn_threshold_nonspam 1
bayes_auto_learn_threshold_spam 14.00

Read more within the SpamAssassin docs for additional settings. A score of 14.00 is about right, as lower settings tend to cause the filters to incorrectly mark e-mails from domains such as Hotmail or AOL as spam.

Setting up Postfix
With Amavisd configured to handle the virus scanning + spam filtering, the final step is to tell your mail transport agent (MTA), Postfix, that it should pass all e-mails handled through the Amavisd agent. Firstly, add the following to the end of ‘/etc/postfix/master.cf‘:

smtp-amavis   unix   -   -   y   -   2   smtp
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes
 
127.0.0.1:10025   inet   n   -   y   -   -   smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes

This basically tells Postfix to enable the processing of messages via Amavisd, and then creates another instance of Postfix to handle the messages that are then passed back to it after Amavisd has checked the content for virus’ or spam.

Secondly, in order to tell Postfix exactly where Amavisd is running, add the following line to the end of ‘/etc/postfix/main.cf‘:

content_filter = smtp-amavis:[127.0.0.1]:10024

Tidying up
Now that we have all the configuration options set, we need to start (or restart) our services:

/etc/inid.d/amavisd start
/etc/init.d/spamassassin start
/etc/init.d/postfix restart

We should also set our Amavisd and SpamAssassin daemon’s to load on boot:

chkconfig --add amavisd
chkconfig --add spamassassin

Testing it works!
A quick way of testing Amavisd and our second instance of Postfix are running correctly can be done using telnet:

telnet localhost 10024

which should return a response from the Amavisd service such as:

220 [127.0.0.1] ESMTP amavisd-new service ready

and then to make sure our second instance of Postfix is running:

telnet localhost 10025

which should bring back:

220 Welcome to Open-Xchange server

If either fails, go back through and check that Amavisd is running and that your ‘master.cf‘ and ‘main.cf‘ options are set correctly. After making any changes, ensure you restart the Postfix daemon. If you encounter messages in your ‘/var/logs/maillog‘ from Postfix attempting to use the Amavisd service that had previously been mis-configured, after making your changes, re-queue the messages:

postsuper -r ALL

Now for the fun bit! We want to send a couple of e-mails to ourself to ensure that our virus scanner + spam filtering is working. To test your virus scanners, send an e-mail to yourself with the following contained in the message body:

X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

This is a standard Eicar virus test string and won’t harm your computer! It’s simply to ensure that Amavisd picks it up. Check ‘/var/logs/maillog‘ and you should see something along the lines of:

Blocked INFECTED (Eicar-Test-Signature)

An e-mail should also be fired off to whatever mailbox you defined within ‘/etc/amavisd.conf‘ for ‘virusalert’, informing you what virus was detected, the receipient, and the actions carried out, etc.

In order to run a check on the spam filtering, another test string is available. Simply include the following in the message body (again, it’s harmless and simply to check the filters are working):

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

and within ‘/var/logs/maillog‘ the following should appear for the message as it’s being processed:

(30303-07) Blocked SPAM

Now, whenever you send an e-mail, you should see everything nicely working away within the message headers, including the virus scanning results + spam filtering scores!

Open-Xchange on CentOS 4.2 Guide

Wednesday, February 15th, 2006

Well, a few days of messing around (and some positively annoying head-scratching figuring out some problems) has finally resulted in Open-Xchange running quite happily, on CentOS 4.2. Yet another distro, I know. But, thanks to Mike for pointing me in the direction of CentOS, which I’d been meaning to try for a while, and the excellent script from Giorgio Tobia, everything’s up + running. But, there is a definate lack of information about actually configuring Open-Xchange, as it’s assumed you already know a hell of a lot about Posfix, Cyrus-IMAP, Tomat, etc.

So, with a number of problems resolved, I figured it would be a good idea to group together all my resources for anyone else encountering problems (or simply for my reference when I’m building another server!).

First off, most of the install is based straight from the guide by Giorgio Tobia which may be worth a read. However, I’ve grouped everything together, taken out alternative ideas if you’re running Fedora instead of CentOS, etc. and added in a number of configuration options.

Install Base CentOS server
Grab a copy of CentOS from a local mirror - CentOS 4.2 is the latest at the time of writing. You’ll actually only need the first CD, as we’ll be performing a minimal install. Once downloaded and burnt to CD, reboot and run through the installer. Pick ‘Custom’ install if you want to play with additional settings, paying attention to how you want your partition scheme laying out. I think it’s sensible to have /var/spool/imap on it’s own partition at the very least. You can leave the firewall turned on, and enable any services you require. Giogio’s guide recommends turning off SELinux - I haven’t tried it with it turned back on. Finally, at the package selection stage, choose ‘Minimal’.

Once installed and rebooted, login and run a yum update via

yum update

There may well be a few packages coming down but shouldn’t take too long with a decent connection. Reboot once finished to ensure it runs latest kernel image if one was downloaded, then you’re ready to start installing Open-Xchange!

Open-Xchange install
For installing Open-Xchange, grab the install script tarball by Giorgio, along with his pre-compiled OpenLDAP rpm’s for CentOS. You can compile these yourself if you wish, but he advises it will take a while and does!

Unpack the tarballs as follows:

tar xvzf ox_install.tar.gz
tar xvzf ox_install_centos_rpms.tar.gz

You should now find within ‘oxtempdir/rpms‘, the three extracted OpenLDAP rpm’s. Next, you will need the following Java packages which must be downloaded from Sun manually as the licence agreements must be accepted first:

Copy all these files to the ‘oxtempdir/sources‘ directory, then change to the ‘oxtempdir‘ and run the Open-Xchange install script:

./ox_install.sh

This will prompt for a few responses at the start of the install:

  • Set your domain name (i.e. example.com)
  • Set the name of your organization: (do not use quotes)
  • Set release number of Open-Xchange (i.e. 0.8.0-6)
  • Set your language (EN, DE, NO, IT, FR, NL, BR, RU, CO)
  • Set your LDAP password
  • Do you want to compile Openldap on your own? y for yes, n for no (choose ‘n’ to use the OpenLDAP rpm’s previously extracted)
  • Do you want to crypt communications with your apache server with SSL? y for yes, n for no
  • Do you want to automatically delete all installation files? y for yes, n for no

Then sit back and wait a while! Feel free to browse through the script to see what it’s actually doing, and please direct any comments back to Giorgio. Basically it pulls down a load of packages + dependencies via yum, installs apt, grabs some more packages, sets up your Postgresql database, downloads + installs Open-Xchange, configures your OpenLDAP server, installs Apache + Tomcat including associated Java classes (including optionally enabling SSL communications if selected), etc. then tidies up a few things ready for you to use.

It should be noted that during the install script, when prompted for passwords for Open-Xchange and your Postgresql database, these can be whatever you want. The script seems to indicate you have to use the password ‘openexchange‘, but this is not the case.

Configuring Open-Xchange
With the install script finished, it looks like everything is up + running. However, there’s a number of things which can be changed to improve the way the system responds and Open-Xchange works.

Make sure you edit ‘/etc/yum.conf‘ to stop OpenLDAP being updated with a newer version not compiled with ACI support. If any glaring security updates are released requiring updates to OpenLDAP, these will have to be done manually unfortunately. Add the following line to ‘yum.conf‘:

exclude=openldap

I’m assuming you’ll want the mailbox folders to be created automatically on logging in - it’s fairly common sense. Edit ‘/srv/ox/etc/webmail/webmail.properties‘ and set:

user.default.folder.autocreate=true

Within ‘/etc/imap.conf‘, it should already be setup to create the required folders, however it does not auto-subscribe to them. Fairly silly, as when you login you will only see ‘Inbox’ unless you go into your mail settings, select ‘Folders’, and manually subscribe. Your ‘/etc/imap.conf‘ should contain the following:

autocreateinboxfolders: Trash | Drafts | Spam | Sent
autosubscribeinboxfolders: Trash | Drafts | Spam | Sent

This way, when your users first login, the mailbox folders are created, subscribed to, and automatically displayed. Easy!

Adding users can either be done with the built-in Open-Xchange scripts, found under ‘/srv/ox/sbin‘, or via Giorgio’s script, found with ‘oxtempdir‘. The script is called ‘useradd_ox.sh‘ and before running it, you will need to edit the script to provide the default maildomain, password, timezone, etc. You then simply add a new user with:

useradd_ox.sh username

And you will then be prompted for the firstname and surname, whilst the script then adds them to the OpenLDAP structure and Postgresql database.

Tinkering with Open-Xchange
The rest of the changes are purely down to preference. We mainly use the webmail features and that’s it, so the groupware isn’t widely used. To facilitate this, ‘login.pm‘ can be adjusted to make webmail the default option whilst logging in. Also, as we only use the EN localisation, you can get rid of the drop-down box and simply tell the system to use EN (or whatever localisation you want). For adjusting the default re-direct to load webmail rather than groupware, edit ‘/var/www/cgi-bin/login.pm‘ and change:

print $cgi->popup_menu(-name=>'whereto',
     -values=>['/servlet/intranet?SITE=beforeAuth&sessionID=',
'/servlet/webmail?SITE=mauth&sessionID='],
     -labels=>\%labels,
     -default=>'servlet/intranet?SITE=beforeAuth&sessionID=');

to:

print $cgi->popup_menu(-name=>'whereto',
     -values=>['/servlet/intranet?SITE=beforeAuth&sessionID=',
'/servlet/webmail?SITE=mauth&sessionID='],
     -labels=>\%labels,
     -default=>'/servlet/webmail?SITE=mauth&sessionID=');

The key change is the last line where you set default option to ‘/servlet/webmail‘ rather than ‘/servlet/intranet‘. When you reload your front page, ‘Webmail’ should now be the default action.

To force the default language and thus remove an un-necessary drop-down box, further down within ‘/var/www/cgi-bin/login.pm‘ edit the section to read:

# Hide the language choice - tell it we want EN
print "<input type='hidden' name='whichlang' value='EN'/>";
 
#print $cgi->start_Tr();
#print $cgi->start_td({-align => 'right', -valign => 'middle', -class => 'tds'});
#print $cgi->font({-class => 'text'}, 'Language:');
#print $cgi->end_td();
#print $cgi->start_td({-valign => 'middle', align => 'left', -class => 'tds'});
#print $cgi->popup_menu(-name=>'whichlang', -values=> $languages, -default=>$default_lang);
#print $cgi->end_td();
#print $cgi->end_Tr();

Again, once reloading the page you should find that lanuage
drop-down box has disppeared, and upon logging in, you’re automatically taken through with EN set as the localisation. This leaves a much cleaner login screen with the user only required for their username + password to access webmail.

All the actual html content for controlling how the groupware + webmail is displayed can be found under ‘/srv/ox/share/groupware/data/templates/EN/‘ and ‘/srv/ox/share/webmail/data/templates/EN/‘ respectively. I haven’t really edited the groupware section as we’re not utilising it much, but the webmail screen has been changed quite a bit.

First area you might wish to change is ‘loadmain.htm‘ which controls the framesets for displaying the webmail area. We’ve found the default layout annoying, with not enough space shown on the right hand side for scrolling through messages. To adjust this, edit ‘loadmain.htm‘ and change the second instance of declaring the frameset to something such as:

document.writeln('<frameset rows="50%,50%">');</frameset>

When initially opening the webmail screen, the bottom right-hand side displays a load of user information which although can be useful if someone is encountering a problem, could be considered confusing for a normal user. I changed this to display a few paragraphs explaining basic use of the e-mail system, how to change a password, etc. It’s ‘main.htm‘ that needs editing - simply add another row in the table before it starts listing name, e-mail, client info, etc. and enter whatever content you wish.

To add a link to the personal settings area that allows the changing of password, user contact information, etc. you need to edit ‘left_top.htm‘ and insert the following wherever you want the button to appear within the existing list:

<tr>
     <td align="left" valign="middle"><a href="../umin/Login?NAS_ID=**NAS_ID**&sessionID=**NAS_ID**" target="_blank"><img src="**imageLink**/email_options_s.png" border="0" alt="Settings" title="Settings"/>
     <td><a href="../umin/Login?NAS_ID=**NAS_ID**&sessionID=**NAS_ID**" target="_blank"><b>Personal Settings</b>
    </a></td></a></td></tr>

Still within editing your menu’s, I changed the bottom menu to handle logging out, rather than simply closing the window. In order to change the button for logging out, replace those two lines with the following:

<tr>
     <td align="left" valign="middle"><a href="**webmail**?NAS_ID=**NAS_ID**&SITE=logout&NAS_END_SESSION=TRUE&sessionID=**NAS_ID**&nlf=**NAS_LF**" target="_top"><img src="**imageLink**/email_logout_s.png" border="0" alt="Close" title="Close"/>
     <td><a href="**webmail**?NAS_ID=**NAS_ID**&SITE=logout&NAS_END_SESSION=TRUE&sessionID=**NAS_ID**&nlf=**NAS_LF**" target="_top"><b>Logout</b>
    
</a></td></a></td></tr>

I also took this a step further by adjusting the actual logout process to re-direct back to the login page rather than simply closing the window. This was to facilitate tabbed-browsing users from not experiencing any quirks whereby the whole browser would close rather than the individual tab. Some recommend closing the window for added security, but I don’t quite follow that train of thought. Instead, edit ‘logout.htm‘ and remove all the lines for the JavaScript, and simply add the following into the ‘head‘ section to redirect the browser back to the login page after 2 seconds:

<meta http-equiv="Refresh" content="2; URL=../cgi-bin/login.pl"></meta>

Aliases and mailing groups
Using aliases is fairly straightforward for providing additional aliases for users. For example, although your IMAP mailboxes work as ‘ifoulds, for example, you could create an alias allowing someone to send an e-mail to ‘iain‘. To do this, simply edit ‘/etc/aliases‘ as follows:

iain:     ifoulds

where the first name is the alias you wish to create, and the second name is the actual existing system user. In order for these new aliases to take effect, you then need to inform Postfix to update it’s database:

postalias /etc/aliases

However, taking things a step further which is something I really struggled with - trying to figure out how to use IMAP shared mail folders for direct mail delivery, configuring groups of users and assigning them to these shared folders, etc. You can also create groups within ‘aliases‘ to control such mailing lists, which although doesn’t provide any management features such as managing subscriptions, providing a shared folder for users to connect to view archived messages, etc., it was perfect for what we were after. Upon sending an e-mail to the group, Postfix simply forwards the e-mail to each member of the group, meaning it simply pops-up directly in their inbox. To do this, edit ‘/etc/aliases‘ as follows:

mailgroup:    
     ifoulds,
     jdoe,
     mmouse

You simply add the usernames to the list, and then tell Postfix to update it’s database:

postalias /etc/aliases

This is one of those things which is a pretty widely-used feature of mail servers, but unless you already know the ins + outs, is very poorly documented. I stumbled across it by accident!

Conclusions
Although from a management point of view this is a big change from our old SuSE Linux Openexchange server, the front-end is no different for the users. It is a little more fiddly managing things from the command line, but just as quick as using a web front-end. OxAdm is a fairly well used PHP admin tool for Open-Xchange, though will require a few extra packages installing through yum first:

yum -y install php php-ldap php-pgsql php-imap

The installation from Giorgio really was a massive help, and a few hours tinkering with the nuts + bolts of Open-Xchange to see how it works made things a lot clearer. Just a shame there’s no guide already setup on how to make basic changes to appearance, layout, mailing groups, etc.

If you have problems, please try the Open-Xchange forums first, which although are not terribly active and often filled with people saying they have the same problems, there are solutions available if you browse around. For problems with the installation, please get in touch with Giogio. Any comments on my guide - either leave your comments here or drop me an e-mail.

Not quite admitting defeat, but…

Friday, February 10th, 2006

Open-Xchange on the Gentoo Sparc64 was just a nightmare! Along with taking an age to run through emerging each package, too many packages weren’t in ’stable’ on the Sparc platform, and stepping back to Blackdown JDK rather than offical Sun-JDK was causing a lot of problems compiling the Java dependencies during the base system install.

So, plan B is running Open-Xchange on my dual-PII testing system. Although mainly for trying out various distros and desktop environments, it’s speed helps, and the fact it’s x86 based! Initially I’ll follow through installing it running off a local OpenLDAP server before complicating matters by powering it from the OpenLDAP server currently configured on one of the Ultra 5’s for user logins and Samba authentication.

Although I’m a little disappointed not to be able to run everything off the stack of Ultra 5’s, I’m more interested in the actual systems configuration and connections across the network than arsing around resolving annoying package dependencies on what appears to be a platform not really receiving much attention for Open-Xchange!

Not planned, but Open-Xchange on Debian

Friday, February 10th, 2006

So, our SuSE Linux OpenExchange e-mail server has given up the ghost. The hard drive the base system is (or rather “was”…) installed to, has died. Not a problem, but with it being a Friday and no huge rush to get it up and running, I thought I’d try Open-Xchange instead. It’s the natural migration, and although forced a bit quickly, is worth a try.

After all my testing + development at home running Gentoo and with an Ultra 5 at home currently building Open-Xchange onto a Gentoo Sparc64 base, why am I now installing this on Debian? Simple, I know it works very well in the production environment, matches it up with the rest of our Linux systems, and would be quick to install. Sure enough, it’s been fairly easy with the Open-Xchange on Debian Sarge with from .deb packages instructions. Have run into a minor problem in that adduser_ox isn’t automatically creating the IMAP mailboxes when the config is set for this to happen. Think that’s down to messing up the Courier-IMAP config during the install and enabling web folders.

Have been impressed with the speed everything is up and running, especially considering this is my first time with a full Open-Xchange system. I’m now running back through the install creating it all from scratch since I played around with some extra stuff for SSL connections between the services and such and want to clean things up.

The only downside is lack of web-management by default unless you purchase the commercial version, but when it’s basically creating new users, changing passwords, creating shared mail folders and assigning users, there seems to be a ton of scripts available for this on-line. Or, it shouldn’t be too hard to script something to tie-in with our existing web-based control systems for managing the internet content filtering, access rights, user permissions, etc.

Open-Xchange on Gentoo Sparc64

Wednesday, February 8th, 2006

So, I’ve done bugger all with my stash of Sun Ultra 5’s since well before Christmas, and since getting back from my holidays I haven’t been bothered either. Terrible waste of equipment, I know!

But, having received an e-mail from the Open-Xchange team about further migration support and whitepapers from SLOX 4.1 across to Open-Xchange, figured that sooner or later our mail server at school is probably going to be shuffled across. If possible, I’d like to get this done before I leave in May as with SLOX support no longer, applying updates is a right pain, and it’s going on for 2 years since it’s been in operation anyway.

One thing I’ve been looking at for a while is expanding the e-mail systems to incorporate external mail functions as well. At the moment, it’s only handling internal e-mail, but bridging the gap seems logical. I’d want to bring in virus scanning of attachments and spam filters for that, which is why I’ve already been looking at ClamAV and SpamAssassin for my Gentoo network systems.

Anyways, I’ve actually got the 3rd Ultra 5 now running Gentoo Sparc64, integrated with the LDAP server (now I know the steps for creating the certificates from configuring the Samba server…) and have made a start on Open-Xchange on Gentoo. Running Sparc64 has already brough up an issue in that there’s no stable Sun-JDK, though there is a blackdown-jdk ebuild I’m currently compiling.

Of course, running it on such an old system means this may take a while, and since the 2nd package on the (long) list of base software has already caused problems, it may take even longer! But, I do like a challenge…