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"
@ -17782,9 +17787,8 @@ incompatible with option "--ip" (PTR-record)'))
if not netmask == "24" or \
not self.isCorrectStringNet(zoneName):
self.printERROR(_('Incorrect network %s for reverse zone')\
%zoneName)
self.printWARNING(_("Example network for reverse zone") +\
" :")
%zoneName)
self.printWARNING(_("Example network for reverse zone") + " :")
self.printWARNING('"-n 192.168.0.0/24"')
return False
dataIP = self.getDomainAndZoneFromIP(network)
@ -17800,27 +17804,27 @@ incompatible with option "--ip" (PTR-record)'))
zoneData = self.searchAllDomainNamesInLDAP("@.%s"%zoneName)
if not zoneData:
self.printERROR(_("Can not found SOA-record in zone %s")\
%zoneName)
%zoneName)
return False
# Удаление A записи
if 'ip' in options:
if 'aRecord' not in zoneData[0][0][1]:
self.printERROR(_("Can not found A-records in zone %s")\
%zoneName)
%zoneName)
return False
if 'mx' in options:
if 'mXRecord' not in zoneData[0][0][1]:
self.printERROR(\
_("Can not found MX-records in zone %s")\
%zoneName)
%zoneName)
return False
relZoneDN = self.getRelZoneDN(zoneName)
modAttrs =[(ldap.MOD_DELETE, 'aRecord', None)]
DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs):
self.printERROR(\
_("Can not delete A-records for zone %s")\
%zoneName)
_("Can not delete A-records for zone %s")\
%zoneName)
return False
self.printSUCCESS(_("Deleted A-records for zone %s")%zoneName)
ret = True
@ -17828,11 +17832,10 @@ incompatible with option "--ip" (PTR-record)'))
if 'mx' in options:
if 'mXRecord' not in zoneData[0][0][1]:
self.printERROR(_("Can not found MX-records in zone %s")\
%zoneName)
%zoneName)
return False
# Удаляем все MX записи в записи зоны
ret = self.modMXRecord("@", zoneName, zoneName,
True, [])
ret = self.modMXRecord("@", zoneName, zoneName, True, [])
# Увеличиваем на 1 серийный номер зоны
if not self.incrementSerialNumberZone(zoneName):
return False
@ -17866,14 +17869,14 @@ incompatible with option "--ip" (PTR-record)'))
else:
self.printERROR(_("Zone type %s unsupported")%zoneType)
self.printWARNING(_("Supported zone types: %s")\
%", ".join(["master","slave"]))
%", ".join(["master","slave"]))
return False
if not set(minKeys) <= set(optKeys):
notFoundKeys = list(set(minKeys)-set(optKeys))
notFoundKeys (len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys)
self.printERROR(_("Not enough command line options: %s")\
%", ".join(notFoundKeys))
%", ".join(notFoundKeys))
return False
# Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x)
@ -17899,20 +17902,20 @@ 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 \
not self.isCorrectStringNet(zoneName):
self.printERROR(_('Incorrect network %s for reverse zone')\
%zoneName)
%zoneName)
self.printWARNING(_("Example network for reverse zone") +\
" :")
" :")
self.printWARNING('"-n 192.168.0.0/24"')
return False
netSpl = network.split(".")
@ -17929,7 +17932,7 @@ incompatible with reverse DNS zone %s')%zoneName)
objTxtZone = dnsTxt()
if zoneName in objTxtZone.getAllNamesZones():
self.printERROR(_("DNS zone %s exists in /etc/bind/named.conf")\
%zoneName)
%zoneName)
return False
# ip зоны
zoneIP = ""
@ -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 = []
@ -18495,7 +18500,7 @@ with option "--mxmod"')
if self.searchZoneInLDAP(nsZoneName) and\
not self.searchDomainNameInLDAP(nameServer):
self.printERROR(_("Can not found host name %s in LDAP")\
%nameServer)
%nameServer)
self.printWARNING(\
_("Add A-record %s (autoritative DNS server) in LDAP")\
% nameServer)
@ -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
# Результат исполнения для пользователя
# Изменен ли главный сервер авторизации
@ -18563,7 +18568,7 @@ in LDAP") % zoneName)
# Изменены ли авторитативные DNS сервера зоны
if set(oldNamesServers) != set(namesServers):
self.printSUCCESS(\
_("Modified all autoritative DNS servers for zone"))
_("Modified all autoritative DNS servers for zone"))
# Вывод модифицированных параметров времени
for nameOpt in zoneTimeIntervals.keys():
valueOld = zoneTimeIntervals[nameOpt]
@ -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"
@ -18613,12 +18618,12 @@ incorrect, use "--automod on" or "--automod off"')%autoMod)
if not typeRec in supportTypes:
self.printERROR(_("Record type %s unsupported")%typeRec)
self.printWARNING(_("Supported record types: %s")\
%", ".join(supportTypes))
%", ".join(supportTypes))
return False
# Проверка на 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]
@ -18656,14 +18661,14 @@ with option "--mxmod"')
typeRec = "cname"
else:
self.printERROR(_("Incorrect command line options %s")\
%", ".join(addQ(optKeys)))
%", ".join(addQ(optKeys)))
return False
# Проверка обязательных опций
if not set(requiredOpt) <= set(optKeys):
notFoundReqOpt = list(set(requiredOpt) - set(optKeys))
self.printERROR(_('Can not found required command line options %s')\
%", ".join(addQ(notFoundReqOpt)))
%", ".join(addQ(notFoundReqOpt)))
return False
if "f" in options.keys():
optionalOpt['f'] = options['f']
@ -18676,17 +18681,17 @@ with option "--mxmod"')
break
if errorOptionalOpt:
self.printERROR(\
_('Optional comand line option %s it has a wrong value')\
%addQ([key])[0])
_('Optional comand line option %s it has a wrong value')\
%addQ([key])[0])
self.printWARNING(_('Valid values are the options %s')\
%addQ([key])[0] + " " + '(%s)'\
% (" "+_("or")+" ").join(('"%s"' % x for x in value)))
%addQ([key])[0] + " " + '(%s)'\
% (" "+_("or")+" ").join(('"%s"' % x for x in value)))
return False
# Проверка лишних опций
unnecessaryOpt = list(set(optKeys) - set(requiredOpt + list(optionalOpt.keys())))
if unnecessaryOpt:
self.printERROR(_("Exists unnecessary command line options %s")\
%",".join(addQ(unnecessaryOpt)))
%",".join(addQ(unnecessaryOpt)))
return False
mxServers = []
@ -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)
@ -18760,12 +18765,12 @@ incompatible with CNAME-record (option "-t")'))
if foundNewDomain:
if foundNewCnameRecord:
self.printERROR(_("CNAME-record %s exists in LDAP")\
%newDomainName)
%newDomainName)
self.printERROR("%s --> %s"%(newDomainName,\
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
else:
self.printERROR(_("A-record %s exists in LDAP")\
%newDomainName)
%newDomainName)
self.printERROR("%s --> %s"\
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0].decode("UTF-8")))
self.printERROR("")
@ -18797,14 +18802,15 @@ incompatible with CNAME-record (option "-t")'))
if foundNewDomain:
if foundNewCnameRecord:
self.printERROR(_("CNAME-record %s exists in LDAP")\
%newDomainName)
%newDomainName)
self.printERROR("%s --> %s"%(newDomainName,\
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
else:
self.printERROR(_("A-record %s exists in LDAP")\
%newDomainName)
%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']
@ -18839,7 +18845,7 @@ is incompatible with option "--ip"')
if foundNewIp:
self.printERROR(_("IP address %s exists in LDAP")%newIP)
self.printERROR("%s --> %s"%(newIP,\
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
self.printERROR("")
return False
# Проверка существования обратной записи
@ -18870,7 +18876,7 @@ is incompatible with option "--ip"')
if foundNewIp:
self.printERROR(_("IP address %s exists in LDAP")%newIP)
self.printERROR("%s --> %s"%(newIP,\
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
self.printERROR("")
return False
# Имена изменяемых зон
@ -18898,13 +18904,13 @@ is incompatible with option "--ip"')
# найдена CNAME запись?
if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName)
%domainName)
self.printWARNING(_('Use command line option "-t cname"'))
return False
foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\
%domainName)
%domainName)
return False
otherIP = delDot(foundMain[0][0][1]['aRecord'][0].decode("UTF-8"))
# Поиcк в обратной зоне в случае необходимости
@ -18917,12 +18923,12 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther:
self.printERROR(_("PTR-record %s not exists in LDAP")\
%otherDomain)
%otherDomain)
return False
# Проверка на соответствие имени хоста
if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
self.printERROR(_("Found PTR-record %s in LDAP")\
%otherDomain)
%otherDomain)
self.printERROR("%s --> %s"%(otherIP,\
delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
self.printERROR("")
@ -18985,7 +18991,7 @@ is incompatible with option "--ip"')
IPs = self.searchIPForHostInReverse(domainName)
if not IPs:
self.printERROR(_("Can not found %s in reverse zone")\
%domainName)
%domainName)
return False
if len(IPs)>1:
self.printERROR(_("Found multiple records in reverse zone"))
@ -19010,7 +19016,7 @@ is incompatible with option "--ip"')
foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR)
if not foundMain:
self.printERROR(_("PTR-record %s not exists in LDAP")\
%domainNamePTR)
%domainNamePTR)
return False
# Поиcк в обратной зоне в случае необходимости
if modOther:
@ -19018,14 +19024,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther:
self.printERROR(_("A-record %s not exists in LDAP")\
%otherDomain)
%otherDomain)
return False
# Проверка на соответствие ip хоста
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
self.printERROR(_("Found A-record %s in LDAP")\
%otherDomain)
%otherDomain)
self.printERROR("%s --> %s"\
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
self.printERROR("")
return False
# Модифицируем PTR запись
@ -19037,7 +19043,7 @@ is incompatible with option "--ip"')
return False
# Изменение IP A записи (прямая зона)
if not self.modARecord(hostName, domainName, zoneName,
otherIP, newIP):
otherIP, newIP):
return False
# Изменяемая обратная зона
namesZones.append(otherZoneName)
@ -19076,8 +19082,8 @@ is incompatible with option "--ip"')
# Если изменяется доменное имя
# Изменение доменного имени PTR записи (обратная зона)
if not self.modPTRRecord(otherIP, otherHostName,
otherDomainName, otherZoneName,
newDomainName):
otherDomainName, otherZoneName,
newDomainName):
return False
# Изменяемая обратная зона
namesZones.append(otherZoneName)
@ -19085,12 +19091,12 @@ is incompatible with option "--ip"')
foundMain = self.searchCNameInLDAP(domainName)
if not foundMain:
self.printERROR(_("CNAME-record %s not exists in LDAP")\
%domainName)
%domainName)
return False
# Изменяем cname указатель
if cnameServer:
if not self.modCNAMERecord(hostName, domainName, zoneName,
cnameServer):
cnameServer):
return False
# Изменяемая прямая зона
namesZones.append(zoneName)
@ -19098,7 +19104,7 @@ is incompatible with option "--ip"')
if newDomainName:
oldCname = delDot(foundMain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))
if not self.moveCNAMERecord(oldCname,domainName,
newDomainName):
newDomainName):
return False
# Изменяемая прямая зона
namesZones.append(zoneName)
@ -19109,7 +19115,7 @@ is incompatible with option "--ip"')
foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\
%domainName)
%domainName)
return False
flagFoundMX = False
if 'mXRecord' in foundMain[0][0][1]:
@ -19118,19 +19124,19 @@ is incompatible with option "--ip"')
if modMxServers:
if not flagFoundMX:
self.printERROR(\
_("Can not found MX-record in A-record %s")\
%domainName)
_("Can not found MX-record in A-record %s")\
%domainName)
return False
# Находим нужную запись
foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\
and delDot(x.decode("UTF-8"))
or delDot(x.decode("UTF-8").split(" ")[1])
for x in foundMain[0][0][1]['mXRecord']]
and delDot(x.decode("UTF-8"))
or delDot(x.decode("UTF-8").split(" ")[1])
for x in foundMain[0][0][1]['mXRecord']]
oldMxHost = modMxServers[0]
newMxHost = modMxServers[1]
if not oldMxHost in foundMxServers:
self.printERROR(_("Can not found MX host %s")\
%oldMxHost +" " + _("in A-record %s")%domainName)
%oldMxHost +" " + _("in A-record %s")%domainName)
return False
# Проверка наличия новой MX записи в A записи
if newMxHost in foundMxServers:
@ -19149,7 +19155,7 @@ is incompatible with option "--ip"')
else:
addMxServers.append(foundMxServer)
if not self.modMXRecord(hostName, domainName, zoneName,
flagFoundMX, addMxServers):
flagFoundMX, addMxServers):
return False
# Изменяемая прямая зона
namesZones.append(zoneName)
@ -19159,7 +19165,7 @@ is incompatible with option "--ip"')
if not self.checkMXDomains(mxServers):
return False
if not self.modMXRecord(hostName, domainName, zoneName,
flagFoundMX, mxServers):
flagFoundMX, mxServers):
return False
# Изменяемая прямая зона
namesZones.append(zoneName)
@ -19173,11 +19179,11 @@ is incompatible with option "--ip"')
otherIP = ip
if typeRec == "cname":
self.printERROR(_('IP address %s')%ip + " " +\
_('incompatible with CNAME-record (option "-t")'))
_('incompatible with CNAME-record (option "-t")'))
return False
if "cname" in optKeys:
self.printERROR(_('IP address %s')%ip + " " +\
_('incompatible with CNAME-record (option "--cname")'))
_('incompatible with CNAME-record (option "--cname")'))
return False
# Поиск модифицируемой записи в DNS
# Поиск основной записи
@ -19196,7 +19202,7 @@ is incompatible with option "--ip"')
foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR)
if not foundMain:
self.printERROR(_("PTR-record %s not exists in LDAP")\
%domainNamePTR)
%domainNamePTR)
return False
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0].decode("UTF-8"))
# Модификация
@ -19208,14 +19214,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther:
self.printERROR(_("A-record %s not exists in LDAP")\
%otherDomain)
%otherDomain)
return False
# Проверка на соответствие ip хоста
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
self.printERROR(_("Found A-record %s in LDAP")\
%otherDomain)
%otherDomain)
self.printERROR("%s --> %s"\
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
self.printERROR("")
return False
# Модифицируем PTR запись
@ -19287,13 +19293,13 @@ is incompatible with option "--ip"')
# найдена CNAME запись?
if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName)
%domainName)
self.printWARNING(_('Use command line option "-t cname"'))
return False
foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\
%domainName)
%domainName)
return False
# Поиcк в обратной зоне в случае необходимости
if modOther:
@ -19306,14 +19312,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther:
self.printERROR(_("PTR-record %s not exists in LDAP")\
%otherDomain)
%otherDomain)
return False
# Проверка на соответствие имени хоста
if domainName != delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
self.printERROR(_("Found PTR-record %s in LDAP")\
%otherDomain)
%otherDomain)
self.printERROR("%s --> %s"%(otherIP,\
delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
self.printERROR("")
return False
# Изменяем в двух зонах
@ -19392,8 +19398,8 @@ is incompatible with option "--ip"')
if modMxServers:
if not flagFoundMX:
self.printERROR(\
_("Can not found MX-record in A-record %s")\
%domainName)
_("Can not found MX-record in A-record %s")\
%domainName)
return False
# Находим нужную запись
foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\
@ -19404,7 +19410,7 @@ is incompatible with option "--ip"')
newMxHost = modMxServers[1]
if not oldMxHost in foundMxServers:
self.printERROR(_("Can not found MX host %s")\
%oldMxHost +" " + _("in A-record %s")%domainName)
%oldMxHost +" " + _("in A-record %s")%domainName)
return False
# Проверка существования A записи для MX хоста
if not self.checkMXDomains([newMxHost]):
@ -19536,7 +19542,7 @@ is incompatible with option "--ip"')
if not typeRec in supportTypes:
self.printERROR(_("Record type %s unsupported")%typeRec)
self.printWARNING(_("Supported record types: %s")\
%", ".join(supportTypes))
%", ".join(supportTypes))
return False
if typeRec == "cname":
minKeys = ["cname","host"]
@ -19546,18 +19552,18 @@ is incompatible with option "--ip"')
notFoundKeys = list(set(minKeys)-set(optKeys))
notFoundKeys = [len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys]
self.printERROR(_("Not enough command line options: %s")\
%", ".join(notFoundKeys))
%", ".join(notFoundKeys))
return False
# Флаг автоматического создания PTR записи
createPtr = True
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)
@ -19676,7 +19682,7 @@ with type DNS record PTR (option "-t")'))
# Поиск имени хоста
if not self.searchDomainNameInLDAP(cnDomainName):
self.printERROR(_("Can not found A-record %s in LDAP")\
%cnDomainName)
%cnDomainName)
return False
# Поиск зоны
if not self.searchZoneInLDAP(zoneName):
@ -19686,7 +19692,7 @@ with type DNS record PTR (option "-t")'))
findCName = self.searchCNameInLDAP(domainName)
if findCName:
self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName)
%domainName)
cnameHosts = findCName[0][0][1]['cNAMERecord']
for cnameHost in cnameHosts:
self.printERROR("%s --> %s"%(domainName,cnameHost.decode("UTF-8")))
@ -19695,10 +19701,10 @@ with type DNS record PTR (option "-t")'))
# Метод добавляющий в конце текста точку если ее нет
addDot = lambda x: (len(x)>0 and x[-1]!="." and "%s."%x) or x
domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']),
('zoneName', [zoneName.encode("UTF-8")]),
('cNAMERecord', [addDot(cnDomainName).encode("UTF-8")])]
('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']),
('zoneName', [zoneName.encode("UTF-8")]),
('cNAMERecord', [addDot(cnDomainName).encode("UTF-8")])]
baseDN = self.clVars.Get("ld_dns_dn")
ouZonesDN = self.getOUZonesDN(zoneName)
zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN)
@ -19753,8 +19759,8 @@ with type DNS record PTR (option "-t")'))
notFoundMailServers = self.getNotFoundRecords(namesMailServers)
if notFoundMailServers:
self.printERROR(\
_("Can not found A-records for MX-records - %s")\
%", ".join(notFoundMailServers))
_("Can not found A-records for MX-records - %s")\
%", ".join(notFoundMailServers))
self.printWARNING(\
_("First, add the A-records required for MX-records"))
return False
@ -19771,12 +19777,12 @@ with type DNS record PTR (option "-t")'))
return False
if self.searchDomainNameInLDAP(domainName):
self.printERROR(_("Record %s exists in LDAP")\
%domainName)
%domainName)
return False
# Поиск CNAME записи
if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName)
%domainName)
return False
flagForward = self.isForwardZone(zoneName)
# Метод добавляющий в конце текста точку если ее нет
@ -19787,10 +19793,10 @@ with type DNS record PTR (option "-t")'))
return False
namesMailServersDot = [addDot(x).encode("UTF-8") for x in namesMailServers]
domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']),
('zoneName',[zoneName.encode("UTF-8")]),
('aRecord',[ipAddrOrHost.encode("UTF-8")])]
('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']),
('zoneName',[zoneName.encode("UTF-8")]),
('aRecord',[ipAddrOrHost.encode("UTF-8")])]
mxValues = [b"%s %s" % (x * 10 + 10, namesMailServersDot[x])
for x in range(len(namesMailServersDot))]
if mxValues:
@ -19798,9 +19804,9 @@ with type DNS record PTR (option "-t")'))
domainEntry.append(('mXRecord', mxValues))
else:
domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]),
('zoneName',[zoneName.encode("UTF-8")]),
('pTRRecord',[addDot(ipAddrOrHost).encode("UTF-8")])]
('relativeDomainName', [hostName.encode("UTF-8")]),
('zoneName',[zoneName.encode("UTF-8")]),
('pTRRecord',[addDot(ipAddrOrHost).encode("UTF-8")])]
baseDN = self.clVars.Get("ld_dns_dn")
ouZonesDN = self.getOUZonesDN(zoneName)
zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN)
@ -19845,7 +19851,7 @@ with type DNS record PTR (option "-t")'))
foundNames = self.searchDomainNameInLDAP("@.%s"%zoneName)
if not foundNames:
self.printERROR(_("Can not found SOA-record in DNS zone %s")\
%zoneName)
%zoneName)
return False
sOARecord = foundNames[0][0][1]['sOARecord'][0].decode("UTF-8")
sOAList = sOARecord.split(" ")
@ -19857,7 +19863,7 @@ with type DNS record PTR (option "-t")'))
except:
self.printERROR(_("Incorrect SOA-record in DNS zone %s")%zoneName)
self.printERROR(_("Incorrect serial number %s in SOA-record")\
%str(sOAList[2]))
%str(sOAList[2]))
return False
sOAList[2] = serialNumber
sOARecord = " ".join(sOAList)
@ -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
@ -19940,7 +19946,7 @@ net-dns/bind version>=9.6.1'))
if self.clVars.Get("sr_dns_set") == "on" and\
not forceOptions:
self.printWARNING (_("WARNING") + ": " +\
_("DNS server is configured")+ ".")
_("DNS server is configured")+ ".")
return True
# Доверительные сети по умолчанию
allowNet = self.clVars.Get("os_net_allow")
@ -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