|
|
|
@ -14,8 +14,6 @@
|
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
import os
|
|
|
|
|
import pwd
|
|
|
|
|
import sys
|
|
|
|
@ -24,7 +22,7 @@ import socket
|
|
|
|
|
import time
|
|
|
|
|
import urllib.request as urllib2
|
|
|
|
|
from urllib.error import URLError
|
|
|
|
|
from .function import _print, get_ip_mac_type
|
|
|
|
|
from .function import _print, get_ip_mac_type, parse_error
|
|
|
|
|
import OpenSSL
|
|
|
|
|
import hashlib
|
|
|
|
|
from .client_class import HTTPSClientCertTransport
|
|
|
|
@ -117,7 +115,7 @@ def new_key_req(key, cert_path, server_host_name, private_key_passwd=None,
|
|
|
|
|
try:
|
|
|
|
|
pwdObj = pwd.getpwnam(user_name)
|
|
|
|
|
except KeyError as e:
|
|
|
|
|
_print(e)
|
|
|
|
|
_print(parse_error(e))
|
|
|
|
|
return None
|
|
|
|
|
os.chown(key, pwdObj.pw_uid, pwdObj.pw_gid)
|
|
|
|
|
os.chmod(key, 0o600)
|
|
|
|
@ -132,7 +130,7 @@ def delete_old_cert(client):
|
|
|
|
|
os.unlink(client.PKEY_FILE)
|
|
|
|
|
os.unlink(client.PubKEY_FILE)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
_print(e)
|
|
|
|
|
_print(parse_error(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def client_post_request(cert_path, args):
|
|
|
|
@ -260,13 +258,13 @@ def client_get_cert(cert_path, args):
|
|
|
|
|
try:
|
|
|
|
|
os.unlink(cert_path + 'req_id')
|
|
|
|
|
except OSError as e:
|
|
|
|
|
_print(e)
|
|
|
|
|
_print(parse_error(e))
|
|
|
|
|
print(_('Certificate saved. Your certificate ID: %s') % req_id)
|
|
|
|
|
user_name = pwd.getpwuid(os.getuid()).pw_name
|
|
|
|
|
try:
|
|
|
|
|
pwdObj = pwd.getpwnam(user_name)
|
|
|
|
|
except KeyError as e:
|
|
|
|
|
_print(e)
|
|
|
|
|
_print(parse_error(e))
|
|
|
|
|
return None
|
|
|
|
|
os.chown(cert_file, pwdObj.pw_uid, pwdObj.pw_gid)
|
|
|
|
|
os.chmod(cert_file, 0o600)
|
|
|
|
@ -401,7 +399,7 @@ def create_socket(file_path, username):
|
|
|
|
|
try:
|
|
|
|
|
os.unlink(file_path)
|
|
|
|
|
except OSError as e:
|
|
|
|
|
_print(e)
|
|
|
|
|
_print(parse_error(e))
|
|
|
|
|
|
|
|
|
|
cmd = ['cl-consoled']
|
|
|
|
|
# print cmd
|
|
|
|
|