|
|
@ -18,29 +18,22 @@ import os
|
|
|
|
import stat
|
|
|
|
import stat
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import pwd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import subprocess
|
|
|
|
import ldap
|
|
|
|
import ldap
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import types
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import getpass
|
|
|
|
import getpass
|
|
|
|
from os import path
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
|
|
from datavars import DataVarsClient, DataVars, __version__,__app__
|
|
|
|
from calculate.lib.cl_ini_parser import iniParser
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_template import (Template, iniParser, TemplatesError,
|
|
|
|
|
|
|
|
ProgressTemplate)
|
|
|
|
|
|
|
|
from calculate.lib.cl_print import color_print
|
|
|
|
from calculate.lib.cl_print import color_print
|
|
|
|
from calculate.lib.cl_ldap import ldapUser
|
|
|
|
from calculate.lib.utils.ip import Pinger, IPError
|
|
|
|
from calculate.lib.utils.ip import Pinger, isOpenPort, IPError
|
|
|
|
|
|
|
|
from calculate.lib.utils.files import (getModeFile, removeDir,
|
|
|
|
from calculate.lib.utils.files import (getModeFile, removeDir,
|
|
|
|
isMount, readFile, pathJoin, tarLinks,
|
|
|
|
isMount, pathJoin, tarLinks,
|
|
|
|
listDirectory, process, find, STDOUT,
|
|
|
|
listDirectory, process, find, STDOUT,
|
|
|
|
sambaPasswordCheck, checkUtils)
|
|
|
|
sambaPasswordCheck, checkUtils)
|
|
|
|
from calculate.lib.utils.common import (getpathenv, appendProgramToEnvFile,
|
|
|
|
from calculate.lib.utils.common import cmpVersion
|
|
|
|
removeProgramToEnvFile, cmpVersion)
|
|
|
|
|
|
|
|
from calculate.desktop._cl_keys import getKey, clearKey
|
|
|
|
from calculate.desktop._cl_keys import getKey, clearKey
|
|
|
|
from calculate.lib.convertenv import convertEnv
|
|
|
|
from calculate.lib.convertenv import convertEnv
|
|
|
|
from calculate.lib.encrypt import encrypt
|
|
|
|
from calculate.lib.encrypt import encrypt
|
|
|
@ -48,16 +41,19 @@ from client_cache import userCache
|
|
|
|
from shutil import copy2
|
|
|
|
from shutil import copy2
|
|
|
|
from socket import gethostbyname
|
|
|
|
from socket import gethostbyname
|
|
|
|
import tarfile
|
|
|
|
import tarfile
|
|
|
|
from collections import OrderedDict
|
|
|
|
|
|
|
|
from calculate.desktop.desktop import Desktop
|
|
|
|
from calculate.desktop.desktop import Desktop
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
setLocalTranslate('cl_client3', sys.modules[__name__])
|
|
|
|
setLocalTranslate('cl_client3', sys.modules[__name__])
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ClientError(Exception):
|
|
|
|
class ClientError(Exception):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RsyncProgressBar:
|
|
|
|
class RsyncProgressBar:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Rsync with using setProgress
|
|
|
|
Rsync with using setProgress
|
|
|
@ -171,6 +167,7 @@ class RsyncProgressBar:
|
|
|
|
def close(self):
|
|
|
|
def close(self):
|
|
|
|
self.parent.endTask()
|
|
|
|
self.parent.endTask()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class commandServer(color_print):
|
|
|
|
class commandServer(color_print):
|
|
|
|
"""Server command object"""
|
|
|
|
"""Server command object"""
|
|
|
|
|
|
|
|
|
|
|
@ -217,7 +214,6 @@ class commandServer(color_print):
|
|
|
|
стандартного ввода (stdin)
|
|
|
|
стандартного ввода (stdin)
|
|
|
|
pwDialog - структура для вывода приглашения в режиме диалога
|
|
|
|
pwDialog - структура для вывода приглашения в режиме диалога
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
userPwd = ""
|
|
|
|
|
|
|
|
if optStdIn and options.has_key(optStdIn):
|
|
|
|
if optStdIn and options.has_key(optStdIn):
|
|
|
|
pwdA = sys.stdin.readline().rstrip()
|
|
|
|
pwdA = sys.stdin.readline().rstrip()
|
|
|
|
pwdB = sys.stdin.readline().rstrip()
|
|
|
|
pwdB = sys.stdin.readline().rstrip()
|
|
|
@ -227,8 +223,8 @@ class commandServer(color_print):
|
|
|
|
_("Retype the new password")]
|
|
|
|
_("Retype the new password")]
|
|
|
|
pwdA = getpass.getpass(pwDialog[0] + _(":"))
|
|
|
|
pwdA = getpass.getpass(pwDialog[0] + _(":"))
|
|
|
|
pwdB = getpass.getpass(pwDialog[1] + _(":"))
|
|
|
|
pwdB = getpass.getpass(pwDialog[1] + _(":"))
|
|
|
|
if (optStdIn and options.has_key(optStdIn)) or\
|
|
|
|
else:
|
|
|
|
(optDialog and options.has_key(optDialog)):
|
|
|
|
return ""
|
|
|
|
if not pwdA or not (pwdA == pwdB):
|
|
|
|
if not pwdA or not (pwdA == pwdB):
|
|
|
|
self.printERROR(_("ERROR") + _(": ") + \
|
|
|
|
self.printERROR(_("ERROR") + _(": ") + \
|
|
|
|
_("passwords do not match"))
|
|
|
|
_("passwords do not match"))
|
|
|
@ -236,6 +232,7 @@ class commandServer(color_print):
|
|
|
|
userPwd = pwdA
|
|
|
|
userPwd = pwdA
|
|
|
|
return userPwd
|
|
|
|
return userPwd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Client(commandServer, encrypt, Desktop):
|
|
|
|
class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Клиентский модуль работы с доменом
|
|
|
|
Клиентский модуль работы с доменом
|
|
|
@ -278,7 +275,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
self.clVars.Set("os_remote_auth", "", True)
|
|
|
|
self.clVars.Set("os_remote_auth", "", True)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def mountSambaRes(self,host,userName,userPwd,res,rpath,uid=None,gid=None):
|
|
|
|
def mountSambaRes(self, host, userName, userPwd, res, rpath, uid=None,
|
|
|
|
|
|
|
|
gid=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Подключить samba ресурс
|
|
|
|
Подключить samba ресурс
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -290,7 +288,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if not uid is None:
|
|
|
|
if not uid is None:
|
|
|
|
# mount by uid
|
|
|
|
# mount by uid
|
|
|
|
p = process(mountCmd, "-t", "cifs", "-o",
|
|
|
|
p = process(mountCmd, "-t", "cifs", "-o",
|
|
|
|
"cache=loose,user=%s,uid=%d,gid=%d,noperm%s"%(userName,uid,gid,nomapposix),
|
|
|
|
"cache=loose,user=%s,uid=%d,gid=%d,noperm%s" % (
|
|
|
|
|
|
|
|
userName, uid, gid, nomapposix),
|
|
|
|
"//%s/%s" % (host, res), rpath,
|
|
|
|
"//%s/%s" % (host, res), rpath,
|
|
|
|
envdict={"PASSWD": userPwd}, stderr=STDOUT)
|
|
|
|
envdict={"PASSWD": userPwd}, stderr=STDOUT)
|
|
|
|
return p.success()
|
|
|
|
return p.success()
|
|
|
@ -301,7 +300,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
envdict={"PASSWD": userPwd}, stderr=STDOUT)
|
|
|
|
envdict={"PASSWD": userPwd}, stderr=STDOUT)
|
|
|
|
return p.success()
|
|
|
|
return p.success()
|
|
|
|
|
|
|
|
|
|
|
|
def mountSleepRes(self,host,userName,userPwd,res,rpath,uid=None,gid=None):
|
|
|
|
def mountSleepRes(self, host, userName, userPwd, res, rpath, uid=None,
|
|
|
|
|
|
|
|
gid=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Подключить пользовательский ресурс
|
|
|
|
Подключить пользовательский ресурс
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -319,11 +319,10 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def syncUser(self, uid, gid, userHome, sync, remoteProfile,
|
|
|
|
def syncUser(self, uid, gid, userHome, sync, remoteProfile,
|
|
|
|
host="default",skipList=[]):
|
|
|
|
host="default", skipList=()):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Синхронизация профиля пользователя
|
|
|
|
Синхронизация профиля пользователя
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
flagError = False
|
|
|
|
|
|
|
|
execStr = ""
|
|
|
|
execStr = ""
|
|
|
|
skipPaths = self.clVars.Get("cl_sync_skip_path")
|
|
|
|
skipPaths = self.clVars.Get("cl_sync_skip_path")
|
|
|
|
if not skipPaths:
|
|
|
|
if not skipPaths:
|
|
|
@ -333,35 +332,39 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
deletePaths = self.clVars.Get("cl_sync_del_path")
|
|
|
|
deletePaths = self.clVars.Get("cl_sync_del_path")
|
|
|
|
if not deletePaths:
|
|
|
|
if not deletePaths:
|
|
|
|
deletePaths = []
|
|
|
|
deletePaths = []
|
|
|
|
excludePaths = " ".join(map(lambda x: '--exclude="/%s"'\
|
|
|
|
excludePaths = " ".join(map(
|
|
|
|
%x.replace('"',"").replace("'",""),
|
|
|
|
lambda x: '--exclude="/%s"' % x.replace('"', "").replace(
|
|
|
|
|
|
|
|
"'", ""),
|
|
|
|
skipPaths + deletePaths + skipList))
|
|
|
|
skipPaths + deletePaths + skipList))
|
|
|
|
if sync == "login":
|
|
|
|
if sync == "login":
|
|
|
|
if os.path.exists(userHome) and \
|
|
|
|
if os.path.exists(userHome) and \
|
|
|
|
os.path.exists(remoteProfile):
|
|
|
|
os.path.exists(remoteProfile):
|
|
|
|
filterPath = " ".join(map(lambda x: '--filter="P /%s"'\
|
|
|
|
filterPath = " ".join(map(
|
|
|
|
%x.replace('"',"").replace("'",""),
|
|
|
|
lambda x: '--filter="P /%s"' % x.replace(
|
|
|
|
|
|
|
|
'"', "").replace("'", ""),
|
|
|
|
skipPaths))
|
|
|
|
skipPaths))
|
|
|
|
execStr = '/usr/bin/rsync --delete-excluded --delete %s %s '\
|
|
|
|
execStr = ('/usr/bin/rsync --delete-excluded --delete %s %s '
|
|
|
|
'-rlptgo -x -v -v -v %s/ %s/' \
|
|
|
|
'-rlptgo -x -v -v -v %s/ %s/'
|
|
|
|
%(excludePaths, filterPath, remoteProfile, userHome)
|
|
|
|
% (excludePaths, filterPath,
|
|
|
|
|
|
|
|
remoteProfile, userHome))
|
|
|
|
elif sync == "logout":
|
|
|
|
elif sync == "logout":
|
|
|
|
if os.path.exists(userHome) and os.listdir(userHome) and \
|
|
|
|
if os.path.exists(userHome) and os.listdir(userHome) and \
|
|
|
|
os.path.exists(remoteProfile):
|
|
|
|
os.path.exists(remoteProfile):
|
|
|
|
execStr = '/usr/bin/rsync --delete-excluded --delete %s \
|
|
|
|
execStr = ('/usr/bin/rsync --delete-excluded --delete %s '
|
|
|
|
-rlpt -x -v -v -v %s/ %s/'%(excludePaths, userHome, remoteProfile)
|
|
|
|
'-rlpt -x -v -v -v %s/ %s/' % (
|
|
|
|
|
|
|
|
excludePaths, userHome, remoteProfile))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ClientError(
|
|
|
|
raise ClientError(
|
|
|
|
_("Method syncUser: wrong option sync=%s") % str(sync))
|
|
|
|
_("Method syncUser: wrong option sync=%s") % str(sync))
|
|
|
|
if execStr:
|
|
|
|
if execStr:
|
|
|
|
host = "<i>" + host + "</i>"
|
|
|
|
host = "<i>" + host + "</i>"
|
|
|
|
if sync == "login":
|
|
|
|
if sync == "login":
|
|
|
|
rsync = RsyncProgressBar(\
|
|
|
|
rsync = RsyncProgressBar(
|
|
|
|
_("Fetching the file list from %s") % host,
|
|
|
|
_("Fetching the file list from %s") % host,
|
|
|
|
_("Fetching the user profile from %s") % host,
|
|
|
|
_("Fetching the user profile from %s") % host,
|
|
|
|
execStr, self, rsyncver=self.clVars.Get('cl_rsync_ver'))
|
|
|
|
execStr, self, rsyncver=self.clVars.Get('cl_rsync_ver'))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
rsync = RsyncProgressBar(\
|
|
|
|
rsync = RsyncProgressBar(
|
|
|
|
_("Sending the file list to %s") % host,
|
|
|
|
_("Sending the file list to %s") % host,
|
|
|
|
_("Uploading the user profile to %s") % host,
|
|
|
|
_("Uploading the user profile to %s") % host,
|
|
|
|
execStr, self, rsyncver=self.clVars.Get('cl_rsync_ver'))
|
|
|
|
execStr, self, rsyncver=self.clVars.Get('cl_rsync_ver'))
|
|
|
@ -379,15 +382,15 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if sync == "login":
|
|
|
|
if sync == "login":
|
|
|
|
# get rsync files
|
|
|
|
# get rsync files
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
numfiles = \
|
|
|
|
numfiles = iniParser(
|
|
|
|
iniParser(configFileName).getVar('rsync','files')
|
|
|
|
configFileName).getVar('rsync', 'files')
|
|
|
|
if numfiles is False:
|
|
|
|
if numfiles is False:
|
|
|
|
if os.path.exists(configFileName):
|
|
|
|
if os.path.exists(configFileName):
|
|
|
|
os.remove(configFileName)
|
|
|
|
os.remove(configFileName)
|
|
|
|
numfiles = 0
|
|
|
|
numfiles = 0
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
numfiles = int(numfiles)
|
|
|
|
numfiles = int(numfiles)
|
|
|
|
except:
|
|
|
|
except Exception:
|
|
|
|
numfiles = 0
|
|
|
|
numfiles = 0
|
|
|
|
rsync.maximum = numfiles
|
|
|
|
rsync.maximum = numfiles
|
|
|
|
if sync == "login":
|
|
|
|
if sync == "login":
|
|
|
@ -395,19 +398,19 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if sync == "logout":
|
|
|
|
if sync == "logout":
|
|
|
|
rsync.run()
|
|
|
|
rsync.run()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if iniParser(configFileName).setVar('rsync',
|
|
|
|
if iniParser(configFileName).setVar(
|
|
|
|
{'files':rsync.getFilesNum()}):
|
|
|
|
'rsync', {'files': rsync.getFilesNum()}):
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
rsync.close()
|
|
|
|
rsync.close()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if iniParser(configFileName).setVar(\
|
|
|
|
if iniParser(configFileName).setVar(
|
|
|
|
'rsync', {'exitcode': rsync.getExitCode()}):
|
|
|
|
'rsync', {'exitcode': rsync.getExitCode()}):
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
if rsync.getExitCode() != 0:
|
|
|
|
if rsync.getExitCode() != 0:
|
|
|
|
self.printERROR(rsync.getErrMessage())
|
|
|
|
self.printERROR(rsync.getErrMessage())
|
|
|
@ -455,7 +458,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
eq=resourceName, limit=1),
|
|
|
|
eq=resourceName, limit=1),
|
|
|
|
profileName)
|
|
|
|
profileName)
|
|
|
|
# if currect server has any files then sync it
|
|
|
|
# if currect server has any files then sync it
|
|
|
|
if any(not x in ('.calculate') for x in listDirectory(homeProfile)):
|
|
|
|
if any(x not in ('.calculate',) for x in listDirectory(homeProfile)):
|
|
|
|
if not self.syncUser(uid, gid, homeDir, "login",
|
|
|
|
if not self.syncUser(uid, gid, homeDir, "login",
|
|
|
|
homeProfile, host=host):
|
|
|
|
homeProfile, host=host):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -496,7 +499,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
remoteProfilePath = path.join(
|
|
|
|
remoteProfilePath = path.join(
|
|
|
|
self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
where='cl_client_user_mount_name', eq=resourceName,
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
|
|
|
|
eq=resourceName,
|
|
|
|
limit=1), profileName)
|
|
|
|
limit=1), profileName)
|
|
|
|
fileServer = path.join(remoteProfilePath,
|
|
|
|
fileServer = path.join(remoteProfilePath,
|
|
|
|
Client.configFileServer)
|
|
|
|
Client.configFileServer)
|
|
|
@ -516,32 +520,34 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Ожидание архива профиля от домена
|
|
|
|
Ожидание архива профиля от домена
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
archPathSuccess,archPathProcess = \
|
|
|
|
arch_fn_success, arch_fn_process = self._getArchNames(
|
|
|
|
self._getArchNames(packTime,profileName,resourceName)
|
|
|
|
packTime, profileName, resourceName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def arch_exists():
|
|
|
|
|
|
|
|
return any(os.path.exists(x) for x in (arch_fn_process,
|
|
|
|
|
|
|
|
arch_fn_success))
|
|
|
|
|
|
|
|
|
|
|
|
for sleeptime in [0.1, 0.2, 0.5]:
|
|
|
|
for sleeptime in [0.1, 0.2, 0.5]:
|
|
|
|
# archive in packing process found
|
|
|
|
# archive in packing process found
|
|
|
|
if os.path.exists(archPathProcess) or \
|
|
|
|
if arch_exists():
|
|
|
|
os.path.exists(archPathSuccess):
|
|
|
|
|
|
|
|
break
|
|
|
|
break
|
|
|
|
time.sleep(sleeptime)
|
|
|
|
time.sleep(sleeptime)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
# wait finish packing
|
|
|
|
# wait finish packing
|
|
|
|
if path.exists(archPathProcess) or \
|
|
|
|
if arch_exists():
|
|
|
|
path.exists(archPathSuccess):
|
|
|
|
while arch_exists():
|
|
|
|
while path.exists(archPathProcess) or \
|
|
|
|
|
|
|
|
path.exists(archPathSuccess):
|
|
|
|
|
|
|
|
for waittime in [0.5, 1, 2]:
|
|
|
|
for waittime in [0.5, 1, 2]:
|
|
|
|
if path.exists(archPathSuccess):
|
|
|
|
if path.exists(arch_fn_success):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
startSize = os.stat(archPathProcess).st_size
|
|
|
|
startSize = os.stat(arch_fn_process).st_size
|
|
|
|
time.sleep(waittime)
|
|
|
|
time.sleep(waittime)
|
|
|
|
if startSize != os.stat(archPathProcess).st_size:
|
|
|
|
if startSize != os.stat(arch_fn_process).st_size:
|
|
|
|
break
|
|
|
|
break
|
|
|
|
except OSError as e:
|
|
|
|
except OSError:
|
|
|
|
if path.exists(archPathSuccess):
|
|
|
|
if path.exists(arch_fn_success):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -551,6 +557,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Распаковать архив с профилем
|
|
|
|
Распаковать архив с профилем
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def fileReader(fileName, stdin, maxSize):
|
|
|
|
def fileReader(fileName, stdin, maxSize):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Прочитать файл по блокам
|
|
|
|
Прочитать файл по блокам
|
|
|
@ -580,9 +587,11 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
close_fds=True,
|
|
|
|
close_fds=True,
|
|
|
|
env=os.environ, shell=True)
|
|
|
|
env=os.environ, shell=True)
|
|
|
|
|
|
|
|
try:
|
|
|
|
# прочитать в конвеер
|
|
|
|
# прочитать в конвеер
|
|
|
|
fileReader(archFile, pipe.stdin, archiveSize)
|
|
|
|
fileReader(archFile, pipe.stdin, archiveSize)
|
|
|
|
self.endTask()
|
|
|
|
self.endTask()
|
|
|
|
|
|
|
|
finally:
|
|
|
|
ret = pipe.wait()
|
|
|
|
ret = pipe.wait()
|
|
|
|
pipe.stdout.close()
|
|
|
|
pipe.stdout.close()
|
|
|
|
pipe.stderr.close()
|
|
|
|
pipe.stderr.close()
|
|
|
@ -601,7 +610,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
профиля
|
|
|
|
профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
for rmFile in filter(lambda x: x and path.exists(x),
|
|
|
|
for rmFile in filter(lambda x: x and path.exists(x),
|
|
|
|
self._getArchNames(packTime,profileName,resourceName)):
|
|
|
|
self._getArchNames(packTime, profileName,
|
|
|
|
|
|
|
|
resourceName)):
|
|
|
|
os.remove(rmFile)
|
|
|
|
os.remove(rmFile)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -633,7 +643,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if iniParser(configFileName).setVar(nameSection, varsDict):
|
|
|
|
if iniParser(configFileName).setVar(nameSection, varsDict):
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except:
|
|
|
|
except Exception:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -655,7 +665,6 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Mount all local samba resource
|
|
|
|
Mount all local samba resource
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
res = True
|
|
|
|
|
|
|
|
for rpath, res, host in \
|
|
|
|
for rpath, res, host in \
|
|
|
|
self.clVars.Select(['cl_client_user_mount_path',
|
|
|
|
self.clVars.Select(['cl_client_user_mount_path',
|
|
|
|
'cl_client_user_mount_resource',
|
|
|
|
'cl_client_user_mount_resource',
|
|
|
@ -690,12 +699,11 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
Создать tar архив с симлинками
|
|
|
|
Создать tar архив с симлинками
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
linkArch = pathJoin(userHome, ".calculate/links.tar.bz2")
|
|
|
|
linkArch = pathJoin(userHome, ".calculate/links.tar.bz2")
|
|
|
|
symList = []
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
tarLinks(userHome, linkArch, skip=delPath + skipPath)
|
|
|
|
tarLinks(userHome, linkArch, skip=delPath + skipPath)
|
|
|
|
if path.exists(linkArch):
|
|
|
|
if path.exists(linkArch):
|
|
|
|
os.chown(linkArch, uid, gid)
|
|
|
|
os.chown(linkArch, uid, gid)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -709,7 +717,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
tf = tarfile.open(linksArch)
|
|
|
|
tf = tarfile.open(linksArch)
|
|
|
|
tf.extractall(userHome)
|
|
|
|
tf.extractall(userHome)
|
|
|
|
tf.close()
|
|
|
|
tf.close()
|
|
|
|
except Exception as e:
|
|
|
|
except Exception:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -720,14 +728,13 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
desktopDir = "Desktop"
|
|
|
|
desktopDir = "Desktop"
|
|
|
|
resourcePath = self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
resourcePath = self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
where='cl_client_user_mount_name', eq=resourceName,
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
|
|
|
|
eq=resourceName,
|
|
|
|
limit=1)
|
|
|
|
limit=1)
|
|
|
|
if not isMount(resourcePath):
|
|
|
|
if not isMount(resourcePath):
|
|
|
|
raise ClientError(_("Unable to mount %s") % resourcePath)
|
|
|
|
raise ClientError(_("Unable to mount %s") % resourcePath)
|
|
|
|
movedPath = path.join(resourcePath, movedDir)
|
|
|
|
movedPath = path.join(resourcePath, movedDir)
|
|
|
|
movedLink = path.join(userHome, movedDir)
|
|
|
|
movedLink = path.join(userHome, movedDir)
|
|
|
|
dirs = []
|
|
|
|
|
|
|
|
files = []
|
|
|
|
|
|
|
|
if not skipPaths:
|
|
|
|
if not skipPaths:
|
|
|
|
skipPaths = ['Disks', 'Share', 'Home', 'Moved', 'FTP', 'Desktop']
|
|
|
|
skipPaths = ['Disks', 'Share', 'Home', 'Moved', 'FTP', 'Desktop']
|
|
|
|
filesAndDir = filter(lambda x: not (
|
|
|
|
filesAndDir = filter(lambda x: not (
|
|
|
@ -744,12 +751,12 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# find files in Desktop
|
|
|
|
# find files in Desktop
|
|
|
|
pathDesktop = path.join(userHome, desktopDir)
|
|
|
|
pathDesktop = path.join(userHome, desktopDir)
|
|
|
|
filesDirDesk = filter(lambda x: (not path.islink(x) and
|
|
|
|
filesDirDesk = filter(lambda x: (not path.islink(x) and
|
|
|
|
not path.split(x)[1].startswith('.') and
|
|
|
|
not path.split(x)[1].startswith(
|
|
|
|
|
|
|
|
'.') and
|
|
|
|
not x.rpartition('.')[2] == 'desktop'),
|
|
|
|
not x.rpartition('.')[2] == 'desktop'),
|
|
|
|
listDirectory(pathDesktop, fullPath=True))
|
|
|
|
listDirectory(pathDesktop, fullPath=True))
|
|
|
|
movedPathDesk = os.path.join(movedPath, desktopDir)
|
|
|
|
|
|
|
|
filesDir += filesDirDesk
|
|
|
|
filesDir += filesDirDesk
|
|
|
|
if not filesDir or not path.exists(movedPath):
|
|
|
|
if not filesDir or not path.exists(resourcePath):
|
|
|
|
# remove empty Moved folder
|
|
|
|
# remove empty Moved folder
|
|
|
|
if path.exists(movedPath) and not listDirectory(movedPath):
|
|
|
|
if path.exists(movedPath) and not listDirectory(movedPath):
|
|
|
|
os.rmdir(movedPath)
|
|
|
|
os.rmdir(movedPath)
|
|
|
@ -798,7 +805,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# .ssh files relative user home directory
|
|
|
|
# .ssh files relative user home directory
|
|
|
|
privateFiles += map(lambda x: os.path.join(privateHomeDir, x),
|
|
|
|
privateFiles += map(lambda x: os.path.join(privateHomeDir, x),
|
|
|
|
filter(lambda x: \
|
|
|
|
filter(lambda x: \
|
|
|
|
os.path.isfile(os.path.join(privateDir,x)),
|
|
|
|
os.path.isfile(
|
|
|
|
|
|
|
|
os.path.join(privateDir, x)),
|
|
|
|
os.listdir(privateDir)))
|
|
|
|
os.listdir(privateDir)))
|
|
|
|
return self.privateFiles + privateFiles
|
|
|
|
return self.privateFiles + privateFiles
|
|
|
|
|
|
|
|
|
|
|
@ -826,7 +834,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if not os.path.exists(dstPath):
|
|
|
|
if not os.path.exists(dstPath):
|
|
|
|
listElPath = []
|
|
|
|
listElPath = []
|
|
|
|
for el in filter(lambda x: x,
|
|
|
|
for el in filter(lambda x: x,
|
|
|
|
dstPath.partition(userHomeDir)[2].split("/")):
|
|
|
|
dstPath.partition(userHomeDir)[2].split(
|
|
|
|
|
|
|
|
"/")):
|
|
|
|
listElPath.append(el)
|
|
|
|
listElPath.append(el)
|
|
|
|
joinPath = "/".join(listElPath)
|
|
|
|
joinPath = "/".join(listElPath)
|
|
|
|
dPath = os.path.join(userHomeDir, joinPath)
|
|
|
|
dPath = os.path.join(userHomeDir, joinPath)
|
|
|
@ -855,7 +864,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# read file list from config
|
|
|
|
# read file list from config
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
filesProfileTxt = open(pathListFile).read()
|
|
|
|
filesProfileTxt = open(pathListFile).read()
|
|
|
|
except:
|
|
|
|
except IOError:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
listFilesProfile = filter(lambda x: x.strip(),
|
|
|
|
listFilesProfile = filter(lambda x: x.strip(),
|
|
|
|
filesProfileTxt.split("\n"))
|
|
|
|
filesProfileTxt.split("\n"))
|
|
|
@ -866,7 +875,6 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
filesHome = set(listFilesHome)
|
|
|
|
filesHome = set(listFilesHome)
|
|
|
|
filesRemove = list(filesHome - filesProfile)
|
|
|
|
filesRemove = list(filesHome - filesProfile)
|
|
|
|
rmPath = ""
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
for rmFile in sorted(filesRemove, reverse=True):
|
|
|
|
for rmFile in sorted(filesRemove, reverse=True):
|
|
|
|
rmPath = os.path.join(homeDir, rmFile)
|
|
|
|
rmPath = os.path.join(homeDir, rmFile)
|
|
|
@ -880,12 +888,13 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
os.rmdir(rmPath)
|
|
|
|
os.rmdir(rmPath)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
os.remove(rmPath)
|
|
|
|
os.remove(rmPath)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def getRunCommandsWithEnv(self):
|
|
|
|
def getRunCommandsWithEnv(self):
|
|
|
|
"""List run program"""
|
|
|
|
"""List run program"""
|
|
|
|
|
|
|
|
|
|
|
|
def getCmd(procNum):
|
|
|
|
def getCmd(procNum):
|
|
|
|
cmdLineFile = '/proc/%s/cmdline' % procNum
|
|
|
|
cmdLineFile = '/proc/%s/cmdline' % procNum
|
|
|
|
environFile = '/proc/%s/environ' % procNum
|
|
|
|
environFile = '/proc/%s/environ' % procNum
|
|
|
@ -894,24 +903,25 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
os.path.exists(environFile):
|
|
|
|
os.path.exists(environFile):
|
|
|
|
return (open(cmdLineFile, 'r').read().strip(),
|
|
|
|
return (open(cmdLineFile, 'r').read().strip(),
|
|
|
|
open(environFile, 'r').read().strip())
|
|
|
|
open(environFile, 'r').read().strip())
|
|
|
|
except:
|
|
|
|
except (OSError, IOError):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
return ("","")
|
|
|
|
return "", ""
|
|
|
|
|
|
|
|
|
|
|
|
if not os.access('/proc', os.R_OK):
|
|
|
|
if not os.access('/proc', os.R_OK):
|
|
|
|
return []
|
|
|
|
return []
|
|
|
|
return map(getCmd,
|
|
|
|
return map(getCmd,
|
|
|
|
filter(lambda x: x.isdigit(),
|
|
|
|
filter(lambda x: x.isdigit(),
|
|
|
|
os.listdir('/proc')))
|
|
|
|
os.listdir('/proc')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clearUserKey(self, userName):
|
|
|
|
def clearUserKey(self, userName):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Clear user key from kernel
|
|
|
|
Clear user key from kernel
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# find user key in kernel and check on relogout
|
|
|
|
# find user key in kernel and check on relogout
|
|
|
|
if getKey(userName) and not \
|
|
|
|
if getKey(userName) and not \
|
|
|
|
filter(lambda x:"xdm/xdm\x00--login" in x[0] and \
|
|
|
|
filter(lambda x: "xdm/xdm\x00--login" in x[0] and
|
|
|
|
("USER=%s"%userName) in x[1],self.getRunCommandsWithEnv()):
|
|
|
|
("USER=%s" % userName) in x[1],
|
|
|
|
|
|
|
|
self.getRunCommandsWithEnv()):
|
|
|
|
# clean
|
|
|
|
# clean
|
|
|
|
ret = clearKey(userName)
|
|
|
|
ret = clearKey(userName)
|
|
|
|
if ret == 0:
|
|
|
|
if ret == 0:
|
|
|
@ -939,7 +949,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
retRes = True
|
|
|
|
retRes = True
|
|
|
|
for resourceName in resourceNames:
|
|
|
|
for resourceName in resourceNames:
|
|
|
|
resourcePath = self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
resourcePath = self.clVars.Select('cl_client_user_mount_path',
|
|
|
|
where='cl_client_user_mount_name', eq=resourceName,
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
|
|
|
|
eq=resourceName,
|
|
|
|
limit=1)
|
|
|
|
limit=1)
|
|
|
|
if resourcePath:
|
|
|
|
if resourcePath:
|
|
|
|
result = self.umountSleepPath(resourcePath)
|
|
|
|
result = self.umountSleepPath(resourcePath)
|
|
|
@ -973,7 +984,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
filter(lambda x: len(x) > 1 and "default" in x[1],
|
|
|
|
filter(lambda x: len(x) > 1 and "default" in x[1],
|
|
|
|
# [\s*<название_службы>\s*,\s*уровень запуска\s*]
|
|
|
|
# [\s*<название_службы>\s*,\s*уровень запуска\s*]
|
|
|
|
map(lambda x: x.split('|'),
|
|
|
|
map(lambda x: x.split('|'),
|
|
|
|
# \s*<название_службы>\s*|\s*<уроверь запуска>?\s*
|
|
|
|
# \s*<название_службы>\s*|
|
|
|
|
|
|
|
|
# \s*<уроверь запуска>?\s*
|
|
|
|
p.readlines())))
|
|
|
|
p.readlines())))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise ClientError(_("ERROR") + _(": ") + p.read())
|
|
|
|
raise ClientError(_("ERROR") + _(": ") + p.read())
|
|
|
@ -1014,7 +1026,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
Получить параметр севирса из удаленного env
|
|
|
|
Получить параметр севирса из удаленного env
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if not envFile:
|
|
|
|
if not envFile:
|
|
|
|
if self.convObj == None:
|
|
|
|
if self.convObj is None:
|
|
|
|
# file /var/calculate/remote/server.env
|
|
|
|
# file /var/calculate/remote/server.env
|
|
|
|
envFile = self.clVars.Get("cl_env_server_path")
|
|
|
|
envFile = self.clVars.Get("cl_env_server_path")
|
|
|
|
if os.access(envFile, os.R_OK):
|
|
|
|
if os.access(envFile, os.R_OK):
|
|
|
@ -1046,6 +1058,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
domain = domainName
|
|
|
|
domain = domainName
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
import socket
|
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
domain = "%s.%s" % (domainName, netDomain)
|
|
|
|
domain = "%s.%s" % (domainName, netDomain)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
gethostbyname(domain)
|
|
|
|
gethostbyname(domain)
|
|
|
@ -1074,17 +1087,17 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Получить пароль для ввода в домен
|
|
|
|
Получить пароль для ввода в домен
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def passwdQueue():
|
|
|
|
def passwdQueue():
|
|
|
|
remotePw = self.clVars.Get('cl_remote_pw')
|
|
|
|
remotePw = self.clVars.Get('cl_remote_pw')
|
|
|
|
if remotePw:
|
|
|
|
if remotePw:
|
|
|
|
yield remotePw
|
|
|
|
yield remotePw
|
|
|
|
if remotePw:
|
|
|
|
if remotePw:
|
|
|
|
self.printERROR(_("Wrong password"))
|
|
|
|
self.printERROR(_("Wrong password"))
|
|
|
|
yield self.askPassword(\
|
|
|
|
yield self.askPassword(
|
|
|
|
_("Domain password for the desktop"), False)
|
|
|
|
_("Domain password for the desktop"), False)
|
|
|
|
self.printERROR(_("Wrong password"))
|
|
|
|
self.printERROR(_("Wrong password"))
|
|
|
|
|
|
|
|
|
|
|
|
pathRemote = "/var/calculate/remote"
|
|
|
|
|
|
|
|
for pwdRemote in passwdQueue():
|
|
|
|
for pwdRemote in passwdQueue():
|
|
|
|
pwdRemote = pwdRemote or ""
|
|
|
|
pwdRemote = pwdRemote or ""
|
|
|
|
if sambaPasswordCheck("client", pwdRemote, domain, "remote"):
|
|
|
|
if sambaPasswordCheck("client", pwdRemote, domain, "remote"):
|
|
|
@ -1114,7 +1127,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# check info from server
|
|
|
|
# check info from server
|
|
|
|
if not (servDn and unixDn and bindDn and bindPw):
|
|
|
|
if not (servDn and unixDn and bindDn and bindPw):
|
|
|
|
raise ClientError(_("Info not found on the server") + _(": ") +
|
|
|
|
raise ClientError(_("Info not found on the server") + _(": ") +
|
|
|
|
_("services DN or unix DN or bind DN or bind password"))
|
|
|
|
_(
|
|
|
|
|
|
|
|
"services DN or unix DN or bind DN or bind password"))
|
|
|
|
self.clVars.Set("os_remote_auth", domain)
|
|
|
|
self.clVars.Set("os_remote_auth", domain)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
@ -1140,7 +1154,6 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
if hostAuth:
|
|
|
|
if hostAuth:
|
|
|
|
self.printSUCCESS(_("The workstation was configured for work "
|
|
|
|
self.printSUCCESS(_("The workstation was configured for work "
|
|
|
|
"in the domain"))
|
|
|
|
"in the domain"))
|
|
|
|
currentVersion = self.clVars.Get("cl_ver")
|
|
|
|
|
|
|
|
self.clVars.Write("os_remote_auth", hostAuth, True)
|
|
|
|
self.clVars.Write("os_remote_auth", hostAuth, True)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printSUCCESS(_("The workstation was configured for work "
|
|
|
|
self.printSUCCESS(_("The workstation was configured for work "
|
|
|
@ -1153,7 +1166,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
Удалить LDAP пользователей из системы (/etc/passwd и т.д.) и
|
|
|
|
Удалить LDAP пользователей из системы (/etc/passwd и т.д.) и
|
|
|
|
синхронизировать кэш
|
|
|
|
синхронизировать кэш
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
cacheObj = userCache()
|
|
|
|
cacheObj = userCache(self)
|
|
|
|
if not cacheObj.deleteCacheUsersFromSystem():
|
|
|
|
if not cacheObj.deleteCacheUsersFromSystem():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
if not cacheObj.syncCacheToLdap():
|
|
|
|
if not cacheObj.syncCacheToLdap():
|
|
|
@ -1164,7 +1177,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Добавить кэш пользователей из системы
|
|
|
|
Добавить кэш пользователей из системы
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
cacheObj = userCache()
|
|
|
|
cacheObj = userCache(self)
|
|
|
|
if not cacheObj.addCacheUsersFromSystem():
|
|
|
|
if not cacheObj.addCacheUsersFromSystem():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
@ -1173,7 +1186,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Добавить пользователя в кэш
|
|
|
|
Добавить пользователя в кэш
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
cacheObj = userCache()
|
|
|
|
cacheObj = userCache(self)
|
|
|
|
pwdHash = self.getHashPasswd(userPwd, "shadow_ssha256")
|
|
|
|
pwdHash = self.getHashPasswd(userPwd, "shadow_ssha256")
|
|
|
|
if not cacheObj.addUserToCache(userName, pwdHash):
|
|
|
|
if not cacheObj.addUserToCache(userName, pwdHash):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -1183,7 +1196,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Удалить LDAP пользователей из системы и очистить кэш
|
|
|
|
Удалить LDAP пользователей из системы и очистить кэш
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
cacheObj = userCache()
|
|
|
|
cacheObj = userCache(self)
|
|
|
|
if not cacheObj.deleteCacheUsersFromSystem():
|
|
|
|
if not cacheObj.deleteCacheUsersFromSystem():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
if not cacheObj.clearCache():
|
|
|
|
if not cacheObj.clearCache():
|
|
|
@ -1223,16 +1236,19 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
varsConfig = {"unix_hash": self.getHashPasswd(password, "ssha"),
|
|
|
|
varsConfig = {"unix_hash": self.getHashPasswd(password, "ssha"),
|
|
|
|
"samba_lm_hash": self.getHashPasswd(password, "lm"),
|
|
|
|
"samba_lm_hash": self.getHashPasswd(password, "lm"),
|
|
|
|
"samba_nt_hash": self.getHashPasswd(password, "nt"),
|
|
|
|
"samba_nt_hash": self.getHashPasswd(password, "nt"),
|
|
|
|
"samba_nt_hash_old":self.getHashPasswd(curPassword,"nt")}
|
|
|
|
"samba_nt_hash_old": self.getHashPasswd(curPassword,
|
|
|
|
|
|
|
|
"nt")}
|
|
|
|
if filter(lambda x: not x, varsConfig.values()):
|
|
|
|
if filter(lambda x: not x, varsConfig.values()):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
# ~/.calculate/server.env
|
|
|
|
# ~/.calculate/server.env
|
|
|
|
fileConfig = os.path.join(homeDir, self.configFileServer)
|
|
|
|
fileConfig = os.path.join(homeDir, self.configFileServer)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
res = self.setServerCommand(["passwd_samba"], varsConfig, fileConfig,
|
|
|
|
res = self.setServerCommand(["passwd_samba"], varsConfig,
|
|
|
|
|
|
|
|
fileConfig,
|
|
|
|
uid, gid)
|
|
|
|
uid, gid)
|
|
|
|
except OSError as e:
|
|
|
|
except OSError as e:
|
|
|
|
if e.errno == 13:
|
|
|
|
if e.errno == 13:
|
|
|
|
self.printERROR(_("Permission denied"))
|
|
|
|
self.printERROR(_("Permission denied"))
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
return False
|
|
|
|
return res
|
|
|
|
return res
|
|
|
|