From 23f9d519229c308760f2d81cf75333e14bbfc798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Wed, 14 Nov 2018 17:43:52 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B2=20=D0=B4=D0=BE=D0=BC=D0=B5=D0=BD=D0=B0=20=D0=BD=D0=B0=20?= =?UTF-8?q?samba=204.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pym/client/client.py | 24 ++++++++++++++++++++---- pym/client/variables/client.py | 5 +++++ 2 files changed, 25 insertions(+), 4 deletions(-) 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): """