|
|
|
@ -1681,6 +1681,7 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
# Отмонтируем пользовательские ресурсы в случае ошибки
|
|
|
|
|
self.errorAndUnmountUserRes = True
|
|
|
|
|
return False
|
|
|
|
|
flagFirstSync = False
|
|
|
|
|
# Синхронизируем настройки
|
|
|
|
|
if sync:
|
|
|
|
|
# Короткое имя системы
|
|
|
|
@ -1715,7 +1716,6 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
# Если на текущем сервере в ресурсе unix есть файлы
|
|
|
|
|
# то синхронируем настройки
|
|
|
|
|
# Получаем директорию хранения профиля на сервере
|
|
|
|
|
# Получаем директорию хранения профиля на сервере
|
|
|
|
|
homeProfile = os.path.join(home, "." + userName, osLinuxShort)
|
|
|
|
|
if not os.path.exists(homeProfile):
|
|
|
|
|
homeProfile = os.path.join(home, "." + userName,
|
|
|
|
@ -1962,58 +1962,34 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def copyProfileDir(self, destDir, srcDir):
|
|
|
|
|
"""Копируем директорию в другое место
|
|
|
|
|
"""Перенос файлов и директорий в директории srcDir в директорию destDir
|
|
|
|
|
|
|
|
|
|
При копировании сохраняются владелец, группа, права
|
|
|
|
|
"""
|
|
|
|
|
if os.path.exists(destDir) and not os.listdir(destDir):
|
|
|
|
|
os.rmdir(destDir)
|
|
|
|
|
# Файловый объект
|
|
|
|
|
fileObj = cl_profile._file()
|
|
|
|
|
# Сканируем директорию
|
|
|
|
|
scanObjs = fileObj.scanDirs([srcDir])
|
|
|
|
|
if not os.path.exists(destDir):
|
|
|
|
|
# Создаем директорию
|
|
|
|
|
if not os.path.exists(srcDir):
|
|
|
|
|
self.printERROR(_("Not found directory %s")%srcDir)
|
|
|
|
|
return False
|
|
|
|
|
files = os.listdir(srcDir)
|
|
|
|
|
if os.path.exists(destDir):
|
|
|
|
|
if not os.listdir(destDir):
|
|
|
|
|
os.rmdir(destDir)
|
|
|
|
|
else:
|
|
|
|
|
# Файловый объект
|
|
|
|
|
fileObj = cl_profile._file()
|
|
|
|
|
os.makedirs(destDir)
|
|
|
|
|
if not scanObjs:
|
|
|
|
|
return True
|
|
|
|
|
for dirSrc in scanObjs[0].dirs:
|
|
|
|
|
#создаем в домашней директории директории из srcDir
|
|
|
|
|
dirName = destDir + dirSrc.split(srcDir)[1]
|
|
|
|
|
os.mkdir(dirName)
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(dirSrc)
|
|
|
|
|
os.chown(dirName, uid,gid)
|
|
|
|
|
os.chmod(destDir, mode)
|
|
|
|
|
for fileCopy in scanObjs[0].files:
|
|
|
|
|
oldFile = destDir + fileCopy.split(srcDir)[1]
|
|
|
|
|
#копируем файлы
|
|
|
|
|
fileObj.openFiles(fileCopy, oldFile)
|
|
|
|
|
fileObj.saveOldFile()
|
|
|
|
|
fileObj.oldProfile = False
|
|
|
|
|
fileObj.closeFiles()
|
|
|
|
|
os.chown(oldFile, fileObj._uid, fileObj._gid)
|
|
|
|
|
os.chmod(oldFile, fileObj._mode)
|
|
|
|
|
for linkCreate in scanObjs[0].links:
|
|
|
|
|
#копируем ссылки
|
|
|
|
|
dst = destDir + linkCreate[1].split(srcDir)[1]
|
|
|
|
|
srcDestList = linkCreate[0].split(srcDir)
|
|
|
|
|
if len(srcDestList)>1:
|
|
|
|
|
src = destDir + srcDestList[1]
|
|
|
|
|
else:
|
|
|
|
|
src = linkCreate[0]
|
|
|
|
|
os.symlink(src,dst)
|
|
|
|
|
if os.path.exists(dst):
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(dst)
|
|
|
|
|
#Изменение прав на ссылки
|
|
|
|
|
os.lchown(dst, uid, gid)
|
|
|
|
|
# Удаляем сокеты
|
|
|
|
|
for rmSocket in scanObjs[0].sockets:
|
|
|
|
|
os.remove(rmSocket)
|
|
|
|
|
mode,uid,gid = fileObj.getModeFile(srcDir)
|
|
|
|
|
os.chmod(destDir, 0700)
|
|
|
|
|
os.chown(destDir, uid,gid)
|
|
|
|
|
# Удаляем директории и файлы предыдущего профиля
|
|
|
|
|
self.removeDir(scanObjs)
|
|
|
|
|
flagError=False
|
|
|
|
|
for srcFile in files:
|
|
|
|
|
destFile = destDir + srcFile.split(srcDir)[1]
|
|
|
|
|
if os.system("mv %s %s &>/dev/null"%(srcFile,destFile)) != 0:
|
|
|
|
|
self.printERROR(_("Can not move %s")%srcFile + " " +\
|
|
|
|
|
_("to %s")%destFile)
|
|
|
|
|
flagError=True
|
|
|
|
|
break
|
|
|
|
|
if flagError:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def upgradeProfileClient(self, userName, userHome):
|
|
|
|
|