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] [not x in retList and retList.append(x) for x in listEl]
return retList return retList
#TODO debug jpeg encoding #TODO debug magick png to jpeg encoding
def setJpegPhotoUser(self, userName, photoPath, attr="uid"): def setJpegPhotoUser(self, userName, photoPath, attr="uid"):
"""Добавляем jpeg фотографию пользователя в LDAP""" """Добавляем jpeg фотографию пользователя в LDAP"""
import subprocess import subprocess
@ -2797,7 +2797,6 @@ service"))
addUsers.append(user) addUsers.append(user)
modAttrs = [] modAttrs = []
for userName in addUsers: for userName in addUsers:
#TODO check userName encoding
modAttrs.append((ldap.MOD_ADD, 'memberUid', userName.encode("UTF-8"))) modAttrs.append((ldap.MOD_ADD, 'memberUid', userName.encode("UTF-8")))
if modAttrs: if modAttrs:
groupDN = self.addDN("cn=" + groupName, self.relGroupsDN) groupDN = self.addDN("cn=" + groupName, self.relGroupsDN)
@ -5947,10 +5946,9 @@ of version > 2.1.10, then you can delete this file.") + "\n"
foundUserNames = [] foundUserNames = []
if searchUsers: if searchUsers:
for data in searchUsers: for data in searchUsers:
#TODO check encoding foundUserNames.append(data[0][1]["uid"][0].decode("UTF-8"))
foundUserNames.append(data[0][1]["uid"][0])
if foundUserNames: if foundUserNames:
primaryUsers = list(set(foundUserNames)&set(users)) primaryUsers = list(set(foundUserNames) & set(users))
if primaryUsers: if primaryUsers:
self.printERROR(_("%s is primary group")% groupName + " " +\ self.printERROR(_("%s is primary group")% groupName + " " +\
_("for users (%s)")%", ".join(primaryUsers)) _("for users (%s)")%", ".join(primaryUsers))
@ -10066,6 +10064,12 @@ the password will be changed only for Samba account")
'helpChapter':_("DHCP service options"), 'helpChapter':_("DHCP service options"),
'help':_("forced setup service") 'help':_("forced setup service")
}, },
{'progAccess':(6,),
'shortOption':"f",
'longOption':"force",
'helpChapter':_("Samba service options"),
'help':_("forced setup service")
},
{'progAccess':(6,), {'progAccess':(6,),
'longOption':"net", 'longOption':"net",
'optVal':"NET", 'optVal':"NET",
@ -14930,7 +14934,7 @@ with another option."))
headers = [_("Field"),_("Value")] headers = [_("Field"),_("Value")]
attributes = [x[0] for x in data] attributes = [x[0] for x in data]
retrAttrs = [x[1] for x in data] retrAttrs = [x[1] for x in data]
retClVars=False retClVars = False
#TODO check encoding #TODO check encoding
searchRes = self.getQueryLDAP(service, "computers", searchAttr, searchRes = self.getQueryLDAP(service, "computers", searchAttr,
searchStr, retrAttrs) searchStr, retrAttrs)
@ -14953,7 +14957,7 @@ with another option."))
flagFirst = False flagFirst = False
for value in ldapValue: for value in ldapValue:
if not flagFirst: if not flagFirst:
data.append((attrName, value.decode("UTF-8"))) data.append((attrName, value))
flagFirst = True flagFirst = True
else: else:
data.append(("", value.decode("UTF-8"))) data.append(("", value.decode("UTF-8")))
@ -14965,12 +14969,12 @@ with another option."))
if value: if value:
memberGroups.insert(0, value.decode("UTF-8")) memberGroups.insert(0, value.decode("UTF-8"))
flagFirst = False flagFirst = False
for value in memberGroups: for member_group in memberGroups:
if not flagFirst: if not flagFirst:
data.append((attrApp, value)) data.append((attrApp, member_group))
flagFirst = True flagFirst = True
else: else:
data.append(("", value)) data.append(("", member_group))
else: else:
data.append((attrName, _("No"))) data.append((attrName, _("No")))
return (headers, data) return (headers, data)
@ -16899,22 +16903,23 @@ class dnsTxt(cl_profile.bind,shareTxt):
# прямая зона # прямая зона
dnsDN = "ou=Forward,%s"%dnsBaseDN dnsDN = "ou=Forward,%s"%dnsBaseDN
template = 'zone "%s" in {\n\ template = 'zone "%s" in {\n\
\ttype %s;\n\ \ttype %s;\n\
\tdatabase "ldap ldap://127.0.0.1/zoneName=%s,%s????\ \tdatabase "ldap ldap://127.0.0.1/zoneName=%s,%s????\
!bindname=%s,!x-bindpw=%s 178600";\n\ !bindname=%s,!x-bindpw=%s 178600";\n\
};' %(zoneName,zoneType,zoneName,dnsDN,dnsCommaSplDN,dnsBasePw) };' %(zoneName,zoneType,zoneName,dnsDN,dnsCommaSplDN,dnsBasePw)
return template return template
elif zoneType == "slave": elif zoneType == "slave":
if not zoneMasters: if not zoneMasters:
self.setError(\ 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 return False
zoneFile = "%s.zone" %zoneName.split(".in-addr.arpa")[0] zoneFile = "%s.zone" %zoneName.split(".in-addr.arpa")[0]
template = 'zone "%s" {\n\ template = 'zone "%s" {\n\
\ttype %s;\n\ \ttype %s;\n\
\tfile "sec/%s";\n\ \tfile "sec/%s";\n\
\tmasters { %s; };\n\ \tmasters { %s; };\n\
};' %(zoneName,zoneType,zoneFile, "; ".join(zoneMasters)) };' %(zoneName,zoneType,zoneFile, "; ".join(zoneMasters))
return template return template
else: else:
self.setError(_('DNS zone type %s unsupported')%zoneType) self.setError(_('DNS zone type %s unsupported')%zoneType)
@ -17479,7 +17484,7 @@ class servDns(shareLdap):
flagDeleteZone = True flagDeleteZone = True
else: else:
self.printWARNING(_("Can not found zone %s in \ self.printWARNING(_("Can not found zone %s in \
/etc/bind/named.conf")%zoneName) /etc/bind/named.conf")%zoneName)
# Если зона найдена в LDAP удаляем ее # Если зона найдена в LDAP удаляем ее
if self.searchZoneInLDAP(zoneName): if self.searchZoneInLDAP(zoneName):
# Удаление зоны из LDAP # Удаление зоны из LDAP
@ -17631,7 +17636,7 @@ class servDns(shareLdap):
incompKeys = ["host","ip"] incompKeys = ["host","ip"]
if set(incompKeys)<=set(optKeys): if set(incompKeys)<=set(optKeys):
self.printERROR(_('Command line option "--host" (A-record) \ self.printERROR(_('Command line option "--host" (A-record) \
incompatible with option "--ip" (PTR-record)')) incompatible with option "--ip" (PTR-record)'))
return False return False
# Флаг MX - записи # Флаг MX - записи
flagDeleteMX = False flagDeleteMX = False
@ -17654,7 +17659,7 @@ incompatible with option "--ip" (PTR-record)'))
elif 'ip' in options: elif 'ip' in options:
if flagDeleteMX: if flagDeleteMX:
self.printERROR(_('Command line option "--mx" (MX-record) \ self.printERROR(_('Command line option "--mx" (MX-record) \
incompatible with option "--ip" (PTR-record)')) incompatible with option "--ip" (PTR-record)'))
return False return False
# ip адрес # ip адрес
typeRec = "ptr" typeRec = "ptr"
@ -17782,9 +17787,8 @@ incompatible with option "--ip" (PTR-record)'))
if not netmask == "24" or \ if not netmask == "24" or \
not self.isCorrectStringNet(zoneName): not self.isCorrectStringNet(zoneName):
self.printERROR(_('Incorrect network %s for reverse zone')\ self.printERROR(_('Incorrect network %s for reverse zone')\
%zoneName) %zoneName)
self.printWARNING(_("Example network for reverse zone") +\ self.printWARNING(_("Example network for reverse zone") + " :")
" :")
self.printWARNING('"-n 192.168.0.0/24"') self.printWARNING('"-n 192.168.0.0/24"')
return False return False
dataIP = self.getDomainAndZoneFromIP(network) dataIP = self.getDomainAndZoneFromIP(network)
@ -17800,27 +17804,27 @@ incompatible with option "--ip" (PTR-record)'))
zoneData = self.searchAllDomainNamesInLDAP("@.%s"%zoneName) zoneData = self.searchAllDomainNamesInLDAP("@.%s"%zoneName)
if not zoneData: if not zoneData:
self.printERROR(_("Can not found SOA-record in zone %s")\ self.printERROR(_("Can not found SOA-record in zone %s")\
%zoneName) %zoneName)
return False return False
# Удаление A записи # Удаление A записи
if 'ip' in options: if 'ip' in options:
if 'aRecord' not in zoneData[0][0][1]: if 'aRecord' not in zoneData[0][0][1]:
self.printERROR(_("Can not found A-records in zone %s")\ self.printERROR(_("Can not found A-records in zone %s")\
%zoneName) %zoneName)
return False return False
if 'mx' in options: if 'mx' in options:
if 'mXRecord' not in zoneData[0][0][1]: if 'mXRecord' not in zoneData[0][0][1]:
self.printERROR(\ self.printERROR(\
_("Can not found MX-records in zone %s")\ _("Can not found MX-records in zone %s")\
%zoneName) %zoneName)
return False return False
relZoneDN = self.getRelZoneDN(zoneName) relZoneDN = self.getRelZoneDN(zoneName)
modAttrs =[(ldap.MOD_DELETE, 'aRecord', None)] modAttrs =[(ldap.MOD_DELETE, 'aRecord', None)]
DN = self.addDN("relativeDomainName=@", relZoneDN) DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs): if not self.modAttrsDN(DN, modAttrs):
self.printERROR(\ self.printERROR(\
_("Can not delete A-records for zone %s")\ _("Can not delete A-records for zone %s")\
%zoneName) %zoneName)
return False return False
self.printSUCCESS(_("Deleted A-records for zone %s")%zoneName) self.printSUCCESS(_("Deleted A-records for zone %s")%zoneName)
ret = True ret = True
@ -17828,11 +17832,10 @@ incompatible with option "--ip" (PTR-record)'))
if 'mx' in options: if 'mx' in options:
if 'mXRecord' not in zoneData[0][0][1]: if 'mXRecord' not in zoneData[0][0][1]:
self.printERROR(_("Can not found MX-records in zone %s")\ self.printERROR(_("Can not found MX-records in zone %s")\
%zoneName) %zoneName)
return False return False
# Удаляем все MX записи в записи зоны # Удаляем все MX записи в записи зоны
ret = self.modMXRecord("@", zoneName, zoneName, ret = self.modMXRecord("@", zoneName, zoneName, True, [])
True, [])
# Увеличиваем на 1 серийный номер зоны # Увеличиваем на 1 серийный номер зоны
if not self.incrementSerialNumberZone(zoneName): if not self.incrementSerialNumberZone(zoneName):
return False return False
@ -17866,14 +17869,14 @@ incompatible with option "--ip" (PTR-record)'))
else: else:
self.printERROR(_("Zone type %s unsupported")%zoneType) self.printERROR(_("Zone type %s unsupported")%zoneType)
self.printWARNING(_("Supported zone types: %s")\ self.printWARNING(_("Supported zone types: %s")\
%", ".join(["master","slave"])) %", ".join(["master","slave"]))
return False return False
if not set(minKeys) <= set(optKeys): if not set(minKeys) <= set(optKeys):
notFoundKeys = list(set(minKeys)-set(optKeys)) notFoundKeys = list(set(minKeys)-set(optKeys))
notFoundKeys (len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys) notFoundKeys (len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys)
self.printERROR(_("Not enough command line options: %s")\ self.printERROR(_("Not enough command line options: %s")\
%", ".join(notFoundKeys)) %", ".join(notFoundKeys))
return False return False
# Удаляет лишние точки в названии # Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x) delDot = lambda y: ".".join(x for x in y.split(".") if x)
@ -17899,20 +17902,20 @@ incompatible with option "--ip" (PTR-record)'))
# ip зоны для обратной зоны недопустим # ip зоны для обратной зоны недопустим
if 'ip' in options: if 'ip' in options:
self.printERROR(_('Command line option "--ip" \ self.printERROR(_('Command line option "--ip" \
incompatible with reverse DNS zone %s')%zoneName) incompatible with reverse DNS zone %s')%zoneName)
return False return False
# MX записи для обратной зоны недопустимы # MX записи для обратной зоны недопустимы
if 'mx' in options: if 'mx' in options:
self.printERROR(_('Command line option "--mx" \ self.printERROR(_('Command line option "--mx" \
incompatible with reverse DNS zone %s')%zoneName) incompatible with reverse DNS zone %s')%zoneName)
return False return False
network, spl, netmask = zoneName.rpartition("/") network, spl, netmask = zoneName.rpartition("/")
if not netmask == "24" or \ if not netmask == "24" or \
not self.isCorrectStringNet(zoneName): not self.isCorrectStringNet(zoneName):
self.printERROR(_('Incorrect network %s for reverse zone')\ self.printERROR(_('Incorrect network %s for reverse zone')\
%zoneName) %zoneName)
self.printWARNING(_("Example network for reverse zone") +\ self.printWARNING(_("Example network for reverse zone") +\
" :") " :")
self.printWARNING('"-n 192.168.0.0/24"') self.printWARNING('"-n 192.168.0.0/24"')
return False return False
netSpl = network.split(".") netSpl = network.split(".")
@ -17929,7 +17932,7 @@ incompatible with reverse DNS zone %s')%zoneName)
objTxtZone = dnsTxt() objTxtZone = dnsTxt()
if zoneName in objTxtZone.getAllNamesZones(): if zoneName in objTxtZone.getAllNamesZones():
self.printERROR(_("DNS zone %s exists in /etc/bind/named.conf")\ self.printERROR(_("DNS zone %s exists in /etc/bind/named.conf")\
%zoneName) %zoneName)
return False return False
# ip зоны # ip зоны
zoneIP = "" zoneIP = ""
@ -17957,7 +17960,7 @@ incompatible with reverse DNS zone %s')%zoneName)
if not self.isCorrectStringNet(options['servers'], False): if not self.isCorrectStringNet(options['servers'], False):
self.printERROR(_('Incorrect autoritatives servers IP')) self.printERROR(_('Incorrect autoritatives servers IP'))
self.printERROR(_('Error in command line option \ self.printERROR(_('Error in command line option \
"--servers"')) "--servers"'))
self.printWARNING(_('Example:')) self.printWARNING(_('Example:'))
self.printWARNING('--servers 192.168.0.1,192.168.0.2') self.printWARNING('--servers 192.168.0.1,192.168.0.2')
return False return False
@ -17970,7 +17973,7 @@ incompatible with reverse DNS zone %s')%zoneName)
if flagErrorNs: if flagErrorNs:
self.printERROR(_('Incorrect autoritatives servers names')) self.printERROR(_('Incorrect autoritatives servers names'))
self.printERROR(_('Error in command line option \ self.printERROR(_('Error in command line option \
"--servers"')) "--servers"'))
self.printWARNING(_('Example:')) self.printWARNING(_('Example:'))
self.printWARNING('--servers ns.domain.ru,ns1.domain.ru') self.printWARNING('--servers ns.domain.ru,ns1.domain.ru')
return False return False
@ -17986,14 +17989,14 @@ incompatible with reverse DNS zone %s')%zoneName)
if self.isCorrectStringNet(nameServer, False): if self.isCorrectStringNet(nameServer, False):
self.printERROR(_('Incorrect autoritative server')) self.printERROR(_('Incorrect autoritative server'))
self.printERROR(_('Error in command line option \ self.printERROR(_('Error in command line option \
"--server"')) "--server"'))
self.printWARNING(_('Example:')) self.printWARNING(_('Example:'))
self.printWARNING('--server ns.domain.com') self.printWARNING('--server ns.domain.com')
return False return False
if not nameServer: if not nameServer:
self.printERROR(_('Incorrect autoritative server name')) self.printERROR(_('Incorrect autoritative server name'))
self.printERROR(_('Error in command line option \ self.printERROR(_('Error in command line option \
"--server"')) "--server"'))
return False return False
# Добавляем мастер сервер в имена авторитативаных серверов # Добавляем мастер сервер в имена авторитативаных серверов
if not nameServer in namesServers: if not nameServer in namesServers:
@ -18007,14 +18010,14 @@ incompatible with reverse DNS zone %s')%zoneName)
not self.searchDomainNameInLDAP(nameServer)): not self.searchDomainNameInLDAP(nameServer)):
if 'ipserver' not in options: if 'ipserver' not in options:
self.printERROR(_('Not found A-record for "%s" \ self.printERROR(_('Not found A-record for "%s" \
(master server DNS)')%nameServer) (master server DNS)')%nameServer)
self.printERROR(_('Not enough command line option \ self.printERROR(_('Not enough command line option \
"--ipserver"')) "--ipserver"'))
return False return False
else: else:
if nameServer == zoneName and zoneIP: if nameServer == zoneName and zoneIP:
self.printERROR(_("The same zone name and name of \ 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"')) self.printERROR(_('We do not need the option "--ip"'))
return False return False
ipserver = options["ipserver"] ipserver = options["ipserver"]
@ -18027,11 +18030,13 @@ the primary authoritative server for the zone"))
if self.searchZoneInLDAP(nsZoneName) and\ if self.searchZoneInLDAP(nsZoneName) and\
self.searchDomainNameInLDAP(nameServer): self.searchDomainNameInLDAP(nameServer):
self.printERROR(_('Command line option "--ipserver" \ 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: else:
self.printERROR(_('Command line option "--ipserver" \ self.printERROR(_('Command line option "--ipserver" \
is not needed, as the host name "%s" does not belong to the existing zones on \ is not needed, as the host name "%s" does not\
this DNS server')%nameServer) belong to the existing zones on \
this DNS server')%nameServer)
return False return False
# Почтовый адрес администратора зоны # Почтовый адрес администратора зоны
# по умолчанию # по умолчанию
@ -18350,7 +18355,7 @@ this DNS server')%nameServer)
# Проверка на mx совместно с mxmod # Проверка на mx совместно с mxmod
if 'mx' in options and 'mxmod' in options: if 'mx' in options and 'mxmod' in options:
self.printERROR('Command line option "-mx" is incompatible \ self.printERROR('Command line option "-mx" is incompatible \
with option "--mxmod"') with option "--mxmod"')
return False return False
# MX серверы # MX серверы
mxServers = [] mxServers = []
@ -18495,7 +18500,7 @@ with option "--mxmod"')
if self.searchZoneInLDAP(nsZoneName) and\ if self.searchZoneInLDAP(nsZoneName) and\
not self.searchDomainNameInLDAP(nameServer): not self.searchDomainNameInLDAP(nameServer):
self.printERROR(_("Can not found host name %s in LDAP")\ self.printERROR(_("Can not found host name %s in LDAP")\
%nameServer) %nameServer)
self.printWARNING(\ self.printWARNING(\
_("Add A-record %s (autoritative DNS server) in LDAP")\ _("Add A-record %s (autoritative DNS server) in LDAP")\
% nameServer) % nameServer)
@ -18550,7 +18555,7 @@ with option "--mxmod"')
DN = self.addDN("relativeDomainName=@", relZoneDN) DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs): if not self.modAttrsDN(DN, modAttrs):
self.printERROR(_("Can not modify new SOA-record for zone %s \ self.printERROR(_("Can not modify new SOA-record for zone %s \
in LDAP") % zoneName) in LDAP") % zoneName)
return False return False
# Результат исполнения для пользователя # Результат исполнения для пользователя
# Изменен ли главный сервер авторизации # Изменен ли главный сервер авторизации
@ -18563,7 +18568,7 @@ in LDAP") % zoneName)
# Изменены ли авторитативные DNS сервера зоны # Изменены ли авторитативные DNS сервера зоны
if set(oldNamesServers) != set(namesServers): if set(oldNamesServers) != set(namesServers):
self.printSUCCESS(\ self.printSUCCESS(\
_("Modified all autoritative DNS servers for zone")) _("Modified all autoritative DNS servers for zone"))
# Вывод модифицированных параметров времени # Вывод модифицированных параметров времени
for nameOpt in zoneTimeIntervals.keys(): for nameOpt in zoneTimeIntervals.keys():
valueOld = zoneTimeIntervals[nameOpt] valueOld = zoneTimeIntervals[nameOpt]
@ -18588,7 +18593,7 @@ in LDAP") % zoneName)
# Проверка на имя хоста вместе с ip # Проверка на имя хоста вместе с ip
if 'ip' in options and 'host' in options: if 'ip' in options and 'host' in options:
self.printERROR('Command line option "--host" is incompatible \ self.printERROR('Command line option "--host" is incompatible \
with option "--ip"') with option "--ip"')
return False return False
# Удаляет лишние точки в названии # Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x) delDot = lambda y: ".".join(x for x in y.split(".") if x)
@ -18602,7 +18607,7 @@ with option "--ip"')
modOther = False modOther = False
else: else:
self.printERROR(_('Command line option "--automod %s" \ 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 return False
# По умолчанию прямой тип записи # По умолчанию прямой тип записи
typeRec = "a" typeRec = "a"
@ -18613,12 +18618,12 @@ incorrect, use "--automod on" or "--automod off"')%autoMod)
if not typeRec in supportTypes: if not typeRec in supportTypes:
self.printERROR(_("Record type %s unsupported")%typeRec) self.printERROR(_("Record type %s unsupported")%typeRec)
self.printWARNING(_("Supported record types: %s")\ self.printWARNING(_("Supported record types: %s")\
%", ".join(supportTypes)) %", ".join(supportTypes))
return False return False
# Проверка на mx совместно с mxmod # Проверка на mx совместно с mxmod
if 'mx' in options and 'mxmod' in options: if 'mx' in options and 'mxmod' in options:
self.printERROR('Command line option "-mx" is incompatible \ self.printERROR('Command line option "-mx" is incompatible \
with option "--mxmod"') with option "--mxmod"')
return False return False
# Добавляем кавычки и -- # Добавляем кавычки и --
addQ = lambda y: [len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in y] 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" typeRec = "cname"
else: else:
self.printERROR(_("Incorrect command line options %s")\ self.printERROR(_("Incorrect command line options %s")\
%", ".join(addQ(optKeys))) %", ".join(addQ(optKeys)))
return False return False
# Проверка обязательных опций # Проверка обязательных опций
if not set(requiredOpt) <= set(optKeys): if not set(requiredOpt) <= set(optKeys):
notFoundReqOpt = list(set(requiredOpt) - set(optKeys)) notFoundReqOpt = list(set(requiredOpt) - set(optKeys))
self.printERROR(_('Can not found required command line options %s')\ self.printERROR(_('Can not found required command line options %s')\
%", ".join(addQ(notFoundReqOpt))) %", ".join(addQ(notFoundReqOpt)))
return False return False
if "f" in options.keys(): if "f" in options.keys():
optionalOpt['f'] = options['f'] optionalOpt['f'] = options['f']
@ -18676,17 +18681,17 @@ with option "--mxmod"')
break break
if errorOptionalOpt: if errorOptionalOpt:
self.printERROR(\ self.printERROR(\
_('Optional comand line option %s it has a wrong value')\ _('Optional comand line option %s it has a wrong value')\
%addQ([key])[0]) %addQ([key])[0])
self.printWARNING(_('Valid values are the options %s')\ self.printWARNING(_('Valid values are the options %s')\
%addQ([key])[0] + " " + '(%s)'\ %addQ([key])[0] + " " + '(%s)'\
% (" "+_("or")+" ").join(('"%s"' % x for x in value))) % (" "+_("or")+" ").join(('"%s"' % x for x in value)))
return False return False
# Проверка лишних опций # Проверка лишних опций
unnecessaryOpt = list(set(optKeys) - set(requiredOpt + list(optionalOpt.keys()))) unnecessaryOpt = list(set(optKeys) - set(requiredOpt + list(optionalOpt.keys())))
if unnecessaryOpt: if unnecessaryOpt:
self.printERROR(_("Exists unnecessary command line options %s")\ self.printERROR(_("Exists unnecessary command line options %s")\
%",".join(addQ(unnecessaryOpt))) %",".join(addQ(unnecessaryOpt)))
return False return False
mxServers = [] mxServers = []
@ -18696,11 +18701,11 @@ with option "--mxmod"')
# Почтовые серверы для доменного имени # Почтовые серверы для доменного имени
if typeRec == "ptr": if typeRec == "ptr":
self.printERROR(_('Command line option "--mx" \ self.printERROR(_('Command line option "--mx" \
incompatible with PTR-record (option "-t")')) incompatible with PTR-record (option "-t")'))
return False return False
if typeRec == "cname": if typeRec == "cname":
self.printERROR(_('Command line option "--mx" \ self.printERROR(_('Command line option "--mx" \
incompatible with CNAME-record (option "-t")')) incompatible with CNAME-record (option "-t")'))
return False return False
mxServers = [delDot(x.lower()) for x in options['mx'].split(",")] mxServers = [delDot(x.lower()) for x in options['mx'].split(",")]
mxServers = self.unicList(mxServers) mxServers = self.unicList(mxServers)
@ -18714,11 +18719,11 @@ incompatible with CNAME-record (option "-t")'))
# Почтовые cерверы для доменного имени # Почтовые cерверы для доменного имени
if typeRec == "ptr": if typeRec == "ptr":
self.printERROR(_('Command line option "--mxmod" \ self.printERROR(_('Command line option "--mxmod" \
incompatible with PTR-record (option "-t")')) incompatible with PTR-record (option "-t")'))
return False return False
if typeRec == "cname": if typeRec == "cname":
self.printERROR(_('Command line option "--mxmod" \ self.printERROR(_('Command line option "--mxmod" \
incompatible with CNAME-record (option "-t")')) incompatible with CNAME-record (option "-t")'))
return False return False
modMxServers = [delDot(x.lower()) for x in options['mxmod'].split(",")] modMxServers = [delDot(x.lower()) for x in options['mxmod'].split(",")]
modMxServers = self.unicList(modMxServers) modMxServers = self.unicList(modMxServers)
@ -18760,12 +18765,12 @@ incompatible with CNAME-record (option "-t")'))
if foundNewDomain: if foundNewDomain:
if foundNewCnameRecord: if foundNewCnameRecord:
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%newDomainName) %newDomainName)
self.printERROR("%s --> %s"%(newDomainName,\ self.printERROR("%s --> %s"%(newDomainName,\
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8")))) delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
else: else:
self.printERROR(_("A-record %s exists in LDAP")\ self.printERROR(_("A-record %s exists in LDAP")\
%newDomainName) %newDomainName)
self.printERROR("%s --> %s"\ 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("") self.printERROR("")
@ -18797,14 +18802,15 @@ incompatible with CNAME-record (option "-t")'))
if foundNewDomain: if foundNewDomain:
if foundNewCnameRecord: if foundNewCnameRecord:
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%newDomainName) %newDomainName)
self.printERROR("%s --> %s"%(newDomainName,\ self.printERROR("%s --> %s"%(newDomainName,\
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8")))) delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
else: else:
self.printERROR(_("A-record %s exists in LDAP")\ self.printERROR(_("A-record %s exists in LDAP")\
%newDomainName) %newDomainName)
self.printERROR("%s --> %s"\ 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("") self.printERROR("")
return False return False
newIP = "" newIP = ""
@ -18813,7 +18819,7 @@ incompatible with CNAME-record (option "-t")'))
if 'ip' in options: if 'ip' in options:
if typeRec == "cname": if typeRec == "cname":
self.printERROR('Command line option "-t cname" \ self.printERROR('Command line option "-t cname" \
is incompatible with option "--ip"') is incompatible with option "--ip"')
return False return False
# newIP адрес # newIP адрес
newIP = options['ip'] newIP = options['ip']
@ -18839,7 +18845,7 @@ is incompatible with option "--ip"')
if foundNewIp: if foundNewIp:
self.printERROR(_("IP address %s exists in LDAP")%newIP) self.printERROR(_("IP address %s exists in LDAP")%newIP)
self.printERROR("%s --> %s"%(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("") self.printERROR("")
return False return False
# Проверка существования обратной записи # Проверка существования обратной записи
@ -18870,7 +18876,7 @@ is incompatible with option "--ip"')
if foundNewIp: if foundNewIp:
self.printERROR(_("IP address %s exists in LDAP")%newIP) self.printERROR(_("IP address %s exists in LDAP")%newIP)
self.printERROR("%s --> %s"%(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("") self.printERROR("")
return False return False
# Имена изменяемых зон # Имена изменяемых зон
@ -18898,13 +18904,13 @@ is incompatible with option "--ip"')
# найдена CNAME запись? # найдена CNAME запись?
if self.searchCNameInLDAP(domainName): if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName) %domainName)
self.printWARNING(_('Use command line option "-t cname"')) self.printWARNING(_('Use command line option "-t cname"'))
return False return False
foundMain = self.searchDomainNameInLDAP(domainName) foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain: if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\ self.printERROR(_("Record %s not exists in LDAP")\
%domainName) %domainName)
return False return False
otherIP = delDot(foundMain[0][0][1]['aRecord'][0].decode("UTF-8")) otherIP = delDot(foundMain[0][0][1]['aRecord'][0].decode("UTF-8"))
# Поиcк в обратной зоне в случае необходимости # Поиcк в обратной зоне в случае необходимости
@ -18917,12 +18923,12 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain) foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther: if not foundOther:
self.printERROR(_("PTR-record %s not exists in LDAP")\ self.printERROR(_("PTR-record %s not exists in LDAP")\
%otherDomain) %otherDomain)
return False return False
# Проверка на соответствие имени хоста # Проверка на соответствие имени хоста
if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")): if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
self.printERROR(_("Found PTR-record %s in LDAP")\ self.printERROR(_("Found PTR-record %s in LDAP")\
%otherDomain) %otherDomain)
self.printERROR("%s --> %s"%(otherIP,\ 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("") self.printERROR("")
@ -18985,7 +18991,7 @@ is incompatible with option "--ip"')
IPs = self.searchIPForHostInReverse(domainName) IPs = self.searchIPForHostInReverse(domainName)
if not IPs: if not IPs:
self.printERROR(_("Can not found %s in reverse zone")\ self.printERROR(_("Can not found %s in reverse zone")\
%domainName) %domainName)
return False return False
if len(IPs)>1: if len(IPs)>1:
self.printERROR(_("Found multiple records in reverse zone")) self.printERROR(_("Found multiple records in reverse zone"))
@ -19010,7 +19016,7 @@ is incompatible with option "--ip"')
foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR) foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR)
if not foundMain: if not foundMain:
self.printERROR(_("PTR-record %s not exists in LDAP")\ self.printERROR(_("PTR-record %s not exists in LDAP")\
%domainNamePTR) %domainNamePTR)
return False return False
# Поиcк в обратной зоне в случае необходимости # Поиcк в обратной зоне в случае необходимости
if modOther: if modOther:
@ -19018,14 +19024,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain) foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther: if not foundOther:
self.printERROR(_("A-record %s not exists in LDAP")\ self.printERROR(_("A-record %s not exists in LDAP")\
%otherDomain) %otherDomain)
return False return False
# Проверка на соответствие ip хоста # Проверка на соответствие ip хоста
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"): if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
self.printERROR(_("Found A-record %s in LDAP")\ self.printERROR(_("Found A-record %s in LDAP")\
%otherDomain) %otherDomain)
self.printERROR("%s --> %s"\ 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("") self.printERROR("")
return False return False
# Модифицируем PTR запись # Модифицируем PTR запись
@ -19037,7 +19043,7 @@ is incompatible with option "--ip"')
return False return False
# Изменение IP A записи (прямая зона) # Изменение IP A записи (прямая зона)
if not self.modARecord(hostName, domainName, zoneName, if not self.modARecord(hostName, domainName, zoneName,
otherIP, newIP): otherIP, newIP):
return False return False
# Изменяемая обратная зона # Изменяемая обратная зона
namesZones.append(otherZoneName) namesZones.append(otherZoneName)
@ -19076,8 +19082,8 @@ is incompatible with option "--ip"')
# Если изменяется доменное имя # Если изменяется доменное имя
# Изменение доменного имени PTR записи (обратная зона) # Изменение доменного имени PTR записи (обратная зона)
if not self.modPTRRecord(otherIP, otherHostName, if not self.modPTRRecord(otherIP, otherHostName,
otherDomainName, otherZoneName, otherDomainName, otherZoneName,
newDomainName): newDomainName):
return False return False
# Изменяемая обратная зона # Изменяемая обратная зона
namesZones.append(otherZoneName) namesZones.append(otherZoneName)
@ -19085,12 +19091,12 @@ is incompatible with option "--ip"')
foundMain = self.searchCNameInLDAP(domainName) foundMain = self.searchCNameInLDAP(domainName)
if not foundMain: if not foundMain:
self.printERROR(_("CNAME-record %s not exists in LDAP")\ self.printERROR(_("CNAME-record %s not exists in LDAP")\
%domainName) %domainName)
return False return False
# Изменяем cname указатель # Изменяем cname указатель
if cnameServer: if cnameServer:
if not self.modCNAMERecord(hostName, domainName, zoneName, if not self.modCNAMERecord(hostName, domainName, zoneName,
cnameServer): cnameServer):
return False return False
# Изменяемая прямая зона # Изменяемая прямая зона
namesZones.append(zoneName) namesZones.append(zoneName)
@ -19098,7 +19104,7 @@ is incompatible with option "--ip"')
if newDomainName: if newDomainName:
oldCname = delDot(foundMain[0][0][1]['cNAMERecord'][0].decode("UTF-8")) oldCname = delDot(foundMain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))
if not self.moveCNAMERecord(oldCname,domainName, if not self.moveCNAMERecord(oldCname,domainName,
newDomainName): newDomainName):
return False return False
# Изменяемая прямая зона # Изменяемая прямая зона
namesZones.append(zoneName) namesZones.append(zoneName)
@ -19109,7 +19115,7 @@ is incompatible with option "--ip"')
foundMain = self.searchDomainNameInLDAP(domainName) foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain: if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\ self.printERROR(_("Record %s not exists in LDAP")\
%domainName) %domainName)
return False return False
flagFoundMX = False flagFoundMX = False
if 'mXRecord' in foundMain[0][0][1]: if 'mXRecord' in foundMain[0][0][1]:
@ -19118,19 +19124,19 @@ is incompatible with option "--ip"')
if modMxServers: if modMxServers:
if not flagFoundMX: if not flagFoundMX:
self.printERROR(\ self.printERROR(\
_("Can not found MX-record in A-record %s")\ _("Can not found MX-record in A-record %s")\
%domainName) %domainName)
return False return False
# Находим нужную запись # Находим нужную запись
foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\ foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\
and delDot(x.decode("UTF-8")) and delDot(x.decode("UTF-8"))
or delDot(x.decode("UTF-8").split(" ")[1]) or delDot(x.decode("UTF-8").split(" ")[1])
for x in foundMain[0][0][1]['mXRecord']] for x in foundMain[0][0][1]['mXRecord']]
oldMxHost = modMxServers[0] oldMxHost = modMxServers[0]
newMxHost = modMxServers[1] newMxHost = modMxServers[1]
if not oldMxHost in foundMxServers: if not oldMxHost in foundMxServers:
self.printERROR(_("Can not found MX host %s")\ self.printERROR(_("Can not found MX host %s")\
%oldMxHost +" " + _("in A-record %s")%domainName) %oldMxHost +" " + _("in A-record %s")%domainName)
return False return False
# Проверка наличия новой MX записи в A записи # Проверка наличия новой MX записи в A записи
if newMxHost in foundMxServers: if newMxHost in foundMxServers:
@ -19149,7 +19155,7 @@ is incompatible with option "--ip"')
else: else:
addMxServers.append(foundMxServer) addMxServers.append(foundMxServer)
if not self.modMXRecord(hostName, domainName, zoneName, if not self.modMXRecord(hostName, domainName, zoneName,
flagFoundMX, addMxServers): flagFoundMX, addMxServers):
return False return False
# Изменяемая прямая зона # Изменяемая прямая зона
namesZones.append(zoneName) namesZones.append(zoneName)
@ -19159,7 +19165,7 @@ is incompatible with option "--ip"')
if not self.checkMXDomains(mxServers): if not self.checkMXDomains(mxServers):
return False return False
if not self.modMXRecord(hostName, domainName, zoneName, if not self.modMXRecord(hostName, domainName, zoneName,
flagFoundMX, mxServers): flagFoundMX, mxServers):
return False return False
# Изменяемая прямая зона # Изменяемая прямая зона
namesZones.append(zoneName) namesZones.append(zoneName)
@ -19173,11 +19179,11 @@ is incompatible with option "--ip"')
otherIP = ip otherIP = ip
if typeRec == "cname": if typeRec == "cname":
self.printERROR(_('IP address %s')%ip + " " +\ self.printERROR(_('IP address %s')%ip + " " +\
_('incompatible with CNAME-record (option "-t")')) _('incompatible with CNAME-record (option "-t")'))
return False return False
if "cname" in optKeys: if "cname" in optKeys:
self.printERROR(_('IP address %s')%ip + " " +\ self.printERROR(_('IP address %s')%ip + " " +\
_('incompatible with CNAME-record (option "--cname")')) _('incompatible with CNAME-record (option "--cname")'))
return False return False
# Поиск модифицируемой записи в DNS # Поиск модифицируемой записи в DNS
# Поиск основной записи # Поиск основной записи
@ -19196,7 +19202,7 @@ is incompatible with option "--ip"')
foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR) foundMain = self.searchAllDomainNamesInLDAP(domainNamePTR)
if not foundMain: if not foundMain:
self.printERROR(_("PTR-record %s not exists in LDAP")\ self.printERROR(_("PTR-record %s not exists in LDAP")\
%domainNamePTR) %domainNamePTR)
return False return False
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0].decode("UTF-8")) otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0].decode("UTF-8"))
# Модификация # Модификация
@ -19208,14 +19214,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain) foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther: if not foundOther:
self.printERROR(_("A-record %s not exists in LDAP")\ self.printERROR(_("A-record %s not exists in LDAP")\
%otherDomain) %otherDomain)
return False return False
# Проверка на соответствие ip хоста # Проверка на соответствие ip хоста
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"): if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
self.printERROR(_("Found A-record %s in LDAP")\ self.printERROR(_("Found A-record %s in LDAP")\
%otherDomain) %otherDomain)
self.printERROR("%s --> %s"\ 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("") self.printERROR("")
return False return False
# Модифицируем PTR запись # Модифицируем PTR запись
@ -19287,13 +19293,13 @@ is incompatible with option "--ip"')
# найдена CNAME запись? # найдена CNAME запись?
if self.searchCNameInLDAP(domainName): if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName) %domainName)
self.printWARNING(_('Use command line option "-t cname"')) self.printWARNING(_('Use command line option "-t cname"'))
return False return False
foundMain = self.searchDomainNameInLDAP(domainName) foundMain = self.searchDomainNameInLDAP(domainName)
if not foundMain: if not foundMain:
self.printERROR(_("Record %s not exists in LDAP")\ self.printERROR(_("Record %s not exists in LDAP")\
%domainName) %domainName)
return False return False
# Поиcк в обратной зоне в случае необходимости # Поиcк в обратной зоне в случае необходимости
if modOther: if modOther:
@ -19306,14 +19312,14 @@ is incompatible with option "--ip"')
foundOther = self.searchAllDomainNamesInLDAP(otherDomain) foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
if not foundOther: if not foundOther:
self.printERROR(_("PTR-record %s not exists in LDAP")\ self.printERROR(_("PTR-record %s not exists in LDAP")\
%otherDomain) %otherDomain)
return False return False
# Проверка на соответствие имени хоста # Проверка на соответствие имени хоста
if domainName != delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")): if domainName != delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
self.printERROR(_("Found PTR-record %s in LDAP")\ self.printERROR(_("Found PTR-record %s in LDAP")\
%otherDomain) %otherDomain)
self.printERROR("%s --> %s"%(otherIP,\ 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("") self.printERROR("")
return False return False
# Изменяем в двух зонах # Изменяем в двух зонах
@ -19392,8 +19398,8 @@ is incompatible with option "--ip"')
if modMxServers: if modMxServers:
if not flagFoundMX: if not flagFoundMX:
self.printERROR(\ self.printERROR(\
_("Can not found MX-record in A-record %s")\ _("Can not found MX-record in A-record %s")\
%domainName) %domainName)
return False return False
# Находим нужную запись # Находим нужную запись
foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\ foundMxServers = [len(x.decode("UTF-8").split(" ")) == 1\
@ -19404,7 +19410,7 @@ is incompatible with option "--ip"')
newMxHost = modMxServers[1] newMxHost = modMxServers[1]
if not oldMxHost in foundMxServers: if not oldMxHost in foundMxServers:
self.printERROR(_("Can not found MX host %s")\ self.printERROR(_("Can not found MX host %s")\
%oldMxHost +" " + _("in A-record %s")%domainName) %oldMxHost +" " + _("in A-record %s")%domainName)
return False return False
# Проверка существования A записи для MX хоста # Проверка существования A записи для MX хоста
if not self.checkMXDomains([newMxHost]): if not self.checkMXDomains([newMxHost]):
@ -19536,7 +19542,7 @@ is incompatible with option "--ip"')
if not typeRec in supportTypes: if not typeRec in supportTypes:
self.printERROR(_("Record type %s unsupported")%typeRec) self.printERROR(_("Record type %s unsupported")%typeRec)
self.printWARNING(_("Supported record types: %s")\ self.printWARNING(_("Supported record types: %s")\
%", ".join(supportTypes)) %", ".join(supportTypes))
return False return False
if typeRec == "cname": if typeRec == "cname":
minKeys = ["cname","host"] minKeys = ["cname","host"]
@ -19546,18 +19552,18 @@ is incompatible with option "--ip"')
notFoundKeys = list(set(minKeys)-set(optKeys)) notFoundKeys = list(set(minKeys)-set(optKeys))
notFoundKeys = [len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys] notFoundKeys = [len(x) > 1 and '"--%s"' % x or '"-%s"' % x for x in notFoundKeys]
self.printERROR(_("Not enough command line options: %s")\ self.printERROR(_("Not enough command line options: %s")\
%", ".join(notFoundKeys)) %", ".join(notFoundKeys))
return False return False
# Флаг автоматического создания PTR записи # Флаг автоматического создания PTR записи
createPtr = True createPtr = True
if 'autoptr' in options: if 'autoptr' in options:
if typeRec == "ptr": if typeRec == "ptr":
self.printERROR(_('Command line option "--autoptr" \ self.printERROR(_('Command line option "--autoptr" \
incompatible with type DNS record PTR (option "-t")')) incompatible with type DNS record PTR (option "-t")'))
return False return False
if typeRec == "cname": if typeRec == "cname":
self.printERROR(_('Command line option "--autoptr" \ self.printERROR(_('Command line option "--autoptr" \
incompatible with type DNS record CNAME (option "-t")')) incompatible with type DNS record CNAME (option "-t")'))
return False return False
autoPtr = options['autoptr'] autoPtr = options['autoptr']
if autoPtr == "on": if autoPtr == "on":
@ -19566,7 +19572,7 @@ incompatible with type DNS record CNAME (option "-t")'))
createPtr = False createPtr = False
else: else:
self.printERROR(_('Command line option "--autoptr %s" \ 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 return False
# Удаляет лишние точки в названии # Удаляет лишние точки в названии
delDot = lambda y: ".".join(x for x in y.split(".") if x) 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 'cname' in options:
if 'ip' in options: if 'ip' in options:
self.printERROR(_('Command line option "--ip" incompatible \ self.printERROR(_('Command line option "--ip" incompatible \
with type DNS record CNAME (option "-t")')) with type DNS record CNAME (option "-t")'))
return False return False
if 'mx' in options: if 'mx' in options:
self.printERROR(_('Command line option "--mx" incompatible \ self.printERROR(_('Command line option "--mx" incompatible \
with type DNS record CNAME (option "-t")')) with type DNS record CNAME (option "-t")'))
return False return False
# Доменное каноническое имя (имя включающее домен) для CNAME # Доменное каноническое имя (имя включающее домен) для CNAME
cnDomainName = delDot(options['cname'].lower()) cnDomainName = delDot(options['cname'].lower())
@ -19620,7 +19626,7 @@ with type DNS record CNAME (option "-t")'))
# Почтовые серверы для доменного имени # Почтовые серверы для доменного имени
if typeRec == "ptr": if typeRec == "ptr":
self.printERROR(_('Command line option "--mx" incompatible \ self.printERROR(_('Command line option "--mx" incompatible \
with type DNS record PTR (option "-t")')) with type DNS record PTR (option "-t")'))
return False return False
mxServers = [delDot(x.lower()) for x in options['mx'].split(",")] mxServers = [delDot(x.lower()) for x in options['mx'].split(",")]
mxServers = self.unicList(mxServers) mxServers = self.unicList(mxServers)
@ -19676,7 +19682,7 @@ with type DNS record PTR (option "-t")'))
# Поиск имени хоста # Поиск имени хоста
if not self.searchDomainNameInLDAP(cnDomainName): if not self.searchDomainNameInLDAP(cnDomainName):
self.printERROR(_("Can not found A-record %s in LDAP")\ self.printERROR(_("Can not found A-record %s in LDAP")\
%cnDomainName) %cnDomainName)
return False return False
# Поиск зоны # Поиск зоны
if not self.searchZoneInLDAP(zoneName): if not self.searchZoneInLDAP(zoneName):
@ -19686,7 +19692,7 @@ with type DNS record PTR (option "-t")'))
findCName = self.searchCNameInLDAP(domainName) findCName = self.searchCNameInLDAP(domainName)
if findCName: if findCName:
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName) %domainName)
cnameHosts = findCName[0][0][1]['cNAMERecord'] cnameHosts = findCName[0][0][1]['cNAMERecord']
for cnameHost in cnameHosts: for cnameHost in cnameHosts:
self.printERROR("%s --> %s"%(domainName,cnameHost.decode("UTF-8"))) 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 addDot = lambda x: (len(x)>0 and x[-1]!="." and "%s."%x) or x
domainEntry = [('objectclass', [b'top', b'dNSZone']), domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]), ('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']), ('dNSClass', [b'IN']),
('zoneName', [zoneName.encode("UTF-8")]), ('zoneName', [zoneName.encode("UTF-8")]),
('cNAMERecord', [addDot(cnDomainName).encode("UTF-8")])] ('cNAMERecord', [addDot(cnDomainName).encode("UTF-8")])]
baseDN = self.clVars.Get("ld_dns_dn") baseDN = self.clVars.Get("ld_dns_dn")
ouZonesDN = self.getOUZonesDN(zoneName) ouZonesDN = self.getOUZonesDN(zoneName)
zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN) zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN)
@ -19753,8 +19759,8 @@ with type DNS record PTR (option "-t")'))
notFoundMailServers = self.getNotFoundRecords(namesMailServers) notFoundMailServers = self.getNotFoundRecords(namesMailServers)
if notFoundMailServers: if notFoundMailServers:
self.printERROR(\ self.printERROR(\
_("Can not found A-records for MX-records - %s")\ _("Can not found A-records for MX-records - %s")\
%", ".join(notFoundMailServers)) %", ".join(notFoundMailServers))
self.printWARNING(\ self.printWARNING(\
_("First, add the A-records required for MX-records")) _("First, add the A-records required for MX-records"))
return False return False
@ -19771,12 +19777,12 @@ with type DNS record PTR (option "-t")'))
return False return False
if self.searchDomainNameInLDAP(domainName): if self.searchDomainNameInLDAP(domainName):
self.printERROR(_("Record %s exists in LDAP")\ self.printERROR(_("Record %s exists in LDAP")\
%domainName) %domainName)
return False return False
# Поиск CNAME записи # Поиск CNAME записи
if self.searchCNameInLDAP(domainName): if self.searchCNameInLDAP(domainName):
self.printERROR(_("CNAME-record %s exists in LDAP")\ self.printERROR(_("CNAME-record %s exists in LDAP")\
%domainName) %domainName)
return False return False
flagForward = self.isForwardZone(zoneName) flagForward = self.isForwardZone(zoneName)
# Метод добавляющий в конце текста точку если ее нет # Метод добавляющий в конце текста точку если ее нет
@ -19787,10 +19793,10 @@ with type DNS record PTR (option "-t")'))
return False return False
namesMailServersDot = [addDot(x).encode("UTF-8") for x in namesMailServers] namesMailServersDot = [addDot(x).encode("UTF-8") for x in namesMailServers]
domainEntry = [('objectclass', [b'top', b'dNSZone']), domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]), ('relativeDomainName', [hostName.encode("UTF-8")]),
('dNSClass', [b'IN']), ('dNSClass', [b'IN']),
('zoneName',[zoneName.encode("UTF-8")]), ('zoneName',[zoneName.encode("UTF-8")]),
('aRecord',[ipAddrOrHost.encode("UTF-8")])] ('aRecord',[ipAddrOrHost.encode("UTF-8")])]
mxValues = [b"%s %s" % (x * 10 + 10, namesMailServersDot[x]) mxValues = [b"%s %s" % (x * 10 + 10, namesMailServersDot[x])
for x in range(len(namesMailServersDot))] for x in range(len(namesMailServersDot))]
if mxValues: if mxValues:
@ -19798,9 +19804,9 @@ with type DNS record PTR (option "-t")'))
domainEntry.append(('mXRecord', mxValues)) domainEntry.append(('mXRecord', mxValues))
else: else:
domainEntry = [('objectclass', [b'top', b'dNSZone']), domainEntry = [('objectclass', [b'top', b'dNSZone']),
('relativeDomainName', [hostName.encode("UTF-8")]), ('relativeDomainName', [hostName.encode("UTF-8")]),
('zoneName',[zoneName.encode("UTF-8")]), ('zoneName',[zoneName.encode("UTF-8")]),
('pTRRecord',[addDot(ipAddrOrHost).encode("UTF-8")])] ('pTRRecord',[addDot(ipAddrOrHost).encode("UTF-8")])]
baseDN = self.clVars.Get("ld_dns_dn") baseDN = self.clVars.Get("ld_dns_dn")
ouZonesDN = self.getOUZonesDN(zoneName) ouZonesDN = self.getOUZonesDN(zoneName)
zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN) zoneBaseDN = "zoneName=%s,%s,%s" %(zoneName, ouZonesDN, baseDN)
@ -19845,7 +19851,7 @@ with type DNS record PTR (option "-t")'))
foundNames = self.searchDomainNameInLDAP("@.%s"%zoneName) foundNames = self.searchDomainNameInLDAP("@.%s"%zoneName)
if not foundNames: if not foundNames:
self.printERROR(_("Can not found SOA-record in DNS zone %s")\ self.printERROR(_("Can not found SOA-record in DNS zone %s")\
%zoneName) %zoneName)
return False return False
sOARecord = foundNames[0][0][1]['sOARecord'][0].decode("UTF-8") sOARecord = foundNames[0][0][1]['sOARecord'][0].decode("UTF-8")
sOAList = sOARecord.split(" ") sOAList = sOARecord.split(" ")
@ -19857,7 +19863,7 @@ with type DNS record PTR (option "-t")'))
except: except:
self.printERROR(_("Incorrect SOA-record in DNS zone %s")%zoneName) self.printERROR(_("Incorrect SOA-record in DNS zone %s")%zoneName)
self.printERROR(_("Incorrect serial number %s in SOA-record")\ self.printERROR(_("Incorrect serial number %s in SOA-record")\
%str(sOAList[2])) %str(sOAList[2]))
return False return False
sOAList[2] = serialNumber sOAList[2] = serialNumber
sOARecord = " ".join(sOAList) sOARecord = " ".join(sOAList)
@ -19866,7 +19872,7 @@ with type DNS record PTR (option "-t")'))
DN = self.addDN("relativeDomainName=@", relZoneDN) DN = self.addDN("relativeDomainName=@", relZoneDN)
if not self.modAttrsDN(DN, modAttrs): if not self.modAttrsDN(DN, modAttrs):
self.printERROR(_("Can not write new serial number for zone %s \ self.printERROR(_("Can not write new serial number for zone %s \
in LDAP")%zoneName) in LDAP")%zoneName)
return False return False
return True return True
@ -19923,7 +19929,7 @@ in LDAP")%zoneName)
if not self.checkSDBLDAP(): if not self.checkSDBLDAP():
self.printERROR(_('Can not found USE="sdb-ldap" in package bind')) self.printERROR(_('Can not found USE="sdb-ldap" in package bind'))
self.printWARNING(_('Key USE="sdb-ldap" added to the package \ 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 return False
# Принудительная установка # Принудительная установка
forceOptions = False forceOptions = False
@ -19940,7 +19946,7 @@ net-dns/bind version>=9.6.1'))
if self.clVars.Get("sr_dns_set") == "on" and\ if self.clVars.Get("sr_dns_set") == "on" and\
not forceOptions: not forceOptions:
self.printWARNING (_("WARNING") + ": " +\ self.printWARNING (_("WARNING") + ": " +\
_("DNS server is configured")+ ".") _("DNS server is configured")+ ".")
return True return True
# Доверительные сети по умолчанию # Доверительные сети по умолчанию
allowNet = self.clVars.Get("os_net_allow") 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])]: if [x for x in dataMinMaxIP if isRange(minNumber, x[0], x[1]) and isRange(maxNumber, x[0], x[1])]:
return True return True
self.printERROR("Can not found network %s in network interfaces: \ self.printERROR("Can not found network %s in network interfaces: \
eth0, eth1, ... etc."%net) eth0, eth1, ... etc."%net)
if osNets: if osNets:
self.printWARNING(_("Existing nets: %s") % osNets) self.printWARNING(_("Existing nets: %s") % osNets)
return False return False

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

Loading…
Cancel
Save