/usr/share/pysieved/plugins/mysql.py is in pysieved 1.1-0.1ubuntu1.
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 | #! /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 MySQLdb
class PysievedPlugin(__init__.PysievedPlugin):
def init(self, config):
dbhost = config.get('MySQL', 'dbhost')
dbuser = config.get('MySQL', 'dbuser')
dbpass = config.get('MySQL', 'dbpass')
dbname = config.get('MySQL', 'dbname')
self.auth_query = config.get('MySQL', 'auth_query')
self.user_query = config.get('MySQL', 'user_query')
self.conn = MySQLdb.connect(host = dbhost,
user = dbuser,
passwd = dbpass,
db = dbname)
def __del__(self):
self.conn.close()
def auth(self, params):
cursor = self.conn.cursor()
cursor.execute(self.auth_query % params)
row = cursor.fetchone()
cursor.close()
# Only return true if there was a row result
if row:
return True
return False
def lookup(self, params):
cursor = self.conn.cursor()
cursor.execute(self.user_query % params)
row = cursor.fetchone()
assert row, 'No results from select (invalid user?)'
cursor.close()
return row[0]
|