This file is indexed.

/usr/share/pysieved/plugins/lmtpd.py is in pysieved 1.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#! /usr/bin/python

## pysieved - Python managesieve server
## Copyright (C) 2007 Neale Pickett

## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or (at
## your option) any later version.

## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.

## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
## USA

import __init__
import warnings
import os
import FileStorage
import subprocess


class PysievedPlugin(__init__.PysievedPlugin):

    def init(self, config):
        self.capabilities = ('fileinto reject envelope comparator-i;ascii-numeric relational subaddress copy')
        self.scripts_dir = config.get('lmtpd', 'scripts', '.pysieved')
        self.active_file = config.get('lmtpd', 'active', 'ssfilter')
        self.checker = config.get('lmtpd', 'checker', '/usr/bin/sieve-check')

        if not os.path.exists(self.checker):
            raise OSError('Sieve check not found')


    def create_storage(self, params):
        return FileStorage.FileStorage(self.scripts_dir,
                                       self.active_file,
                                       params['homedir'])


    def sieve_has_error(self, tmpdir, script):
        testfile = FileStorage.TempFile(tmpdir)
        testfile.write(script)
        testfile.close()

        self.log(7, 'Popen("%s %s")' % (self.checker,
                                        testfile.name))
        p = subprocess.Popen([self.checker, testfile.name],
                             stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE, close_fds=True)
        (ret_str, err_str) = p.communicate()
        ret_str = ret_str.strip()
        err_str = err_str.strip()
        rc = p.returncode
        self.log(7, 'rc = %d' % rc)
        if rc:
            self.log(7, 'err_str = %s' % err_str)
            self.log(5, 'check failed')
            return err_str
        self.log(5, 'check succeeded')
        return None


    def pre_save(self, tmpdir, script):
        err_str = self.sieve_has_error(tmpdir, script)
        if err_str:
            raise ValueError(err_str)

        return script


    def post_load(self, script):
        return script