add check configuration, path log file in cmd line command

master3.3
Спиридонов Денис 12 years ago
parent 7b3089d645
commit fd35999c1a

@ -23,9 +23,19 @@ from calculate.core.client.function import get_ip_mac_type
from calculate.core.datavars import DataVarsCore
from calculate.lib.utils import ip as ip_mod
import os, hashlib, OpenSSL, pwd, socket
import os, hashlib, OpenSSL, pwd, socket, sys
from os import path
def check(cert, key, cert_path, data_path, certbase, args):
error_flag = 0
if not path.isfile(cert):
error_flag = 1
print 'Certificate %s not found' %cert
if not path.isfile(key):
error_flag = 1
print 'Secret key %s not found' %key
sys.exit(error_flag)
def init(cert, key, cert_path, data_path, certbase, args, port, user_name):
try:
pwdObj = pwd.getpwnam(user_name)

@ -1048,15 +1048,15 @@ def revoke_signed_cert(revoke_cert_id, data_path, cert_path):
def parse():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--pid-file', type=str, dest='pidfile',
help=_('Specify the location of a PID file'))
parser.add_argument(
'-l', '--lang', type=str, dest='lang',
help=_('language for translate'))
parser.add_argument(
'-p', '--port', type=int, default = '8888', dest='port',
help=_('port number'))
parser.add_argument(
'--pid-file', type=str, dest='pidfile',
help=_('Specify the location of a PID file'))
parser.add_argument(
'-c', '--cert', type=str, dest='Id',
help=_('operations with certificates (number or "all"). Server not run'))
@ -1109,7 +1109,13 @@ def parse():
parser.add_argument(
'--rv', '--revoke-cert', type=str, dest='revoke_cert_id',
help=_("revoke early signed server (or ca) certificate. rm to remove CRL"))
parser.add_argument(
parser.add_argument(
'--check', action='store_true', default=False, dest = 'check',
help=_('check configuration'))
parser.add_argument(
'--log-path', type=str, dest='log_path',
help=_('path to log files'))
parser.add_argument(
'--version', action='store_true', default=False, dest = 'version',
help=_('prints the version number, then exits'))

@ -37,34 +37,6 @@ from func import initialization
from server_class import ClApplication
class OpenSSLAdapter (pyOpenSSLAdapter):
#def check_cert(self, cert):
#if cert == None:
#return -1
#cert_id = 0
#from func import find_cert_id
#find_cert_id(cert, self.data_path, self.certbase)
## open database with certificates
#if not os.path.exists(self.certbase):
#fc = open(self.certbase,"w")
#fc.close()
#fc = open(self.certbase,"r")
#while 1:
#try:
## read all on one record
#cert_dict = pickle.load(fc)
#except:
#break
## if input and cert from database equal
#if cert == cert_dict["cert"]:
## get certificate id
#cert_id = cert_dict["Id"]
#fc.close()
#return cert_id
def verify_func(self, connection, x509, errnum, errdepth, ok):
# get client certificate
curThread = threading.currentThread()
@ -112,29 +84,9 @@ def main(*args, **keywords):
# translate
if args.lang:
translate(args.lang)
debug = args.debug
import logging
import logging.handlers
if not os.path.exists('/var/log/calculate'):
os.makedirs('/var/log/calculate')
LOG_FILENAME = '/var/log/calculate/logging_cl_core_server.out'
file_logger = logging.getLogger('MyLogger')
file_logger.setLevel(logging.DEBUG)
# Add the log message handler to the logger
handler = logging.handlers.RotatingFileHandler(
LOG_FILENAME, maxBytes=10000000, backupCount=3)
file_logger.addHandler(handler)
# debug
if debug:
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('soaplib.wsgi')
logger.setLevel(logging.DEBUG)
if args.version:
print cl_ver
return 0
port = args.port
ob = DataVarsCore()
@ -159,15 +111,38 @@ def main(*args, **keywords):
cert = ob.Get('cl_core_cert')
key = ob.Get('cl_core_key')
cl_ver = ob.Get('cl_ver')
log_path_var = ob.Get('cl_log_path')
import logging
import logging.handlers
log_path = args.log_path if args.log_path else log_path_var
if not os.path.exists(log_path):
os.makedirs(log_path)
LOG_FILENAME = os.path.join(log_path, 'logging_cl_core.out')
file_logger = logging.getLogger('MyLogger')
file_logger.setLevel(logging.DEBUG)
# Add the log message handler to the logger
handler = logging.handlers.RotatingFileHandler(
LOG_FILENAME, maxBytes=10000000, backupCount=3)
file_logger.addHandler(handler)
# debug
if args.debug:
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('soaplib.wsgi')
logger.setLevel(logging.DEBUG)
# delete all sid and pid informations file
clean(sids_file, pids_file, sids_pids, sids, pids)
cert_cmd.create_path(data_path, certbase, rights, group_rights)
#####################
''' view information about client certificates '''
if args.version:
print cl_ver
if args.check:
bootstrap.check(cert, key, cert_path, data_path, certbase, args)
return 0
if args.bootstrap_user_name:
bootstrap.init(cert, key, cert_path, data_path, certbase, args, port,\
@ -198,9 +173,8 @@ def main(*args, **keywords):
if args.id_del_req:
cert_cmd.del_request(args.id_del_req, serv_certbase, data_path)
return 0
#####################
#####################
# importing other modules
other_mod = initialization(cl_wsdl)
#try:

@ -178,6 +178,12 @@ class VariableClClientCertDir(Variable):
Client certificates directory
"""
value = '~/.calculate/client_cert'
class VariableClLogPath(Variable):
"""
Server log file path certificates directory
"""
value = '/var/log/calculate'
class VariableClUserRootCert(Variable):
"""

@ -116,6 +116,7 @@ class VariableClGroupRights(Variable):
group_name = self.Get('cl_group_name')
group_rights = self.Get('cl_core_group_rights')
print 'group_name = ', group_name
t = open(group_rights, 'r').read()
results = []
for line in t.splitlines():
@ -125,8 +126,10 @@ class VariableClGroupRights(Variable):
for i in methods:
results.append(i.strip())
print 'results = ', results
if group_name == 'all' and results == []:
right_list = []
print Dec.rightsMethods
for key in Dec.rightsMethods.keys():
right_list += Dec.rightsMethods[key]

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save