Changeset 787

Show
Ignore:
Timestamp:
09/06/08 03:29:56 (3 months ago)
Author:
free
Message:

Added class _Amavis

Location:
ares/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • ares/trunk/ares.py

    r785 r787  
    5757        self.ssl      = _Ssl(self) 
    5858        self.squirrel = _Squirrel(self) 
     59        self.amavis   = _Amavis(self) 
    5960 
    6061if __name__ == '__main__': 
     
    364365        aug.set(cfg + '/PHP/memory_limit', '32M') 
    365366 
     367# 
     368# Amavis 
     369# 
     370class _Amavis: 
     371 
     372    def __init__(self, ares): 
     373        self._ares = ares 
     374 
     375    def _uncomment(self, str, cfg): 
     376        cmd = 'sed -i -e \'s|^#%s|%s|g\' %s' % (str, str, cfg) 
     377        if os.system(cmd) != 0: 
     378            raise AresError('F: %s' % cmd) 
     379 
     380    def setup(self): 
     381        # TODO: do this with augeas 
     382        cfg = self._ares.root + 'etc/amavis/conf.d/15-content_filter_mode' 
     383 
     384        for str in [ 
     385            '@bypass_virus_checks_maps = (', 
     386            '   \\\\%bypass_virus_checks, \\\\@bypass_virus_checks_acl, \\\\$bypass_virus_checks_re);', 
     387            '   \\\\%bypass_spam_checks, \\\\@bypass_spam_checks_acl, \\\\$bypass_spam_checks_re);', 
     388            '@bypass_spam_checks_maps = (' ]: 
     389            self._uncomment(str,cfg) 
     390 
     391        cfg = self._ares.root + 'etc/amavis/conf.d/20-debian_defaults' 
     392        str = '\$final_banned_destiny    ' 
     393        cmd = 'sed -i -e \'s|^%s = D_BOUNCE;|%s = D_DISCARD;|g\' %s' % (str,str,cfg) 
     394        if os.system(cmd) != 0: 
     395            raise AresError('F: %s' % cmd) 
     396 
     397        str = '\$final_spam_destiny      ' 
     398        cmd = 'sed -i -e \'s|^%s = D_BOUNCE;|%s = D_DISCARD;|g\' %s' % (str,str,cfg) 
     399        if os.system(cmd) != 0: 
     400            raise AresError('F: %s' % cmd) 
     401 
     402        # Stop here if we not running as root 
     403        aug = self._ares.aug 
     404        if aug.get('/augeas/root') == 'fakeroot/': 
     405            return 
     406 
     407        cmd = 'adduser clamav amavis > /dev/null' 
     408        if os.system(cmd) != 0: 
     409            raise AresError('F: %s' % cmd) 
     410 
  • ares/trunk/tests/TestAres.py

    r785 r787  
    2323        ares.ssl.setup() 
    2424        ares.squirrel.setup() 
     25        ares.amavis.setup() 
    2526        ares.aug.save() 
    2627