| | 367 | # |
| | 368 | # Amavis |
| | 369 | # |
| | 370 | class _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 | |