diff --git a/pym/client/client.py b/pym/client/client.py index 3397231..1e5b40c 100644 --- a/pym/client/client.py +++ b/pym/client/client.py @@ -33,6 +33,7 @@ from calculate.lib.utils.files import (getModeFile, removeDir, pathJoin, tarLinks, listDirectory, process, find, STDOUT, sambaPasswordCheck, checkUtils) +from calculate.lib.utils.samba import Samba, SambaError from calculate.lib.utils.mount import isMount from calculate.lib.utils.common import cmpVersion from calculate.desktop._cl_keys import getKey, clearKey @@ -264,6 +265,9 @@ class Client(commandServer, encrypt, Desktop): # private user directories privateDirs = [] + def init(self): + self.domainnames = {} + def removeVars(self): """ Remove domain variables. Useing on remove package @@ -288,23 +292,34 @@ class Client(commandServer, encrypt, Desktop): else: nomapposix = ",nomapposix" 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') if not uid is None: # mount by uid p = process(mountCmd, "-t", "cifs", "-o", - "cache=%s,vers=%s,user=%s,uid=%d,gid=%d,noperm%s" % ( - cache_method, cifs_mount_vers, userName, uid, gid, nomapposix), + "cache=%s,domain=%s,user=%s,uid=%d,gid=%d,noperm%s" % ( + cache_method, domain, cifs_mount_vers, + userName, uid, gid, nomapposix), "//%s/%s" % (host, res), rpath, envdict={"PASSWD": userPwd}, stderr=STDOUT) return p.success() else: p = process(mountCmd, "-t", "cifs", "-o", - "cache=%s,vers=%s,user=%s%s" % (cache_method, - cifs_mount_vers, userName, nomapposix), + "cache=%s,domain=%s,vers=%s,user=%s%s" % (cache_method, + domain, cifs_mount_vers, userName, nomapposix), "//%s/%s" % (host, res), rpath, envdict={"PASSWD": userPwd}, stderr=STDOUT) 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, gid=None): """ @@ -1093,6 +1108,7 @@ class Client(commandServer, encrypt, Desktop): p = process(smbClientCmd, "-N", "//{}/remote".format(domain), stderr=STDOUT) if "NT_STATUS_ACCESS_DENIED" in p.read(): + self.get_server_domainname(domain) return True else: self.printERROR(_("Samba server not found in %s") % domain) diff --git a/pym/client/variables/client.py b/pym/client/variables/client.py index dbf64df..560a8f0 100644 --- a/pym/client/variables/client.py +++ b/pym/client/variables/client.py @@ -52,6 +52,11 @@ class VariableClRemoteHost(Variable): """ value = "" +class VariableClRemoteDomain(Variable): + """ + Имя домена + """ + value = "" class VariableClRemoteHostNew(Variable): """