|
|
|
@ -598,7 +598,7 @@ in a sambaDomainName',
|
|
|
|
|
# id пользователя
|
|
|
|
|
strUid = ""
|
|
|
|
|
if searchUnixUser:
|
|
|
|
|
strUid = searchUnixUser[0][0][1]['uidNumber'][0]
|
|
|
|
|
strUid = searchUnixUser[0][0][1]['uidNumber'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
resPasswd = servUnixObj.searchPasswdUser(userName)
|
|
|
|
|
if resPasswd:
|
|
|
|
@ -641,7 +641,7 @@ in a sambaDomainName',
|
|
|
|
|
# id пользователя
|
|
|
|
|
strUid = ""
|
|
|
|
|
if searchUnixUser:
|
|
|
|
|
strUid = searchUnixUser[0][0][1]['uidNumber'][0]
|
|
|
|
|
strUid = searchUnixUser[0][0][1]['uidNumber'][0].decode("UTF-8")
|
|
|
|
|
if strUid:
|
|
|
|
|
delBackDir =\
|
|
|
|
|
os.path.join(self.clVars.Get("sr_deleted_path"),
|
|
|
|
@ -1090,7 +1090,7 @@ in a sambaDomainName',
|
|
|
|
|
pwd = re.sub("(\W)", r"\\\1", password)
|
|
|
|
|
pwdHash = self.execProg("slappasswd -s %s -h %s" %(pwd,cryptStr))
|
|
|
|
|
if pwdHash and len(pwdHash)>lenCryptStr and\
|
|
|
|
|
pwdHash[:lenCryptStr] == cryptStr:
|
|
|
|
|
pwdHash[:lenCryptStr] == cryptStr.encode("UTF-8"):
|
|
|
|
|
return pwdHash
|
|
|
|
|
self.printERROR(_("ERROR") + " getHashPasswd: " +\
|
|
|
|
|
_("create crypto password"))
|
|
|
|
@ -1193,7 +1193,7 @@ in a sambaDomainName',
|
|
|
|
|
for linkRm in scanObjs[0].links:
|
|
|
|
|
# Удаляем ссылки
|
|
|
|
|
os.unlink(linkRm[1])
|
|
|
|
|
scanObjs[0].dirs.sort(lambda x, y: cmp(len(y), len(x)))
|
|
|
|
|
scanObjs[0].dirs.sort(key=len)
|
|
|
|
|
for dirRm in scanObjs[0].dirs:
|
|
|
|
|
# Удаляем директории
|
|
|
|
|
os.rmdir(dirRm)
|
|
|
|
@ -1686,7 +1686,8 @@ This command is not allowed."))
|
|
|
|
|
return False
|
|
|
|
|
for dn, f in dnList:
|
|
|
|
|
delListDN.append(dn)
|
|
|
|
|
delListDN.sort(lambda x, y: cmp(len(y), len(x)))
|
|
|
|
|
delListDN.sort(key=len)
|
|
|
|
|
|
|
|
|
|
for dn in delListDN:
|
|
|
|
|
try:
|
|
|
|
|
self.conLdap.delete_s(dn)
|
|
|
|
@ -1704,9 +1705,13 @@ This command is not allowed."))
|
|
|
|
|
Возвращаемые параметры:
|
|
|
|
|
строка которую выведет внешняя программа или False в случае ошибки
|
|
|
|
|
"""
|
|
|
|
|
env_path = {"PATH":cl_utils.getpathenv()}
|
|
|
|
|
env_path = {"PATH" : cl_utils.getpathenv()}
|
|
|
|
|
env = {}
|
|
|
|
|
env.update(os.environ.items() + env_path.items() + envProg.items())
|
|
|
|
|
env.update(dict(os.environ))
|
|
|
|
|
env.update(env_path)
|
|
|
|
|
env.update(envProg)
|
|
|
|
|
|
|
|
|
|
inStr = inStr.encode("UTF-8") if isinstance(inStr, str) else inStr
|
|
|
|
|
retCode,programOut = cl_utils.runOsCommand(cmdStrProg,inStr,retFull,env)
|
|
|
|
|
if not retCode:
|
|
|
|
|
return programOut
|
|
|
|
@ -2226,7 +2231,7 @@ class servUnix(shareLdap):
|
|
|
|
|
flagError = True
|
|
|
|
|
continue
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]]=\
|
|
|
|
|
res[0][0][1]['gidNumber'][0]
|
|
|
|
|
res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
continue
|
|
|
|
|
gidNumber = gid
|
|
|
|
|
res = self.searchUnixGid(gidNumber)
|
|
|
|
@ -2234,7 +2239,8 @@ class servUnix(shareLdap):
|
|
|
|
|
gidErrors.append(gidNumber)
|
|
|
|
|
flagError = True
|
|
|
|
|
continue
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]] = res[0][0][1]['gidNumber'][0]
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]] =\
|
|
|
|
|
res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
if flagError:
|
|
|
|
|
errorMessage = ""
|
|
|
|
|
if groupErrors:
|
|
|
|
@ -2309,6 +2315,7 @@ class servUnix(shareLdap):
|
|
|
|
|
findUsers = []
|
|
|
|
|
if 'memberUid' in res[0][0][1]:
|
|
|
|
|
usersInGroup = res[0][0][1]['memberUid']
|
|
|
|
|
#TODO maybe we'll need to decode each username
|
|
|
|
|
for userName in usersNames:
|
|
|
|
|
if userName in usersInGroup:
|
|
|
|
|
findUsers.append(userName)
|
|
|
|
@ -2420,7 +2427,7 @@ class servUnix(shareLdap):
|
|
|
|
|
return False
|
|
|
|
|
resSearch = self.servSambaObj.searchSambaGroupName(groupName)
|
|
|
|
|
if resSearch:
|
|
|
|
|
groupId = resSearch[0][0][1]['gidNumber'][0]
|
|
|
|
|
groupId = resSearch[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
gr = self.staticGroups["Domain Computers"]
|
|
|
|
|
groupId = gr.gid
|
|
|
|
@ -2609,7 +2616,7 @@ class servUnix(shareLdap):
|
|
|
|
|
if resGroup:
|
|
|
|
|
userGid = resGroup.split(":")[2]
|
|
|
|
|
if resLdap:
|
|
|
|
|
userGid = resLdap[0][0][1]['gidNumber'][0]
|
|
|
|
|
userGid = resLdap[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
flagAddGroup = self.addGroupUnixServer(userName,{},False)
|
|
|
|
|
flagAdd['group'] = flagAddGroup
|
|
|
|
@ -2707,7 +2714,7 @@ Unix service"))
|
|
|
|
|
%str(userName))
|
|
|
|
|
return False
|
|
|
|
|
if 'registeredAddress' in searchUser[0][0][1]:
|
|
|
|
|
return searchUser[0][0][1]['registeredAddress'][0]
|
|
|
|
|
return searchUser[0][0][1]['registeredAddress'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
@ -2748,7 +2755,7 @@ in Unix service"))
|
|
|
|
|
%str(userName))
|
|
|
|
|
return False
|
|
|
|
|
if 'mail' in searchUser[0][0][1]:
|
|
|
|
|
return searchUser[0][0][1]['mail'][0]
|
|
|
|
|
return searchUser[0][0][1]['mail'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
@ -2989,7 +2996,7 @@ service"))
|
|
|
|
|
# В случае отсутствия других пользователей удаляем
|
|
|
|
|
# основную группу в Samba сервисе
|
|
|
|
|
if 'memberUid' not in resGroupSamba[0][0][1]:
|
|
|
|
|
groupName = resGroupSamba[0][0][1]['cn'][0]
|
|
|
|
|
groupName = resGroupSamba[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
# Находим группы у которых есть аттрибут type
|
|
|
|
|
groupsSambaList = [x for x in self.staticGroups.items() if x[1].type]
|
|
|
|
|
groupsSamba = {}
|
|
|
|
@ -3006,7 +3013,7 @@ service"))
|
|
|
|
|
# В случае отсутствия других пользователей
|
|
|
|
|
# удаляем основную группу в Unix сервисе
|
|
|
|
|
if 'memberUid' not in resGroup[0][0][1]:
|
|
|
|
|
groupName = resGroup[0][0][1]['cn'][0]
|
|
|
|
|
groupName = resGroup[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
if not self.delGroupUnixServer(groupName, {}, False):
|
|
|
|
|
return False
|
|
|
|
|
# Удаляем пользователя из ветки Worked в случае репликации
|
|
|
|
@ -3038,7 +3045,7 @@ service"))
|
|
|
|
|
_("Group %s is not found in Unix service")%groupName)
|
|
|
|
|
return False
|
|
|
|
|
if checkPrimaryGroup:
|
|
|
|
|
groupId = res[0][0][1]['gidNumber'][0]
|
|
|
|
|
groupId = res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
if self.searchUnixUserPrimGroup(groupId):
|
|
|
|
|
self.printWARNING(_("cannot remove user's primary group") + ".")
|
|
|
|
|
return True
|
|
|
|
@ -3141,15 +3148,15 @@ service"))
|
|
|
|
|
if resGroup:
|
|
|
|
|
userGid = resGroup.split(":")[2]
|
|
|
|
|
if resLdap:
|
|
|
|
|
userGid = resLdap[0][0][1]['gidNumber'][0]
|
|
|
|
|
userGid = resLdap[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'gidNumber', userGid)]
|
|
|
|
|
visible = False
|
|
|
|
|
# пользователя видно
|
|
|
|
|
if 'V' in options:
|
|
|
|
|
visible = '1'
|
|
|
|
|
visible = b'1'
|
|
|
|
|
# пользователя не видно
|
|
|
|
|
if 'I' in options:
|
|
|
|
|
visible = '0'
|
|
|
|
|
visible = b'0'
|
|
|
|
|
if visible:
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowFlag', visible)]
|
|
|
|
|
# Изменяем домашнюю директорию
|
|
|
|
@ -3158,10 +3165,10 @@ service"))
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'homeDirectory', homeDir)]
|
|
|
|
|
# Включаем пользователя
|
|
|
|
|
if 'U' in options:
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowExpire', "-1")]
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowExpire', b"-1")]
|
|
|
|
|
# Выключаем пользователя
|
|
|
|
|
if 'L' in options:
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowExpire', "1")]
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowExpire', b"1")]
|
|
|
|
|
# Изменяем комментарий к пользователю
|
|
|
|
|
if 'c' in options:
|
|
|
|
|
comment = options['c']
|
|
|
|
@ -3194,7 +3201,7 @@ service"))
|
|
|
|
|
return False
|
|
|
|
|
# Переносим домашнюю директорию пользователя
|
|
|
|
|
if 'd' in options and 'm' in options:
|
|
|
|
|
homeDirOld = res[0][0][1]['homeDirectory'][0]
|
|
|
|
|
homeDirOld = res[0][0][1]['homeDirectory'][0].decode("UTF-8")
|
|
|
|
|
homeDirNew = homeDir
|
|
|
|
|
textLine = self.execProg("mv %s %s" %(homeDirOld, homeDirNew))
|
|
|
|
|
if textLine == False:
|
|
|
|
@ -3436,6 +3443,7 @@ service"))
|
|
|
|
|
return False
|
|
|
|
|
memberUsers = res[0][0][1]["memberUid"]
|
|
|
|
|
flagError =False
|
|
|
|
|
#TODO decode each member?
|
|
|
|
|
for user in users:
|
|
|
|
|
if not user in memberUsers:
|
|
|
|
|
flagError = True
|
|
|
|
@ -3628,7 +3636,7 @@ class servMail(shareLdap):
|
|
|
|
|
if not searchEmailGroup:
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
userGroupNames.append(searchEmailGroup[0][0][1]['cn'][0])
|
|
|
|
|
userGroupNames.append(searchEmailGroup[0][0][1]['cn'][0].decode("UTF-8"))
|
|
|
|
|
else:
|
|
|
|
|
searchNameGroup = self.searchMailGroupToName(userGroup)
|
|
|
|
|
if not searchNameGroup:
|
|
|
|
@ -3722,7 +3730,7 @@ for user %s in 'Replication/Mail' branch") %str(userName))
|
|
|
|
|
_("Mail user or email %s are not found in Mail service")%\
|
|
|
|
|
str(nameOrMail))
|
|
|
|
|
return False
|
|
|
|
|
userMail = resSearchUser[0][0][1]['mail'][0]
|
|
|
|
|
userMail = resSearchUser[0][0][1]['mail'][0].decode("UTF-8")
|
|
|
|
|
resSearchGroup = self.searchLdapDN(userMail, self.relGroupsDN,
|
|
|
|
|
"rfc822member")
|
|
|
|
|
return (userMail, resSearchGroup)
|
|
|
|
@ -3757,7 +3765,7 @@ for user %s in 'Replication/Mail' branch") %str(userName))
|
|
|
|
|
self.printERROR(\
|
|
|
|
|
_("Member list of group %s is empty")%str(groupName))
|
|
|
|
|
return False
|
|
|
|
|
memberMailUsers = res[0][0][1]["rfc822member"]
|
|
|
|
|
memberMailUsers = res[0][0][1]["rfc822member"].decode("UTF-8")
|
|
|
|
|
flagError = False
|
|
|
|
|
memberUsers = {}
|
|
|
|
|
for mailUser in memberMailUsers:
|
|
|
|
@ -3864,9 +3872,10 @@ are incompatible, use one of the options"))
|
|
|
|
|
attrDeleteFirst.append((ldap.MOD_DELETE, 'filtersender', None))
|
|
|
|
|
if 'e' in options:
|
|
|
|
|
altMails = options['e'].split(",")
|
|
|
|
|
email = searchGroup[0][0][1]["mail"][0]
|
|
|
|
|
email = searchGroup[0][0][1]["mail"][0].decode("UTF-8")
|
|
|
|
|
altEmails = searchGroup[0][0][1]["mailAlternateAddress"]
|
|
|
|
|
# Удаляем альтернативные адреса, кроме первого
|
|
|
|
|
#TODO decode each email
|
|
|
|
|
for altEmail in altEmails:
|
|
|
|
|
if email != altEmail:
|
|
|
|
|
attrDeleteFirst.append(
|
|
|
|
@ -3900,6 +3909,7 @@ option '-e'"))
|
|
|
|
|
if servReplObj:
|
|
|
|
|
if not altMails and filterHosts:
|
|
|
|
|
altMails = searchGroup[0][0][1]["mailAlternateAddress"]
|
|
|
|
|
#TODO decode each
|
|
|
|
|
if altMails:
|
|
|
|
|
for mail in altMails:
|
|
|
|
|
if "@" in altMail:
|
|
|
|
@ -3911,6 +3921,7 @@ option '-e'"))
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
flagError = False
|
|
|
|
|
foundReplUsers = foundReplAlias[0][0][1]['cn']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for foundReplUser in foundReplUsers:
|
|
|
|
|
if foundReplUser!=groupName:
|
|
|
|
|
flagError = True
|
|
|
|
@ -3969,6 +3980,7 @@ mail user or group: %s")%foundReplUser)
|
|
|
|
|
return False
|
|
|
|
|
# изменяем адрес и альтернативный адрес
|
|
|
|
|
altEmails = searchGroup[0][0][1]["mailAlternateAddress"]
|
|
|
|
|
#todo decode each
|
|
|
|
|
for altEmail in altEmails:
|
|
|
|
|
splAltEmail = altEmail.split("@")
|
|
|
|
|
grName = splAltEmail[0]
|
|
|
|
@ -3984,7 +3996,7 @@ mail user or group: %s")%foundReplUser)
|
|
|
|
|
(ldap.MOD_ADD, 'mailAlternateAddress',
|
|
|
|
|
newAltEmail))
|
|
|
|
|
break
|
|
|
|
|
email = searchGroup[0][0][1]["mail"][0]
|
|
|
|
|
email = searchGroup[0][0][1]["mail"][0].decode("UTF-8")
|
|
|
|
|
splEmail = email.split("@")
|
|
|
|
|
emailDomen = ""
|
|
|
|
|
if len(splEmail)==2:
|
|
|
|
@ -4125,6 +4137,7 @@ in 'Replication/Mail' branch") %groupName)
|
|
|
|
|
if 'e' in options:
|
|
|
|
|
altEmails = res[0][0][1]["mailAlternateAddress"]
|
|
|
|
|
altMails = options['e'].split(",")
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for altMail in altMails:
|
|
|
|
|
if "@" in altMail:
|
|
|
|
|
if len(altMail.split("@")) != 2:
|
|
|
|
@ -4168,8 +4181,9 @@ in Unix service") %str(primaryMail))
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
flagError = False
|
|
|
|
|
foundReplUsers = foundReplAlias[0][0][1]['cn']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for foundReplUser in foundReplUsers:
|
|
|
|
|
if foundReplUser!=userName:
|
|
|
|
|
if foundReplUser != userName:
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if flagError:
|
|
|
|
@ -4236,7 +4250,7 @@ option '-e'"))
|
|
|
|
|
if servReplObj:
|
|
|
|
|
foundReplAlias = servReplObj.searchMailAddress(mail)
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0]
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.printERROR(_("Mail address %s is found in \
|
|
|
|
|
'Replication/Mail' branch")%mail)
|
|
|
|
|
self.printERROR(_("The address belongs to \
|
|
|
|
@ -4267,7 +4281,7 @@ mail user or group: %s")%foundReplUser)
|
|
|
|
|
if servReplObj:
|
|
|
|
|
foundReplAlias = servReplObj.searchMailAddress(mail)
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0]
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.printERROR(_("Mail address %s is found in \
|
|
|
|
|
'Replication/Mail' branch")%mail)
|
|
|
|
|
self.printERROR(_("The address belongs to \
|
|
|
|
@ -4363,6 +4377,7 @@ for user %s in 'Replication/Mail' branch") %str(mail))
|
|
|
|
|
findUsers = []
|
|
|
|
|
if 'rfc822member' in res[0][0][1]:
|
|
|
|
|
usersInGroup = res[0][0][1]['rfc822member']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for userName in usersNames:
|
|
|
|
|
userMail = "%s@%s" %(userName,
|
|
|
|
|
self.clVars.Get("sr_mail_host"))
|
|
|
|
@ -4526,7 +4541,7 @@ for user %s in 'Replication/Mail' branch") %str(mail))
|
|
|
|
|
if servReplObj:
|
|
|
|
|
foundReplAlias = servReplObj.searchMailAddress(mail)
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0]
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.printERROR(_("Mail address %s is found in \
|
|
|
|
|
'Replication/Mail' branch")%mail)
|
|
|
|
|
self.printERROR(_("The address belongs to \
|
|
|
|
@ -4552,7 +4567,7 @@ mail user or group: %s")%foundReplUser)
|
|
|
|
|
if servReplObj:
|
|
|
|
|
foundReplAlias = servReplObj.searchMailAddress(mail)
|
|
|
|
|
if foundReplAlias:
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0]
|
|
|
|
|
foundReplUser = foundReplAlias[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.printERROR(_("Mail address %s is found in \
|
|
|
|
|
'Replication/Mail' branch")%mail)
|
|
|
|
|
self.printERROR(_("The address belongs to \
|
|
|
|
@ -4619,7 +4634,7 @@ mail user or group: %s")%foundReplUser)
|
|
|
|
|
fullNameUser = options['c']
|
|
|
|
|
else:
|
|
|
|
|
if resUnix and 'cn' in resUnix[0][0][1]:
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0]
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.clVars.Set("ur_fio",fullNameUser)
|
|
|
|
|
if not userPwd:
|
|
|
|
|
userPwdHash = "crypt{xxx}"
|
|
|
|
@ -5096,8 +5111,8 @@ class servJabber(shareLdap):
|
|
|
|
|
str(userName))
|
|
|
|
|
return False
|
|
|
|
|
modAttrs = []
|
|
|
|
|
descr = groupSearch[0][0][1]["cn"][0]
|
|
|
|
|
uid = userSearch[0][0][1]["uid"][0]
|
|
|
|
|
descr = groupSearch[0][0][1]["cn"][0].decode("UTF-8")
|
|
|
|
|
uid = userSearch[0][0][1]["uid"][0].decode("UTF-8")
|
|
|
|
|
if 'departmentNumber' in userSearch[0][0][1]:
|
|
|
|
|
modAttrs.append((ldap.MOD_REPLACE, 'departmentNumber', descr))
|
|
|
|
|
else:
|
|
|
|
@ -5184,7 +5199,7 @@ in Jabber service"))
|
|
|
|
|
userSearch = self.searchUserToNameOrId(userName)
|
|
|
|
|
if userSearch and 'departmentNumber' in userSearch[0][0][1]:
|
|
|
|
|
if not userSearch[0][0][1]['departmentNumber'][0] == \
|
|
|
|
|
groupSearch[0][0][1]['cn'][0]:
|
|
|
|
|
groupSearch[0][0][1]['cn'][0].decode("UTF-8"):
|
|
|
|
|
self.printERROR(_("User %s is not found in group")%\
|
|
|
|
|
str(userName) + " " + str(groupName))
|
|
|
|
|
res = False
|
|
|
|
@ -5198,9 +5213,9 @@ in Jabber service"))
|
|
|
|
|
return False
|
|
|
|
|
for userName in users:
|
|
|
|
|
userSearch = self.searchUserToNameOrId(userName)
|
|
|
|
|
uid = userSearch[0][0][1]['uid'][0]
|
|
|
|
|
uid = userSearch[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
modAttrs = [(ldap.MOD_DELETE, 'departmentNumber', None)]
|
|
|
|
|
userDN = self.addDN("uid="+uid, self.relUsersDN)
|
|
|
|
|
userDN = self.addDN("uid=" + uid, self.relUsersDN)
|
|
|
|
|
res = self.modAttrsDN(userDN, modAttrs)
|
|
|
|
|
if not res:
|
|
|
|
|
break
|
|
|
|
@ -5271,7 +5286,7 @@ in Jabber service"))
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
if modAttrs:
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0]
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
DN = self.addDN("uid="+userName, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
@ -5315,7 +5330,7 @@ in Jabber service"))
|
|
|
|
|
return False
|
|
|
|
|
searchUser = self.searchUserToId(jabberId)
|
|
|
|
|
if searchUser:
|
|
|
|
|
foundUserName = searchUser[0][0][1]['uid'][0]
|
|
|
|
|
foundUserName = searchUser[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
if foundUserName != userName:
|
|
|
|
|
self.printERROR(_("User %s") %str(foundUserName) + " " +\
|
|
|
|
|
_("has a JID %s") %jabberId)
|
|
|
|
@ -5369,7 +5384,7 @@ in Unix service") %str(jabberId))
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
if modAttrs:
|
|
|
|
|
uid = res[0][0][1]['uid'][0]
|
|
|
|
|
uid = res[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
DN = self.addDN("uid="+uid, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
@ -5439,7 +5454,7 @@ in Unix service") %str(jabberId))
|
|
|
|
|
# Изменяем имя группы
|
|
|
|
|
if 'n' in options:
|
|
|
|
|
newGroupName = options['n']
|
|
|
|
|
oldGroupName = searchGroup[0][0][1]["cn"][0]
|
|
|
|
|
oldGroupName = searchGroup[0][0][1]["cn"][0].decode("UTF-8")
|
|
|
|
|
if self.renameGroup(oldGroupName, newGroupName):
|
|
|
|
|
self.printSUCCESS(_("Group renamed to %s")\
|
|
|
|
|
%newGroupName)
|
|
|
|
@ -5460,7 +5475,7 @@ in Unix service") %str(jabberId))
|
|
|
|
|
self.printERROR (_("ERROR") + ": " +\
|
|
|
|
|
_("User %s is not found in Jabber service") % str(userName))
|
|
|
|
|
return False
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0]
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
# Удаляем jabberID из Unix сервиса
|
|
|
|
|
# удаляем jabberID из Unix
|
|
|
|
|
if self.isServiceSetup("unix",False) and\
|
|
|
|
@ -5632,7 +5647,7 @@ in Unix service") %str(jabberId))
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
# Берем комментарий для пользователя из Unix
|
|
|
|
|
if resUnix and 'cn' in resUnix[0][0][1]:
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0]
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.clVars.Set("ur_fio",fullNameUser)
|
|
|
|
|
ldifFile = self.ldifFileUser
|
|
|
|
|
userLdif = self.createLdif(ldifFile)
|
|
|
|
@ -5922,11 +5937,12 @@ of version > 2.1.10, then you can delete this file.") + "\n"
|
|
|
|
|
"""Удаление пользователей из списка из группы Samba"""
|
|
|
|
|
|
|
|
|
|
def getPrimaryUsers():
|
|
|
|
|
gidNumber = res[0][0][1]["gidNumber"][0]
|
|
|
|
|
gidNumber = res[0][0][1]["gidNumber"][0].decode("UTF-8")
|
|
|
|
|
searchUsers = self.servUnixObj.searchUnixUserPrimGroup(gidNumber)
|
|
|
|
|
foundUserNames = []
|
|
|
|
|
if searchUsers:
|
|
|
|
|
for data in searchUsers:
|
|
|
|
|
#TODO check encoding
|
|
|
|
|
foundUserNames.append(data[0][1]["uid"][0])
|
|
|
|
|
if foundUserNames:
|
|
|
|
|
primaryUsers = list(set(foundUserNames)&set(users))
|
|
|
|
@ -5947,6 +5963,7 @@ of version > 2.1.10, then you can delete this file.") + "\n"
|
|
|
|
|
_("Member list of group %s is empty")%str(groupName))
|
|
|
|
|
return False
|
|
|
|
|
memberUsers = res[0][0][1]["memberUid"]
|
|
|
|
|
#TODO decode each
|
|
|
|
|
flagError =False
|
|
|
|
|
for user in users:
|
|
|
|
|
if not user in memberUsers:
|
|
|
|
@ -5993,7 +6010,7 @@ of version > 2.1.10, then you can delete this file.") + "\n"
|
|
|
|
|
_("Group %s is not found in Samba service")%groupName)
|
|
|
|
|
return False
|
|
|
|
|
if checkPrimaryGroup:
|
|
|
|
|
groupId = res[0][0][1]['gidNumber'][0]
|
|
|
|
|
groupId = res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
if self.servUnixObj.searchUnixUserPrimGroup(groupId):
|
|
|
|
|
self.printWARNING(_("cannot remove user's primary group") + ".")
|
|
|
|
|
return True
|
|
|
|
@ -6125,7 +6142,7 @@ of version > 2.1.10, then you can delete this file.") + "\n"
|
|
|
|
|
uidUnixUser = False
|
|
|
|
|
resSearch = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
if resSearch:
|
|
|
|
|
uidUnixUser = resSearch[0][0][1]['uidNumber'][0]
|
|
|
|
|
uidUnixUser = resSearch[0][0][1]['uidNumber'][0].decode("UTF-8")
|
|
|
|
|
## создание пользователя Unix опция f
|
|
|
|
|
#if not resSearch and not options.has_key('f'):
|
|
|
|
|
#self.printERROR(
|
|
|
|
@ -6426,6 +6443,7 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
findUsers = []
|
|
|
|
|
if 'memberUid' in res[0][0][1]:
|
|
|
|
|
usersInGroup = res[0][0][1]['memberUid']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for userName in usersNames:
|
|
|
|
|
if userName in usersInGroup:
|
|
|
|
|
findUsers.append(userName)
|
|
|
|
@ -6513,7 +6531,7 @@ Samba and Unix services") %", ".join(exclGroup)
|
|
|
|
|
flagError = True
|
|
|
|
|
continue
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]]=\
|
|
|
|
|
res[0][0][1]['gidNumber'][0]
|
|
|
|
|
res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
continue
|
|
|
|
|
gidNumber = gid
|
|
|
|
|
res = self.searchSambaGid(gidNumber)
|
|
|
|
@ -6521,7 +6539,8 @@ Samba and Unix services") %", ".join(exclGroup)
|
|
|
|
|
gidErrors.append(gidNumber)
|
|
|
|
|
flagError = True
|
|
|
|
|
continue
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]] = res[0][0][1]['gidNumber'][0]
|
|
|
|
|
userGroupNames[res[0][0][1]['cn'][0]] =\
|
|
|
|
|
res[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
if flagError:
|
|
|
|
|
errorMessage = ""
|
|
|
|
|
if groupErrors:
|
|
|
|
@ -6726,13 +6745,14 @@ Samba and Unix services") %", ".join(exclGroup)
|
|
|
|
|
machineGroupName = self.clVars.Get('sr_samba_machine_group')
|
|
|
|
|
resSearch = self.searchSambaGroupName(machineGroupName)
|
|
|
|
|
if resSearch:
|
|
|
|
|
machineGid = resSearch[0][0][1]['gidNumber'][0]
|
|
|
|
|
machineGid = resSearch[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
mGr = self.staticGroups["Domain Computers"]
|
|
|
|
|
machineGid = mGr.gid
|
|
|
|
|
searchAllMachines = self.searchAllSambaMachines()
|
|
|
|
|
if searchAllMachines:
|
|
|
|
|
for data in searchAllMachines:
|
|
|
|
|
#TODO check encoding
|
|
|
|
|
machineName = data[0][1]['uid'][0]
|
|
|
|
|
machineDN = self.addDN("uid=" + machineName,
|
|
|
|
|
self.relComputersDN)
|
|
|
|
@ -6878,7 +6898,7 @@ Samba and Unix services") %", ".join(exclGroup)
|
|
|
|
|
resSearch = self.searchLdapDN("*", self.relDN, "sambaDomainName",
|
|
|
|
|
["sambaSID"])
|
|
|
|
|
if resSearch:
|
|
|
|
|
return resSearch[0][0][1]['sambaSID'][0]
|
|
|
|
|
return resSearch[0][0][1]['sambaSID'][0].decode("UTF-8")
|
|
|
|
|
self.printERROR(_("Not found sambaSID in LDAP"))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
@ -11779,7 +11799,7 @@ class servFtp(shareLdap):
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
if modAttrs:
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0]
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
DN = self.addDN("uid="+uid, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
@ -11816,7 +11836,7 @@ class servFtp(shareLdap):
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
if modAttrs:
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0]
|
|
|
|
|
uid = resSearch[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
DN = self.addDN("uid="+userName, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
@ -11838,7 +11858,7 @@ class servFtp(shareLdap):
|
|
|
|
|
self.printERROR(_("User not exists in FTP service"))
|
|
|
|
|
return False
|
|
|
|
|
# FTP директория пользователя
|
|
|
|
|
ftpUserDir = resFtp[0][0][1]['homeDirectory'][0]
|
|
|
|
|
ftpUserDir = resFtp[0][0][1]['homeDirectory'][0].decode("UTF-8")
|
|
|
|
|
ftpPath = self.clVars.Get("sr_ftp_path")
|
|
|
|
|
if ftpUserDir == ftpPath:
|
|
|
|
|
ftpUserDir = os.path.join(ftpPath,"pub/users",userName)
|
|
|
|
@ -11920,7 +11940,7 @@ class servFtp(shareLdap):
|
|
|
|
|
fullNameUser = options['c']
|
|
|
|
|
else:
|
|
|
|
|
if resUnix and 'cn' in resUnix[0][0][1]:
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0]
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0].decode("UTF-8")
|
|
|
|
|
self.clVars.Set("ur_fio",fullNameUser)
|
|
|
|
|
if not userPwd:
|
|
|
|
|
userPwdHash = "crypt{xxx}"
|
|
|
|
@ -12664,7 +12684,7 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
rez = self.searchMailAlias(oldName)
|
|
|
|
|
if not rez:
|
|
|
|
|
return True
|
|
|
|
|
email = rez[0][0][1]["rfc822member"][0]
|
|
|
|
|
email = rez[0][0][1]["rfc822member"][0].decode("UTF-8")
|
|
|
|
|
splEmail = email.split("@")
|
|
|
|
|
attrAppend = []
|
|
|
|
|
relMailDN = self.getRelMailDN()
|
|
|
|
@ -12733,9 +12753,10 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
attrAppend.append((ldap.MOD_ADD, 'filtersender', host))
|
|
|
|
|
if 'filtersender' in rez[0][0][1]:
|
|
|
|
|
attrDelete.append((ldap.MOD_DELETE, 'filtersender', None))
|
|
|
|
|
email = rez[0][0][1]["mail"][0]
|
|
|
|
|
email = rez[0][0][1]["mail"][0].decode("UTF-8")
|
|
|
|
|
altEmails = rez[0][0][1]["mailAlternateAddress"]
|
|
|
|
|
# Удаляем альтернативные адреса, кроме первого
|
|
|
|
|
#TODO decode each
|
|
|
|
|
for altEmail in altEmails:
|
|
|
|
|
if email != altEmail:
|
|
|
|
|
attrDelete.append(
|
|
|
|
@ -12833,12 +12854,12 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
print(_("Variable Error: not set a variable ld_repl_host"))
|
|
|
|
|
return False
|
|
|
|
|
if rez:
|
|
|
|
|
host = rez[0][0][1]['host'][0]
|
|
|
|
|
host = rez[0][0][1]['host'][0].decode("UTF-8")
|
|
|
|
|
if host != replHost:
|
|
|
|
|
# Изменяемые аттрибуты
|
|
|
|
|
modAttrs = [(ldap.MOD_REPLACE, 'host', replHost)]
|
|
|
|
|
relWorkedDN = self.getRelWorkedDN()
|
|
|
|
|
DN = self.addDN("uid="+userName, relWorkedDN)
|
|
|
|
|
DN = self.addDN("uid=" + userName, relWorkedDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
@ -13591,7 +13612,7 @@ remove user %s in the LDAP branch 'Worked'")%str(userName))
|
|
|
|
|
return False
|
|
|
|
|
# Проверка правильности предыдущего пароля
|
|
|
|
|
if 'sambaNTPassword' in resSamba[0][0][1]:
|
|
|
|
|
if userOldNTHash !=resSamba[0][0][1]['sambaNTPassword'][0]:
|
|
|
|
|
if userOldNTHash != resSamba[0][0][1]['sambaNTPassword'][0].decode("UTF-8"):
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("Invalid previous password for the user %s")\
|
|
|
|
|
%str(userName))
|
|
|
|
@ -14538,7 +14559,7 @@ for %s DNS zone")%zoneName)
|
|
|
|
|
self.printERROR(_("Can not found SOA-record in zone %s")\
|
|
|
|
|
%zoneName)
|
|
|
|
|
return False
|
|
|
|
|
soaRecord = zoneData[0][0][1]['sOARecord'][0]
|
|
|
|
|
soaRecord = zoneData[0][0][1]['sOARecord'][0].decode("UTF-8")
|
|
|
|
|
# Все авторитативные сервера зоны
|
|
|
|
|
nSRecords = zoneData[0][0][1]['nSRecord']
|
|
|
|
|
mXRecords = []
|
|
|
|
@ -14977,8 +14998,9 @@ with another option."))
|
|
|
|
|
if service in ("unix", "samba"):
|
|
|
|
|
memberUid = []
|
|
|
|
|
if 'memberUid' in searchRes[0][0][1]:
|
|
|
|
|
#TODO check encoding
|
|
|
|
|
memberUid = searchRes[0][0][1]['memberUid']
|
|
|
|
|
groupId = searchRes[0][0][1]['gidNumber'][0]
|
|
|
|
|
groupId = searchRes[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
primaryUids = self.getUnixUidPrimGroup(groupId)
|
|
|
|
|
memberUid = primaryUids + memberUid
|
|
|
|
|
uniqueUid = []
|
|
|
|
@ -15054,7 +15076,7 @@ with another option."))
|
|
|
|
|
#i[0][1]['uidNumber'] = [uidNumber]
|
|
|
|
|
#data.insert(0,(_("ID"),"uidNumber"))
|
|
|
|
|
|
|
|
|
|
gidNumber = searchResUnix[0][0][1]['gidNumber'][0]
|
|
|
|
|
gidNumber = searchResUnix[0][0][1]['gidNumber'][0].decode("UTF-8")
|
|
|
|
|
#sambaGroup = servObj.searchSambaGid(gidNumber)
|
|
|
|
|
#if sambaGroup:
|
|
|
|
|
i[0][1]['gidNumber'] = [gidNumber]
|
|
|
|
@ -15433,7 +15455,7 @@ with another option."))
|
|
|
|
|
servObj = servMail()
|
|
|
|
|
searchUser = servObj.searchUserToMail(value)
|
|
|
|
|
if searchUser:
|
|
|
|
|
retValue = searchUser[0][0][1]['uid'][0]
|
|
|
|
|
retValue = searchUser[0][0][1]['uid'][0].decode("UTF-8")
|
|
|
|
|
else:
|
|
|
|
|
retValue = "Not found"
|
|
|
|
|
# Заменяем тип группы названием типа
|
|
|
|
@ -15444,7 +15466,7 @@ with another option."))
|
|
|
|
|
retValue = _("local group")
|
|
|
|
|
if value == "5":
|
|
|
|
|
retValue = _("builtin group")
|
|
|
|
|
return retValue.decode("UTF-8") if isinstance(retValue, bytes) else retValue
|
|
|
|
|
return retValue
|
|
|
|
|
|
|
|
|
|
def modUserAttr(self, attr, value, service):
|
|
|
|
|
"""Модифицирует аттрибуты пользователя для вывода на печать"""
|
|
|
|
@ -15932,10 +15954,10 @@ is not valid ") %accessPorts)
|
|
|
|
|
%str(groupName))
|
|
|
|
|
return False
|
|
|
|
|
# Если группа пуста
|
|
|
|
|
if [x for x in searchGroup[0][0][1]['member'] if not x.strip()]:
|
|
|
|
|
if [x.decode("UTF-8") for x in searchGroup[0][0][1]['member'] if not x.strip()]:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("Member list of group %s is empty")%str(groupName))
|
|
|
|
|
memberUsers = [x.rpartition("=")[2] for x
|
|
|
|
|
memberUsers = [x.decode("UTF-8").rpartition("=")[2] for x
|
|
|
|
|
in searchGroup[0][0][1]["member"]]
|
|
|
|
|
flagError = False
|
|
|
|
|
for user in users:
|
|
|
|
@ -17306,8 +17328,8 @@ class servDns(shareLdap):
|
|
|
|
|
if foundIPs:
|
|
|
|
|
for ptrRecord in foundIPs:
|
|
|
|
|
lastOctIPs = ptrRecord[0][1]['relativeDomainName']
|
|
|
|
|
zoneName = ptrRecord[0][1]['zoneName'][0]
|
|
|
|
|
domainNames = ["%s.%s" % (x, zoneName) for x in lastOctIPs]
|
|
|
|
|
zoneName = ptrRecord[0][1]['zoneName'][0].decode("UTF-8")
|
|
|
|
|
domainNames = ["%s.%s" % (x.decode("UTF-8"), zoneName) for x in lastOctIPs]
|
|
|
|
|
for name in domainNames:
|
|
|
|
|
listOctRev = name.rpartition(".in-addr.arpa")[0].split(".")
|
|
|
|
|
listOctRev.reverse()
|
|
|
|
@ -18315,7 +18337,7 @@ with option "--mxmod"')
|
|
|
|
|
self.printERROR(_("Can not found SOA-record in zone %s")%zoneName)
|
|
|
|
|
return False
|
|
|
|
|
#these return lists
|
|
|
|
|
soaRecord = zoneData[0][0][1]['sOARecord'][0]
|
|
|
|
|
soaRecord = zoneData[0][0][1]['sOARecord'][0].decode("UTF-8")
|
|
|
|
|
nSRecords = zoneData[0][0][1]['nSRecord']
|
|
|
|
|
soaData = [delDot(x) for x in soaRecord.split(" ")]
|
|
|
|
|
if len(soaData)!=7:
|
|
|
|
@ -18352,7 +18374,9 @@ with option "--mxmod"')
|
|
|
|
|
%zoneName)
|
|
|
|
|
return False
|
|
|
|
|
# Находим нужную запись
|
|
|
|
|
foundMxServers = [len(x.split(" ")) == 1 and delDot(x) or delDot(x.split(" ")[1])
|
|
|
|
|
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 zoneData[0][0][1]['mXRecord']]
|
|
|
|
|
oldMxHost = modMxServers[0]
|
|
|
|
|
newMxHost = modMxServers[1]
|
|
|
|
@ -18692,12 +18716,12 @@ incompatible with CNAME-record (option "-t")'))
|
|
|
|
|
self.printERROR(_("CNAME-record %s exists in LDAP")\
|
|
|
|
|
%newDomainName)
|
|
|
|
|
self.printERROR("%s --> %s"%(newDomainName,\
|
|
|
|
|
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0])))
|
|
|
|
|
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("A-record %s exists in LDAP")\
|
|
|
|
|
%newDomainName)
|
|
|
|
|
self.printERROR("%s --> %s"\
|
|
|
|
|
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0]))
|
|
|
|
|
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0].decode("UTF-8")))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Проверка существования обратной записи
|
|
|
|
@ -18729,12 +18753,12 @@ incompatible with CNAME-record (option "-t")'))
|
|
|
|
|
self.printERROR(_("CNAME-record %s exists in LDAP")\
|
|
|
|
|
%newDomainName)
|
|
|
|
|
self.printERROR("%s --> %s"%(newDomainName,\
|
|
|
|
|
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0])))
|
|
|
|
|
delDot(foundNewDomain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))))
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("A-record %s exists in LDAP")\
|
|
|
|
|
%newDomainName)
|
|
|
|
|
self.printERROR("%s --> %s"\
|
|
|
|
|
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0]))
|
|
|
|
|
%(newDomainName, foundNewDomain[0][0][1]['aRecord'][0].decode("UTF-8")))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
newIP = ""
|
|
|
|
@ -18769,7 +18793,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])))
|
|
|
|
|
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Проверка существования обратной записи
|
|
|
|
@ -18800,7 +18824,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])))
|
|
|
|
|
delDot(foundNewIp[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Имена изменяемых зон
|
|
|
|
@ -18836,7 +18860,7 @@ is incompatible with option "--ip"')
|
|
|
|
|
self.printERROR(_("Record %s not exists in LDAP")\
|
|
|
|
|
%domainName)
|
|
|
|
|
return False
|
|
|
|
|
otherIP = delDot(foundMain[0][0][1]['aRecord'][0])
|
|
|
|
|
otherIP = delDot(foundMain[0][0][1]['aRecord'][0].decode("UTF-8"))
|
|
|
|
|
# Поиcк в обратной зоне в случае необходимости
|
|
|
|
|
if modOther:
|
|
|
|
|
dataIP = self.getDomainAndZoneFromIP(otherIP)
|
|
|
|
@ -18850,11 +18874,11 @@ is incompatible with option "--ip"')
|
|
|
|
|
%otherDomain)
|
|
|
|
|
return False
|
|
|
|
|
# Проверка на соответствие имени хоста
|
|
|
|
|
if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0]):
|
|
|
|
|
if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
|
|
|
|
|
self.printERROR(_("Found PTR-record %s in LDAP")\
|
|
|
|
|
%otherDomain)
|
|
|
|
|
self.printERROR("%s --> %s"%(otherIP,\
|
|
|
|
|
delDot(foundOther[0][0][1]['pTRRecord'][0])))
|
|
|
|
|
delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Изменяем в двух зонах
|
|
|
|
@ -18944,18 +18968,18 @@ is incompatible with option "--ip"')
|
|
|
|
|
return False
|
|
|
|
|
# Поиcк в обратной зоне в случае необходимости
|
|
|
|
|
if modOther:
|
|
|
|
|
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0])
|
|
|
|
|
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0].decode("UTF-8"))
|
|
|
|
|
foundOther = self.searchAllDomainNamesInLDAP(otherDomain)
|
|
|
|
|
if not foundOther:
|
|
|
|
|
self.printERROR(_("A-record %s not exists in LDAP")\
|
|
|
|
|
%otherDomain)
|
|
|
|
|
return False
|
|
|
|
|
# Проверка на соответствие ip хоста
|
|
|
|
|
if ip != foundOther[0][0][1]['aRecord'][0]:
|
|
|
|
|
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
|
|
|
|
|
self.printERROR(_("Found A-record %s in LDAP")\
|
|
|
|
|
%otherDomain)
|
|
|
|
|
self.printERROR("%s --> %s"\
|
|
|
|
|
%(otherDomain, foundOther[0][0][1]['aRecord'][0]))
|
|
|
|
|
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Модифицируем PTR запись
|
|
|
|
@ -19026,7 +19050,7 @@ is incompatible with option "--ip"')
|
|
|
|
|
namesZones.append(zoneName)
|
|
|
|
|
# CNAME запись (изменяем имя домена)
|
|
|
|
|
if newDomainName:
|
|
|
|
|
oldCname = delDot(foundMain[0][0][1]['cNAMERecord'][0])
|
|
|
|
|
oldCname = delDot(foundMain[0][0][1]['cNAMERecord'][0].decode("UTF-8"))
|
|
|
|
|
if not self.moveCNAMERecord(oldCname,domainName,
|
|
|
|
|
newDomainName):
|
|
|
|
|
return False
|
|
|
|
@ -19052,8 +19076,9 @@ is incompatible with option "--ip"')
|
|
|
|
|
%domainName)
|
|
|
|
|
return False
|
|
|
|
|
# Находим нужную запись
|
|
|
|
|
foundMxServers = [len(x.split(" ")) == 1\
|
|
|
|
|
and delDot(x) or delDot(x.split(" ")[1])
|
|
|
|
|
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']]
|
|
|
|
|
oldMxHost = modMxServers[0]
|
|
|
|
|
newMxHost = modMxServers[1]
|
|
|
|
@ -19127,7 +19152,7 @@ is incompatible with option "--ip"')
|
|
|
|
|
self.printERROR(_("PTR-record %s not exists in LDAP")\
|
|
|
|
|
%domainNamePTR)
|
|
|
|
|
return False
|
|
|
|
|
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0])
|
|
|
|
|
otherDomain = delDot(foundMain[0][0][1]['pTRRecord'][0].decode("UTF-8"))
|
|
|
|
|
# Модификация
|
|
|
|
|
domainName = otherDomain
|
|
|
|
|
# Модификация
|
|
|
|
@ -19140,11 +19165,11 @@ is incompatible with option "--ip"')
|
|
|
|
|
%otherDomain)
|
|
|
|
|
return False
|
|
|
|
|
# Проверка на соответствие ip хоста
|
|
|
|
|
if ip != foundOther[0][0][1]['aRecord'][0]:
|
|
|
|
|
if ip != foundOther[0][0][1]['aRecord'][0].decode("UTF-8"):
|
|
|
|
|
self.printERROR(_("Found A-record %s in LDAP")\
|
|
|
|
|
%otherDomain)
|
|
|
|
|
self.printERROR("%s --> %s"\
|
|
|
|
|
%(otherDomain, foundOther[0][0][1]['aRecord'][0]))
|
|
|
|
|
%(otherDomain, foundOther[0][0][1]['aRecord'][0].decode("UTF-8")))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Модифицируем PTR запись
|
|
|
|
@ -19226,7 +19251,7 @@ is incompatible with option "--ip"')
|
|
|
|
|
return False
|
|
|
|
|
# Поиcк в обратной зоне в случае необходимости
|
|
|
|
|
if modOther:
|
|
|
|
|
otherIP = delDot(foundMain[0][0][1]['aRecord'][0])
|
|
|
|
|
otherIP = delDot(foundMain[0][0][1]['aRecord'][0].decode("UTF-8"))
|
|
|
|
|
dataIP = self.getDomainAndZoneFromIP(otherIP)
|
|
|
|
|
if not dataIP:
|
|
|
|
|
self.printERROR(_("IP address %s incorrectly")%otherIP)
|
|
|
|
@ -19238,11 +19263,11 @@ is incompatible with option "--ip"')
|
|
|
|
|
%otherDomain)
|
|
|
|
|
return False
|
|
|
|
|
# Проверка на соответствие имени хоста
|
|
|
|
|
if domainName!=delDot(foundOther[0][0][1]['pTRRecord'][0]):
|
|
|
|
|
if domainName != delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8")):
|
|
|
|
|
self.printERROR(_("Found PTR-record %s in LDAP")\
|
|
|
|
|
%otherDomain)
|
|
|
|
|
self.printERROR("%s --> %s"%(otherIP,\
|
|
|
|
|
delDot(foundOther[0][0][1]['pTRRecord'][0])))
|
|
|
|
|
delDot(foundOther[0][0][1]['pTRRecord'][0].decode("UTF-8"))))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
return False
|
|
|
|
|
# Изменяем в двух зонах
|
|
|
|
@ -19325,8 +19350,9 @@ is incompatible with option "--ip"')
|
|
|
|
|
%domainName)
|
|
|
|
|
return False
|
|
|
|
|
# Находим нужную запись
|
|
|
|
|
foundMxServers = [len(x.split(" ")) == 1\
|
|
|
|
|
and delDot(x) or delDot(x.split(" ")[1])
|
|
|
|
|
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']]
|
|
|
|
|
oldMxHost = modMxServers[0]
|
|
|
|
|
newMxHost = modMxServers[1]
|
|
|
|
@ -19616,6 +19642,7 @@ with type DNS record PTR (option "-t")'))
|
|
|
|
|
self.printERROR(_("CNAME-record %s exists in LDAP")\
|
|
|
|
|
%domainName)
|
|
|
|
|
cnameHosts = findCName[0][0][1]['cNAMERecord']
|
|
|
|
|
#TODO check encodings
|
|
|
|
|
for cnameHost in cnameHosts:
|
|
|
|
|
self.printERROR("%s --> %s"%(domainName,cnameHost))
|
|
|
|
|
self.printERROR("")
|
|
|
|
@ -19773,7 +19800,7 @@ with type DNS record PTR (option "-t")'))
|
|
|
|
|
self.printERROR(_("Can not found SOA-record in DNS zone %s")\
|
|
|
|
|
%zoneName)
|
|
|
|
|
return False
|
|
|
|
|
sOARecord = foundNames[0][0][1]['sOARecord'][0]
|
|
|
|
|
sOARecord = foundNames[0][0][1]['sOARecord'][0].decode("UTF-8")
|
|
|
|
|
sOAList = sOARecord.split(" ")
|
|
|
|
|
if len(sOAList)!=7:
|
|
|
|
|
self.printERROR(_("Incorrect SOA-record in DNS zone %s")%zoneName)
|
|
|
|
@ -20388,12 +20415,12 @@ eth0, eth1, ... etc."%net)
|
|
|
|
|
hostname = self.servDnsObj.clVars.Get("os_net_hostname")
|
|
|
|
|
if hostname:
|
|
|
|
|
zone = oldDomainNames[0]
|
|
|
|
|
fullServerDNSName = "%s.%s" % (hostname,zone)
|
|
|
|
|
fullServerDNSName = "%s.%s" % (hostname, zone)
|
|
|
|
|
if not [x for x in moveRecords if fullServerDNSName == x[0]]:
|
|
|
|
|
foundServ = self.servDnsObj.searchDomainNameInLDAP(\
|
|
|
|
|
fullServerDNSName)
|
|
|
|
|
if foundServ:
|
|
|
|
|
serverIP = foundServ[0][0][1]['aRecord'][0]
|
|
|
|
|
serverIP = foundServ[0][0][1]['aRecord'][0].decode("UTF-8")
|
|
|
|
|
moveRecords.append((fullServerDNSName,serverIP))
|
|
|
|
|
data = [oldDnsIPs, oldRanges, net]
|
|
|
|
|
if not self.modifyDNSZoneName(oldDomainNames[0], domainNames[0],
|
|
|
|
@ -20716,7 +20743,7 @@ eth0, eth1, ... etc."%net)
|
|
|
|
|
ip = ""
|
|
|
|
|
if recData:
|
|
|
|
|
if 'aRecord' in recData[0][0][1]:
|
|
|
|
|
ip = recData[0][0][1]['aRecord'][0]
|
|
|
|
|
ip = recData[0][0][1]['aRecord'][0].decode("UTF-8")
|
|
|
|
|
# Удаляем A запись
|
|
|
|
|
if not self.servDnsObj.delRecordDnsServer({"host":fullHostName},
|
|
|
|
|
False):
|
|
|
|
@ -20738,7 +20765,7 @@ eth0, eth1, ... etc."%net)
|
|
|
|
|
hostList = recData[0][0][1]['pTRRecord']
|
|
|
|
|
# Удаляет лишние точки в названии
|
|
|
|
|
delDot = lambda y: ".".join(x for x in y.split(".") if x)
|
|
|
|
|
hostList = [delDot(x) for x in hostList]
|
|
|
|
|
hostList = [delDot(x.decode("UTF-8")) for x in hostList]
|
|
|
|
|
if not fullHostName in hostList:
|
|
|
|
|
deleteIP.append(ip)
|
|
|
|
|
deleteIP = list(set(deleteIP))
|
|
|
|
@ -20768,6 +20795,7 @@ eth0, eth1, ... etc."%net)
|
|
|
|
|
flagDelARecord = True
|
|
|
|
|
if 'aRecord' in recData[0][0][1]:
|
|
|
|
|
aRecords = recData[0][0][1]['aRecord']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
if ip in aRecords:
|
|
|
|
|
flagCreateARecord = False
|
|
|
|
|
flagDelARecord = False
|
|
|
|
@ -20849,7 +20877,7 @@ eth0, eth1, ... etc."%net)
|
|
|
|
|
hostList = recData[0][0][1]['pTRRecord']
|
|
|
|
|
# Удаляет лишние точки в названии
|
|
|
|
|
delDot = lambda y: ".".join(x for x in y.split(".") if x)
|
|
|
|
|
hostList = [delDot(x) for x in hostList]
|
|
|
|
|
hostList = [delDot(x.decode("UTF-8")) for x in hostList]
|
|
|
|
|
if fullHostName in hostList:
|
|
|
|
|
deleteIP = [x for x in deleteIP if x != ip]
|
|
|
|
|
flagCreatePTRRecord = False
|
|
|
|
@ -21013,6 +21041,7 @@ incompatible, use one of the options"))
|
|
|
|
|
if recData:
|
|
|
|
|
if 'aRecord' in recData[0][0][1]:
|
|
|
|
|
aRecords = recData[0][0][1]['aRecord']
|
|
|
|
|
#TODO decode each
|
|
|
|
|
if ip in aRecords:
|
|
|
|
|
retData[fullDomainName] = ip
|
|
|
|
|
else:
|
|
|
|
@ -21107,7 +21136,7 @@ incompatible, use one of the options"))
|
|
|
|
|
foundMain = self.servDnsObj.searchDomainNameInLDAP(hostname)
|
|
|
|
|
if not foundMain:
|
|
|
|
|
continue
|
|
|
|
|
otherIP = foundMain[0][0][1]['aRecord'][0]
|
|
|
|
|
otherIP = foundMain[0][0][1]['aRecord'][0].decode("UTF-8")
|
|
|
|
|
# Поиcк в обратной зоне
|
|
|
|
|
dataIP = self.servDnsObj.getDomainAndZoneFromIP(otherIP)
|
|
|
|
|
otherHostName, otherDomain, otherZoneName = dataIP
|
|
|
|
@ -21129,11 +21158,11 @@ incompatible, use one of the options"))
|
|
|
|
|
foundNewARec = self.servDnsObj.searchDomainNameInLDAP(newHostName)
|
|
|
|
|
if foundNewARec:
|
|
|
|
|
if 'aRecord' in foundNewARec[0][0][1]:
|
|
|
|
|
if foundNewARec[0][0][1]['aRecord'][0] != otherIP:
|
|
|
|
|
if foundNewARec[0][0][1]['aRecord'][0].decode("UTF-8") != otherIP:
|
|
|
|
|
self.printERROR(_("Record %s exists in DNS service")\
|
|
|
|
|
%newHostName)
|
|
|
|
|
self.printERROR("%s --> %s"%(newHostName,\
|
|
|
|
|
foundNewARec[0][0][1]['aRecord'][0]))
|
|
|
|
|
foundNewARec[0][0][1]['aRecord'][0].decode("UTF-8")))
|
|
|
|
|
self.printERROR("")
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
@ -21399,6 +21428,7 @@ network %s") % net)
|
|
|
|
|
if recData:
|
|
|
|
|
if 'aRecord' in recData[0][0][1]:
|
|
|
|
|
aRecords = recData[0][0][1]['aRecord']
|
|
|
|
|
#TODO check encoding
|
|
|
|
|
if not ip in aRecords:
|
|
|
|
|
flagError = True
|
|
|
|
|
else:
|
|
|
|
@ -21430,7 +21460,7 @@ network %s") % net)
|
|
|
|
|
hostList = recData[0][0][1]['pTRRecord']
|
|
|
|
|
# Удаляет лишние точки в названии
|
|
|
|
|
delDot = lambda y: ".".join(x for x in y.split(".") if x)
|
|
|
|
|
hostList = [delDot(x) for x in hostList]
|
|
|
|
|
hostList = [delDot(x.decode("UTF-8")) for x in hostList]
|
|
|
|
|
if hostname in hostList:
|
|
|
|
|
deleteIP = [x for x in deleteIP if x != ip]
|
|
|
|
|
flagCreatePTR = False
|
|
|
|
@ -21996,6 +22026,7 @@ network %s") % net)
|
|
|
|
|
fullHostNameServer)
|
|
|
|
|
if recData and 'aRecord' in recData[0][0][1]:
|
|
|
|
|
flagFoundARecord = True
|
|
|
|
|
#TODO check encoding
|
|
|
|
|
if ipServer in recData[0][0][1]['aRecord']:
|
|
|
|
|
flagCreateDNSRecord = False
|
|
|
|
|
else:
|
|
|
|
@ -22012,7 +22043,7 @@ network %s") % net)
|
|
|
|
|
hostList = recData[0][0][1]['pTRRecord']
|
|
|
|
|
# Удаляет лишние точки в названии
|
|
|
|
|
delDot = lambda y: ".".join(x for x in y.split(".") if x)
|
|
|
|
|
hostList = [delDot(x) for x in hostList]
|
|
|
|
|
hostList = [delDot(x.decode("UTF-8")) for x in hostList]
|
|
|
|
|
if not fullHostNameServer in hostList:
|
|
|
|
|
flagCreateDNSRecord = True
|
|
|
|
|
flagDeletePTRRecord = True
|
|
|
|
|