fix read rights

master3.3
Спиридонов Денис 12 years ago
parent 07a6d66849
commit fd9c84e818

@ -526,7 +526,7 @@ def view_cert_info(cert, cert_id, rights, group_rights):
t = fd.read()
fd.close()
for line in t.splitlines():
words = line.split()
words = line.split(' ',1)
# first word in line equal name input method
if words[0] in groups_list:
methods = words[1].split(',')

@ -117,7 +117,7 @@ class ApiWsdl:
with open(group_rights) as fd:
t = fd.read()
for line in t.splitlines():
words = line.split()
words = line.split(' ',1)
# first word in line equal name input method
if words[0] in groups_list:
methods = words[1].split(',')

@ -23,6 +23,7 @@ from soaplib.service import rpc
from calculate.api.server.api_types import ReturnedMessage, getViewForVariables
from calculate.api.server.api_types import Field, GroupField, ViewInfo
from calculate.lib.datavars import VariableError
from calculate.lib.utils.files import readLinesFile
from calculate.api import datavars
import traceback
@ -255,7 +256,7 @@ class ApiWsdl:
dv.flIniFile()
dv.Get('cl_group_name')
dv.addGroup(_("Requests detail"),
dv.addGroup(_("Group detail"),
normal=('cl_group_name', 'cl_group_rights',
'cl_page_count','cl_page_offset'))
@ -284,99 +285,101 @@ class ApiWsdl:
############## END DETAIL GROUP METHOD #######################################
############### BEGIN CONFIRM GROUP METHODS ###################################
#def changeGroupCommon(self,sid,info,methodname):
#try:
#dv = self.get_cache(sid,methodname,"vars")
#errors = self.check_req_params(dv, info,
#ordered=['cl_req_id'],
#allvars=True)
#if errors:
#return errors
#request_meth = type("delRequestCommon",(self.Common,
#ApiWsdl, object), {})
#pid = self.startprocess(sid, target=request_meth,
#method="confirm_request_meth",\
#args_proc = (dv,))
#returnmess = ReturnedMessage(type = 'pid', message = pid)
#returnmess.type = "pid"
#returnmess.message = pid
#dv = self.clear_cache(sid,methodname)
#return [returnmess]
#finally:
#if dv:
#self.set_cache(sid,methodname,"vars",dv,smart=False)
#return []
def changeGroupCommon(self,sid,info,methodname):
try:
dv = self.get_cache(sid,methodname,"vars")
errors = self.check_req_params(dv, info,
ordered=['cl_group_name','cl_group_rights'],
allvars=True)
if errors:
return errors
request_meth = type("delRequestCommon",(self.Common,
ApiWsdl, object), {})
pid = self.startprocess(sid, target=request_meth,
method="change_group_meth",\
args_proc = (dv,))
returnmess = ReturnedMessage(type = 'pid', message = pid)
returnmess.type = "pid"
returnmess.message = pid
dv = self.clear_cache(sid,methodname)
return [returnmess]
finally:
if dv:
self.set_cache(sid,methodname,"vars",dv,smart=False)
return []
#def confirm_request_meth(self, dv):
#try:
#data_path = dv.Get('cl_api_data')
#cert_path = dv.Get('cl_api_cert_path')
#cl_req_id = str(dv.Get('cl_req_id'))
#cl_req_group = str(dv.Get('cl_req_group'))
##self.startTask('Confirm Request')
#self.printSUCCESS ('<b>'+_('Confirm Request')+'</b>')
#self.printSUCCESS ("cl_req_id = %s" %cl_req_id)
#self.printSUCCESS ("cl_req_group = %s" %cl_req_group)
def change_group_meth(self, dv):
try:
group_rights_file = self.Get('cl_api_group_rights')
#server_cert = cert_path + '/root.crt'
#server_key = cert_path + '/root.key'
#cl_req = data_path + '/client_certs/%s.csr' %cl_req_id
#cl_cert = data_path + '/client_certs/%s.crt' %cl_req_id
#if not os.path.exists(cl_req):
#self.printERROR (_("Signing Request %s not found") %cl_req)
#return False
cl_group_name = str(dv.Get('cl_group_name'))
cl_group_rights = str(dv.Get('cl_group_rights'))
#self.startTask('Confirm Request')
#if os.path.exists(cl_cert):
#self.printERROR (_("certificate %s already exists") %cl_cert)
#return False
for line in readLinesFile(group_rights_file):
self.printSUCCESS ('<b>'+_('Change Group')+'</b>')
self.printSUCCESS ("cl_group_name = %s" %cl_group_name)
self.printSUCCESS ("cl_group_rights = %s" %cl_group_rights)
return True
server_cert = cert_path + '/root.crt'
server_key = cert_path + '/root.key'
cl_req = data_path + '/client_certs/%s.csr' %cl_req_id
cl_cert = data_path + '/client_certs/%s.crt' %cl_req_id
if not os.path.exists(cl_req):
self.printERROR (_("Signing Request %s not found") %cl_req)
return False
#group = "group:%s" %cl_req_group
#config = data_path + '/client_certs/ssl-client.cfg'
#if os.path.exists(config):
#os.unlink(config)
#cfg_text = ("[ ssl_client ]\n"
#"basicConstraints = CA:FALSE\n"
#"nsCertType = client\n"
#"keyUsage = digitalSignature, keyEncipherment\n"
#"extendedKeyUsage = clientAuth\n"
#"nsComment = %s") %group
#fc = open(config, 'w')
#fc.write(cfg_text)
#fc.close()
if os.path.exists(cl_cert):
self.printERROR (_("certificate %s already exists") %cl_cert)
return False
#cmd = ("openssl x509 -req -days 11000 -CA %s -CAkey %s -CAcreateserial "
#"-extfile %s -extensions ssl_client -in %s -out %s") \
#%(server_cert, server_key, config, cl_req, cl_cert)
#print cmd
#PIPE = subprocess.PIPE
#p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,
#stderr=subprocess.STDOUT, close_fds=True)
#p.wait()
#self.printSUCCESS ('<b>' + _("certificate %s is signed") %cl_cert \
#+ '</b>')
##self.endTask()
#return True
#except (KeyboardInterrupt,):
#self.printERROR('Process is interrupted!')
#return False
group = "group:%s" %cl_req_group
config = data_path + '/client_certs/ssl-client.cfg'
if os.path.exists(config):
os.unlink(config)
cfg_text = ("[ ssl_client ]\n"
"basicConstraints = CA:FALSE\n"
"nsCertType = client\n"
"keyUsage = digitalSignature, keyEncipherment\n"
"extendedKeyUsage = clientAuth\n"
"nsComment = %s") %group
fc = open(config, 'w')
fc.write(cfg_text)
fc.close()
cmd = ("openssl x509 -req -days 11000 -CA %s -CAkey %s -CAcreateserial "
"-extfile %s -extensions ssl_client -in %s -out %s") \
%(server_cert, server_key, config, cl_req, cl_cert)
print cmd
PIPE = subprocess.PIPE
p = subprocess.Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,
stderr=subprocess.STDOUT, close_fds=True)
p.wait()
self.printSUCCESS ('<b>' + _("certificate %s is signed") %cl_cert \
+ '</b>')
#self.endTask()
return True
except (KeyboardInterrupt,):
self.printERROR('Process is interrupted!')
return False
#@rpc(Integer, DetailRequestInfo, _returns = Array(ReturnedMessage))
#@Dec.check_permissions(["edit-group"])
##@Dec.console('cl-show-request')
##@Dec.gui(_('Api'),_('Confirm Request'),'view-certificate-import')
#@catchExcept()
#def change_group ( self, sid, info):
#dv = self.get_cache(sid,'confirm_request',"vars")
#if not dv:
#dv = datavars.DataVarsApi()
#dv.importApi()
#dv.flIniFile()
@rpc(Integer, DetailGroupInfo, _returns = Array(ReturnedMessage))
@Dec.check_permissions(["edit-group"])
#@Dec.console('cl-show-request')
#@Dec.gui(_('Api'),_('Confirm Request'),'view-certificate-import')
@catchExcept()
def change_group ( self, sid, info):
dv = self.get_cache(sid,'change_group',"vars")
if not dv:
dv = datavars.DataVarsApi()
dv.importApi()
dv.flIniFile()
#try:
#dv.Set('cl_req_id', info.cl_req_id)
#dv.Set('cl_req_group', info.cl_req_group)
dv.Set('cl_group_name', info.cl_group_name)
dv.Set('cl_group_rights', info.cl_group_rights)
#except VariableError, e:
#errors = []
#mess = ''
@ -384,38 +387,37 @@ class ApiWsdl:
#for error in messages:
#mess += str(error) + '\n'
#errors.append(ReturnedMessage(type = 'error',
#field = 'cl_req_group', message = mess))
#field = 'cl_group_name', message = mess))
#return errors
#self.set_cache(sid, 'confirm_request', "vars", dv, smart=False)
#return self.changeGroupCommon(sid,info,'change_group')
self.set_cache(sid, 'change_group', "vars", dv, smart=False)
return self.changeGroupCommon(sid,info,'change_group')
#@rpc(Integer, Integer, Boolean, _returns = ViewInfo)
#@catchExcept()
#def change_group_view (self, sid, step, expert):
#dv = self.get_cache(sid, 'confirm_request', 'dv')
#if not dv:
#dv = datavars.DataVarsApi()
#dv.importApi()
#dv.flIniFile()
#dv.Get('cl_req_id')
@rpc(Integer, Integer, Boolean, _returns = ViewInfo)
@catchExcept()
def change_group_view (self, sid, step, expert):
dv = self.get_cache(sid, 'change_group', 'dv')
if not dv:
dv = datavars.DataVarsApi()
dv.importApi()
dv.flIniFile()
dv.Get('cl_group_name')
#dv.addGroup(_("Change group"),
#normal=('cl_req_id', 'cl_req_user_name', 'cl_req_ip', 'cl_req_mac',
#'cl_req_date', 'cl_req_location', 'cl_req_group'),
#next_label=_("Done"))
dv.addGroup(_("Change group"),
normal=('cl_group_name', 'cl_group_rights'),
next_label=_("Done"))
#view = getViewForVariables (dv,step,expert)
view = getViewForVariables (dv,step,expert)
#group = GroupField(name=_("Change group"),nextlabel=_("Done"),last=True)
#group.fields = []
#group.fields.append(Field(
#name = "but2",
#label = "Confirm",
#value = "confirm_request",
#element = "button"))
#view.groups.append(group)
#self.set_cache(sid, 'delete_request', "vars", dv, smart=False)
#return view
group = GroupField(name=_("Change group"),nextlabel=_("Done"),last=True)
group.fields = []
group.fields.append(Field(
name = "but2",
label = "Confirm",
value = "change_group",
element = "button"))
view.groups.append(group)
self.set_cache(sid, 'change_group', "vars", dv, smart=False)
return view
############### END CONFIRM GROUP METHODS ###################################

@ -196,7 +196,7 @@ class ClApplication(Application):
with open(group_rights) as fd:
t = fd.read()
for line in t.splitlines():
words = line.split()
words = line.split(' ',1)
# first word in line equal name input method
if words[0] in groups_list:
methods = words[1].split(',')

Loading…
Cancel
Save