|
|
|
@ -31,7 +31,7 @@ from calculate.core.datavars import DataVarsCore
|
|
|
|
|
from calculate.core.server.methods_func import get_password
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
|
from calculate.lib.utils.common import getpass
|
|
|
|
|
from calculate.lib.utils.files import listDirectory
|
|
|
|
|
from calculate.lib.utils.files import listDirectory, readFile
|
|
|
|
|
|
|
|
|
|
_ = lambda x: x
|
|
|
|
|
setLocalTranslate('cl_console3', sys.modules[__name__])
|
|
|
|
@ -137,7 +137,7 @@ def client_post_request(cert_path, args):
|
|
|
|
|
if os.path.exists(cert_path + 'req_id'):
|
|
|
|
|
print \
|
|
|
|
|
_("You already sent a certificate signature request.")
|
|
|
|
|
_print(_("Request ID = %s") % open(cert_path + 'req_id', 'r').read())
|
|
|
|
|
_print(_("Request ID = %s") % readFile(cert_path + 'req_id'))
|
|
|
|
|
ans = raw_input(_("Send a new request? y/[n]: "))
|
|
|
|
|
if not ans.lower() in ['y', 'yes']:
|
|
|
|
|
return 0
|
|
|
|
@ -177,7 +177,7 @@ def client_post_request(cert_path, args):
|
|
|
|
|
private_key_passwd=passwd)
|
|
|
|
|
|
|
|
|
|
ip, mac, client_type = get_ip_mac_type()
|
|
|
|
|
data = open(csr_file).read()
|
|
|
|
|
data = readFile(csr_file)
|
|
|
|
|
res = client.service.post_client_request(request=data, ip=ip,
|
|
|
|
|
mac=mac, client_type=client_type)
|
|
|
|
|
if int(res) < 0:
|
|
|
|
@ -226,7 +226,7 @@ def client_get_cert(cert_path, args):
|
|
|
|
|
print _("Request %s not found on the client's side") \
|
|
|
|
|
% (os.path.join(cert_path, server_host_name + '.csr'))
|
|
|
|
|
return 1
|
|
|
|
|
request = open(os.path.join(cert_path, server_host_name + '.csr')).read()
|
|
|
|
|
request = readFile(os.path.join(cert_path, server_host_name + '.csr'))
|
|
|
|
|
md5 = hashlib.md5()
|
|
|
|
|
md5.update(request)
|
|
|
|
|
md5sum = md5.hexdigest()
|
|
|
|
@ -273,7 +273,7 @@ def client_get_cert(cert_path, args):
|
|
|
|
|
if ca_root:
|
|
|
|
|
system_ca_db = clVars.Get('core.cl_glob_root_cert')
|
|
|
|
|
if os.path.exists(system_ca_db):
|
|
|
|
|
if ca_root in open(system_ca_db, 'r').read():
|
|
|
|
|
if ca_root in readFile(system_ca_db):
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
cl_client_cert_dir = clVars.Get('core.cl_client_cert_dir')
|
|
|
|
@ -359,7 +359,7 @@ def getRunProc():
|
|
|
|
|
cmdLineFile = '/proc/%s/cmdline' % procNum
|
|
|
|
|
try:
|
|
|
|
|
if os.path.exists(cmdLineFile):
|
|
|
|
|
return [open(cmdLineFile, 'r').read().strip(), procNum]
|
|
|
|
|
return [readFile(cmdLineFile).strip(), procNum]
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
return ["", procNum]
|
|
|
|
@ -442,7 +442,7 @@ def clear_password(server_host, server_port):
|
|
|
|
|
try:
|
|
|
|
|
while connect_error < 10:
|
|
|
|
|
if os.path.isfile(file_path):
|
|
|
|
|
serv_port, hash_val = open(file_path, 'r').read().split()
|
|
|
|
|
serv_port, hash_val = readFile(file_path).split()
|
|
|
|
|
s.connect(('localhost', int(serv_port)))
|
|
|
|
|
req = 'delete,%s,%s,%s,%s' % (server_host, str(server_port),
|
|
|
|
|
username, hash_val)
|
|
|
|
@ -463,7 +463,7 @@ def socket_connect(s, file_path):
|
|
|
|
|
try:
|
|
|
|
|
while connect_error < 10:
|
|
|
|
|
if os.path.isfile(file_path):
|
|
|
|
|
serv_port, hash_val = open(file_path, 'r').read().split()
|
|
|
|
|
serv_port, hash_val = readFile(file_path).split()
|
|
|
|
|
s.connect(('localhost', int(serv_port)))
|
|
|
|
|
return s, hash_val
|
|
|
|
|
else:
|
|
|
|
|