From 26068662152adaed2310ba877605740f26e997fa Mon Sep 17 00:00:00 2001 From: Kevin Guerineau Date: Tue, 7 May 2024 17:37:57 +0200 Subject: [PATCH] [IMP] Use other lib to remove dirs --- common.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/common.py b/common.py index 7256877..c08e8ba 100644 --- a/common.py +++ b/common.py @@ -6,6 +6,7 @@ import os import configparser import sys from colorama import Fore, Style +import shutil config = configparser.ConfigParser() config.read('samba-pki-tools.ini') @@ -119,6 +120,14 @@ def check_directories(path,verbose=False): def create_openssl_config(force=False,verbose=False): + if force: + Printing.error("Do you realy want to remove ALL you PKI ? This will destroy ALL YOUR CERTIFICATES AND PRIVATE KEY") + Printing.error("After that, you MUST REGENERATE YOUR PKI with NEW certificates and private key for ALL YOUR DOMAIN CONTROLLERS AND USERS") + destroy = input('If you are realy sure, please enter : "I want to remove all my PKI" .') + if destroy == 'I want to remove all my PKI': + Printing.information('OK, too late ! Destroying your PKI !') + shutil.rmtree(TisPKI.pki_dir(), ignore_errors=True) + Printing.information('Check Root CA OpenSSL Config') if config.get('general','pki_dir'): @@ -127,14 +136,6 @@ def create_openssl_config(force=False,verbose=False): Printing.error('No pki_dir set in samba-pki-tools.ini') sys.exit(1) - if force: - Printing.error("Do you realy want to remove ALL you PKI ? This will destroy ALL YOUR CERTIFICATES AND PRIVATE KEY") - Printing.error("After that, you MUST REGENERATE YOUR PKI with NEW certificates and private key for ALL YOUR DOMAIN CONTROLLERS AND USERS") - destroy = input('If you are realy sure, please enter : "I want to remove all my PKI"') - if destroy == 'I want to remove all my PKI': - Printing.information('OK, too late ! Destroying your PKI !') - os.removedirs(TisPKI.pki_dir()) - root_ca_config = os.path.join(TisPKI.pki_dir(),'config','openssl_root_ca.ini') if not os.path.isfile(root_ca_config):