January 24, 2008

 .htaccess password protection via MySQL

mod_auth_mysql (http://modauthmysql.sourceforge.net/), is a module for apache which allows you to password protect a webserver directory with usernames and passwords from a MySQL table.

This is ideal if you would like to password protect the Webmail URL of @Mail, if your organization requires extra security, and you would like to prevent access to the Webmail system for authorized IP's only.

Read below on how to setup Mod-Auth Mysql with Apache

Things to note:

-It is assumed that you are running a linux system with apache web server.
-Detailed instructions regarding the installation and configuration of mod_auth_mysql can be found here: http://modauthmysql.sourceforge.net/

Installing mod_auth_mysql

After building the module, you need to install it to your modules directory.

Apache 1.x:

apxs -i mod_auth_mysql.so

Apache 2.x:

apxs -i mod_auth_mysql.la

Next, add the following directive to httpd.conf:

LoadModule mysql_auth_module modules/mod_auth_mysql.so

Restart the apache webserver.

Once the webserver has restarted, mod_auth_mysql will be started as a module with apache.

Creating the user table

Login to mysql:

mysql -u root -p

The command line will prompt you for a password, and when you hit enter you should be presented with something like this:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2975 to server version: 5.0.22-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

You are now in a mysql shell!

First you must create a mysql database called auth with the following query:

CREATE DATABASE auth;

You must now create a mysql table as below:

CREATE TABLE `users` (
`id` int(5) NOT NULL auto_increment,
`user_name` char(30) NOT NULL,
`user_passwd` char(20) NOT NULL,
`ip_address` varchar(15) default NULL,
`DateAdded` datetime default NULL,
`Expire` int(1) default NULL,
PRIMARY KEY  (`id`)
)
  • The 'id' column simply serves as the PRIMARY KEY to satisfy MySQL requirements, you do not need to enter data into this field, it will enter itself a unique number.
  • The 'user_name' column will hold usernames under 30 characters.
  • The 'user_passwd' column will hold passwords under 20 characters, which should be encrypted.
  • The 'ip_address' column holds allowed ip addresses, this is optional, it will allow ip address based ACL.
  • The 'DateAdded' column will store the date that the user was added, this is optional, it can be used to allow expiry of a user, for this functionality you will also need to include the 'Expire' column.
  • The 'Expire' column holds either '1' or '0', it is also necessary for expiry of a user, but not mandatory for simple username/password authentication.
  • Adding users

    Users can be added into the MySQL table with the following command from the mysql shell.

    INSERT INTO users (user_name,user_passwd,ip_address,Expire) VALUES ('newuser','newpassword','computersip','1');

    NOTE: If you did not include the IP ACL or Expire options, you should use something more like this:

    INSERT INTO users (user_name,user_passwd) VALUES ('newuser','newpassword');

    Setting up .htaccess

    mod_auth_mysql uses the .htaccess file to know which directories need to be protected.

    Your .htaccess file should be located in /usr/local/webmail/atmail/ and should contain the following:

    AuthName "MySQL authenticated zone"
    AuthType Basic
    AuthMySQLEnable on
    AuthMySQLUser username_for_mysql_database
    AuthMySQLPassword password_for_mysql_database
    AuthMySQLDB auth
    AuthMySQLUserTable users
    AuthMySQLNameField user_name
    AuthMySQLPasswordField user_passwd
    AuthMySQLUserCondition "ip_address = '%a'"
    require valid-user

    NOTE:

    The AuthMySQLUserCondition "ip_address = '%a'" line should only be added if you have ip_address columns set up.

    To test your new configuration navigate to www.yourdomain.com/mail/

    If you get an error 500, then there is most likely something wrong with your .htaccess file, if you get a login box, then enter the username/password combination that you have stored in your mysql table, and it should take you straight to your mail.


    Filed under: Customization — info @ 2:47 pm

     

    January 1, 2008

     Having RBL checking on a per-domain basis

    Some users expressed the need to have the RBL-checking done on a per-domain basis. This can be done by running through the following steps:- locate the following line in your /usr/local/atmail/mailserver/configure file;

    MYSQL_CATCHALL = select AliasTo from MailAliases where AliasName='$domain'

    - add the following below:

    MYSQL_RBL = select Hostname from Domains where RBL='1'

    (more...)


    Filed under: Anti-Virus — info @ 12:00 pm

     

     Updating ClamAV to 0.90.2

    The 0.90.2 version of ClamAV fixes a lot of problems with the previous versions, including the stability problems for installations on non-Linux systems (Solaris, FreeBSD, Mac OS X, etc)You will need:

    - a backup of your clamav.conf and freshclam.conf file;
    - zlib-devel, or libz-devel libraries;
    - a post-3.2 version of GCC;

    (more...)


    Filed under: Anti-Virus — info @ 12:00 pm

     

     Finding httpd.conf

    Having trouble with multiple copies of the httpd.conf file on your system?Try:

    httpd -V

    This will give you the following listing:

    (more...)


    Filed under: Applications — info @ 12:00 pm

     

     Expect Error installing Courier-IMAP

    When you get the error:

    --
    configure: WARNING: expect not found - will not be able to change passwds
    configure: WARNING: in webmail
    --

    Means that you are missing the component called "expect", that normally
    comes with tcl. Download the expect RPM, then install on your server
    this should resolve the problem

    (more...)


    Filed under: Applications — info @ 12:00 pm

     

     Compose page slow to load

    Under some browsers with McAfee installed on the system OS, the compose screen of @Mail can take up to 10 seconds to load.This is due to the "scriptscan" feature enabled via McAfee. This will search all java script as a security method.

    Disabling "scriptscan" will resolve the issue with the slow loading of @Mail.


    Filed under: Applications — info @ 12:00 pm

     

     Exim compile problem in Solaris: “Undefined symbol

    When compiling Exim in Solaris, and you get this error:

    ----
    Undefined first referenced
    symbol in file
    floor                               /usr/local/mysql/lib/mysql/libmysqlclient.a(password.o)
    ld: fatal: Symbol referencing errors. No output written to exim
    collect2: ld returned 1 exit status
    ----

    (more...)


    Filed under: Applications — info @ 12:00 pm

     

     Using Pyzor with SpamAssassin

    Pyzor is a collaborative, networked system to detect and block spam using identifying digests of messages. You can use this along with SpamAssassin to identify spam for incoming mail.To use Pyzor with SpamAssassin, just run through the following steps:

    - download the pyzor source from http://pyzor.sourceforge.net

    (more...)


    Filed under: Applications — info @ 12:00 pm

     

     Whitelisting domains for specific users

    Sometimes, you might want to add whole domains to your whitelist for specific users. This is doable via manual manipulation of the @Mail database - just run through the following steps:- in your MySQL database, select the last line:

    mysql> select * from SpamSettings order by prefid desc limit 1;

    (more...)


    Filed under: Applications — info @ 12:00 pm

     

     Script to backup entire atmail system

    Here is a small script which copies and gzips the entire atmail system to a single file. This allows for the resulting file to be copied elsewhere (the script FTPs it to another server) for safe keeping. The file contains everything required to restore the atmail system.Copy and save it to a script and then set a cron task to run it to backup the entire atmail system.

    (more...)


    Filed under: Backup — info @ 12:00 pm