Authentication

How to authenticate into DSPAM's web interface.

mod_auth_imap

mod_auth_imap is an Apache module that allows you to authenticate with an IMAP server. Since dspam is probably running on the same machine is your IMAP server, this is a viable option as well.

Apache Password File

When messages are passed through DSPAM, the recipient address dictates what user the statistics get logged to. The vpasswd for a domain can be used to generate a list of user IDs for authenticating into the DSPAM web interface.

This Perl script will generate an HTPASSWD file for all the users on your email system and place the resulting password file in /var/websites/dspam/htpasswd. Create a script file /usr/local/bin/vpasswd_to_htpasswd:

#!/usr/bin/perl

$htpasswdFile = "/var/websites/dspam/htpasswd";

$vuserinfo = "/home/vpopmail/bin/vuserinfo";
$vdominfo = "/home/vpopmail/bin/vdominfo";

@domainList = `$vdominfo -n `;

open(HTPASSWDFILE,"> $htpasswdFile") or die "Couldn't open htpasswdfile.\n$!\n\n";
foreach $domainName (@domainList) {
  next if ($domainName eq "\n");
  chomp $domainName;

  @userList = `$vuserinfo -D $domainName -n`;

  foreach $userName (@userList) {
    next if $userName eq "\n";
    chomp $userName;
    $userPass = `$vuserinfo -p $userName\@$domainName`;
    chomp $userPass;
    print HTPASSWDFILE "$userName\@$domainName:$userPass\n";
  }
}
close(HTPASSWDFILE);

Make the file executable:

chmod ugo+x /usr/local/bin/vpasswd_to_htpasswd

Apache Configuration
Edit the <VirtualHost> directive in /usr/local/apache2/conf/extra/httpd-vhosts.conf

  AuthType Basic
  AuthName "dspam Login"
  AuthUserFile /var/websites/dspam/htpasswd
  Require valid-user

Automatically updating htpasswd
Rather than manually recreating the htpasswd file whenever we make changes to the mail server, we'll use the Qmail-Updater service that was installed as part of validrcptto on the SMTP service.
Edit /service/qmail-updater/update-qmail and edit the $push_cmd:

my $push_cmd            = "/usr/local/bin/vpasswd_to_htpasswd" ;

Credits

Various bits of code, scripts, and procedures were put together with information from John Simpson's qmail.jms1.net website. It's an excellent resource on managing and setting up a Qmail server.

Recent Updates

  • 2 years 2 days ago
  • 2 years 2 days ago
  • 2 years 4 days ago
    php 8.x
  • 2 years 5 days ago
    10.6.7
  • 2 years 1 week ago
    Drop Centos 5/6 stuff