|
|
|
@ -23,16 +23,22 @@ from calculate.api.client.function import get_ip_mac_type
|
|
|
|
|
from calculate.api.datavars import DataVarsApi
|
|
|
|
|
|
|
|
|
|
from calculate.lib.utils import ip as ip_mod
|
|
|
|
|
import os, hashlib, time, OpenSSL
|
|
|
|
|
import os, hashlib, time, OpenSSL, pwd
|
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
def init(cert, key, cert_path, data_path, certbase, args, port, user_name):
|
|
|
|
|
try:
|
|
|
|
|
pwdObj = pwd.getpwnam(user_name)
|
|
|
|
|
except KeyError, e:
|
|
|
|
|
print e
|
|
|
|
|
return 1
|
|
|
|
|
if check():
|
|
|
|
|
for step in range (2):
|
|
|
|
|
args = change_args(args, step)
|
|
|
|
|
create_server_cert(cert, key, cert_path, args, port)
|
|
|
|
|
|
|
|
|
|
create_client_cert(cert, cert_path, data_path, certbase, user_name)
|
|
|
|
|
change_owner(pwdObj, user_name)
|
|
|
|
|
|
|
|
|
|
def check():
|
|
|
|
|
return True
|
|
|
|
@ -215,4 +221,16 @@ def get_certificate(cert_path, data_path, certbase, client_cert_path):
|
|
|
|
|
print _("CERTIFICATE ADD")
|
|
|
|
|
else:
|
|
|
|
|
print _("file with ca certificates exists")
|
|
|
|
|
return 0
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
def change_owner(pwdObj, user_name):
|
|
|
|
|
if user_name == 'root':
|
|
|
|
|
return 1
|
|
|
|
|
else:
|
|
|
|
|
home_dir = '/home/' + user_name
|
|
|
|
|
|
|
|
|
|
for path in os.walk(home_dir + '/.calculate'):
|
|
|
|
|
os.chown(path[0], pwdObj.pw_uid, pwdObj.pw_gid)
|
|
|
|
|
for file in path[2]:
|
|
|
|
|
os.chown('/'.join([path[0], file]), pwdObj.pw_uid, pwdObj.pw_gid)
|
|
|
|
|
|
|
|
|
|