fixed crash on setup mail

py3_forced
parent 2491f64a43
commit 5ebeb22900

@ -1114,7 +1114,7 @@ in a sambaDomainName',
[not x in retList and retList.append(x) for x in listEl]
return retList
#TODO debug jpeg encoding
#TODO debug magick png to jpeg encoding
def setJpegPhotoUser(self, userName, photoPath, attr="uid"):
"""Добавляем jpeg фотографию пользователя в LDAP"""
import subprocess
@ -2797,7 +2797,6 @@ service"))
addUsers.append(user)
modAttrs = []
for userName in addUsers:
#TODO check userName encoding
modAttrs.append((ldap.MOD_ADD, 'memberUid', userName.encode("UTF-8")))
if modAttrs:
groupDN = self.addDN("cn=" + groupName, self.relGroupsDN)
@ -5947,10 +5946,9 @@ of version > 2.1.10, then you can delete this file.") + "\n"
foundUserNames = []
if searchUsers:
for data in searchUsers:
#TODO check encoding
foundUserNames.append(data[0][1]["uid"][0])
foundUserNames.append(data[0][1]["uid"][0].decode("UTF-8"))
if foundUserNames:
primaryUsers = list(set(foundUserNames)&set(users))
primaryUsers = list(set(foundUserNames) & set(users))
if primaryUsers:
self.printERROR(_("%s is primary group")% groupName + " " +\
_("for users (%s)")%", ".join(primaryUsers))
@ -10066,6 +10064,12 @@ the password will be changed only for Samba account")
'helpChapter':_("DHCP service options"),
'help':_("forced setup service")
},
{'progAccess':(6,),
'shortOption':"f",
'longOption':"force",
'helpChapter':_("Samba service options"),
'help':_("forced setup service")
},
{'progAccess':(6,),
'longOption':"net",
'optVal':"NET",
@ -14930,7 +14934,7 @@ with another option."))
headers = [_("Field"),_("Value")]
attributes = [x[0] for x in data]
retrAttrs = [x[1] for x in data]
retClVars=False
retClVars = False
#TODO check encoding
searchRes = self.getQueryLDAP(service, "computers", searchAttr,
searchStr, retrAttrs)
@ -14953,7 +14957,7 @@ with another option."))
flagFirst = False
for value in ldapValue:
if not flagFirst:
data.append((attrName, value.decode("UTF-8")))
data.append((attrName, value))
flagFirst = True
else:
data.append(("", value.decode("UTF-8")))
@ -14965,12 +14969,12 @@ with another option."))
if value:
memberGroups.insert(0, value.decode("UTF-8"))
flagFirst = False
for value in memberGroups:
for member_group in memberGroups:
if not flagFirst:
data.append((attrApp, value))
data.append((attrApp, member_group))
flagFirst = True
else:
data.append(("", value))
data.append(("", member_group))
else:
data.append((attrName, _("No")))
return (headers, data)
@ -16899,22 +16903,23 @@ class dnsTxt(cl_profile.bind,shareTxt):
# прямая зона
dnsDN = "ou=Forward,%s"%dnsBaseDN
template = 'zone "%s" in {\n\
\ttype %s;\n\
\tdatabase "ldap ldap://127.0.0.1/zoneName=%s,%s????\
!bindname=%s,!x-bindpw=%s 178600";\n\
};' %(zoneName,zoneType,zoneName,dnsDN,dnsCommaSplDN,dnsBasePw)
\ttype %s;\n\
\tdatabase "ldap ldap://127.0.0.1/zoneName=%s,%s????\
!bindname=%s,!x-bindpw=%s 178600";\n\
};' %(zoneName,zoneType,zoneName,dnsDN,dnsCommaSplDN,dnsBasePw)
return template
elif zoneType == "slave":
if not zoneMasters:
self.setError(\
_('Can not found master DNS server in the DNS zone "%s"')%zoneName)
_('Can not found master DNS server\
in the DNS zone "%s"')%zoneName)
return False
zoneFile = "%s.zone" %zoneName.split(".in-addr.arpa")[0]
template = 'zone "%s" {\n\
\ttype %s;\n\
\tfile "sec/%s";\n\
\tmasters { %s; };\n\
};' %(zoneName,zoneType,zoneFile, "; ".join(zoneMasters))
\ttype %s;\n\
\tfile "sec/%s";\n\
\tmasters { %s; };\n\
};' %(zoneName,zoneType,zoneFile, "; ".join(zoneMasters))
return template
else:
self.setError(_('DNS zone type %s unsupported')%zoneType)
@ -17479,7 +17484,7 @@ class servDns(shareLdap):
flagDeleteZone = True
else:
self.printWARNING(_("Can not found zone %s in \
/etc/bind/named.conf")%zoneName)
/etc/bind/named.conf")%zoneName)
# Если зона найдена в LDAP удаляем ее
if self.searchZoneInLDAP(zoneName):
# Удаление зоны из LDAP
@ -17631,7 +17636,7 @@ class servDns(shareLdap):
incompKeys = ["host","ip"]
if set(incompKeys)<=set(optKeys):
self.printERROR(_('Command line option "--host" (A-record) \
incompatible with option "--ip" (PTR-record)'))
incompatible with option "--ip" (PTR-record)'))
return False
# Флаг MX - записи
flagDeleteMX = False
@ -17654,7 +17659,7 @@ incompatible with option "--ip" (PTR-record)'))
elif 'ip' in options:
if flagDeleteMX:
self.printERROR(_('Command line option "--mx" (MX-record) \
incompatible with option "--ip" (PTR-record)'))
incompatible with option "--ip" (PTR-record)'))
return False
# ip адрес
typeRec = "ptr"
@ -17783,8 +17788,7 @@ incompatible with option "--ip" (PTR-record)'))
not self.isCorrectStringNet(zoneName):
self.printERROR(_('Incorrect network %s for reverse zone')\
%zoneName)
self.printWARNING(_("Example network for reverse zone") +\
" :")
self.printWARNING(_("Example network for reverse zone") + " :")
self.printWARNING('"-n 192.168.0.0/24"')
return False
dataIP = self.getDomainAndZoneFromIP(network)
@ -17831,8 +17835,7 @@ incompatible with option "--ip" (PTR-record)'))
%zoneName)
return False
# Удаляем все MX записи в записи зоны
ret = self.modMXRecord("@", zoneName, zoneName,
True, [])
ret = self.modMXRecord("@", zoneName, zoneName, True, [])
# Увеличиваем на 1 серийный номер зоны
if not self.incrementSerialNumberZone(zoneName):
return False
@ -17899,12 +17902,12 @@ incompatible with option "--ip" (PTR-record)'))
# ip зоны для обратной зоны недопустим
if 'ip' in options:
self.printERROR(_('Command line option "--ip" \
incompatible with reverse DNS zone %s')%zoneName)
incompatible with reverse DNS zone %s')%zoneName)
return False
# MX записи для обратной зоны недопустимы
if 'mx' in options:
self.printERROR(_('Command line option "--mx" \
incompatible with reverse DNS zone %s')%zoneName)
incompatible with reverse DNS zone %s')%zoneName)
return False
network, spl, netmask = zoneName.rpartition("/")
if not netmask == "24" or \
@ -17957,7 +17960,7 @@ incompatible with reverse DNS zone %s')%zoneName)
if not self.isCorrectStringNet(options['servers'], False):
self.printERROR(_('Incorrect autoritatives servers IP'))
self.printERROR(_('Error in command line option \
"--servers"'))
"--servers"'))
self.printWARNING(_('Example:'))
self.printWARNING('--servers 192.168.0.1,192.168.0.2')
return False
@ -17970,7 +17973,7 @@ incompatible with reverse DNS zone %s')%zoneName)
if flagErrorNs:
self.printERROR(_('Incorrect autoritatives servers names'))
self.printERROR(_('Error in command line option \
"--servers"'))
"--servers"'))
self.printWARNING(_('Example:'))
self.printWARNING('--servers ns.domain.ru,ns1.domain.ru')
return False
@ -17986,14 +17989,14 @@ incompatible with reverse DNS zone %s')%zoneName)
if self.isCorrectStringNet(nameServer, False):
self.printERROR(_('Incorrect autoritative server'))
self.printERROR(_('Error in command line option \
"--server"'))
"--server"'))
self.printWARNING(_('Example:'))
self.printWARNING('--server ns.domain.com')
return False
if not nameServer:
self.printERROR(_('Incorrect autoritative server name'))
self.printERROR(_('Error in command line option \
"--server"'))
"--server"'))
return False
# Добавляем мастер сервер в имена авторитативаных серверов
if not nameServer in namesServers:
@ -18007,14 +18010,14 @@ incompatible with reverse DNS zone %s')%zoneName)
not self.searchDomainNameInLDAP(nameServer)):
if 'ipserver' not in options:
self.printERROR(_('Not found A-record for "%s" \
(master server DNS)')%nameServer)
(master server DNS)')%nameServer)
self.printERROR(_('Not enough command line option \
"--ipserver"'))
"--ipserver"'))
return False
else:
if nameServer == zoneName and zoneIP:
self.printERROR(_("The same zone name and name of \
the primary authoritative server for the zone"))
the primary authoritative server for the zone"))
self.printERROR(_('We do not need the option "--ip"'))
return False
ipserver = options["ipserver"]
@ -18027,11 +18030,13 @@ the primary authoritative server for the zone"))
if self.searchZoneInLDAP(nsZoneName) and\
self.searchDomainNameInLDAP(nameServer):
self.printERROR(_('Command line option "--ipserver" \
is not needed, as the host name "%s" found in the DNS server')%nameServer)
is not needed, as the host name "%s" found in\
the DNS server')%nameServer)
else:
self.printERROR(_('Command line option "--ipserver" \
is not needed, as the host name "%s" does not belong to the existing zones on \
this DNS server')%nameServer)
is not needed, as the host name "%s" does not\
belong to the existing zones on \
this DNS server')%nameServer)
return False
# Почтовый адрес администратора зоны
# по умолчанию
@ -18350,7 +18355,7 @@ this DNS server')%nameServer)
# Проверка на mx совместно с mxmod
if 'mx' in options and 'mxmod' in options:
self.printERROR('Command line option "-mx" is incompatible \
with option "--mxmod"')
with option "--mxmod"')
return False
# MX серверы
mxServers = []
@ -18550,7 +18555,7 @@ with option "--mxmod"')
DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs):
self.printERROR(_("Can not modify new SOA-record for zone %s \
in LDAP") % zoneName)
in LDAP") % zoneName)
return False
# Результат исполнения для пользователя
# Изменен ли главный сервер авторизации
@ -18588,7 +18593,7 @@ in LDAP") % zoneName)
# Проверка на имя хоста вместе с ip
if 'ip' in options and 'host' in options:
self.printERROR('Command line option "--host" is incompatible \
with option "--ip"')
with option "--ip"')
return False
# Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x)
@ -18602,7 +18607,7 @@ with option "--ip"')
modOther = False
else:
self.printERROR(_('Command line option "--automod %s" \
incorrect, use "--automod on" or "--automod off"')%autoMod)
incorrect, use "--automod on" or "--automod off"')%autoMod)
return False
# По умолчанию прямой тип записи
typeRec = "a"
@ -18618,7 +18623,7 @@ incorrect, use "--automod on" or "--automod off"')%autoMod)
# Проверка на mx совместно с mxmod
if 'mx' in options and 'mxmod' in options:
self.printERROR('Command line option "-mx" is incompatible \
with option "--mxmod"')
with option "--mxmod"')
return False
# Добавляем кавычки и --
addQ = lambda y: [len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in y]
@ -18696,11 +18701,11 @@ with option "--mxmod"')
# Почтовые серверы для доменного имени
if typeRec == "ptr":
self.printERROR(_('Command line option "--mx" \
incompatible with PTR-record (option "-t")'))
incompatible with PTR-record (option "-t")'))
return False
if typeRec == "cname":
self.printERROR(_('Command line option "--mx" \
incompatible with CNAME-record (option "-t")'))
incompatible with CNAME-record (option "-t")'))
return False
mxServers = [delDot(x.lower()) for x in options['mx'].split(",")]
mxServers = self.unicList(mxServers)
@ -18714,11 +18719,11 @@ incompatible with CNAME-record (option "-t")'))
# Почтовые cерверы для доменного имени
if typeRec == "ptr":
self.printERROR(_('Command line option "--mxmod" \
incompatible with PTR-record (option "-t")'))
incompatible with PTR-record (option "-t")'))
return False
if typeRec == "cname":
self.printERROR(_('Command line option "--mxmod" \
incompatible with CNAME-record (option "-t")'))
incompatible with CNAME-record (option "-t")'))
return False
modMxServers = [delDot(x.lower()) for x in options['mxmod'].split(",")]
modMxServers = self.unicList(modMxServers)
@ -18804,7 +18809,8 @@ incompatible with CNAME-record (option "-t")'))
self.printERROR(_("A-record %s exists in LDAP")\
%newDomainName)
self.printERROR("%s --> %s"\
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0].decode("UTF-8")))
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0]\
.decode("UTF-8")))
self.printERROR("")
return False
newIP = ""
@ -18813,7 +18819,7 @@ incompatible with CNAME-record (option "-t")'))
if 'ip' in options:
if typeRec == "cname":
self.printERROR('Command line option "-t cname" \
is incompatible with option "--ip"')
is incompatible with option "--ip"')
return False
# newIP адрес
newIP = options['ip']
@ -19553,11 +19559,11 @@ is incompatible with option "--ip"')
if 'autoptr' in options:
if typeRec == "ptr":
self.printERROR(_('Command line option "--autoptr" \
incompatible with type DNS record PTR (option "-t")'))
incompatible with type DNS record PTR (option "-t")'))
return False
if typeRec == "cname":
self.printERROR(_('Command line option "--autoptr" \
incompatible with type DNS record CNAME (option "-t")'))
incompatible with type DNS record CNAME (option "-t")'))
return False
autoPtr = options['autoptr']
if autoPtr == "on":
@ -19566,7 +19572,7 @@ incompatible with type DNS record CNAME (option "-t")'))
createPtr = False
else:
self.printERROR(_('Command line option "--autoptr %s" \
incorrect, use "--autoptr on" or "--autoptr off"')%autoPtr)
incorrect, use "--autoptr on" or "--autoptr off"')%autoPtr)
return False
# Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x)
@ -19587,11 +19593,11 @@ incorrect, use "--autoptr on" or "--autoptr off"')%autoPtr)
if 'cname' in options:
if 'ip' in options:
self.printERROR(_('Command line option "--ip" incompatible \
with type DNS record CNAME (option "-t")'))
with type DNS record CNAME (option "-t")'))
return False
if 'mx' in options:
self.printERROR(_('Command line option "--mx" incompatible \
with type DNS record CNAME (option "-t")'))
with type DNS record CNAME (option "-t")'))
return False
# Доменное каноническое имя (имя включающее домен) для CNAME
cnDomainName = delDot(options['cname'].lower())
@ -19620,7 +19626,7 @@ with type DNS record CNAME (option "-t")'))
# Почтовые серверы для доменного имени
if typeRec == "ptr":
self.printERROR(_('Command line option "--mx" incompatible \
with type DNS record PTR (option "-t")'))
with type DNS record PTR (option "-t")'))
return False
mxServers = [delDot(x.lower()) for x in options['mx'].split(",")]
mxServers = self.unicList(mxServers)
@ -19866,7 +19872,7 @@ with type DNS record PTR (option "-t")'))
DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs):
self.printERROR(_("Can not write new serial number for zone %s \
in LDAP")%zoneName)
in LDAP")%zoneName)
return False
return True
@ -19923,7 +19929,7 @@ in LDAP")%zoneName)
if not self.checkSDBLDAP():
self.printERROR(_('Can not found USE="sdb-ldap" in package bind'))
self.printWARNING(_('Key USE="sdb-ldap" added to the package \
net-dns/bind version>=9.6.1'))
net-dns/bind version>=9.6.1'))
return False
# Принудительная установка
forceOptions = False
@ -20281,7 +20287,7 @@ class servDhcp(shareLdap, shareIP):
if [x for x in dataMinMaxIP if isRange(minNumber, x[0], x[1]) and isRange(maxNumber, x[0], x[1])]:
return True
self.printERROR("Can not found network %s in network interfaces: \
eth0, eth1, ... etc."%net)
eth0, eth1, ... etc."%net)
if osNets:
self.printWARNING(_("Existing nets: %s") % osNets)
return False

@ -4535,7 +4535,7 @@ class dovecot(bind):
def __init__(self, text):
bind.__init__(self,text)
def postXML(self, xmlArea=False):
def postXML(self, xmlArea=None):
"""Последующая постобработка XML"""
# Добавляем перевод строки если его нет в конец области
if xmlArea is None:

Loading…
Cancel
Save