Исправлена работа в домена на samba 4.8

legacy27
parent f258e34299
commit 23f9d51922

@ -33,6 +33,7 @@ from calculate.lib.utils.files import (getModeFile, removeDir,
pathJoin, tarLinks, pathJoin, tarLinks,
listDirectory, process, find, STDOUT, listDirectory, process, find, STDOUT,
sambaPasswordCheck, checkUtils) sambaPasswordCheck, checkUtils)
from calculate.lib.utils.samba import Samba, SambaError
from calculate.lib.utils.mount import isMount from calculate.lib.utils.mount import isMount
from calculate.lib.utils.common import cmpVersion from calculate.lib.utils.common import cmpVersion
from calculate.desktop._cl_keys import getKey, clearKey from calculate.desktop._cl_keys import getKey, clearKey
@ -264,6 +265,9 @@ class Client(commandServer, encrypt, Desktop):
# private user directories # private user directories
privateDirs = [] privateDirs = []
def init(self):
self.domainnames = {}
def removeVars(self): def removeVars(self):
""" """
Remove domain variables. Useing on remove package Remove domain variables. Useing on remove package
@ -288,23 +292,34 @@ class Client(commandServer, encrypt, Desktop):
else: else:
nomapposix = ",nomapposix" nomapposix = ",nomapposix"
cache_method = self.clVars.Get('cl_cifs_cache') cache_method = self.clVars.Get('cl_cifs_cache')
domain = self.clVars.Get('cl_remote_domain') or \
self.get_server_domainname(host)
cifs_mount_vers = self.clVars.Get('cl_cifs_mount_vers') cifs_mount_vers = self.clVars.Get('cl_cifs_mount_vers')
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=%s,vers=%s,user=%s,uid=%d,gid=%d,noperm%s" % ( "cache=%s,domain=%s,user=%s,uid=%d,gid=%d,noperm%s" % (
cache_method, cifs_mount_vers, userName, uid, gid, nomapposix), cache_method, domain, cifs_mount_vers,
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()
else: else:
p = process(mountCmd, "-t", "cifs", "-o", p = process(mountCmd, "-t", "cifs", "-o",
"cache=%s,vers=%s,user=%s%s" % (cache_method, "cache=%s,domain=%s,vers=%s,user=%s%s" % (cache_method,
cifs_mount_vers, userName, nomapposix), domain, cifs_mount_vers, userName, 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()
def get_server_domainname(self, host):
if host not in self.domainnames:
try:
self.domainnames[host] = Samba().get_server_domainname(host)
except SambaError as e:
raise ClientError(str(e))
return self.domainnames[host]
def mountSleepRes(self, host, userName, userPwd, res, rpath, uid=None, def mountSleepRes(self, host, userName, userPwd, res, rpath, uid=None,
gid=None): gid=None):
""" """
@ -1093,6 +1108,7 @@ class Client(commandServer, encrypt, Desktop):
p = process(smbClientCmd, "-N", "//{}/remote".format(domain), p = process(smbClientCmd, "-N", "//{}/remote".format(domain),
stderr=STDOUT) stderr=STDOUT)
if "NT_STATUS_ACCESS_DENIED" in p.read(): if "NT_STATUS_ACCESS_DENIED" in p.read():
self.get_server_domainname(domain)
return True return True
else: else:
self.printERROR(_("Samba server not found in %s") % domain) self.printERROR(_("Samba server not found in %s") % domain)

@ -52,6 +52,11 @@ class VariableClRemoteHost(Variable):
""" """
value = "" value = ""
class VariableClRemoteDomain(Variable):
"""
Имя домена
"""
value = ""
class VariableClRemoteHostNew(Variable): class VariableClRemoteHostNew(Variable):
""" """

Loading…
Cancel
Save