Installation auf Debian Etch

Im Folgenden soll in aller Kürze die Installation von SysCP auf einem Debian Etch System beschrieben werden. Die reine SysCP Installation ist schnell gemacht. Etwas schwieriger gestaltet sich die Integration von Spamassassin, ClamAV und benutzerdefinierten Mailfilterregeln in die SysCP Konfiguration.

/etc/apt/sources.list:

[...]

deb http://debian.syscp.de/ etch/

[...]
apt-get update
apt-get remove --purge exim4-base
apt-get remove --purge exim4-config popa3d
apt-get install syscp courier-imap courier-imap-ssl courier-pop-ssl

Apache vorbereiten

rm /etc/apache2/sites-enabled/000-default

/etc/apache2/httpd.conf:

DocumentRoot /var/www/
<Directory />
   Options FollowSymLinks
   AllowOverride None
</Directory>
<Directory /var/www/>
   Options FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   allow from all
</Directory>
a2enmod php5

/etc/php5/apache2/php.ini:

disable_functions = ini_restore
extension=mysql.so
/etc/init.d/apache2 restart

SSL mit CAcert

mkdir /etc/apache2/ssl/

Generate a certificate signing request (CSR) using the command:

openssl req -newkey rsa:1024 -subj /CN=*.example.invalid -nodes -keyout private.key -out server.csr

Go to CACert, log in, and select “Server certificates → New”. If a Class 3 certificate is available for you I'd advise you to select a Class 3 certificate. Use Copy/Paste to input your CSR (the content of example_csr.pem in the above example) into the big editor box. Be sure to include the header and footer lines ( —–BEGIN CERTIFICATE REQUEST—– and —–END CERTIFICATE REQUEST—– ) and check that after the paste operation the request has not been truncated.

server.csr —> Inhalt bei cacert einfügen

/etc/apache2/ssl/server.crt:

+++++ERGEBNIS VON CACERT+++++

If using a Class 3 certificate as proposed you'll need the certificate chain file. This is just the Class 3 root certificate and the Class 1 root certificate in PEM format concatenated. Do it yourself or download it from the attachments. Store the certificate chain file in the ssl.crt directory and let's call it CAcert_chain.pem for future reference.

cd /etc/apache2/ssl/
wget http://wiki.cacert.org/wiki/SimpleApacheCert?action=AttachFile&do=get&target=CAcert_chain.pem

mv ~/private.key /etc/apache2/ssl/
rm ~/server.csr

cp /etc/apache2/ssl/private.key /etc/ssl/private/
chown root.ssl-cert /etc/ssl/private/private.key
chmod 0640 /etc/ssl/private/private.key

cp /etc/apache2/ssl/CAcert_chain.pem /etc/ssl/certs/
cp /etc/apache2/ssl/server.crt /etc/ssl/certs/

Die neuen Cert-Dateien:

  • /etc/ssl/private/private.key
  • /etc/ssl/certs/CAcert_chain.pem
  • /etc/ssl/certs/server.crt

Apache

/etc/apache2/sites-available/default-ssl:

<VirtualHost *:443>
  # SSL (START)
  SSLEngine on

  SSLCertificateFile /etc/apache2/ssl/server.crt
  SSLCertificateKeyFile /etc/apache2/ssl/private.key
  SSLCertificateChainFile /etc/apache2/ssl/CAcert_chain.pem
  # SSL (ENDE)

  ServerAdmin webmaster@example.invalid
  ServerName ssl.example.invalid
  DocumentRoot /var/www/
  <Directory "/var/www">
    Order Deny,Allow
    Allow from all
    # Zeige keine Verzeichnisse an
    Options -Indexes
  </Directory>
</VirtualHost>
a2ensite default-ssl

/etc/apache2/ports.conf:

Listen 80
Listen 443
a2enmod ssl

apache2ctl restart

Courier

mv /etc/courier/imapd.pem /etc/courier/imapd.pem.old
cat /etc/ssl/private/private.key /etc/ssl/certs/server.crt > /etc/courier/imapd.pem

/etc/init.d/courier-imap-ssl restart
/etc/init.d/courier-pop-ssl restart

Postfix

/etc/postfix/main.cf:

[...]

# Server side TLS
smtpd_use_tls = yes
smtpd_tls_key_file = /etc/ssl/private/private.key
smtpd_tls_cert_file = /etc/ssl/certs/server.crt
smtpd_tls_CAfile = /etc/ssl/certs/CAcert_chain.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s

# Client side TLS
smtp_use_tls = yes
smtp_tls_key_file = /etc/ssl/private/private.key
smtp_tls_cert_file = /etc/ssl/certs/server.crt
smtp_tls_CAfile = /etc/ssl/certs/CAcert_chain.pem

# Misc TLS
tls_random_source = dev:/dev/urandom

[...]
/etc/init.d/postfix restart

SysCP aufrufen…

https://localhost/syscp/

…und den Anweisungen unter Server → Konfiguration folgen…

Spamassassin

apt-get install spamassassin libmail-spf-query-perl libmailtools-perl libnet-dns-perl dcc-client libdbi-perl libio-socket-ssl-perl libnet-ident-perl libnet-perl pyzor razor spamc

/etc/default/spamassassin:

[...]

ENABLED=1

[...]

#OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
OPTIONS="--create-prefs --max-children 5 -q -x -u vmail"

[...]

NICE="--nicelevel 10" 

[...]
/etc/init.d/spamassassin restart

ClamAV

apt-get update
apt-get install clamav clamav-daemon clamav-freshclam arj unzoo lha unrar

Squirrel Mail

apt-get install squirrelmail squirrelmail-locales imapproxy

/etc/imapproxy.conf:

[...]
listen_port 144
listen_address 127.0.0.1
[...]
squirrelmail-configure
	2
	A
	5
	type: 144
	S
	Q

Maildrop

Änderungen:

https://forum.syscp.org/index.php?topic=3082.0 etch mit maildrop hat seine config in /etc/ nicht in /etc/courier

http://syscp-forum.org/index.php/topic,2345.0.html Problem: Die Userfilter und der Virenscanner wird nicht verwendet

Die Returncodes von /var/www/syscp/scripts/modules/maildrop/getsettings.php scheinen nicht richtig gesetzt zu werden. (Nebenbei bemerkt: Bei Etch ist PHP5 Standard. Daher müsste die erste Zeile »#! /usr/bin/php« lauten. Nicht php4.)

Neues Shell Script, um die Einstellungen aus der DB zu holen: /usr/local/syscp/maildrop/getsettings.sh

https://forum.syscp.org/index.php?topic=3081.0 wegen des Erstellens des Ordners, gibts ein Problem in der default config, wofür ich noch keine schöne Lösung fand,

apt-get update
apt-get install maildrop

/etc/maildropmysql.config:

hostname            127.0.0.1
socket              /var/run/mysqld/mysqld.sock
port                3306
database            syscp
dbuser              syscp
dbpw                MYSQL_PASSWORD
dbtable             mail_users
default_uidnumber   2000
default_gid         2000
uid_field           email
uidnumber_field     uid
gidnumber_field     gid
maildir_field       maildir
homedirectory_field homedir
quota_field         100000000
#quota_field        quota
# unused for now, but needs to be a valid field.
mailstatus_field    postfix
where_clause        AND postfix = 'Y'

“MYSQL_PASSWORD” ersetzen

chmod 600 /etc/maildropmysql.config
chown vmail.vmail /etc/maildropmysql.config

/etc/maildroprc

#########################################################
# Created by Philipp Haefelfinger
#########################################################
# How this script works:
# 1. create maildir if it doesn't exist
# 2. open logfile
# 3. get settings from Database if enabled
# 4. run virusscan if enabled -> if virus found disable all other scans
# 5. run spamscan if enabled -> if spam disable other scans
# 6. run userdefines scans if enabled
# 7. deliver to MAILDIR
#########################################################
#Configuration
#########################################################

DEFAULT=`echo " select maildir from mail_users where username = '$LOGNAME';" |mysql -u syscp -p"MYSQL_PASSWORD" syscp -h 127.0.0.1 | grep \@`

# set this to 1 if you want to log the usersettings vor vscan, etc.
LOGUSERSETTINGS=1

# Full path to the maildrop log of each user
LOGFILEPATH=$HOME$DEFAULT/maildrop.log

# Setting for SysCP maildrop module
USESYSCPSETTINGS=1

# Basedir of your syscp installation
SYSCPBASEDIR="/var/www/syscp"

# Default setting for the spamfilter
SPAMFILTER=0

# use spamc instead of the direct call to spamassassin
USESPAMC=1

# Default setting for the virusscan
VSCAN=0

# include userdefined filters into maildrop
USERFILTER=1

# basedir of your userdefined filterfiles
MAILFILTERDIR="/var/kunden/mailfilter"


# Only scan mails smaller than SCANSPAMSIZE for spam
SCANSPAMSIZE="2000000"

# Only scan mails smaller than VSCANSIZE for a virus
VSCANSIZE="2000000"

#########################################################
# Do NOT change anything below this line unless you know
# what you're doing!
#########################################################
#
# First check if the maildir exists and create it, if 
# it doesn't exist
#
#########################################################
MAILDIR=$HOME$DEFAULT
#MAILDIR=$HOME$LOGNAME

`test -d "$MAILDIR"`				# check if dir exist
if ($RETURNCODE != 0)
{
	`mkdir -p $MAILDIR`			# create dirs with parents
	`rmdir $MAILDIR`			# remove dir for init
	`/usr/bin/maildirmake $MAILDIR`		# create maildir
}

#########################################################
#
# init logfile for this user
#
#########################################################
logfile "$LOGFILEPATH"
log "========================================================================="
if ( $LOGUSERSETTINGS )
{
	log "maildir: $MAILDIR"
	log "SPAMFILTER: $SPAMFILTER - VSCAN: $VSCAN"
	log "logname: $LOGNAME"
}

#########################################################
#
# get settings for account from SysCP-Database
#
#########################################################
if ( $USESYSCPSETTINGS )
{
`/usr/local/syscp/maildrop/getsettings.sh $LOGNAME`
log "CODE nach Abfrage: $RETURNCODE"

    if ($RETURNCODE == 3)
    {
        VSCAN=1
        SPAMFILTER=1
    }
    if ($RETURNCODE == 2)
    {
        VSCAN=1
        SPAMFILTER=0
    }
    if ($RETURNCODE == 1)
    {
        VSCAN=0
        SPAMFILTER=1
    }
    if ($RETURNCODE == 0)
    {
        VSCAN=0
        SPAMFILTER=0
    }
}

#########################################################
#
# run virusscan
#
#########################################################
if ( $VSCAN )
{
    if( $SIZE < $VSCANSIZE )
    {
        exception {
		    xfilter "/usr/bin/clamscan.sh"
        }
    }

    # check if mail is marked as virus
    if(/^X-Virus-Status:.*INFECTED/)
    {
		exception {
		    log "identifyed as virus! -> $MAILDIR/.Virus"
		    MAILDIR = $MAILDIR.Virus/
		    SPAMFILTER=0
		    USERFILTER=0
		}
    }
}

#########################################################
#
# run spamfilter
#
#########################################################
if ( $SPAMFILTER )
{
    if( $SIZE < $SCANSPAMSIZE )
    {
		exception {
			if ( $USESPAMC )
			{
		    	xfilter "/usr/bin/spamc -f -x -u $LOGNAME"
			}
			else
			{
		    	xfilter "/usr/bin/spamassassin -x"
			}
		}
    }

    # check if mail is marked as spam
    if(/^X-Spam-Flag: *YES/)
    {
		exception {
		    log "identifyed as spam! -> $MAILDIR/.Spam"
		    MAILDIR = $MAILDIR.Spam/
	    	    VSCAN=0
		    USERFILTER=0
		}
    }
}

#########################################################
#
# include userdefined mailfilter
#
#########################################################
if ( $USERFILTER )
{
	exception {
		include $MAILFILTERDIR/$LOGNAME
	}
}

#########################################################
#
# create needed sub-directory, if it doesn't exist
#
#########################################################
`test -d "$MAILDIR"`
if( $RETURNCODE == 1 )
{
        `mkdir -p $MAILDIR`
        `rmdir $MAILDIR`
        `/usr/bin/maildirmake "$MAILDIR"`
} 

#########################################################
#
# deliver mail to maildir
#
#########################################################
exception {
    log "filtering done, deliver to $MAILDIR"
    to "$MAILDIR"
}

“MYSQL_PASSWORD” ersetzen

mkdir -p /usr/local/syscp/maildrop

/usr/local/syscp/maildrop/getsettings.sh:

#!/bin/bash

#MySQL Zugangsdaten
user=syscp;
password=MYSQL_PASSWORD;
host=127.0.0.1;
db=syscp;
###

email=$1;
domain=`echo $email | sed -e 's/.*@//'`;

select=$(mysql $db -u$user -p$password -h$host -s -N -e "SELECT CONCAT_WS('',virus,spam) FROM modules_maildrop where email in ('$email','@$domain') order by length(email) desc LIMIT 1")
if [[ "" == "$select" ]]; then
  select=$(mysql $db -u$user -p$password -h$host -s -N -e "SELECT CONCAT_WS('',virus,spam) FROM modules_maildrop WHERE email='%GLOBAL'")
fi

case "$select" in
  "YY" | "yy" )
      exit 3;
  ;;

  "YN" | "yn" )
  exit 2;
  ;;

  "NY" | "ny" )
  exit 1;
  ;;

  *)
  exit 0;
  ;;
esac

“MYSQL_PASSWORD” ersetzen

chmod 600 /usr/local/syscp/maildrop/getsettings.sh 
# Korrektur von Reo: Die Rechte müssen auf 700 gesetzt werden, damit das Skript ausgeführt werden kann!
chown vmail.vmail /usr/local/syscp/maildrop/getsettings.sh

Maildrop SysCP-Modul

SA-Settings SysCP-Modul

Postfix-Anpassungen

/etc/postfix/main.cf:

[...]

# use this for virtual delivery / fuer die Verwendung ohne Maildrop
#virtual_transport = virtual
#use this for maildrop-delivery / fuer die Verwendung mit Maildrop
virtual_transport = maildrop

#Maildrop-Options for usage with maildrop
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1

[...]

Spamassassin-Anpassungen

/etc/default/spamassassin:

[...]
# Change to one to enable spamd
ENABLED=1
[...]
# Default options for use with spamassassin
#OPTIONS="--create-prefs --max-children 5 --helper-home-dir"

# My options for use with spamc and maildrop
OPTIONS="--create-prefs --max-children 5 -q -x -u vmail"
[...]
/etc/init.d/spamassassin restart

ClamAV Anpassungen

- EDIT (gem. http://www.voja.at/2007/05/04/debian-etch-syscp-clamscansh/)

/usr/bin/clamscan.sh:

#!/bin/bash
# Created by Tom Walsh, slim at ala.net
# slightly modified by Wolfgang Ziegler, nuppla at gmx.at
 
RUN=clamscan
# Enable this line, if you are using the clamav-daemon.
# RUN=clamdscan


#start
#MSG=$(cat /proc/self/fd/0) # stdin -> $MSG # sarge-way
MSG=$(cat -) # So klappts unter Etch
SCAN=$(echo "$MSG" | $RUN - --stdout --disable-summary)
EXIT="$?"
VIRUS=$(echo "$SCAN" | awk '{print $2}')
SUBJECT=$(echo "$MSG" | reformail -x Subject:)

if [ "$EXIT" == "1" ]; then
  SUBJECT="**VIRUS** [$VIRUS] $SUBJECT"
  MSG=$(echo "$MSG" | reformail -i"X-Virus-Status: INFECTED")
  MSG=$(echo "$MSG" | reformail -i"Subject: $(echo "$SUBJECT")")
else
  MSG=$(echo "$MSG" | reformail -i"X-Virus-Status: CLEAN")
fi

echo "$MSG"
exit 0
chown vmail.vmail /usr/bin/clamscan.sh
chmod 0755 /usr/bin/clamscan.sh

Bei Debian Etch braucht Maildrop nicht mehr gepatched werden. Es müssen nur die Rechte geändert werden:

chmod +x /var/run/courier/authdaemon

Anmerkung:

Maildrop geht im Standard davon aus, dass der Username eine E-Mail-Adresse ist. Es ist aber denkbar, dass z.B. durch die Übernahme von anderen Verwaltungssystemen die Usernamen und die E-Mail-Adressen keinen Zusammenhang aufweisen. Damit ergibt sich ein Problem. Diese Problem kann durch die Veränderung der Datenbankabfrage in dem dafür vorgesehen File (z.B. /etc/courier/couriermysqlrc oder einem anderen File, der Login in Datenbankconnects abarbeitet) behoben werden.

Courier bedarf dazu einer DEFAULT_DOMAIN, die aber nicht existieren muss. Es handelt sich um einen Dummy. Sodann muss ein Select erzeugt werden, der die notwendigen Felder abfragt und verknüpft. Eine Möglichkeit ist es, folgende Zusätze in den entsprechenden File zu schreiben:

DEFAULT_DOMAIN   test.com
MYSQL_SELECT_CLAUSE SELECT username, password_enc, password, uid, gid, homedir, maildir , "", "", "" FROM mail_users WHERE (email='$(local_part)@$(domain)') or username='$(local_part)')

 
contrib/installation/de/debian/etch.txt · Last modified: 2008/07/03 19:12 (external edit)
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Footer