|
|
|
@ -672,9 +672,65 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
self.printOK(_("Added in domain %s")%domain + " ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def umountUserRes(self, userName):
|
|
|
|
|
"""Отмонтирование пользовательских ресурсов и синхронизация настроек"""
|
|
|
|
|
connectDomain = self.isDomain()
|
|
|
|
|
if not connectDomain:
|
|
|
|
|
return False
|
|
|
|
|
elif not connectDomain[0]:
|
|
|
|
|
self.printERROR(_("Can not mount Samba resource [remote]") + \
|
|
|
|
|
" ...")
|
|
|
|
|
return False
|
|
|
|
|
# Подсоединяемся к серверу
|
|
|
|
|
domain = self.clVars.Get("cl_remote_host")
|
|
|
|
|
if not self.getLdapObjBind(domain):
|
|
|
|
|
return False
|
|
|
|
|
# homeDir из LDAP
|
|
|
|
|
resLdap = self.getUserLdapInfo(userName)
|
|
|
|
|
if not resLdap:
|
|
|
|
|
return False
|
|
|
|
|
homeDir = resLdap[4]
|
|
|
|
|
home = os.path.split(homeDir)[0]
|
|
|
|
|
pathRemote = []
|
|
|
|
|
# Удаленный ресурс профилей
|
|
|
|
|
pathRemote.append((os.path.join(home,"." + userName), "unix"))
|
|
|
|
|
# Удаленный ресурс home
|
|
|
|
|
pathRemote.append((os.path.join(homeDir,"Home"), "homes"))
|
|
|
|
|
# Удаленный ресурс share
|
|
|
|
|
pathRemote.append((os.path.join(homeDir,"Disks"), "share"))
|
|
|
|
|
if not self.syncUser(userName, homeDir, "logout"):
|
|
|
|
|
return False
|
|
|
|
|
flagError = False
|
|
|
|
|
for path, res in pathRemote:
|
|
|
|
|
if self.isMount(path ,"cifs"):
|
|
|
|
|
textLine = self.execProg("umount %s"%path)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not umount Samba resource \
|
|
|
|
|
[%s]")%res + " ...")
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if os.path.exists(path) and not os.listdir(path):
|
|
|
|
|
try:
|
|
|
|
|
os.rmdir(path)
|
|
|
|
|
except:
|
|
|
|
|
self.printERROR(_("Can not remove dir %s")% path)
|
|
|
|
|
flagError = True
|
|
|
|
|
break
|
|
|
|
|
if flagError:
|
|
|
|
|
self.printERROR(_("Keep a user profile in the domain"))
|
|
|
|
|
return False
|
|
|
|
|
self.printSUCCESS(_("Keep a user profile in the domain"))
|
|
|
|
|
self.printOK(_("Umount user resources in domain") + " ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mountUserRes(self, userName):
|
|
|
|
|
"""Монтирование пользовательских ресурсов и синхронизация настроек"""
|
|
|
|
|
self.createClVars()
|
|
|
|
|
# В случае компьютера вне домена
|
|
|
|
|
if not self.clVars.Get("cl_remote_host"):
|
|
|
|
|
self.printSUCCESS(_("To be used by local profile."))
|
|
|
|
|
return True
|
|
|
|
|
# Проверим что компьютер в домене и смонтирован [remote]
|
|
|
|
|
connectDomain = self.isDomain()
|
|
|
|
|
if not connectDomain:
|
|
|
|
@ -683,7 +739,7 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
self.printERROR(_("Can not mount Samba resource [remote]") + \
|
|
|
|
|
" ...")
|
|
|
|
|
return False
|
|
|
|
|
# Подсоединяемся к серверу
|
|
|
|
|
# Подсоединяемся к серверу
|
|
|
|
|
domain = self.clVars.Get("cl_remote_host")
|
|
|
|
|
if not self.getLdapObjBind(domain):
|
|
|
|
|
return False
|
|
|
|
@ -694,6 +750,11 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
uid = int(resLdap[0])
|
|
|
|
|
gid = int(resLdap[1])
|
|
|
|
|
homeDir = resLdap[4]
|
|
|
|
|
# При отсуствии создаем домашнюю директорию
|
|
|
|
|
if not os.path.exists(homeDir):
|
|
|
|
|
os.makedirs(homeDir)
|
|
|
|
|
os.chown(homeDir,uid,gid)
|
|
|
|
|
os.chmod(homeDir,0700)
|
|
|
|
|
# Получаем пароль пользователя из ключей ядра
|
|
|
|
|
userPwd = _cl_keys.getKey(userName)
|
|
|
|
|
if not userPwd:
|
|
|
|
@ -739,27 +800,54 @@ install/6intranet" %(domain,servDn,unixDN,bindDn,bindPw)
|
|
|
|
|
# Синхронизируем настройки
|
|
|
|
|
if not self.syncUser(userName, homeDir, "login"):
|
|
|
|
|
return False
|
|
|
|
|
self.printOK(_("Mount user resources"))
|
|
|
|
|
self.printSUCCESS(_("Mount user resources in domain"))
|
|
|
|
|
self.printOK(_("Get a user profile in the domain") + " ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def syncUser(self, userName, userHome, sync):
|
|
|
|
|
"""Синхронизация пользовательских настроек"""
|
|
|
|
|
home = os.path.split(userHome)[1]
|
|
|
|
|
home = os.path.split(userHome)[0]
|
|
|
|
|
homeProfile = os.path.join(home,"." + userName)
|
|
|
|
|
print "HomeDirs",userHome,homeProfile
|
|
|
|
|
flagError = False
|
|
|
|
|
execStr = ""
|
|
|
|
|
if sync == "login":
|
|
|
|
|
if os.path.exists(userHome) and\
|
|
|
|
|
os.path.exists(homeProfile):
|
|
|
|
|
execStr = '/usr/bin/rsync --exclude="/.googleearth" \
|
|
|
|
|
--exclude="*~" --exclude="/Home" --exclude="/Disks" \
|
|
|
|
|
-a --delete -x %s/ %s/' %(homeProfile,userHome)
|
|
|
|
|
elif sync == "logout":
|
|
|
|
|
if os.path.exists(userHome) and os.listdir(userHome) and\
|
|
|
|
|
os.path.exists(homeProfile) and os.listdir(homeProfile):
|
|
|
|
|
print "START"
|
|
|
|
|
execStr = """/usr/bin/rsync --exclude="/.googleearth"
|
|
|
|
|
--exclude="/.rdesktop" --exclude="/.aMule" --exclude="*~" --exclude="/Home"
|
|
|
|
|
--exclude="/Web" --exclude="/Disks" --exclude="/Office" --exclude="/Factory"
|
|
|
|
|
--exclude="/.local" --exclude="/cache-*" --exclude="/socket-*"
|
|
|
|
|
--exclude="/tmp-*" --stats -a --delete -x %s/.%s %s/%s""" %(home, userName)
|
|
|
|
|
textLines = self.execProg(execStr)
|
|
|
|
|
for line in testLine:
|
|
|
|
|
print line
|
|
|
|
|
return True
|
|
|
|
|
os.path.exists(homeProfile):
|
|
|
|
|
execStr = '/usr/bin/rsync --exclude="/.googleearth" \
|
|
|
|
|
--exclude="*~" --exclude="/Home" --exclude="/Disks" \
|
|
|
|
|
-a -b --delete -x %s/ %s/'%(userHome,homeProfile)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Method syncUser: option sync incorrect"))
|
|
|
|
|
return False
|
|
|
|
|
if execStr:
|
|
|
|
|
textLine = self.execProg(execStr)
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not rsync") + " " + str(sync) +\
|
|
|
|
|
" ...")
|
|
|
|
|
flagError = True
|
|
|
|
|
else:
|
|
|
|
|
if sync == "login":
|
|
|
|
|
if not (os.path.exists(userHome)):
|
|
|
|
|
self.printERROR(_("Directory %s not exists")%userHome)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Directory %s not exists")%homeProfile)
|
|
|
|
|
elif sync == "logout":
|
|
|
|
|
if not (os.path.exists(userHome)):
|
|
|
|
|
self.printERROR(_("Directory %s is empty or not exists")\
|
|
|
|
|
%userHome)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Directory %s not exists")%homeProfile)
|
|
|
|
|
flagError = True
|
|
|
|
|
if flagError:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
class tsOpt(cl_base.opt):
|
|
|
|
|
"""Класс для обработки параметров и вывода help
|
|
|
|
|