Conflicts: pym/cl_base.py pym/cl_profile.py pym/cl_utils2.pymaster3.3
commit
91b1f33f93
@ -0,0 +1,86 @@
|
|||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2008-2010 Mir Calculate Ltd. http://www.calculate-linux.org
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import hashlib
|
||||||
|
import crypt
|
||||||
|
import string
|
||||||
|
from random import choice
|
||||||
|
from base64 import urlsafe_b64encode as b64encode
|
||||||
|
|
||||||
|
from cl_print import color_print
|
||||||
|
import cl_lang
|
||||||
|
|
||||||
|
tr = cl_lang.lang()
|
||||||
|
tr.setLocalDomain('cl_lib')
|
||||||
|
tr.setLanguage(sys.modules[__name__])
|
||||||
|
|
||||||
|
class shareServer(color_print):
|
||||||
|
"""Класс хранения общих методов используемых для настройки сервисов"""
|
||||||
|
|
||||||
|
def __GenCryptSalt__(self):
|
||||||
|
"""Генерация соли для хеширования пароля (CRYPT)"""
|
||||||
|
chars = string.letters + string.digits+ "./"
|
||||||
|
salt = ""
|
||||||
|
for i in range(2):
|
||||||
|
salt = salt + choice(chars)
|
||||||
|
return salt
|
||||||
|
|
||||||
|
def getHashPasswd(self, password, crypt):
|
||||||
|
"""Генерация хеша пароля,
|
||||||
|
|
||||||
|
Поддерживаемые алгоритмы шифрования пароля:
|
||||||
|
plain, md5, smd5, crypt, sha, ssha
|
||||||
|
"""
|
||||||
|
if not password:
|
||||||
|
self.printERROR(_("ERROR") + " getHashPasswd: " +\
|
||||||
|
_("password empty"))
|
||||||
|
return False
|
||||||
|
|
||||||
|
hashPwd = ""
|
||||||
|
if crypt == "plain":
|
||||||
|
hashPwd = password
|
||||||
|
|
||||||
|
elif crypt == "md5":
|
||||||
|
h = hashlib.md5(password)
|
||||||
|
hashPwd = "{MD5}" + b64encode(h.digest())
|
||||||
|
|
||||||
|
elif crypt == "smd5":
|
||||||
|
salt = os.urandom(4)
|
||||||
|
h = hashlib.md5(password)
|
||||||
|
h.update(salt)
|
||||||
|
hashPwd = "{SMD5}" + b64encode(h.digest() + salt)
|
||||||
|
|
||||||
|
elif crypt == "crypt":
|
||||||
|
salt = self.__GenCryptSalt__()
|
||||||
|
hashPwd = "{CRYPT}" + crypt.crypt(password, salt)
|
||||||
|
|
||||||
|
elif crypt == "sha":
|
||||||
|
h = hashlib.sha1(password)
|
||||||
|
hashPwd = "{SHA}" + b64encode(h.digest())
|
||||||
|
|
||||||
|
elif crypt == "ssha":
|
||||||
|
salt = os.urandom(4)
|
||||||
|
h = hashlib.sha1(password)
|
||||||
|
h.update(salt)
|
||||||
|
hashPwd = "{SSHA}" + b64encode(h.digest() + salt)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.printERROR(_("ERROR") + " getHashPasswd: " +\
|
||||||
|
_("Can not support '%s' crypto algoritm")%crypt)
|
||||||
|
return False
|
||||||
|
return hashPwd
|
@ -0,0 +1,58 @@
|
|||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2008-2010 Mir Calculate Ltd. http://www.calculate-linux.org
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import os,sys,gettext
|
||||||
|
|
||||||
|
def __findFileMO(domain, localedir=None, languages=None, all=0):
|
||||||
|
"""Модифицированный метод, ищет файл перевода
|
||||||
|
|
||||||
|
замена gettext.find"""
|
||||||
|
if localedir is None:
|
||||||
|
localedir = _default_localedir
|
||||||
|
if languages is None:
|
||||||
|
languages = []
|
||||||
|
for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
|
||||||
|
val = os.environ.get(envar)
|
||||||
|
if val:
|
||||||
|
languages = val.split(':')
|
||||||
|
break
|
||||||
|
if 'C' not in languages:
|
||||||
|
languages.append('C')
|
||||||
|
# now normalize and expand the languages
|
||||||
|
nelangs = []
|
||||||
|
for lang in languages:
|
||||||
|
for nelang in gettext._expand_lang(lang):
|
||||||
|
if nelang not in nelangs:
|
||||||
|
nelangs.append(nelang)
|
||||||
|
# select a language
|
||||||
|
if all:
|
||||||
|
result = []
|
||||||
|
else:
|
||||||
|
result = None
|
||||||
|
for lang in nelangs:
|
||||||
|
if lang == 'C':
|
||||||
|
break
|
||||||
|
mofile = os.path.join(localedir, '%s_%s.mo' % (domain,lang))
|
||||||
|
if os.path.exists(mofile):
|
||||||
|
if all:
|
||||||
|
result.append(mofile)
|
||||||
|
else:
|
||||||
|
return mofile
|
||||||
|
return result
|
||||||
|
|
||||||
|
def exit(codeExit):
|
||||||
|
"""Метод выхода из программы"""
|
||||||
|
sys.exit(codeExit)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
|||||||
|
#-*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2008-2010 Mir Calculate Ltd. http://www.calculate-linux.org
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
import re
|
||||||
|
from format.samba import samba
|
||||||
|
|
||||||
|
class compiz(samba):
|
||||||
|
"""Класс для обработки конфигурационного файла типа compiz
|
||||||
|
|
||||||
|
"""
|
||||||
|
_comment = "#"
|
||||||
|
configName = "compiz"
|
||||||
|
configVersion = "0.1"
|
||||||
|
reHeader = re.compile("^[\t ]*\[[^\[\]]+\].*\n",re.M)
|
||||||
|
reBody = re.compile(".+",re.M|re.S)
|
||||||
|
reComment = re.compile("\s*%s.*"%(_comment))
|
||||||
|
reSeparator = re.compile("\s*=\s*")
|
||||||
|
sepFields = "\n"
|
||||||
|
reSepFields = re.compile(sepFields)
|
||||||
|
|
||||||
|
def __init__(self,text):
|
||||||
|
samba.__init__(self,text)
|
||||||
|
|
||||||
|
def join(self, compizObj):
|
||||||
|
"""Объединяем конфигурации"""
|
||||||
|
if isinstance(compizObj, compiz):
|
||||||
|
self.docObj.joinDoc(compizObj.doc)
|
||||||
|
self.postXML()
|
Loading…
Reference in new issue