|
|
|
@ -66,8 +66,6 @@ import post_cert, cl_unix_useradd, post_request, send_cert, cl_unix_userdel, \
|
|
|
|
|
#return self.f(selfobj, *args, **kwargs)
|
|
|
|
|
#return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Basic (DefinitionBase) :
|
|
|
|
|
""" Basic server class """
|
|
|
|
|
SERV_VERS = 0.11
|
|
|
|
@ -77,7 +75,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
glob_progress_dict = {}
|
|
|
|
|
glob_table_dict = {}
|
|
|
|
|
glob_frame_list = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data_path = None
|
|
|
|
|
certbase = None
|
|
|
|
|
rights = None
|
|
|
|
@ -87,7 +85,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
ssl_certificate = None
|
|
|
|
|
ssl_private_key = None
|
|
|
|
|
cachedict = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## function getting object from cache
|
|
|
|
|
#def get_cache(self, sid, meth_name, obj):
|
|
|
|
|
#if sid in self.cachedict:
|
|
|
|
@ -99,7 +97,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#setattr(obj, var_name, var_value)
|
|
|
|
|
#return obj
|
|
|
|
|
#return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## function placing object in cache
|
|
|
|
|
#def set_cache(self, sid, meth_name, obj):
|
|
|
|
@ -114,7 +112,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#return True
|
|
|
|
|
#except:
|
|
|
|
|
#return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# function getting object from cache
|
|
|
|
|
def get_cache(self, sid, meth_name, obj_name):
|
|
|
|
|
if sid in self.cachedict:
|
|
|
|
@ -122,7 +120,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
if obj_name in self.cachedict[sid][meth_name]:
|
|
|
|
|
return self.cachedict[sid][meth_name][obj_name]
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# function placing object in cache
|
|
|
|
|
def set_cache(self, sid, meth_name, obj_name, obj, smart = True):
|
|
|
|
@ -144,14 +142,14 @@ class Basic (DefinitionBase) :
|
|
|
|
|
return True
|
|
|
|
|
except:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def clear_cache(self, sid, meth_name = None, obj_name = None):
|
|
|
|
|
if not sid in self.cachedict:
|
|
|
|
|
return True
|
|
|
|
|
if meth_name:
|
|
|
|
|
if not meth_name in self.cachedict[sid]:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if obj_name:
|
|
|
|
|
if not obj_name in self.cachedict[sid][meth_name]:
|
|
|
|
|
return True
|
|
|
|
@ -167,7 +165,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
obj = self.cachedict.pop(sid, None)
|
|
|
|
|
if hasattr (obj, 'close'):
|
|
|
|
|
obj.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_paths (cls, data_path, certbase, serv_certbase, rights, \
|
|
|
|
|
group_rights, sids, pids, \
|
|
|
|
|
sids_pids, sids_file, pids_file, max_sid, \
|
|
|
|
@ -188,7 +186,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
Basic.cert_path = cert_path
|
|
|
|
|
Basic.max_sid = int(max_sid)
|
|
|
|
|
Basic.max_pid = int(max_pid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#start monitor and sid_monitor threads
|
|
|
|
|
monitoring = threading.Thread(target=monitor,\
|
|
|
|
|
args = (Basic.certbase, Basic.sids_file))
|
|
|
|
@ -220,7 +218,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
for pid in self.process_pid.keys():
|
|
|
|
|
if self.process_pid[pid].is_alive():
|
|
|
|
|
num_active_process += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if num_active_process:
|
|
|
|
|
sys.stdout.write('.')
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
@ -228,7 +226,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
print '\n' + _('All processes are closed.')
|
|
|
|
|
return 0
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Cache parameters
|
|
|
|
|
#class cache_old:
|
|
|
|
|
#def __init__(self,func):
|
|
|
|
@ -254,7 +252,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#+list(self.func.func_defaults)):
|
|
|
|
|
#self.args[sid][varname] = varvalue
|
|
|
|
|
#newargs = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## addition list of None values
|
|
|
|
|
#args = list(args)
|
|
|
|
|
|
|
|
|
@ -271,7 +269,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#newargs.append(newarg)
|
|
|
|
|
#else:
|
|
|
|
|
#newargs.append(cachearg[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#return self.func(*newargs)
|
|
|
|
|
|
|
|
|
|
@rpc(String, _returns = String)
|
|
|
|
@ -284,7 +282,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#import post_cert
|
|
|
|
|
returns = post_cert.serv_post_cert (self)
|
|
|
|
|
return returns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, _returns = Integer)
|
|
|
|
|
def clear_session_cache (self, sid) :
|
|
|
|
|
check_sid = self.check_sid_cert(sid)
|
|
|
|
@ -293,12 +291,12 @@ class Basic (DefinitionBase) :
|
|
|
|
|
# clear cache
|
|
|
|
|
self.clear_cache(sid)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, Integer, _returns = Integer)
|
|
|
|
|
def clear_pid_cache (self, sid, pid) :
|
|
|
|
|
if not self.check_sid_cert(sid):
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if pid in self.find_sid_pid_file(sid):
|
|
|
|
|
# clear pid cache
|
|
|
|
|
self._delete_pid(pid)
|
|
|
|
@ -325,9 +323,9 @@ class Basic (DefinitionBase) :
|
|
|
|
|
@rpc(Integer, _returns = Array(Integer))
|
|
|
|
|
def list_pid ( self, sid):
|
|
|
|
|
return self.find_sid_pid_file (sid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(String, _returns = Array(Array(String)))
|
|
|
|
|
def get_methods ( self, client_type) :
|
|
|
|
|
def get_methods ( self, client_type):
|
|
|
|
|
return self.serv_get_methods (client_type)
|
|
|
|
|
|
|
|
|
|
@rpc(_returns = Array(String))
|
|
|
|
@ -340,23 +338,23 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#@Dec.check_permissions(["pid_info"])
|
|
|
|
|
def pid_info ( self, sid, pid) :
|
|
|
|
|
return self.serv_pid_info (sid, pid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, _returns = Array(String))
|
|
|
|
|
#@Dec.check_permissions(['sid_info'])
|
|
|
|
|
def sid_info ( self, sid) :
|
|
|
|
|
return self.serv_sid_info (sid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, _returns = Array(String))
|
|
|
|
|
@Dec.check_permissions(["view_cert_right"])
|
|
|
|
|
#@Dec.console('view-cert-right')
|
|
|
|
|
#@Dec.gui('System')
|
|
|
|
|
def view_cert_right ( self, cert_id) :
|
|
|
|
|
return self.serv_view_cert_right (cert_id, self.data_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(Integer, _returns = Integer)
|
|
|
|
|
def active_client ( self, sid) :
|
|
|
|
|
return self.active_clients (sid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#@rpc(String, String, String, String, \
|
|
|
|
|
#_returns = Array( String ))
|
|
|
|
|
#def post_client_request ( self, request, ip, mac, client_type) :
|
|
|
|
@ -369,7 +367,6 @@ class Basic (DefinitionBase) :
|
|
|
|
|
#results.append (temp)
|
|
|
|
|
#results.append (send_cert.serv_send_cert (num, self.data_path))
|
|
|
|
|
#return results
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(String, String, String, String, _returns = String)
|
|
|
|
|
def post_client_request ( self, request, ip, mac, client_type) :
|
|
|
|
@ -382,7 +379,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
res = post_request.serv_get_client_cert (req_id, request,\
|
|
|
|
|
self.data_path, self.certbase, self.cert_path)
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(String, String, String, _returns = String)
|
|
|
|
|
def post_server_request ( self, request, ip, mac) :
|
|
|
|
|
res = post_request.serv_post_server_request (request, self.data_path,\
|
|
|
|
@ -394,7 +391,7 @@ class Basic (DefinitionBase) :
|
|
|
|
|
res = post_request.serv_get_server_request (req_id, request,\
|
|
|
|
|
self.data_path, self.serv_certbase, self.cert_path)
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc( _returns = String)
|
|
|
|
|
def get_crl (self):
|
|
|
|
|
if os.path.exists(self.data_path + '/server_certs/ca.crl'):
|
|
|
|
@ -416,11 +413,11 @@ class Basic (DefinitionBase) :
|
|
|
|
|
if subj[0] == 'CN':
|
|
|
|
|
return subj[1]
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(_returns = String)
|
|
|
|
|
def get_ca (self):
|
|
|
|
|
return send_cert.get_ca(self.cert_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@rpc(String, _returns = String)
|
|
|
|
|
def cl_unix_userdel ( self, param) :
|
|
|
|
|