|
|
@ -1,6 +1,6 @@
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#-*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# Copyright 2008-2016 Mir Calculate. http://www.calculate-linux.org
|
|
|
|
# Copyright 2008-2013 Calculate Ltd. http://www.calculate-linux.org
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
@ -18,18 +18,12 @@ import os
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
from os import path
|
|
|
|
from os import path
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
from calculate.lib.datavars import (Variable, VariableError, ReadonlyVariable,
|
|
|
|
from calculate.lib.datavars import (Variable,VariableError,ReadonlyVariable,
|
|
|
|
ReadonlyTableVariable, FieldValue,
|
|
|
|
ReadonlyTableVariable,FieldValue)
|
|
|
|
HumanReadable)
|
|
|
|
from calculate.lib.cl_template import iniParser
|
|
|
|
from calculate.lib.cl_ini_parser import iniParser
|
|
|
|
from calculate.lib.utils.files import readLinesFile,isMount,readFile, find
|
|
|
|
from calculate.lib.configparser import ConfigParser
|
|
|
|
from calculate.lib.utils.common import getValueFromCmdLine,cmpVersion
|
|
|
|
import calculate.lib.utils.device as device
|
|
|
|
from calculate.lib.variables.user import VariableUrLogin
|
|
|
|
from calculate.lib.utils.files import (readFile, find,
|
|
|
|
|
|
|
|
FindFileType)
|
|
|
|
|
|
|
|
from calculate.lib.utils.mount import isMount
|
|
|
|
|
|
|
|
from calculate.lib.utils.common import getValueFromCmdLine, CmdlineParams
|
|
|
|
|
|
|
|
from calculate.lib.utils.portage import isPkgInstalled
|
|
|
|
|
|
|
|
from calculate.lib.variables import user
|
|
|
|
|
|
|
|
from calculate.lib.convertenv import convertEnv
|
|
|
|
from calculate.lib.convertenv import convertEnv
|
|
|
|
from calculate.lib.utils.ip import isOpenPort
|
|
|
|
from calculate.lib.utils.ip import isOpenPort
|
|
|
|
import time
|
|
|
|
import time
|
|
|
@ -38,15 +32,10 @@ from socket import gethostbyname
|
|
|
|
from calculate.lib.cl_ldap import ldapUser
|
|
|
|
from calculate.lib.cl_ldap import ldapUser
|
|
|
|
from calculate.lib.variables.user import LdapHelper
|
|
|
|
from calculate.lib.variables.user import LdapHelper
|
|
|
|
import pwd
|
|
|
|
import pwd
|
|
|
|
from ..client import Client
|
|
|
|
from calculate.client.client import Client
|
|
|
|
from ..rsync import ProfileSyncer, ProfileSyncerError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
|
|
|
|
setLocalTranslate('cl_client3', sys.modules[__name__])
|
|
|
|
|
|
|
|
__ = getLazyLocalTranslate(_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
|
|
|
|
setLocalTranslate('cl_client3',sys.modules[__name__])
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClRemoteHost(Variable):
|
|
|
|
class VariableClRemoteHost(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -54,12 +43,6 @@ class VariableClRemoteHost(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
value = ""
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClRemoteDomain(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Имя домена
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
value = ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClRemoteHostNew(Variable):
|
|
|
|
class VariableClRemoteHostNew(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
IP or domain name of CDS
|
|
|
|
IP or domain name of CDS
|
|
|
@ -74,25 +57,22 @@ class VariableClRemoteHostNew(Variable):
|
|
|
|
self.label = _("Domain IP")
|
|
|
|
self.label = _("Domain IP")
|
|
|
|
self.help = _("domain")
|
|
|
|
self.help = _("domain")
|
|
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
def check(self,value):
|
|
|
|
if self.Get('cl_client_mount_set') == 'off':
|
|
|
|
if self.Get('cl_client_mount_set') == 'off':
|
|
|
|
if self.Get('cl_localhost_set') == 'off':
|
|
|
|
if self.Get('cl_localhost_set') == 'off':
|
|
|
|
if self.Get('cl_remote_host') == '':
|
|
|
|
if self.Get('cl_remote_host') == '':
|
|
|
|
if not value:
|
|
|
|
if not value:
|
|
|
|
raise VariableError(_("Please specify the domain"))
|
|
|
|
raise VariableError(_("Need to specify the domain"))
|
|
|
|
elif not isOpenPort(value, 445):
|
|
|
|
elif not isOpenPort(value,445):
|
|
|
|
raise VariableError(
|
|
|
|
raise VariableError(
|
|
|
|
_("The specified address is not available"))
|
|
|
|
_("The specified address is not available"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClRemoteHostLive(ReadonlyVariable):
|
|
|
|
class VariableClRemoteHostLive(ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Remote host from /proc/cmdline param domain
|
|
|
|
Remote host from /proc/cmdline param domain
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return getValueFromCmdLine(CmdlineParams.Calculate,
|
|
|
|
return getValueFromCmdLine("calculate","domain") or ""
|
|
|
|
CmdlineParams.Domain) or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableOsRemoteAuth(Variable):
|
|
|
|
class VariableOsRemoteAuth(Variable):
|
|
|
@ -116,21 +96,18 @@ class VariableClRemotePw(Variable):
|
|
|
|
opt = ["--domain-password"]
|
|
|
|
opt = ["--domain-password"]
|
|
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
def init(self):
|
|
|
|
self.label = __("Domain password")
|
|
|
|
self.label = _("Domain password")
|
|
|
|
self.help = _("specify the domain password")
|
|
|
|
self.help = _("specify the domain password")
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return getValueFromCmdLine(CmdlineParams.Calculate,
|
|
|
|
return getValueFromCmdLine("calculate","domain_pw") or ""
|
|
|
|
CmdlineParams.DomainPassword) or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClMovedSkipPath(Variable):
|
|
|
|
class VariableClMovedSkipPath(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Skip "Moved" path
|
|
|
|
Skip "Moved" path
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
type = "list"
|
|
|
|
type = "list"
|
|
|
|
value = ['Disks', 'Home', 'Moved', 'FTP', 'Desktop', 'Share']
|
|
|
|
value = ['Disks','Home','Moved','FTP','Desktop', 'Share']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClSyncSkipPath(Variable):
|
|
|
|
class VariableClSyncSkipPath(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -138,13 +115,12 @@ class VariableClSyncSkipPath(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
type = "list"
|
|
|
|
type = "list"
|
|
|
|
value = [".googleearth", "Home", "Disks", "FTP",
|
|
|
|
value = [".googleearth", "Home", "Disks", "FTP",
|
|
|
|
'Share', ".local/share/akonadi/db_data", ".VirtualBox",
|
|
|
|
'Share', ".local/share/akonadi/db_data", ".VirtualBox",
|
|
|
|
".mozilla/firefox/calculate.default/urlclassifier3.sqlite",
|
|
|
|
".mozilla/firefox/calculate.default/urlclassifier3.sqlite",
|
|
|
|
".local/share/mime/mime.cache", ".gvfs",
|
|
|
|
".local/share/mime/mime.cache", ".gvfs",
|
|
|
|
".kde4/share/apps/nepomuk/repository/main/data", ".logout",
|
|
|
|
".kde4/share/apps/nepomuk/repository/main/data", ".logout",
|
|
|
|
".Xauthority", ".thumbnails", ".mozilla/firefox/*/Cache",
|
|
|
|
".Xauthority", ".thumbnails", ".mozilla/firefox/*/Cache",
|
|
|
|
".kde4/socket-*", ".cache/", ".local/share/Trash"]
|
|
|
|
".kde4/socket-*", ".cache/", ".local/share/Trash"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClSyncDelPath(Variable):
|
|
|
|
class VariableClSyncDelPath(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -154,12 +130,10 @@ class VariableClSyncDelPath(Variable):
|
|
|
|
value = [".kde4/share/config/phonondevicesrc",
|
|
|
|
value = [".kde4/share/config/phonondevicesrc",
|
|
|
|
".kde4/cache-*", ".kde4/tmp-*"]
|
|
|
|
".kde4/cache-*", ".kde4/tmp-*"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClProfileAllSet(Variable):
|
|
|
|
class VariableClProfileAllSet(Variable):
|
|
|
|
type = "bool"
|
|
|
|
type = "bool"
|
|
|
|
value = "off"
|
|
|
|
value = "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSync(Variable):
|
|
|
|
class VariableClClientSync(Variable):
|
|
|
|
type = "bool"
|
|
|
|
type = "bool"
|
|
|
|
value = "on"
|
|
|
|
value = "on"
|
|
|
@ -171,7 +145,6 @@ class VariableClClientSync(Variable):
|
|
|
|
self.label = _("Synchronize the user profile")
|
|
|
|
self.label = _("Synchronize the user profile")
|
|
|
|
self.help = _("synchronize user preferences")
|
|
|
|
self.help = _("synchronize user preferences")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClLocalhostSet(Variable):
|
|
|
|
class VariableClLocalhostSet(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Using autopartition
|
|
|
|
Using autopartition
|
|
|
@ -184,30 +157,28 @@ class VariableClLocalhostSet(Variable):
|
|
|
|
untrusted = True
|
|
|
|
untrusted = True
|
|
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
def init(self):
|
|
|
|
self.label = _("Workstation role")
|
|
|
|
self.label = _("Computer role")
|
|
|
|
self.help = _("remove the domain connection settings")
|
|
|
|
self.help = _("remove the domain connection settings")
|
|
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
def choice(self):
|
|
|
|
return [("off", _("Domain workstation")),
|
|
|
|
return [("off",_("Domain workstation")),
|
|
|
|
("on", _("Local workstation"))]
|
|
|
|
("on",_("Local workstation"))]
|
|
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
def check(self,value):
|
|
|
|
if self.Get('cl_client_mount_set') == 'off':
|
|
|
|
if self.Get('cl_client_mount_set') == 'off':
|
|
|
|
if self.Get('cl_remote_host') == '' and value == "on":
|
|
|
|
if self.Get('cl_remote_host') == '' and value == "on":
|
|
|
|
raise VariableError(_("The workstation is not in the domain"))
|
|
|
|
raise VariableError(_("The computer is not in the domain"))
|
|
|
|
if self.Get('cl_remote_host') != '' and value == "off":
|
|
|
|
if self.Get('cl_remote_host') != '' and value == "off":
|
|
|
|
raise VariableError(
|
|
|
|
raise VariableError(_("The computer is already in the domain %s")
|
|
|
|
_("The workstation is already in the domain %s")
|
|
|
|
%self.Get('cl_remote_host') + "\n" +
|
|
|
|
% self.Get('cl_remote_host') + "\n" +
|
|
|
|
_("Before joining the domain, "
|
|
|
|
_("Before joining the domain, "
|
|
|
|
"you need to remove it from the previous domain"))
|
|
|
|
"you need to remove it from the previous domain"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def get(self):
|
|
|
|
|
|
|
|
# if self.Get('cl_remote_host') == '':
|
|
|
|
|
|
|
|
# return "on"
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
# return "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#def get(self):
|
|
|
|
|
|
|
|
# if self.Get('cl_remote_host') == '':
|
|
|
|
|
|
|
|
# return "on"
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
# return "off"
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientMountSet(Variable):
|
|
|
|
class VariableClClientMountSet(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -222,8 +193,7 @@ class VariableClClientMountSet(Variable):
|
|
|
|
self.label = _("Only mount the domain resource")
|
|
|
|
self.label = _("Only mount the domain resource")
|
|
|
|
self.help = _("only mount the [remote] domain resource")
|
|
|
|
self.help = _("only mount the [remote] domain resource")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableUrUserPw(Variable,LdapHelper):
|
|
|
|
class VariableUrUserPw(Variable, LdapHelper):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Current user password
|
|
|
|
Current user password
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -239,16 +209,18 @@ class VariableUrUserPw(Variable, LdapHelper):
|
|
|
|
|
|
|
|
|
|
|
|
def checkUserPwdLDAP(self, server, userDN, password):
|
|
|
|
def checkUserPwdLDAP(self, server, userDN, password):
|
|
|
|
"""Check unix user password on server"""
|
|
|
|
"""Check unix user password on server"""
|
|
|
|
ldapInit = ldap.initialize("ldap://%s" % server)
|
|
|
|
ldapInit = ldap.initialize("ldap://%s"%server)
|
|
|
|
|
|
|
|
errMessage = ""
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
ldapInit.bind_s(userDN, password)
|
|
|
|
ldapInit.bind_s(userDN, password)
|
|
|
|
except ldap.INVALID_CREDENTIALS:
|
|
|
|
except ldap.INVALID_CREDENTIALS:
|
|
|
|
raise VariableError(_("Wrong password"))
|
|
|
|
raise VariableError(_("Wrong password"))
|
|
|
|
except ldap.LDAPError as e:
|
|
|
|
except ldap.LDAPError, e:
|
|
|
|
raise VariableError(f"{e.args[0]['desc']}; {e.args[0]['info']}")
|
|
|
|
errMessage = e[0]['desc']
|
|
|
|
|
|
|
|
raise VariableError(errMessage)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
def check(self,value):
|
|
|
|
if not value:
|
|
|
|
if not value:
|
|
|
|
raise VariableError(_("Empty password"))
|
|
|
|
raise VariableError(_("Empty password"))
|
|
|
|
# читаем os_remote_auth, так как при смене пароля
|
|
|
|
# читаем os_remote_auth, так как при смене пароля
|
|
|
@ -258,10 +230,9 @@ class VariableUrUserPw(Variable, LdapHelper):
|
|
|
|
ldapObj = self.getLdapUserObject()
|
|
|
|
ldapObj = self.getLdapUserObject()
|
|
|
|
if ldapObj:
|
|
|
|
if ldapObj:
|
|
|
|
usersDN = ldapObj.getUsersDN()
|
|
|
|
usersDN = ldapObj.getUsersDN()
|
|
|
|
userDN = ldapObj.addDN("uid=%s" % self.Get('ur_login'),
|
|
|
|
userDN = ldapObj.addDN("uid=%s"%self.Get('ur_login'),
|
|
|
|
usersDN)
|
|
|
|
usersDN)
|
|
|
|
self.checkUserPwdLDAP(server, userDN, value)
|
|
|
|
self.checkUserPwdLDAP(server,userDN,value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableUrUserNewPw(Variable):
|
|
|
|
class VariableUrUserNewPw(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -277,12 +248,11 @@ class VariableUrUserNewPw(Variable):
|
|
|
|
self.label = _("New password")
|
|
|
|
self.label = _("New password")
|
|
|
|
self.help = _("new user password")
|
|
|
|
self.help = _("new user password")
|
|
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
def check(self,value):
|
|
|
|
if not value:
|
|
|
|
if not value:
|
|
|
|
raise VariableError(_("Empty password"))
|
|
|
|
raise VariableError(_("Empty password"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientLogin(VariableUrLogin):
|
|
|
|
class VariableClClientLogin(user.VariableUrLogin):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
User Login
|
|
|
|
User Login
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -290,33 +260,32 @@ class VariableClClientLogin(user.VariableUrLogin):
|
|
|
|
alias = "ur_login"
|
|
|
|
alias = "ur_login"
|
|
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
def choice(self):
|
|
|
|
loginChoice = user.VariableUrLogin.choice(self)
|
|
|
|
loginChoice = VariableUrLogin.choice(self)
|
|
|
|
if self.Get('cl_action') == 'passwd':
|
|
|
|
if self.Get('cl_action') == 'passwd':
|
|
|
|
return [x for x in loginChoice if x != "root"]
|
|
|
|
return filter(lambda x:x != "root",loginChoice)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return loginChoice
|
|
|
|
return loginChoice
|
|
|
|
|
|
|
|
|
|
|
|
def check(self, value):
|
|
|
|
def check(self,value):
|
|
|
|
"""Does user exist"""
|
|
|
|
"""Does user exist"""
|
|
|
|
if not value in self.choice() and self.Get('cl_action') == 'logout':
|
|
|
|
if not value in self.choice() and self.Get('cl_action') == 'logout':
|
|
|
|
raise VariableError(_("X session users not found"))
|
|
|
|
raise VariableError(_("X session users not found"))
|
|
|
|
if value == "":
|
|
|
|
if value == "":
|
|
|
|
raise VariableError(_("Please specify the user"))
|
|
|
|
raise VariableError(_("Need to specify user"))
|
|
|
|
if value == "root" and self.Get('cl_action') == 'passwd':
|
|
|
|
if value == "root" and self.Get('cl_action') == 'passwd':
|
|
|
|
raise VariableError(
|
|
|
|
raise VariableError(\
|
|
|
|
_("This action can be executed by a non-root user only"))
|
|
|
|
_("The action can be executed by a non-root user only"))
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
pwd.getpwnam(value).pw_gid
|
|
|
|
pwd.getpwnam(value).pw_gid
|
|
|
|
except (TypeError, KeyError):
|
|
|
|
except:
|
|
|
|
raise VariableError(_("User %s does not exist") % value)
|
|
|
|
raise VariableError(_("User %s does not exist")%value)
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
if (self.Get('cl_action') == 'passwd' and
|
|
|
|
if (self.Get('cl_action') == 'passwd' and
|
|
|
|
self.Get('ur_login') != 'root'):
|
|
|
|
self.Get('ur_login') != 'root'):
|
|
|
|
return self.Get('ur_login')
|
|
|
|
return self.Get('ur_login')
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientRelevanceSet(ReadonlyVariable):
|
|
|
|
class VariableClClientRelevanceSet(ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Актуальны ли сейчас выполненные шаблоны
|
|
|
|
Актуальны ли сейчас выполненные шаблоны
|
|
|
@ -324,37 +293,34 @@ class VariableClClientRelevanceSet(ReadonlyVariable):
|
|
|
|
type = "bool"
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
# если происходят действия ввода или вывода из домена
|
|
|
|
|
|
|
|
if (self.Get('cl_action') in ("domain", "undomain") and
|
|
|
|
|
|
|
|
self.Get('cl_client_mount_set') == 'off'):
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
# если изменился домен
|
|
|
|
# если изменился домен
|
|
|
|
if self.Get('cl_remote_host') != self.Get("os_remote_auth"):
|
|
|
|
if self.Get('cl_remote_host') != self.Get("os_remote_auth"):
|
|
|
|
return "off"
|
|
|
|
return "off"
|
|
|
|
if (self.Get('cl_remote_host') and
|
|
|
|
if (self.Get('cl_remote_host') and
|
|
|
|
not isMount(self.Get('cl_client_remote_path'))):
|
|
|
|
not isMount(self.Get('cl_client_remote_path'))):
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
currentVersion = self.Get("cl_ver")
|
|
|
|
|
|
|
|
# версия программы, который были наложены шаблоны
|
|
|
|
|
|
|
|
previousVersion = self.Get("os_remote_client")
|
|
|
|
|
|
|
|
if cmpVersion(currentVersion,previousVersion):
|
|
|
|
return "off"
|
|
|
|
return "off"
|
|
|
|
return "on"
|
|
|
|
return "on"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientRemotePath(Variable):
|
|
|
|
class VariableClClientRemotePath(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Путь для монитрования //domain/remote
|
|
|
|
Путь для монитрования //domain/remote
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
value = "/var/calculate/remote"
|
|
|
|
value = "/var/calculate/remote"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientProfileName(Variable):
|
|
|
|
class VariableClClientProfileName(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Название удаленного профиля (CLD,CLDX,all)
|
|
|
|
Название удаленного профиля (CLD,CLDX,all)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return ("all" if self.Get('cl_profile_all_set') == 'on'
|
|
|
|
return ("all" if self.Get('cl_profile_all_set') == 'on'
|
|
|
|
else self.Get('os_linux_shortname'))
|
|
|
|
else self.Get('os_linux_shortname'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClLdapData(ldapUser,ReadonlyVariable):
|
|
|
|
class VariableClLdapData(ldapUser, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Внутренняя переменная, содержащая объект для доступа к данным LDAP
|
|
|
|
Внутренняя переменная, содержащая объект для доступа к данным LDAP
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -374,7 +340,7 @@ class VariableClLdapData(ldapUser, ReadonlyVariable):
|
|
|
|
if usersDN:
|
|
|
|
if usersDN:
|
|
|
|
partDN = "ou=Worked,ou=Replication,ou=LDAP"
|
|
|
|
partDN = "ou=Worked,ou=Replication,ou=LDAP"
|
|
|
|
servicesDN = "ou=Services"
|
|
|
|
servicesDN = "ou=Services"
|
|
|
|
baseDN = usersDN.rpartition(servicesDN + ",")[2]
|
|
|
|
baseDN = usersDN.rpartition(servicesDN+",")[2]
|
|
|
|
replDN = self.addDN(partDN, servicesDN, baseDN)
|
|
|
|
replDN = self.addDN(partDN, servicesDN, baseDN)
|
|
|
|
return replDN
|
|
|
|
return replDN
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -386,8 +352,8 @@ class VariableClLdapData(ldapUser, ReadonlyVariable):
|
|
|
|
bindDn, bindPw, host = connectData
|
|
|
|
bindDn, bindPw, host = connectData
|
|
|
|
replDN = self.getReplDN()
|
|
|
|
replDN = self.getReplDN()
|
|
|
|
# find string for service replication branch
|
|
|
|
# find string for service replication branch
|
|
|
|
userAndOsName = "%s@%s" % (userName, osLinuxShort)
|
|
|
|
userAndOsName = "%s@%s"%(userName,osLinuxShort)
|
|
|
|
findAttr = "uid=%s" % userAndOsName
|
|
|
|
findAttr = "uid=%s"%userAndOsName
|
|
|
|
# connect to LDAP
|
|
|
|
# connect to LDAP
|
|
|
|
if not self.ldapConnect(bindDn, bindPw, host):
|
|
|
|
if not self.ldapConnect(bindDn, bindPw, host):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -396,19 +362,20 @@ class VariableClLdapData(ldapUser, ReadonlyVariable):
|
|
|
|
return resSearch
|
|
|
|
return resSearch
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def _gethostbyname(self, hostname):
|
|
|
|
def _gethostbyname(self,hostname):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return gethostbyname(hostname)
|
|
|
|
return gethostbyname(hostname)
|
|
|
|
except Exception:
|
|
|
|
except:
|
|
|
|
return None
|
|
|
|
pass
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def getNameRemoteServer(self, userName, osLinuxShort, curHost):
|
|
|
|
def getNameRemoteServer(self,userName, osLinuxShort, curHost):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Get remote domain hostname or empty if profile is keeped on
|
|
|
|
Get remote domain hostname or empty if profile is keeped on
|
|
|
|
current server
|
|
|
|
current server
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
searchPrevHost = self.searchPrevHost(userName, osLinuxShort)
|
|
|
|
searchPrevHost = self.searchPrevHost(userName, osLinuxShort)
|
|
|
|
if searchPrevHost and 'host' in searchPrevHost[0][0][1]:
|
|
|
|
if searchPrevHost and searchPrevHost[0][0][1].has_key('host'):
|
|
|
|
prevHost = searchPrevHost[0][0][1]['host'][0]
|
|
|
|
prevHost = searchPrevHost[0][0][1]['host'][0]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
prevHost = None
|
|
|
|
prevHost = None
|
|
|
@ -431,7 +398,7 @@ class VariableClLdapData(ldapUser, ReadonlyVariable):
|
|
|
|
usersDN = self.getUsersDN()
|
|
|
|
usersDN = self.getUsersDN()
|
|
|
|
partDN = "ou=Replication,ou=LDAP"
|
|
|
|
partDN = "ou=Replication,ou=LDAP"
|
|
|
|
servicesDN = "ou=Services"
|
|
|
|
servicesDN = "ou=Services"
|
|
|
|
baseDN = usersDN.rpartition(servicesDN + ",")[2]
|
|
|
|
baseDN = usersDN.rpartition(servicesDN+",")[2]
|
|
|
|
replDN = self.addDN(partDN, servicesDN, baseDN)
|
|
|
|
replDN = self.addDN(partDN, servicesDN, baseDN)
|
|
|
|
findAttr = "ou=Worked"
|
|
|
|
findAttr = "ou=Worked"
|
|
|
|
# connect to LDAP
|
|
|
|
# connect to LDAP
|
|
|
@ -449,13 +416,11 @@ class VariableClReplicationHost(ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Удаленный сервер при репликации, который содержит актуальный профиль
|
|
|
|
Удаленный сервер при репликации, который содержит актуальный профиль
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return self.Get('cl_ldap_data').getNameRemoteServer(
|
|
|
|
return self.Get('cl_ldap_data').getNameRemoteServer(
|
|
|
|
self.Get('ur_login'), self.Get('cl_client_profile_name'),
|
|
|
|
self.Get('ur_login'),self.Get('cl_client_profile_name'),
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountData(ReadonlyTableVariable):
|
|
|
|
class VariableClClientUserMountData(ReadonlyTableVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Таблица монтирования ресурсов
|
|
|
|
Таблица монтирования ресурсов
|
|
|
@ -465,68 +430,30 @@ class VariableClClientUserMountData(ReadonlyTableVariable):
|
|
|
|
'cl_client_user_mount_path',
|
|
|
|
'cl_client_user_mount_path',
|
|
|
|
'cl_client_user_mount_host']
|
|
|
|
'cl_client_user_mount_host']
|
|
|
|
|
|
|
|
|
|
|
|
def get(self, hr=HumanReadable.No):
|
|
|
|
def get(self):
|
|
|
|
home = path.split(self.Get('ur_home_path'))[0]
|
|
|
|
home = path.split(self.Get('ur_home_path'))[0]
|
|
|
|
envFile = self.Get('cl_env_server_path')
|
|
|
|
envFile = self.Get('cl_env_server_path')
|
|
|
|
samba_host = self.Get('sr_samba_host')
|
|
|
|
|
|
|
|
ftp_host = convertEnv().getVar("ftp", "host")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def map_names(name):
|
|
|
|
|
|
|
|
name_dct = {'domain.dmz': 'Санкт-Петербург', 'domain.spb': 'Санкт-Петербург',
|
|
|
|
|
|
|
|
'domain.msk': 'Москва', 'domain.verevo': 'Производство'}
|
|
|
|
|
|
|
|
for i in name_dct:
|
|
|
|
|
|
|
|
if i in name:
|
|
|
|
|
|
|
|
return name_dct[i]
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return 'error'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate():
|
|
|
|
def generate():
|
|
|
|
yield (
|
|
|
|
yield ("share","share",path.join(self.Get('ur_home_path'),"Share"),
|
|
|
|
"share", "share", path.join(self.Get('ur_home_path'), "Share"),
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
samba_host)
|
|
|
|
yield ("unix","unix",path.join(home,".%s"%self.Get('ur_login')),
|
|
|
|
yield (
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
"unix", "unix", path.join(home, ".%s" % self.Get('ur_login'),
|
|
|
|
yield ("homes","homes",path.join(self.Get('ur_home_path'),"Home"),
|
|
|
|
"profile"),
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
samba_host)
|
|
|
|
if convertEnv().getVar("ftp","host"):
|
|
|
|
yield (
|
|
|
|
yield ("ftp","ftp",path.join(self.Get('ur_home_path'),"FTP"),
|
|
|
|
"homes", "homes", path.join(self.Get('ur_home_path'), "Home"),
|
|
|
|
self.Get('cl_remote_host'))
|
|
|
|
samba_host)
|
|
|
|
|
|
|
|
if ftp_host:
|
|
|
|
|
|
|
|
yield ("ftp", "ftp", path.join(self.Get('ur_home_path'), "FTP"),
|
|
|
|
|
|
|
|
ftp_host)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
yield ("ftp", '', '', '')
|
|
|
|
yield ("ftp",'','','')
|
|
|
|
if self.Get('cl_replication_host'):
|
|
|
|
if self.Get('cl_replication_host'):
|
|
|
|
yield ("remote_profile", "unix",
|
|
|
|
yield ("remote_profile","unix",
|
|
|
|
path.join(home, ".%s" % self.Get('ur_login'),
|
|
|
|
path.join(home,".%s.remote"%self.Get('ur_login')),
|
|
|
|
"remote_profile"),
|
|
|
|
|
|
|
|
self.Get('cl_replication_host'))
|
|
|
|
self.Get('cl_replication_host'))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
yield ("remote_profile", 'unix', '', '')
|
|
|
|
yield ("remote_profile",'unix','','')
|
|
|
|
|
|
|
|
|
|
|
|
for host, mount_path in zip(self.Get('cl_share_hosts'), self.Get('cl_share_mounts')):
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
resource = host.split('/')[-1]
|
|
|
|
|
|
|
|
host = host.replace('//', '', 1).split(f"/{resource}")[0]
|
|
|
|
|
|
|
|
if mount_path.startswith('~/'):
|
|
|
|
|
|
|
|
mount_path = f"{path.join(self.Get('ur_home_path'), mount_path.replace('~/', '', 1))}"
|
|
|
|
|
|
|
|
yield (resource, resource, mount_path, host)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return list(generate())
|
|
|
|
return list(generate())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountName(FieldValue,ReadonlyVariable):
|
|
|
|
class VariableClClientUserMountUnixPath(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Путь до подключенного unix ресурса данного пользователя
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
return self.select('cl_client_user_mount_path',
|
|
|
|
|
|
|
|
cl_client_user_mount_name='unix', limit=1) or ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountName(FieldValue, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Название удаленного ресурса
|
|
|
|
Название удаленного ресурса
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -535,7 +462,7 @@ class VariableClClientUserMountName(FieldValue, ReadonlyVariable):
|
|
|
|
column = 0
|
|
|
|
column = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountResource(FieldValue, ReadonlyVariable):
|
|
|
|
class VariableClClientUserMountResource(FieldValue,ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Название удаленного ресурса
|
|
|
|
Название удаленного ресурса
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -543,8 +470,7 @@ class VariableClClientUserMountResource(FieldValue, ReadonlyVariable):
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
column = 1
|
|
|
|
column = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountPath(FieldValue,ReadonlyVariable):
|
|
|
|
class VariableClClientUserMountPath(FieldValue, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Путь подключения удаленного ресурса
|
|
|
|
Путь подключения удаленного ресурса
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -552,8 +478,7 @@ class VariableClClientUserMountPath(FieldValue, ReadonlyVariable):
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
column = 2
|
|
|
|
column = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientUserMountHost(FieldValue,ReadonlyVariable):
|
|
|
|
class VariableClClientUserMountHost(FieldValue, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Удаленный сервер
|
|
|
|
Удаленный сервер
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -561,24 +486,12 @@ class VariableClClientUserMountHost(FieldValue, ReadonlyVariable):
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
source_variable = "cl_client_user_mount_data"
|
|
|
|
column = 3
|
|
|
|
column = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SyncHelper:
|
|
|
|
class VariableClShareHosts(Variable):
|
|
|
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
value = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClShareMounts(Variable):
|
|
|
|
|
|
|
|
type = "list"
|
|
|
|
|
|
|
|
value = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SyncHelper():
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Вспомогательный объект для определения статуса синхронизации и времени
|
|
|
|
Вспомогательный объект для определения статуса синхронизации и времени
|
|
|
|
по конфигурационным файлам
|
|
|
|
по конфигурационным файлам
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
def getSyncStatus(self,rpath):
|
|
|
|
def getSyncStatus(self, rpath):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Получить status_sync из desktop файла
|
|
|
|
Получить status_sync из desktop файла
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -587,9 +500,9 @@ class SyncHelper():
|
|
|
|
if os.path.exists(fileConfig):
|
|
|
|
if os.path.exists(fileConfig):
|
|
|
|
objConfig = iniParser(fileConfig)
|
|
|
|
objConfig = iniParser(fileConfig)
|
|
|
|
data = self.getDataInConfig("main", ["status_sync"],
|
|
|
|
data = self.getDataInConfig("main", ["status_sync"],
|
|
|
|
objConfig)
|
|
|
|
objConfig)
|
|
|
|
if data:
|
|
|
|
if data:
|
|
|
|
return data.get("status_sync", "")
|
|
|
|
return data.get("status_sync","")
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def getDataInConfig(self, section, listVars, objConfig):
|
|
|
|
def getDataInConfig(self, section, listVars, objConfig):
|
|
|
@ -598,18 +511,19 @@ class SyncHelper():
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
varsConfig = {}
|
|
|
|
varsConfig = {}
|
|
|
|
for varName in listVars:
|
|
|
|
for varName in listVars:
|
|
|
|
varsConfig[varName] = objConfig.getVar(section, varName)
|
|
|
|
varsConfig[varName] = objConfig.getVar(section,varName)
|
|
|
|
if objConfig.getError():
|
|
|
|
if objConfig.getError():
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return varsConfig
|
|
|
|
return varsConfig
|
|
|
|
|
|
|
|
|
|
|
|
def convertDate(self, strdate, dateformat="%Y-%m-%d %H:%M:%S"):
|
|
|
|
|
|
|
|
|
|
|
|
def convertDate(self,strdate,dateformat="%Y-%m-%d %H:%M:%S"):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Convert date from string format (dateformat) to stuct or None
|
|
|
|
Convert date from string format (dateformat) to stuct or None
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if strdate:
|
|
|
|
if strdate:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return time.strptime(strdate, dateformat)
|
|
|
|
return time.strptime(strdate,dateformat)
|
|
|
|
except ValueError:
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
@ -625,281 +539,124 @@ class SyncHelper():
|
|
|
|
objConfig)
|
|
|
|
objConfig)
|
|
|
|
timeLogout = data["date_logout"]
|
|
|
|
timeLogout = data["date_logout"]
|
|
|
|
timeConfig = data["date"]
|
|
|
|
timeConfig = data["date"]
|
|
|
|
dates = [x for x in [self.convertDate(timeLogout),
|
|
|
|
dates = filter(None,
|
|
|
|
self.convertDate(timeConfig)] if x]
|
|
|
|
[self.convertDate(timeLogout),
|
|
|
|
|
|
|
|
self.convertDate(timeConfig)])
|
|
|
|
if dates:
|
|
|
|
if dates:
|
|
|
|
return dates[0]
|
|
|
|
return dates[0]
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
def checkNeedSync(self, homeDir, rpath, curTimeObj, curStatusSync,
|
|
|
|
def checkNeedSync(self,homeDir,rpath,curTimeObj,curStatusSync,osLinuxShort):
|
|
|
|
osLinuxShort):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Проверить необходимость синхронизации текущего профиля с удаленным
|
|
|
|
Проверить необходимость синхронизации текущего профиля с удаленным
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
# profile directory
|
|
|
|
# profile directory
|
|
|
|
# fileConfig = os.path.join(homeDir, Client.configFileServer)
|
|
|
|
#fileConfig = os.path.join(homeDir, Client.configFileServer)
|
|
|
|
pathProfile = os.path.join(rpath, osLinuxShort)
|
|
|
|
pathProfile = os.path.join(rpath, osLinuxShort)
|
|
|
|
# if readFile(fileConfig).strip():
|
|
|
|
#if readFile(fileConfig).strip():
|
|
|
|
# return True
|
|
|
|
# return True
|
|
|
|
fileSoftConfigThis = os.path.join(pathProfile,
|
|
|
|
fileSoftConfigThis = os.path.join(pathProfile,
|
|
|
|
Client.configFileSoft)
|
|
|
|
Client.configFileSoft)
|
|
|
|
fileSoftConfigCur = os.path.join(homeDir,
|
|
|
|
fileSoftConfigCur = os.path.join(homeDir,
|
|
|
|
Client.configFileSoft)
|
|
|
|
Client.configFileSoft)
|
|
|
|
xSessionCur = iniParser(fileSoftConfigCur).getVar('main', 'xsession')
|
|
|
|
xSessionCur = iniParser(fileSoftConfigCur).getVar('main','xsession')
|
|
|
|
xSessionThis = iniParser(fileSoftConfigThis).getVar('main', 'xsession')
|
|
|
|
xSessionThis = iniParser(fileSoftConfigThis).getVar('main','xsession')
|
|
|
|
# check profile date on current server
|
|
|
|
# check profile date on current server
|
|
|
|
# fileConfigThis = os.path.join(pathProfile, Client.configFileDesktop)
|
|
|
|
#fileConfigThis = os.path.join(pathProfile, Client.configFileDesktop)
|
|
|
|
# if iniParser(fileConfigThis).getVar('main','status_sync') == "success":
|
|
|
|
#if iniParser(fileConfigThis).getVar('main','status_sync') == "success":
|
|
|
|
# self.setVarToConfig("main", {"status_sync":"success_mount"},
|
|
|
|
# self.setVarToConfig("main", {"status_sync":"success_mount"},
|
|
|
|
# fileConfigThis)
|
|
|
|
# fileConfigThis)
|
|
|
|
thisTimeObj = self.getDateObjClientConf(pathProfile)
|
|
|
|
thisTimeObj = self.getDateObjClientConf(pathProfile)
|
|
|
|
if curStatusSync == "success_logout" and \
|
|
|
|
if curStatusSync == "success_logout" and \
|
|
|
|
xSessionCur == xSessionThis and \
|
|
|
|
xSessionCur == xSessionThis and \
|
|
|
|
thisTimeObj and curTimeObj and \
|
|
|
|
thisTimeObj and curTimeObj and \
|
|
|
|
curTimeObj >= thisTimeObj:
|
|
|
|
curTimeObj >= thisTimeObj:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def getSyncDate(self, osLinuxShort, ps):
|
|
|
|
class VariableClClientSyncTime(SyncHelper,ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
|
|
|
|
Получить время синхронизации из ::profile/.calculate/desktop.env
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
desktopEnvRemoteData = ps.readfile("::profile/{}/{}".format(
|
|
|
|
|
|
|
|
osLinuxShort, Client.configFileDesktop))
|
|
|
|
|
|
|
|
if desktopEnvRemoteData:
|
|
|
|
|
|
|
|
cpRemote = ConfigParser(strict=False)
|
|
|
|
|
|
|
|
cpRemote.read_string(desktopEnvRemoteData)
|
|
|
|
|
|
|
|
timeLogout = cpRemote.get("main", "date_logout", fallback=None)
|
|
|
|
|
|
|
|
timeConfig = cpRemote.get("main", "date", fallback=None)
|
|
|
|
|
|
|
|
dates = [x for x in [self.convertDate(timeLogout),
|
|
|
|
|
|
|
|
self.convertDate(timeConfig)] if x]
|
|
|
|
|
|
|
|
if dates:
|
|
|
|
|
|
|
|
return dates[0]
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkNeedSyncNew(self, homeDir, rpath, curTimeObj, curStatusSync,
|
|
|
|
|
|
|
|
osLinuxShort, ps):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Проверить необходимость синхронизации текущего профиля с удаленным
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
iniEnvRemoteData = ps.readfile("::profile/{}/{}".format(
|
|
|
|
|
|
|
|
osLinuxShort, Client.configFileSoft))
|
|
|
|
|
|
|
|
fileConfigCur = os.path.join(homeDir, Client.configFileSoft)
|
|
|
|
|
|
|
|
iniEnvCurrentData = readFile(fileConfigCur)
|
|
|
|
|
|
|
|
cpCur = ConfigParser(strict=False)
|
|
|
|
|
|
|
|
cpCur.read_string(iniEnvCurrentData)
|
|
|
|
|
|
|
|
cpRemote = ConfigParser(strict=False)
|
|
|
|
|
|
|
|
cpRemote.read_string(iniEnvRemoteData)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xSessionCur = cpCur.get('main', 'xsession', fallback=None)
|
|
|
|
|
|
|
|
xSessionThis = cpRemote.get('main', 'xsession', fallback=None)
|
|
|
|
|
|
|
|
if curStatusSync == "success_logout" and \
|
|
|
|
|
|
|
|
xSessionCur == xSessionThis:
|
|
|
|
|
|
|
|
thisTimeObj = self.getSyncDate(osLinuxShort, ps)
|
|
|
|
|
|
|
|
if thisTimeObj and curTimeObj and \
|
|
|
|
|
|
|
|
curTimeObj >= thisTimeObj:
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSyncTime(SyncHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Текущее время синхронизации профиля
|
|
|
|
Текущее время синхронизации профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return self.getDateObjClientConf(self.Get('ur_home_path'))
|
|
|
|
return self.getDateObjClientConf(self.Get('ur_home_path'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientPackTime(SyncHelper,ReadonlyVariable):
|
|
|
|
class VariableClClientPackTime(SyncHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Время комады упаковки профиля
|
|
|
|
Время комады упаковки профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return str(float(time.time()))
|
|
|
|
return str(float(time.time()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSyncStatus(SyncHelper,ReadonlyVariable):
|
|
|
|
class VariableClClientSyncStatus(SyncHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Текущий статус синхронизации профиля
|
|
|
|
Текущий статус синхронизации профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return self.getSyncStatus(self.Get('ur_home_path'))
|
|
|
|
return self.getSyncStatus(self.Get('ur_home_path'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientLocalSyncTime(SyncHelper,ReadonlyVariable):
|
|
|
|
class VariableClClientLocalSyncTime(SyncHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Текущий статус синхронизации профиля
|
|
|
|
Текущий статус синхронизации профиля
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
return self.getDateObjClientConf(
|
|
|
|
return self.getDateObjClientConf(
|
|
|
|
path.join(
|
|
|
|
path.join(
|
|
|
|
self.Select('cl_client_user_mount_path',
|
|
|
|
self.Select('cl_client_user_mount_path',
|
|
|
|
where='cl_client_user_mount_name', eq='unix',
|
|
|
|
where='cl_client_user_mount_name',eq='unix',
|
|
|
|
limit=1), self.Get('cl_client_profile_name')))
|
|
|
|
limit=1),self.Get('cl_client_profile_name')))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientRsyncProfileSet(ReadonlyVariable):
|
|
|
|
class VariableClClientSyncReplicationSet(SyncHelper,ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
|
|
|
|
Используется rsync через ssh для синхронизации пользовательского профиля
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
value = "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSyncReplicationSet(SyncHelper, ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Нужно ли синхронизировать текущий профиль с удаленным доменом
|
|
|
|
Нужно ли синхронизировать текущий профиль с удаленным доменом
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
type = "bool"
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
|
|
host_varname = "cl_replication_host"
|
|
|
|
def get(self):
|
|
|
|
profile_type = "remote_profile"
|
|
|
|
if not self.Get('cl_replication_host'):
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
def old_synchronize(self):
|
|
|
|
|
|
|
|
profilePath = self.Select('cl_client_user_mount_path',
|
|
|
|
profilePath = self.Select('cl_client_user_mount_path',
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
eq=self.profile_type, limit=1)
|
|
|
|
eq='remote_profile',limit=1)
|
|
|
|
if self.Get('cl_action') == 'login' and not isMount(profilePath):
|
|
|
|
if self.Get('cl_action') == 'login' and not isMount(profilePath):
|
|
|
|
raise VariableError(_("Remote profile not mounted"))
|
|
|
|
raise VariableError(_("Remote profile not mounted"))
|
|
|
|
return "on" if self.checkNeedSync(self.Get('ur_home_path'), profilePath,
|
|
|
|
return "on" if self.checkNeedSync(self.Get('ur_home_path'),profilePath,
|
|
|
|
self.Get('cl_client_sync_time'),
|
|
|
|
self.Get('cl_client_sync_time'),
|
|
|
|
self.Get('cl_client_sync_status'),
|
|
|
|
self.Get('cl_client_sync_status'),
|
|
|
|
self.Get(
|
|
|
|
self.Get('cl_client_profile_name')) else "off"
|
|
|
|
'cl_client_profile_name')) else "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def new_synchronize(self):
|
|
|
|
|
|
|
|
user = self.Get('ur_login')
|
|
|
|
|
|
|
|
pwd = self.Get('desktop.ur_password')
|
|
|
|
|
|
|
|
remotehost = self.Get(self.host_varname)
|
|
|
|
|
|
|
|
ps = ProfileSyncer(remotehost, 2009, user, pwd)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#there was a typo before - profilePath was missing
|
|
|
|
|
|
|
|
profilePath = self.Select('cl_client_user_mount_path',
|
|
|
|
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
|
|
|
|
eq=self.profile_type, limit=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ps.check():
|
|
|
|
|
|
|
|
return "on" if self.checkNeedSyncNew(
|
|
|
|
|
|
|
|
self.Get('ur_home_path'), profilePath,
|
|
|
|
|
|
|
|
self.Get('cl_client_sync_time'),
|
|
|
|
|
|
|
|
self.Get('cl_client_sync_status'),
|
|
|
|
|
|
|
|
self.Get('cl_client_profile_name'),
|
|
|
|
|
|
|
|
ps) else "off"
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
if not self.Get(self.host_varname):
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.GetBool('cl_client_rsync_profile_set'):
|
|
|
|
|
|
|
|
return self.new_synchronize()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return self.old_synchronize()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSyncLocalSet(VariableClClientSyncReplicationSet):
|
|
|
|
class VariableClClientSyncLocalSet(SyncHelper,ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Нужно ли синхронизировать текущий профиль с локальным доменом
|
|
|
|
Нужно ли синхронизировать текущий профиль с локальным доменом
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
type = "bool"
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
|
|
|
|
host_varname = "cl_remote_host"
|
|
|
|
def get(self):
|
|
|
|
profile_type = "unix"
|
|
|
|
if not self.Get('cl_remote_host'):
|
|
|
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
profilePath = self.Select('cl_client_user_mount_path',
|
|
|
|
|
|
|
|
where='cl_client_user_mount_name',
|
|
|
|
|
|
|
|
eq='unix',limit=1)
|
|
|
|
|
|
|
|
if self.Get('cl_action') == 'login' and not isMount(profilePath):
|
|
|
|
|
|
|
|
raise VariableError(_("Remote profile not mounted"))
|
|
|
|
|
|
|
|
return "on" if self.checkNeedSync(self.Get('ur_home_path'),profilePath,
|
|
|
|
|
|
|
|
self.Get('cl_client_sync_time'),
|
|
|
|
|
|
|
|
self.Get('cl_client_sync_status'),
|
|
|
|
|
|
|
|
self.Get('cl_client_profile_name')) else "off"
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientSymlinks(ReadonlyVariable):
|
|
|
|
class VariableClClientSymlinks(ReadonlyVariable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Список симлинков в пользовательском профиле
|
|
|
|
Список симлинков в пользовательском профиле
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
skipFiles = (self.Get('cl_sync_del_path') +
|
|
|
|
skipFiles = (self.Get('cl_sync_del_path') +
|
|
|
|
self.Get('cl_sync_skip_path'))
|
|
|
|
self.Get('cl_sync_skip_path'))
|
|
|
|
reSkip = re.compile("|".join((x.replace("*", ".*") for x in skipFiles))).search
|
|
|
|
reSkip = re.compile("|".join(map(lambda x:x.replace("*",".*"),
|
|
|
|
return [x for x in find(self.Get('ur_home_path'), onefilesystem=True,
|
|
|
|
skipFiles))).search
|
|
|
|
filetype=FindFileType.SymbolicLink)
|
|
|
|
return filter(lambda x:not reSkip(x),
|
|
|
|
if not reSkip(x)]
|
|
|
|
find(self.Get('ur_home_path'),onefilesystem=True,filetype='l'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientNscdCache(Variable):
|
|
|
|
class VariableClClientNscdCache(Variable):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Частота обновления кэша nscd при работе в домене в часах
|
|
|
|
Частота обновления кэша nscd при работе в домене в часах
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClCifsVer(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Версия модуля CIFS
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
return device.sysfs.read(device.sysfs.Path.Module, "cifs/version")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClCifsCache(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Параметр cache= при монтировании cifs
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
value = "loose"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClCifsMountVers(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Параметр vers= для cifs
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
value = "1.0"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClRsyncVer(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Версия rsync
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
data = isPkgInstalled('net-misc/rsync')
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
|
|
|
return data[0]['PVR']
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClCifsutilsVer(ReadonlyVariable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Версия cifs-utils
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
data = isPkgInstalled('net-fs/cifs-utils')
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
|
|
|
return data[0]['PV']
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClClientIgnoreErrorsSet(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Параметр, для отключения отмонтирования пользовательских ресурсов,
|
|
|
|
|
|
|
|
при ошбиках, возникших во вермя cl-client-sync-login
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
value = "on"
|
|
|
|
|
|
|
|
metavalue = "ON/OFF"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opt = ["--unmount-on-error"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
|
|
|
self.label = _("Unmount user resources on error")
|
|
|
|
|
|
|
|
self.help = _("unmount user resources on error")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableClSyncMovedSet(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Использовать или нет перенос файлов из домашней директории в Home/Moved при
|
|
|
|
|
|
|
|
синхронизации
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
type = "bool"
|
|
|
|
|
|
|
|
value = "on"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VariableSrSambaHost(Variable):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Хост на котором находятся samba ресурсы
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
|
|
|
return self.Get('cl_remote_host') or ''
|
|
|
|
|
|
|
|