Changeset View
Changeset View
Standalone View
Standalone View
pykolab/plugins/roundcubedb/__init__.py
Show All 39 Lines | class KolabRoundcubedb(object): | ||||
def user_delete(self, *args, **kw): | def user_delete(self, *args, **kw): | ||||
""" | """ | ||||
The arguments passed to the 'user_delete' hook: | The arguments passed to the 'user_delete' hook: | ||||
user - full user entry from LDAP | user - full user entry from LDAP | ||||
domain - domain name | domain - domain name | ||||
""" | """ | ||||
log.debug(_("user_delete: %r") % (kw), level=9) | log.debug(_("user_delete: %r") % (kw), level=8) | ||||
if os.path.isdir('/usr/share/roundcubemail'): | if os.path.isdir('/usr/share/roundcubemail'): | ||||
rcpath = '/usr/share/roundcubemail/' | rcpath = '/usr/share/roundcubemail/' | ||||
elif os.path.isdir('/usr/share/roundcube'): | elif os.path.isdir('/usr/share/roundcube'): | ||||
rcpath = '/usr/share/roundcube/' | rcpath = '/usr/share/roundcube/' | ||||
else: | else: | ||||
log.error(_("Roundcube installation path not found.")) | log.error(_("Roundcube installation path not found.")) | ||||
return False | return False | ||||
result_attribute = conf.get('cyrus-sasl', 'result_attribute') | result_attribute = conf.get('cyrus-sasl', 'result_attribute') | ||||
# execute Roundcube's bin/deluser.sh script to do the work | # execute Roundcube's bin/deluser.sh script to do the work | ||||
if kw.has_key('user') and kw['user'].has_key(result_attribute) and os.path.exists(rcpath + 'bin/deluser.sh'): | if kw.has_key('user') and kw['user'].has_key(result_attribute) and os.path.exists(rcpath + 'bin/deluser.sh'): | ||||
proc = subprocess.Popen([ 'sudo -u apache', rcpath + 'bin/deluser.sh', kw['user'][result_attribute] ], stderr=subprocess.PIPE, stdout=subprocess.PIPE) | proc = subprocess.Popen([ 'sudo -u apache', rcpath + 'bin/deluser.sh', kw['user'][result_attribute] ], stderr=subprocess.PIPE, stdout=subprocess.PIPE) | ||||
procout, procerr = proc.communicate() | procout, procerr = proc.communicate() | ||||
if proc.returncode != 0: | if proc.returncode != 0: | ||||
log.error(rcpath + "bin/deluser.sh exited with error %d: %r" % (proc.returncode, procerr)) | log.error(rcpath + "bin/deluser.sh exited with error %d: %r" % (proc.returncode, procerr)) | ||||
else: | else: | ||||
log.debug(rcpath + "bin/deluser.sh success: %r; %r" % (procout, procerr), level=9) | log.debug(rcpath + "bin/deluser.sh success: %r; %r" % (procout, procerr), level=8) | ||||
return None | return None |