summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-29 13:17:02 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-29 13:17:02 +0100
commit38793dbd91a0679cd581b04ca0d1bbc48f4b268d (patch)
tree0691bb7bab2601740a577076517617ebfe7f26d9
parent0b59f02c25c9d846bcf0244c8e1f9270e3bbf817 (diff)
parentf9c50355bd0be03b80d952325b4fa4d740ad4c19 (diff)
downloadpykolab-38793dbd91a0679cd581b04ca0d1bbc48f4b268d.tar.gz
Merge branch 'master' of ssh://git.kolabsys.com/git/pykolab
-rw-r--r--cyruslib.py14
-rw-r--r--kolabd/process.py2
-rw-r--r--pykolab/auth/__init__.py17
-rw-r--r--pykolab/auth/ldap/__init__.py21
-rw-r--r--pykolab/auth/ldap/syncrepl.py27
-rw-r--r--pykolab/base.py5
-rw-r--r--pykolab/conf/__init__.py8
-rw-r--r--pykolab/wap_client/__init__.py14
8 files changed, 86 insertions, 22 deletions
diff --git a/cyruslib.py b/cyruslib.py
index 460cf82..85d7e63 100644
--- a/cyruslib.py
+++ b/cyruslib.py
@@ -673,16 +673,20 @@ class CYRUS:
continue
for annotation in annotations:
+ annotation = annotation.strip()
- folder = annotation.split()[0].replace('"','')
+ if not annotation[0] == '"':
+ folder = annotation.split('"')[0].replace('"','').strip()
+ key = annotation.split('"')[1].replace('"','').replace("'","").strip()
+ _annot = annotation.split('(')[1].split(')')[0].strip()
+ else:
+ folder = annotation.split('"')[1].replace('"','').strip()
+ key = annotation.split('"')[3].replace('"','').replace("'","").strip()
+ _annot = annotation.split('(')[1].split(')')[0].strip()
if not ann.has_key(folder):
ann[folder] = {}
- key = annotation.split()[1].replace('"','').replace("'","")
-
- _annot = annotation.split('(')[1].split(')')[0]
-
try:
value_priv = _annot[(_annot.index('"value.priv"')+len('"value.priv"')):_annot.index('"size.priv"')].strip()
except ValueError, errmsg:
diff --git a/kolabd/process.py b/kolabd/process.py
index 659b74f..ffe33f5 100644
--- a/kolabd/process.py
+++ b/kolabd/process.py
@@ -30,6 +30,7 @@ conf = pykolab.getConf()
class KolabdProcess(multiprocessing.Process):
def __init__(self, domain):
self.domain = domain
+ log.debug(_("Process created for domain %s") % (domain), level=8)
multiprocessing.Process.__init__(
self,
target=self.synchronize,
@@ -38,6 +39,7 @@ class KolabdProcess(multiprocessing.Process):
)
def synchronize(self, domain):
+ log.debug(_("Synchronizing for domain %s") % (domain), level=8)
sync_interval = conf.get('kolab', 'sync_interval')
if sync_interval == None or sync_interval == 0:
diff --git a/pykolab/auth/__init__.py b/pykolab/auth/__init__.py
index 6eaa874..b75f9c3 100644
--- a/pykolab/auth/__init__.py
+++ b/pykolab/auth/__init__.py
@@ -37,15 +37,10 @@ class Auth(pykolab.base.Base):
"""
Initialize the authentication class.
"""
- pykolab.base.Base.__init__(self)
+ pykolab.base.Base.__init__(self, domain=domain)
self._auth = None
- if not domain == None:
- self.domain = domain
- else:
- self.domain = conf.get('kolab', 'primary_domain')
-
def authenticate(self, login):
"""
Verify login credentials supplied in login against the appropriate
@@ -97,8 +92,12 @@ class Auth(pykolab.base.Base):
return
if domain == None:
- section = 'kolab'
- domain = conf.get('kolab', 'primary_domain')
+ if not self.domain == None:
+ section = self.domain
+ domain = self.domain
+ else:
+ section = 'kolab'
+ domain = conf.get('kolab', 'primary_domain')
else:
self.list_domains()
section = domain
@@ -228,6 +227,8 @@ class Auth(pykolab.base.Base):
except:
if not self.domain == kolab_primary_domain:
return [(self.domain, [])]
+ else:
+ domains = []
# If no domains are found, the primary domain is used.
if len(domains) < 1:
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index 441153a..a6a1044 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -868,8 +868,18 @@ class LDAP(pykolab.base.Base):
else:
override_search = False
+ config_base_dn = self.config_get('base_dn')
+ ldap_base_dn = self._kolab_domain_root_dn(self.domain)
+
+ if not ldap_base_dn == None and not ldap_base_dn == config_base_dn:
+ base_dn = ldap_base_dn
+ else:
+ base_dn = config_base_dn
+
+ log.debug(_("Synchronization is searching against base DN: %s") % (base_dn), level=8)
+
self._search(
- self.config_get('base_dn'),
+ base_dn,
filterstr=_filter,
attrlist=[
'*',
@@ -2021,6 +2031,15 @@ class LDAP(pykolab.base.Base):
else:
change = change_dict['change_type']
+ # See if we can find the cache entry - this way we can get to
+ # the value of a (former, on a deleted entry) result_attribute
+ result_attribute = conf.get('cyrus-sasl', 'result_attribute')
+ if not entry.has_key(result_attribute):
+ cache_entry = cache.get_entry(self.domain, entry, update=False)
+
+ if hasattr(cache_entry, 'result_attribute') and change == 'delete':
+ entry[result_attribute] = cache_entry.result_attribute
+
eval(
"self._change_%s_%s(entry, change_dict)" % (
change,
diff --git a/pykolab/auth/ldap/syncrepl.py b/pykolab/auth/ldap/syncrepl.py
index e02e086..03ab5ae 100644
--- a/pykolab/auth/ldap/syncrepl.py
+++ b/pykolab/auth/ldap/syncrepl.py
@@ -5,8 +5,13 @@ import ldap
import ldap.syncrepl
import ldapurl
+import pykolab
+
from pykolab import utils
+log = pykolab.getLogger('pykolab.syncrepl')
+conf = pykolab.getConf()
+
class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer):
callback = None
@@ -28,16 +33,36 @@ class DNSync(ldap.ldapobject.LDAPObject,ldap.syncrepl.SyncreplConsumer):
return self.__db['cookie']
def syncrepl_delete(self, uuids):
+ log.debug("syncrepl_delete uuids: %r" % (uuids), level=8)
+
+ # Get the unique_attribute name to issue along with our
+ # callback (if any)
+ unique_attr = conf.get('ldap', 'unique_attribute')
+ if unique_attr == None:
+ unique_attr = 'entryuuid'
+
+ if unique_attr == 'nsuniqueid':
+ log.warning(
+ _("The name of the persistent, unique attribute " + \
+ "is very probably not compatible with the use of " + \
+ "syncrepl.")
+ )
+
+
for uuid in uuids:
dn = self.__db[uuid]
+ log.debug("syncrepl_delete dn: %r" % (dn), level=8)
+
if not self.callback == None:
self.callback(
change_type='delete',
previous_dn=None,
change_number=None,
dn=dn,
- entry={}
+ entry={
+ unique_attr: uuid
+ }
)
del self.__db[uuid]
diff --git a/pykolab/base.py b/pykolab/base.py
index b63ca2d..207783c 100644
--- a/pykolab/base.py
+++ b/pykolab/base.py
@@ -26,7 +26,10 @@ class Base(object):
Abstraction class for functions commonly shared between auth, imap, etc.
"""
def __init__(self, *args, **kw):
- self.domain = conf.get('kolab', 'primary_domain')
+ if kw.has_key('domain') and not kw['domain'] == None:
+ self.domain = kw['domain']
+ else:
+ self.domain = conf.get('kolab', 'primary_domain')
# Placeholder primary_domain => [secondary_domains]. Should be updated
# on auth backend _connect().
diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py
index 690152a..239c0dd 100644
--- a/pykolab/conf/__init__.py
+++ b/pykolab/conf/__init__.py
@@ -182,7 +182,7 @@ class Conf(object):
return
for key in config.options('testing'):
- retval = False
+ retval = False
if isinstance(self.defaults.__dict__['testing'][key], int):
value = config.getint('testing',key)
@@ -596,7 +596,7 @@ class Conf(object):
if value:
try:
from smtplib import SMTP
- self.use_mail = value
+ self.use_mail = value
return True
except ImportError:
log.error(_("No SMTP class found in the smtplib library."))
@@ -606,8 +606,8 @@ class Conf(object):
# Attempt to load the suite,
# Get the suite's options,
# Set them here.
- if not hasattr(self,'test_suites'):
- self.test_suites = []
+ if not hasattr(self,'test_suites'):
+ self.test_suites = []
if "zpush" in value:
selectively = False
diff --git a/pykolab/wap_client/__init__.py b/pykolab/wap_client/__init__.py
index 5daa61c..9274be3 100644
--- a/pykolab/wap_client/__init__.py
+++ b/pykolab/wap_client/__init__.py
@@ -246,9 +246,19 @@ def group_add(params=None):
if params == None:
params = get_group_input()
- params = json.dumps(params)
+ post = json.dumps(params)
+
+ return request('POST', 'group.add', post=post)
+
+def group_delete(params=None):
+ if params == None:
+ params = {
+ 'id': utils.ask_question("Name of group to delete", "group")
+ }
+
+ post = json.dumps(params)
- return request('POST', 'group.add', params)
+ return request('POST', 'group.delete', post=post)
def group_form_value_generate_mail(params=None):
if params == None: