|
|
|
@ -316,12 +316,12 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
# Cоздаем объект профиль
|
|
|
|
|
clProf = cl_profile.profile(self.clVars)
|
|
|
|
|
# Объединяем профили
|
|
|
|
|
clProf.applyProfiles()
|
|
|
|
|
dirsFiles = clProf.applyProfiles()
|
|
|
|
|
if clProf.getError():
|
|
|
|
|
self.printERROR(clProf.getError())
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
|
def getUserPassword(self, pwDialog=False):
|
|
|
|
|
"""Получить пароль у пользователя
|
|
|
|
@ -334,25 +334,37 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
userPwd = re.sub("(\W)", r"\\\1",userPwd)
|
|
|
|
|
return userPwd
|
|
|
|
|
|
|
|
|
|
def chownR(self, directory, uid, gid):
|
|
|
|
|
def chownR(self, directory, uid, gid, dirsAndFiles=False):
|
|
|
|
|
"""изменяет владельца и группу
|
|
|
|
|
|
|
|
|
|
для всех файлов и директорий внутри directory
|
|
|
|
|
"""
|
|
|
|
|
fileObj = cl_profile._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
|
|
|
|
|
if dirsAndFiles:
|
|
|
|
|
dirs, files = dirsAndFiles
|
|
|
|
|
# меняем владельца домашней директории
|
|
|
|
|
os.chown(directory, uid,gid)
|
|
|
|
|
# Меняем владельца директорий
|
|
|
|
|
for dirCh in dirs:
|
|
|
|
|
os.chown(dirCh, uid,gid)
|
|
|
|
|
# Меняем владельца файлов
|
|
|
|
|
for fileCh in files:
|
|
|
|
|
os.chown(fileCh, uid,gid)
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
fileObj = cl_profile._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):
|
|
|
|
|
"""Выполняет внешнюю программу
|
|
|
|
@ -388,6 +400,14 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def getAlwaysProfilePath(self):
|
|
|
|
|
"""Получаем пути к профилям которые применяются постоянно"""
|
|
|
|
|
profilePath = self.clVars.Get('cl_profile_path')
|
|
|
|
|
alwProfilePath = []
|
|
|
|
|
for prPath in profilePath:
|
|
|
|
|
if os.path.split(prPath)[1] == "always":
|
|
|
|
|
alwProfilePath.append(prPath)
|
|
|
|
|
return alwProfilePath
|
|
|
|
|
|
|
|
|
|
def createHome(self, userName):
|
|
|
|
|
"""Создание пользовательской директории с настройками для kde4"""
|
|
|
|
@ -417,9 +437,14 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
# Создаем пользовательскую директорию
|
|
|
|
|
homeDir = os.path.join("/home",userName)
|
|
|
|
|
self.clVars.Set('cl_root_path',homeDir,True)
|
|
|
|
|
if os.path.exists(homeDir) and os.listdir(homeDir):
|
|
|
|
|
homeExists = os.path.exists(homeDir)
|
|
|
|
|
if homeExists and os.listdir(homeDir):
|
|
|
|
|
self.printWARNING(_("home dir %s exists")%homeDir)
|
|
|
|
|
return True
|
|
|
|
|
alwProfilePath = self.getAlwaysProfilePath()
|
|
|
|
|
if not alwProfilePath:
|
|
|
|
|
return True
|
|
|
|
|
self.printSUCCESS(_("apply always profiles") + " ...")
|
|
|
|
|
self.clVars.Set('cl_profile_path',alwProfilePath, True)
|
|
|
|
|
if not os.path.exists(homeDir):
|
|
|
|
|
self.createUserDir(uid, gid, homeDir)
|
|
|
|
|
# Записываем переменную логин
|
|
|
|
@ -427,11 +452,13 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
self.clVars.Set('ur_fullname',fullName)
|
|
|
|
|
self.clVars.Set('ur_mail',mail)
|
|
|
|
|
# Применяем профили для пользователя
|
|
|
|
|
if not self.applyProfilesFromUser():
|
|
|
|
|
self.printERROR(_(" Not apply user profile"))
|
|
|
|
|
dirsAndFiles = self.applyProfilesFromUser()
|
|
|
|
|
if not dirsAndFiles:
|
|
|
|
|
self.printERROR(_("Not apply user profile"))
|
|
|
|
|
return False
|
|
|
|
|
self.chownR(homeDir, uid, gid)
|
|
|
|
|
self.printSUCCESS(_("created home dir %s")%homeDir)
|
|
|
|
|
self.chownR(homeDir, uid, gid, dirsAndFiles)
|
|
|
|
|
if not homeExists:
|
|
|
|
|
self.printSUCCESS(_("created home dir %s")%homeDir + " ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def mountRemote(self):
|
|
|
|
|