|
|
@ -480,7 +480,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
|
|
|
|
|
|
|
def errorExit(self):
|
|
|
|
def errorExit(self):
|
|
|
|
"""Отмонтирование пользовательских ресурсов при ошибке"""
|
|
|
|
"""Отмонтирование пользовательских ресурсов при ошибке"""
|
|
|
|
# TODO: добавить удаление приватных файлов
|
|
|
|
|
|
|
|
if self.errorAndUnmountUserRes and self.userName:
|
|
|
|
if self.errorAndUnmountUserRes and self.userName:
|
|
|
|
self.umountUserResNoSync(self.userName, False, False, False, True)
|
|
|
|
self.umountUserResNoSync(self.userName, False, False, False, True)
|
|
|
|
|
|
|
|
|
|
|
@ -646,18 +645,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return ()
|
|
|
|
return ()
|
|
|
|
|
|
|
|
|
|
|
|
def createUserDir(self, uid, gid, userDir, mode=0700):
|
|
|
|
|
|
|
|
"""Создание пользовательской директории"""
|
|
|
|
|
|
|
|
if not os.path.exists(userDir):
|
|
|
|
|
|
|
|
os.makedirs(userDir)
|
|
|
|
|
|
|
|
if mode:
|
|
|
|
|
|
|
|
os.chmod(userDir,mode)
|
|
|
|
|
|
|
|
os.chown(userDir,uid,gid)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.printERROR(_("Path %s exists") %userDir)
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def applyTemplatesFromUser(self,progress=False):
|
|
|
|
def applyTemplatesFromUser(self,progress=False):
|
|
|
|
"""Применяем шаблоны для пользователя"""
|
|
|
|
"""Применяем шаблоны для пользователя"""
|
|
|
|
# Cоздаем объект шаблон
|
|
|
|
# Cоздаем объект шаблон
|
|
|
@ -697,43 +684,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
userPwd = getpass.getpass(pwDialog+":")
|
|
|
|
userPwd = getpass.getpass(pwDialog+":")
|
|
|
|
return userPwd
|
|
|
|
return userPwd
|
|
|
|
|
|
|
|
|
|
|
|
def chownR(self, directory, uid, gid, dirsAndFiles=False):
|
|
|
|
|
|
|
|
"""изменяет владельца и группу
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
для всех файлов и директорий внутри directory
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if dirsAndFiles:
|
|
|
|
|
|
|
|
dirs, files = dirsAndFiles
|
|
|
|
|
|
|
|
# меняем владельца домашней директории
|
|
|
|
|
|
|
|
os.chown(directory, uid,gid)
|
|
|
|
|
|
|
|
# Меняем владельца директорий
|
|
|
|
|
|
|
|
for dirCh in dirs:
|
|
|
|
|
|
|
|
if os.path.exists(dirCh):
|
|
|
|
|
|
|
|
os.chown(dirCh, uid,gid)
|
|
|
|
|
|
|
|
# Меняем владельца файлов
|
|
|
|
|
|
|
|
for fileCh in files:
|
|
|
|
|
|
|
|
if os.path.exists(fileCh):
|
|
|
|
|
|
|
|
if os.path.islink(fileCh):
|
|
|
|
|
|
|
|
os.lchown(fileCh, uid, gid)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
os.chown(fileCh, uid,gid)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
fileObj = _file()
|
|
|
|
|
|
|
|
scanObjs = fileObj.scanDirs([directory])
|
|
|
|
|
|
|
|
# меняем владельца домашней директории
|
|
|
|
|
|
|
|
os.chown(directory, uid,gid)
|
|
|
|
|
|
|
|
# Меняем владельца директорий
|
|
|
|
|
|
|
|
for dirCh in scanObjs[0].dirs:
|
|
|
|
|
|
|
|
os.chown(dirCh, uid,gid)
|
|
|
|
|
|
|
|
# Меняем владельца файлов
|
|
|
|
|
|
|
|
for fileCh in scanObjs[0].files:
|
|
|
|
|
|
|
|
os.chown(fileCh, uid,gid)
|
|
|
|
|
|
|
|
# Меняем владельца ссылок
|
|
|
|
|
|
|
|
for linkCh in scanObjs[0].links:
|
|
|
|
|
|
|
|
os.lchown(linkCh[1], uid, gid)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execProg(self, cmdStrProg, inStr=False, retFull=True, envProg={}):
|
|
|
|
def execProg(self, cmdStrProg, inStr=False, retFull=True, envProg={}):
|
|
|
|
"""Выполняет внешнюю программу
|
|
|
|
"""Выполняет внешнюю программу
|
|
|
|
|
|
|
|
|
|
|
@ -832,7 +782,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
self.printERROR(_("Not found user primary group (gid=%s)"%str(gid)))
|
|
|
|
self.printERROR(_("Not found user primary group (gid=%s)"%str(gid)))
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
# Создаем пользовательскую директорию
|
|
|
|
# Создаем пользовательскую директорию
|
|
|
|
self.clVars.Set('cl_root_path',homeDir,True)
|
|
|
|
|
|
|
|
homeExists = os.path.exists(homeDir)
|
|
|
|
homeExists = os.path.exists(homeDir)
|
|
|
|
# Первый проход
|
|
|
|
# Первый проход
|
|
|
|
self.clVars.Set('cl_pass_step','first',True)
|
|
|
|
self.clVars.Set('cl_pass_step','first',True)
|
|
|
@ -844,10 +793,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
self.clVars.Set('cl_pass_step','next',True)
|
|
|
|
self.clVars.Set('cl_pass_step','next',True)
|
|
|
|
self.printSUCCESS(_("Apply always templates") + " ...")
|
|
|
|
self.printSUCCESS(_("Apply always templates") + " ...")
|
|
|
|
|
|
|
|
|
|
|
|
# Создаем домашнюю директорию
|
|
|
|
|
|
|
|
if not os.path.exists(homeDir):
|
|
|
|
|
|
|
|
self.createUserDir(uid, gid, homeDir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Записываем переменные
|
|
|
|
# Записываем переменные
|
|
|
|
self.clVars.Set('ur_login', userName)
|
|
|
|
self.clVars.Set('ur_login', userName)
|
|
|
|
self.clVars.Set('ur_fullname', fullName)
|
|
|
|
self.clVars.Set('ur_fullname', fullName)
|
|
|
@ -861,7 +806,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
self.errorAndUnmountUserRes = True
|
|
|
|
self.errorAndUnmountUserRes = True
|
|
|
|
self.printERROR(_("Can not apply user profile"))
|
|
|
|
self.printERROR(_("Can not apply user profile"))
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
self.chownR(homeDir, uid, gid, dirsAndFiles)
|
|
|
|
|
|
|
|
if not homeExists:
|
|
|
|
if not homeExists:
|
|
|
|
self.printSUCCESS(_("Created home dir %s")%homeDir + " ...")
|
|
|
|
self.printSUCCESS(_("Created home dir %s")%homeDir + " ...")
|
|
|
|
self.printSUCCESS(_("User account is configured") + " ...")
|
|
|
|
self.printSUCCESS(_("User account is configured") + " ...")
|
|
|
@ -962,8 +906,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
# Обнуляем переменную удаленный хост
|
|
|
|
# Обнуляем переменную удаленный хост
|
|
|
|
if hostAuth == "local":
|
|
|
|
if hostAuth == "local":
|
|
|
|
self.clVars.Set("cl_remote_host","",True)
|
|
|
|
self.clVars.Set("cl_remote_host","",True)
|
|
|
|
# Изменяем базовую директорию наложения шаблонов
|
|
|
|
|
|
|
|
self.clVars.Set("cl_root_path","/",True)
|
|
|
|
|
|
|
|
# Устанавливаем действие templates_domain
|
|
|
|
# Устанавливаем действие templates_domain
|
|
|
|
self.clVars.Set("cl_pass_type","domain",True)
|
|
|
|
self.clVars.Set("cl_pass_type","domain",True)
|
|
|
|
# Наложим шаблоны templates/domain
|
|
|
|
# Наложим шаблоны templates/domain
|
|
|
@ -1033,9 +975,11 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
if not os.path.exists(pathRemote):
|
|
|
|
if not os.path.exists(pathRemote):
|
|
|
|
os.makedirs(pathRemote)
|
|
|
|
os.makedirs(pathRemote)
|
|
|
|
mountStr = "mount -t cifs -o user=client //%s/remote %s"\
|
|
|
|
#mountStr = "mount -t cifs -o user=client //%s/remote %s"\
|
|
|
|
%(domain,pathRemote)
|
|
|
|
# %(domain,pathRemote)
|
|
|
|
textLine = self.execProg(mountStr, None, True, {"PASSWD":pwdRemote})
|
|
|
|
#textLine= self.execProg(mountStr, None, True, {"PASSWD":pwdRemote})
|
|
|
|
|
|
|
|
textLine = self.mountSleepRes("client", pwdRemote, None, None,
|
|
|
|
|
|
|
|
"remote", pathRemote)
|
|
|
|
if not (textLine == None):
|
|
|
|
if not (textLine == None):
|
|
|
|
self.printWARNING(_("Can not mount Samba resource [%s]")%\
|
|
|
|
self.printWARNING(_("Can not mount Samba resource [%s]")%\
|
|
|
|
"remote" + " ...")
|
|
|
|
"remote" + " ...")
|
|
|
@ -1097,8 +1041,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
self.clVars.Delete("cl_remote_pw","local")
|
|
|
|
self.clVars.Delete("cl_remote_pw","local")
|
|
|
|
self.clVars.Set("cl_remote_host","",True)
|
|
|
|
self.clVars.Set("cl_remote_host","",True)
|
|
|
|
self.clVars.Set("cl_remote_pw","",True)
|
|
|
|
self.clVars.Set("cl_remote_pw","",True)
|
|
|
|
# Изменяем базовую директорию наложения шаблонов
|
|
|
|
|
|
|
|
self.clVars.Set("cl_root_path","/",True)
|
|
|
|
|
|
|
|
# Наложим шаблоны templates/domain
|
|
|
|
# Наложим шаблоны templates/domain
|
|
|
|
# Новые пути к шаблонам
|
|
|
|
# Новые пути к шаблонам
|
|
|
|
# Устанавливаем действие templates_domain
|
|
|
|
# Устанавливаем действие templates_domain
|
|
|
@ -1134,8 +1076,6 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
manager") + " ..."
|
|
|
|
manager") + " ..."
|
|
|
|
# Устанавливаем переменную шаблона
|
|
|
|
# Устанавливаем переменную шаблона
|
|
|
|
clVars.Set("cl_pass_run","off",True)
|
|
|
|
clVars.Set("cl_pass_run","off",True)
|
|
|
|
# Изменяем базовую директорию наложения шаблонов
|
|
|
|
|
|
|
|
clVars.Set("cl_root_path","/",True)
|
|
|
|
|
|
|
|
# Устанавливаем действие templates_client
|
|
|
|
# Устанавливаем действие templates_client
|
|
|
|
clVars.Set("cl_pass_type","install",True)
|
|
|
|
clVars.Set("cl_pass_type","install",True)
|
|
|
|
# Новые пути к шаблонам
|
|
|
|
# Новые пути к шаблонам
|
|
|
@ -1170,8 +1110,6 @@ manager") + " ..."
|
|
|
|
manager") + " ..."
|
|
|
|
manager") + " ..."
|
|
|
|
# Устанавливаем переменную шаблона
|
|
|
|
# Устанавливаем переменную шаблона
|
|
|
|
clVars.Set("cl_pass_run","on",True)
|
|
|
|
clVars.Set("cl_pass_run","on",True)
|
|
|
|
# Изменяем базовую директорию наложения шаблонов
|
|
|
|
|
|
|
|
clVars.Set("cl_root_path","/",True)
|
|
|
|
|
|
|
|
# Устанавливаем действие templates_client
|
|
|
|
# Устанавливаем действие templates_client
|
|
|
|
clVars.Set("cl_pass_type","install",True)
|
|
|
|
clVars.Set("cl_pass_type","install",True)
|
|
|
|
# Новые пути к шаблонам
|
|
|
|
# Новые пути к шаблонам
|
|
|
@ -1634,7 +1572,7 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
def mountSambaRes(self,userName,userPwd,uid,gid,res,path,
|
|
|
|
def mountSambaRes(self,userName,userPwd,uid,gid,res,path,
|
|
|
|
mountUidList=['ftp','home','share']):
|
|
|
|
mountUidList=['ftp','home','share']):
|
|
|
|
"""Монтирует Samba ресурсы"""
|
|
|
|
"""Монтирует Samba ресурсы"""
|
|
|
|
if res in mountUidList:
|
|
|
|
if not uid is None and not gid is None and res in mountUidList:
|
|
|
|
# Монтируем директории c uid
|
|
|
|
# Монтируем директории c uid
|
|
|
|
mountStr="mount -t cifs -o user=%s,uid=%s,gid=%s,noperm"\
|
|
|
|
mountStr="mount -t cifs -o user=%s,uid=%s,gid=%s,noperm"\
|
|
|
|
%(userName,uid,gid) +\
|
|
|
|
%(userName,uid,gid) +\
|
|
|
|