mirror of
https://github.com/netinvent/npbackup.git
synced 2025-11-10 06:01:39 +08:00
Rename old key to earlier key for better understanding
This commit is contained in:
parent
202edb4def
commit
677d9f8cfe
1 changed files with 9 additions and 15 deletions
|
|
@ -33,20 +33,20 @@ try:
|
||||||
AES_KEY = obfuscation(AES_KEY)
|
AES_KEY = obfuscation(AES_KEY)
|
||||||
IS_PRIV_BUILD = True
|
IS_PRIV_BUILD = True
|
||||||
try:
|
try:
|
||||||
from PRIVATE._private_secret_keys import OLD_AES_KEY
|
from PRIVATE._private_secret_keys import EARLIER_AES_KEY
|
||||||
|
|
||||||
OLD_AES_KEY = obfuscation(OLD_AES_KEY)
|
EARLIER_AES_KEY = obfuscation(EARLIER_AES_KEY)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
OLD_AES_KEY = None
|
EARLIER_AES_KEY = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from npbackup.secret_keys import AES_KEY, DEFAULT_BACKUP_ADMIN_PASSWORD
|
from npbackup.secret_keys import AES_KEY, DEFAULT_BACKUP_ADMIN_PASSWORD
|
||||||
|
|
||||||
IS_PRIV_BUILD = False
|
IS_PRIV_BUILD = False
|
||||||
try:
|
try:
|
||||||
from npbackup.secret_keys import OLD_AES_KEY
|
from npbackup.secret_keys import EARLIER_AES_KEY
|
||||||
except ImportError:
|
except ImportError:
|
||||||
OLD_AES_KEY = None
|
EARLIER_AES_KEY = None
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("No secret_keys file. Please read documentation.")
|
print("No secret_keys file. Please read documentation.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
@ -254,18 +254,12 @@ def evaluate_variables(config_dict: dict, value: str) -> str:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def update_encryption(config_file: str) -> Optional[dict]:
|
|
||||||
"""
|
|
||||||
If we changed AES KEY, let's use the old key to update the config file
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def load_config(config_file: str) -> Optional[dict]:
|
def load_config(config_file: str) -> Optional[dict]:
|
||||||
"""
|
"""
|
||||||
Using ruamel.yaml preserves comments and order of yaml files
|
Using ruamel.yaml preserves comments and order of yaml files
|
||||||
"""
|
"""
|
||||||
global AES_KEY
|
global AES_KEY
|
||||||
global OLD_AES_KEY
|
global EARLIER_AES_KEY
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.debug("Using configuration file {}".format(config_file))
|
logger.debug("Using configuration file {}".format(config_file))
|
||||||
|
|
@ -286,9 +280,9 @@ def load_config(config_file: str) -> Optional[dict]:
|
||||||
|
|
||||||
config_dict_decrypted = decrypt_data(config_dict)
|
config_dict_decrypted = decrypt_data(config_dict)
|
||||||
if config_dict_decrypted == False:
|
if config_dict_decrypted == False:
|
||||||
if OLD_AES_KEY:
|
if EARLIER_AES_KEY:
|
||||||
new_aes_key = AES_KEY
|
new_aes_key = AES_KEY
|
||||||
AES_KEY = OLD_AES_KEY
|
AES_KEY = EARLIER_AES_KEY
|
||||||
logger.info("Trying to migrate encryption key")
|
logger.info("Trying to migrate encryption key")
|
||||||
config_dict_decrypted = decrypt_data(config_dict)
|
config_dict_decrypted = decrypt_data(config_dict)
|
||||||
if config_dict_decrypted is not False:
|
if config_dict_decrypted is not False:
|
||||||
|
|
@ -296,7 +290,7 @@ def load_config(config_file: str) -> Optional[dict]:
|
||||||
logger.info("Migrated encryption")
|
logger.info("Migrated encryption")
|
||||||
config_file_needs_save = True
|
config_file_needs_save = True
|
||||||
new_aes_key = None
|
new_aes_key = None
|
||||||
OLD_AES_KEY = None
|
EARLIER_AES_KEY = None
|
||||||
else:
|
else:
|
||||||
logger.critical("Cannot decrypt config file.")
|
logger.critical("Cannot decrypt config file.")
|
||||||
sys.exit(12)
|
sys.exit(12)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue