|
|
|
@ -393,8 +393,8 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
|
|
|
|
|
def runLdapServer(self):
|
|
|
|
|
"""Запускает LDAP сервер"""
|
|
|
|
|
textLine = self.execProg("/etc/init.d/slapd start")
|
|
|
|
|
if "ok" in textLine:
|
|
|
|
|
textLines = self.execProg("/etc/init.d/slapd start",False,False)
|
|
|
|
|
if textLines and "ok" in textLines[-1]:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.printNotOK(_("Starting LDAP")+ " ...")
|
|
|
|
@ -402,8 +402,8 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
|
|
|
|
|
def restartLdapServer(self):
|
|
|
|
|
"""Запускает LDAP сервер"""
|
|
|
|
|
textLine = self.execProg("/etc/init.d/slapd restart")
|
|
|
|
|
if "ok" in textLine:
|
|
|
|
|
textLines = self.execProg("/etc/init.d/slapd restart", False, False)
|
|
|
|
|
if textLines and "ok" in textLines[-1]:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.printNotOK(_("Restarting LDAP")+ " ...")
|
|
|
|
@ -411,8 +411,8 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
|
|
|
|
|
def stopLdapServer(self):
|
|
|
|
|
"""Останавливает LDAP сервер"""
|
|
|
|
|
textLine = self.execProg("/etc/init.d/slapd stop")
|
|
|
|
|
if "ok" in textLine:
|
|
|
|
|
textLines = self.execProg("/etc/init.d/slapd stop")
|
|
|
|
|
if textLines and "ok" in textLines[-1]:
|
|
|
|
|
#self.printOK(_("LDAP stop")+ " ...")
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
@ -498,8 +498,9 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
flagError = False
|
|
|
|
|
for daemon in daemons:
|
|
|
|
|
if not self.getRunDaemons([daemon]):
|
|
|
|
|
textLine = self.execProg("/etc/init.d/%s start" %(daemon))
|
|
|
|
|
if not ("ok" in textLine):
|
|
|
|
|
textLines = self.execProg("/etc/init.d/%s start" %(daemon),
|
|
|
|
|
False, False)
|
|
|
|
|
if (not textLines) or textLines and ("ok" in textLines[-1]):
|
|
|
|
|
self.printERROR( _("Daemon %s was not started") %daemon)
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
@ -541,6 +542,16 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
self.setDaemonAutostart("dovecot")):
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
# В случае почтового релея
|
|
|
|
|
elif service == "mail_relay":
|
|
|
|
|
if not self.startDaemons('mail',['postfix'],
|
|
|
|
|
printSuccess):
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
# Устанавливаем автозапуск демонов
|
|
|
|
|
if not self.setDaemonAutostart("postfix"):
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
elif service == "jabber":
|
|
|
|
|
if not self.startDaemons('jabber',['ejabberd'], printSuccess):
|
|
|
|
|
flagError = True
|
|
|
|
@ -579,6 +590,15 @@ class shareLdap(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
for service in servInstalled:
|
|
|
|
|
if service == "unix" or service == "ldap":
|
|
|
|
|
flagLdap = True
|
|
|
|
|
# В случае почтового релея
|
|
|
|
|
elif service == "mail_relay":
|
|
|
|
|
if self.getRunDaemons(["postfix"]):
|
|
|
|
|
textLine = self.execProg("/etc/init.d/postfix stop")
|
|
|
|
|
if not ("ok" in textLine):
|
|
|
|
|
self.printERROR( "Postfix" + " " +
|
|
|
|
|
_("service is not stopped"))
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
elif service == "mail":
|
|
|
|
|
if self.getRunDaemons(["postfix"]):
|
|
|
|
|
textLine = self.execProg("/etc/init.d/postfix stop")
|
|
|
|
@ -1049,10 +1069,14 @@ if you want to continue to run the program again"))
|
|
|
|
|
DNs.append(dn)
|
|
|
|
|
return ','.join(DNs)
|
|
|
|
|
|
|
|
|
|
def initialChecks(self, service, printError=True):
|
|
|
|
|
"""Начальная проверка перед запуском методов сервиса
|
|
|
|
|
|
|
|
|
|
Проверяет что сервис установлен"""
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def initialChecks(self, service, printError=True):
|
|
|
|
|
"""Начальная проверка перед запуском методов сервиса"""
|
|
|
|
|
if self.clVars.Get("sr_mail_relay_set") == "on":
|
|
|
|
|
self.printERROR(_("This server is a mail relay. \
|
|
|
|
|
This command is not allowed."))
|
|
|
|
|
return False
|
|
|
|
|
if not self.isServiceSetup(service, printError):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
@ -1168,8 +1192,8 @@ if you want to continue to run the program again"))
|
|
|
|
|
#return self.fullElementDNtoText(relDN,'(&(|(|(&(ou:dn:=Replication)\
|
|
|
|
|
#(ou:dn:=Mail))(!(ou:dn:=Services)))(ou=Services))(!(&(%s:dn:=%s)\
|
|
|
|
|
#(%s:dn:=%s))))'%(proxyDNName, proxyLogin, baseDNName, baseLogin))
|
|
|
|
|
return self.fullElementDNtoText(relDN,'(&(&(|(|(ou:dn:=LDAP)\
|
|
|
|
|
(!(ou:dn:=Services)))(ou=Services))(!(&(%s:dn:=%s)(%s:dn:=%s))))\
|
|
|
|
|
return self.fullElementDNtoText(relDN,'(&(&(|(|(|(ou:dn:=LDAP)\
|
|
|
|
|
(ou=Mail))(!(ou:dn:=Services)))(ou=Services))(!(&(%s:dn:=%s)(%s:dn:=%s))))\
|
|
|
|
|
(!(ou:dn:=Worked)))'%(proxyDNName, proxyLogin, baseDNName, baseLogin))
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
@ -3692,12 +3716,12 @@ if you want to continue to run the program again"))
|
|
|
|
|
_("input 'yes'") +", "+ _("if not 'no'")
|
|
|
|
|
if not self.dialogYesNo(messDialog):
|
|
|
|
|
return True
|
|
|
|
|
if options.has_key("allow"):
|
|
|
|
|
if options.has_key("a"):
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
if not self.getAllowNet():
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
if options.has_key("allow"):
|
|
|
|
|
if options.has_key("a"):
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
if not self.getAllowNet():
|
|
|
|
|
return False
|
|
|
|
@ -4513,17 +4537,6 @@ class servSamba(shareLdap):
|
|
|
|
|
# создаем объект сервиса Unix
|
|
|
|
|
self.servUnixObj = servUnix(self)
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def initialChecks(self, service, printError=True):
|
|
|
|
|
"""Начальная проверка перед запуском методов сервиса"""
|
|
|
|
|
if self.clVars.Get("sr_mail_relay_set") == "on":
|
|
|
|
|
self.printERROR(_("This server is a mail relay. \
|
|
|
|
|
This command is not allowed."))
|
|
|
|
|
return False
|
|
|
|
|
if not self.isServiceSetup(service, printError):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def getLdapObjInFile(self):
|
|
|
|
|
"""Cоединение с LDAP администратором Samba сервиса"""
|
|
|
|
|
return shareLdap.getLdapObjInFile(self, "samba")
|
|
|
|
@ -4971,12 +4984,12 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
_("input 'yes'") +", "+ _("if not 'no'")
|
|
|
|
|
if not self.dialogYesNo(messDialog):
|
|
|
|
|
return True
|
|
|
|
|
if options.has_key("allow"):
|
|
|
|
|
if options.has_key("a"):
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
if not self.getAllowNet():
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
if options.has_key("allow"):
|
|
|
|
|
if options.has_key("a"):
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
if not self.getAllowNet():
|
|
|
|
|
return False
|
|
|
|
@ -5271,6 +5284,38 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
class filterProfiles(cl_profile.profile):
|
|
|
|
|
def __init__(self, objVar, servDir=False, dirFilter=[],
|
|
|
|
|
fileFilter=[]):
|
|
|
|
|
self.dirFilter = dirFilter
|
|
|
|
|
self.fileFilter = fileFilter
|
|
|
|
|
cl_profile.profile.__init__(self, objVar, servDir)
|
|
|
|
|
def scanDirs(self, profilesDirs):
|
|
|
|
|
rez = cl_profile.profile.scanDirs(self, profilesDirs)
|
|
|
|
|
if rez and (dirFilter or fileFilter):
|
|
|
|
|
for obj in rez:
|
|
|
|
|
dirs = []
|
|
|
|
|
dirsRel = []
|
|
|
|
|
for dirName in obj.dirs:
|
|
|
|
|
oldDir = dirName.split(obj.baseDir)[1]
|
|
|
|
|
if not oldDir in self.dirFilter:
|
|
|
|
|
dirs.append(dirName)
|
|
|
|
|
dirsRel.append(oldDir)
|
|
|
|
|
files = []
|
|
|
|
|
for fileName in obj.files:
|
|
|
|
|
oldFile = fileName.split(obj.baseDir)[1]
|
|
|
|
|
dirName,fileName = os.path.split(oldFile)
|
|
|
|
|
if dirName in dirsRel:
|
|
|
|
|
fileName = fileName.split("?")[0]
|
|
|
|
|
oldFile = os.path.join(dirName, fileName)
|
|
|
|
|
if not oldFile in self.fileFilter:
|
|
|
|
|
files.append(fileName)
|
|
|
|
|
obj.dirs = dirs
|
|
|
|
|
obj.files = files
|
|
|
|
|
|
|
|
|
|
return rez
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class servLdap(shareLdap):
|
|
|
|
|
"""Методы севисa Ldap"""
|
|
|
|
|
def __init__(self):
|
|
|
|
@ -5427,8 +5472,8 @@ outdated. If the backup is obsolete, use cl-backup."))
|
|
|
|
|
opt = {}
|
|
|
|
|
if options.has_key("v"):
|
|
|
|
|
opt['v'] = ''
|
|
|
|
|
if options.has_key("allow"):
|
|
|
|
|
opt['allow'] = ''
|
|
|
|
|
if options.has_key("a"):
|
|
|
|
|
opt['a'] = ''
|
|
|
|
|
# Сервисы для которых не будет задаваться вопрос о доступных сетях
|
|
|
|
|
# при включенной опции allow
|
|
|
|
|
noInputAllowNetServices = []
|
|
|
|
@ -5443,6 +5488,23 @@ outdated. If the backup is obsolete, use cl-backup."))
|
|
|
|
|
"""Перегенерирует конфигурационные файлы, и базу данных LDAP"""
|
|
|
|
|
return self.rebuildServer(options)
|
|
|
|
|
|
|
|
|
|
def applyProfilesFromService(self, service, verbose=False):
|
|
|
|
|
"""Применяем профили для данного сервиса"""
|
|
|
|
|
# Cоздаем объект профиль устанавливая директорию
|
|
|
|
|
# service для файлов профилей
|
|
|
|
|
clProf = filterProfiles(self.clVars,service)
|
|
|
|
|
# Объединяем профили
|
|
|
|
|
data = clProf.applyProfiles()
|
|
|
|
|
if clProf.getError():
|
|
|
|
|
self.printERROR(clProf.getError())
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
if verbose and type(data) == types.TupleType:
|
|
|
|
|
dirs, files = data
|
|
|
|
|
return files
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def updateServer(self, options, serviceUpdate, clVars=False,
|
|
|
|
|
noInputAllowNetServices=[]):
|
|
|
|
|
"""Перегенерируем конфигурационные файлы
|
|
|
|
@ -5523,13 +5585,15 @@ outdated. If the backup is obsolete, use cl-backup."))
|
|
|
|
|
if options.has_key("v"):
|
|
|
|
|
verbose = True
|
|
|
|
|
if not flagError:
|
|
|
|
|
# Флаг почтового релея
|
|
|
|
|
flagMailRelay = False
|
|
|
|
|
for service in servInstalled:
|
|
|
|
|
if service == "ldap":
|
|
|
|
|
continue
|
|
|
|
|
if service == "samba":
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
# для сервиса Samba
|
|
|
|
|
if options.has_key("allow") and\
|
|
|
|
|
if options.has_key("a") and\
|
|
|
|
|
not service in noInputAllowNetServices:
|
|
|
|
|
self.servSambaObj.clVars = self.clVars
|
|
|
|
|
if not self.servSambaObj.getAllowNet():
|
|
|
|
@ -5570,12 +5634,16 @@ it was added by the calculate-server")
|
|
|
|
|
if service == "mail":
|
|
|
|
|
# Получаем от пользователя доверительные сети
|
|
|
|
|
# для сервиса Mail
|
|
|
|
|
if options.has_key("allow") and\
|
|
|
|
|
if options.has_key("a") and\
|
|
|
|
|
not service in noInputAllowNetServices:
|
|
|
|
|
self.servMailObj.clVars = self.clVars
|
|
|
|
|
if not self.servMailObj.getAllowNet():
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
# В случае почтового релея
|
|
|
|
|
if self.clVars.Get("ld_repl_mail_set") == "on" and\
|
|
|
|
|
self.clVars.Get("sr_mail_relay_set") == "on":
|
|
|
|
|
flagMailRelay = True
|
|
|
|
|
if not flagError:
|
|
|
|
|
files = self.applyProfilesFromService(service, verbose)
|
|
|
|
|
if not files:
|
|
|
|
@ -5590,12 +5658,16 @@ it was added by the calculate-server")
|
|
|
|
|
else:
|
|
|
|
|
self.printOK(_("Updating config from service %s")\
|
|
|
|
|
%service.capitalize())
|
|
|
|
|
if flagMailRelay:
|
|
|
|
|
service = "mail_relay"
|
|
|
|
|
if not self.stopServices([service]):
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if not self.startServices([service], False):
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if flagMailRelay:
|
|
|
|
|
service = "mail"
|
|
|
|
|
self.printOK(_("Restarting service %s")%service.capitalize())
|
|
|
|
|
# Перезапускаем ldap
|
|
|
|
|
if not flagError:
|
|
|
|
@ -6075,6 +6147,12 @@ it was added by the calculate-server")
|
|
|
|
|
"""
|
|
|
|
|
# находим установленные сервисы
|
|
|
|
|
servInstalled = self.getServiceSetup()
|
|
|
|
|
# Если почтовый релей и установлен только Mail сервис то
|
|
|
|
|
# заменяем mail на mail_relay
|
|
|
|
|
if set(["mail","ldap"]) == set(servInstalled) and\
|
|
|
|
|
self.clVars.Get("sr_mail_relay_set") == "on":
|
|
|
|
|
servInstalled = filter(lambda x: x!="mail",servInstalled) +\
|
|
|
|
|
["mail_relay"]
|
|
|
|
|
return self.startServices(servInstalled)
|
|
|
|
|
|
|
|
|
|
def getArchFile(self):
|
|
|
|
@ -7385,6 +7463,7 @@ the password will be changed only for Samba account")
|
|
|
|
|
(on/off)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(9,),
|
|
|
|
|
'shortOption':"a",
|
|
|
|
|
'longOption':"allow",
|
|
|
|
|
'helpChapter':_("Mail service options"),
|
|
|
|
|
'help':_("enter the allowed ip addresses and network")
|
|
|
|
@ -7404,11 +7483,13 @@ the password will be changed only for Samba account")
|
|
|
|
|
'help':_("encryption type - 'none', 'tls'")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(9,),
|
|
|
|
|
'shortOption':"a",
|
|
|
|
|
'longOption':"allow",
|
|
|
|
|
'helpChapter':_("Samba service options"),
|
|
|
|
|
'help':_("enter the allowed ip addresses and network")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(10,),
|
|
|
|
|
'shortOption':"a",
|
|
|
|
|
'longOption':"allow",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("enter the allowed ip addresses and network\
|
|
|
|
@ -7961,10 +8042,9 @@ class servFtp(shareLdap):
|
|
|
|
|
self.printOK(_("Added ldif file") +" ...")
|
|
|
|
|
if self.getRunService('ftp'):
|
|
|
|
|
textLines = self.execProg("/etc/init.d/proftpd restart",False,False)
|
|
|
|
|
textLine = textLines[0]
|
|
|
|
|
else:
|
|
|
|
|
textLine = self.execProg("/etc/init.d/proftpd start")
|
|
|
|
|
if "ok" in textLine:
|
|
|
|
|
textLines = self.execProg("/etc/init.d/proftpd start",False,False)
|
|
|
|
|
if textLines and "ok" in textLines[-1]:
|
|
|
|
|
self.printOK(_("Starting") + " " + "Proftpd" + " ...")
|
|
|
|
|
else:
|
|
|
|
|
self.printNotOK(_("Starting") + " " + "Proftpd" + " ...")
|
|
|
|
@ -8279,7 +8359,7 @@ class servRepl(shareLdap):
|
|
|
|
|
"ld_repl_samba_servers","ld_repl_ids",
|
|
|
|
|
"sr_samba_net_allow", "sr_mail_host",
|
|
|
|
|
"sr_mail_type", "sr_mail_crypt",
|
|
|
|
|
"sr_mail_relay_set"]
|
|
|
|
|
"sr_mail_relay_set","ld_repl_mail_servers"]
|
|
|
|
|
# Переменные клиента (/var/calculate/remote/calculate.env)
|
|
|
|
|
# которые будут сохранены при rebuild
|
|
|
|
|
self.restoreRemoteClientVar = ["ld_base_dn", "ld_bind_dn",
|
|
|
|
@ -8421,7 +8501,7 @@ class servRepl(shareLdap):
|
|
|
|
|
self.restoreLocalVar = removeNameFoundText("samba",
|
|
|
|
|
self.restoreLocalVar)
|
|
|
|
|
self.restoreRemoteClientVar = []
|
|
|
|
|
# Получаем от пользователя доверительные сети для сервиса Samba
|
|
|
|
|
# Получаем от пользователя доверительные сети для сервиса Mail
|
|
|
|
|
# Переназначаем объект переменных
|
|
|
|
|
print _("Replications servers for Mail: %s")\
|
|
|
|
|
% " ".join(replMailServers)
|
|
|
|
|