|
|
@ -14,6 +14,7 @@
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import stat
|
|
|
|
import stat
|
|
|
|
import re
|
|
|
|
import re
|
|
|
@ -39,7 +40,7 @@ from calculate.lib.utils.common import 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
|
|
|
|
from client_cache import userCache
|
|
|
|
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
|
|
|
@ -48,6 +49,7 @@ from calculate.client.rsync import ProfileSyncer, ProfileSyncerError
|
|
|
|
from calculate.lib.utils.common import get_fastlogin_domain_path
|
|
|
|
from calculate.lib.utils.common import get_fastlogin_domain_path
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate
|
|
|
|
|
|
|
|
from functools import reduce
|
|
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
_ = lambda x: x
|
|
|
|
setLocalTranslate('cl_client3', sys.modules[__name__])
|
|
|
|
setLocalTranslate('cl_client3', sys.modules[__name__])
|
|
|
@ -203,7 +205,7 @@ class commandServer(color_print):
|
|
|
|
except ldap.INVALID_CREDENTIALS:
|
|
|
|
except ldap.INVALID_CREDENTIALS:
|
|
|
|
errMessage = _("Wrong password")
|
|
|
|
errMessage = _("Wrong password")
|
|
|
|
return False, errMessage
|
|
|
|
return False, errMessage
|
|
|
|
except ldap.LDAPError, e:
|
|
|
|
except ldap.LDAPError as e:
|
|
|
|
errMessage = e[0]['desc']
|
|
|
|
errMessage = e[0]['desc']
|
|
|
|
return False, errMessage
|
|
|
|
return False, errMessage
|
|
|
|
return True, errMessage
|
|
|
|
return True, errMessage
|
|
|
@ -218,10 +220,10 @@ class commandServer(color_print):
|
|
|
|
стандартного ввода (stdin)
|
|
|
|
стандартного ввода (stdin)
|
|
|
|
pwDialog - структура для вывода приглашения в режиме диалога
|
|
|
|
pwDialog - структура для вывода приглашения в режиме диалога
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if optStdIn and options.has_key(optStdIn):
|
|
|
|
if optStdIn and optStdIn in options:
|
|
|
|
pwdA = sys.stdin.readline().rstrip()
|
|
|
|
pwdA = sys.stdin.readline().rstrip()
|
|
|
|
pwdB = sys.stdin.readline().rstrip()
|
|
|
|
pwdB = sys.stdin.readline().rstrip()
|
|
|
|
elif optDialog and options.has_key(optDialog):
|
|
|
|
elif optDialog and optDialog in options:
|
|
|
|
if not pwDialog:
|
|
|
|
if not pwDialog:
|
|
|
|
pwDialog = [_("New password"),
|
|
|
|
pwDialog = [_("New password"),
|
|
|
|
_("Retype the new password")]
|
|
|
|
_("Retype the new password")]
|
|
|
@ -429,7 +431,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if iniParser(configFileName).setVar(
|
|
|
|
if iniParser(configFileName).setVar(
|
|
|
|
'rsync', {'files': rsync.getFilesNum()}):
|
|
|
|
'rsync', {'files': rsync.getFilesNum()}):
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chmod(configFileName, 0o600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -437,7 +439,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
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, 0o600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -452,8 +454,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# get directory permissions
|
|
|
|
# get directory permissions
|
|
|
|
mode = getModeFile(changeDir, mode="mode")
|
|
|
|
mode = getModeFile(changeDir, mode="mode")
|
|
|
|
# if permission wrong( not 0700) then change it
|
|
|
|
# if permission wrong( not 0700) then change it
|
|
|
|
if mode != 0700:
|
|
|
|
if mode != 0o700:
|
|
|
|
os.chmod(changeDir, 0700)
|
|
|
|
os.chmod(changeDir, 0o700)
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def clearHomeDir(self, homeDir):
|
|
|
|
def clearHomeDir(self, homeDir):
|
|
|
@ -671,7 +673,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
self.createUserDirectory(pathConfig, uid, gid)
|
|
|
|
self.createUserDirectory(pathConfig, uid, gid)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
if iniParser(configFileName).setVar(nameSection, varsDict):
|
|
|
|
if iniParser(configFileName).setVar(nameSection, varsDict):
|
|
|
|
os.chmod(configFileName, 0600)
|
|
|
|
os.chmod(configFileName, 0o600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -688,7 +690,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
self.createUserDirectory(pdir, uid, gid)
|
|
|
|
self.createUserDirectory(pdir, uid, gid)
|
|
|
|
os.mkdir(userdir)
|
|
|
|
os.mkdir(userdir)
|
|
|
|
os.chown(userdir, uid, gid)
|
|
|
|
os.chown(userdir, uid, gid)
|
|
|
|
os.chmod(userdir, 0700)
|
|
|
|
os.chmod(userdir, 0o700)
|
|
|
|
except OSError:
|
|
|
|
except OSError:
|
|
|
|
raise ClientError(_("Failed to create the directory") + ". " +
|
|
|
|
raise ClientError(_("Failed to create the directory") + ". " +
|
|
|
|
_("Permission denied: '%s'") % userdir)
|
|
|
|
_("Permission denied: '%s'") % userdir)
|
|
|
@ -1433,7 +1435,7 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
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, 0o600)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
os.chown(configFileName, uid, gid)
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -1445,8 +1447,8 @@ class Client(commandServer, encrypt, Desktop):
|
|
|
|
# get directory permissions
|
|
|
|
# get directory permissions
|
|
|
|
mode = getModeFile(changeDir, mode="mode")
|
|
|
|
mode = getModeFile(changeDir, mode="mode")
|
|
|
|
# if permission wrong( not 0700) then change it
|
|
|
|
# if permission wrong( not 0700) then change it
|
|
|
|
if mode != 0700:
|
|
|
|
if mode != 0o700:
|
|
|
|
os.chmod(changeDir, 0700)
|
|
|
|
os.chmod(changeDir, 0o700)
|
|
|
|
self.endTask()
|
|
|
|
self.endTask()
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|