diff --git a/freezer/engine/tar/tar_builders.py b/freezer/engine/tar/tar_builders.py index 034df572..772c3231 100644 --- a/freezer/engine/tar/tar_builders.py +++ b/freezer/engine/tar/tar_builders.py @@ -109,6 +109,7 @@ class TarCommandRestoreBuilder: '--ignore-zeros --warning=none' UNIX_TEMPLATE = '{0} {1} --incremental --extract --unlink-first ' \ '--ignore-zeros --warning=none --overwrite --directory {2}' + OPENSSL_DEC = "{openssl_path} enc -d -aes-256-cfb -pass file:{file}" def __init__(self, restore_path, compression_algo, is_windows, tar_path=None): @@ -143,9 +144,9 @@ class TarCommandRestoreBuilder: # Check if encryption file is provided and set the openssl decrypt # command accordingly if self.encrypt_pass_file: - openssl_cmd = "{openssl_path} enc -aes-256-cfb -pass file:{file}"\ - .format(openssl_path=self.openssl_path, - file=self.encrypt_pass_file) + openssl_cmd = self.OPENSSL_DEC.format( + openssl_path=self.openssl_path, + file=self.encrypt_pass_file) tar_command = '{0} | {1}'.format(openssl_cmd, tar_command) return tar_command diff --git a/tests/unit/engines/tar/test_tar_builders.py b/tests/unit/engines/tar/test_tar_builders.py index 267ff19c..9d54cb0a 100644 --- a/tests/unit/engines/tar/test_tar_builders.py +++ b/tests/unit/engines/tar/test_tar_builders.py @@ -90,7 +90,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase): self.builder.set_encryption("encrypt_pass_file", "openssl") self.assertEquals( self.builder.build(), - "openssl enc -aes-256-cfb -pass file:encrypt_pass_file | gnutar " + "openssl enc -d -aes-256-cfb -pass file:encrypt_pass_file | gnutar " "-z --incremental --extract --unlink-first --ignore-zeros" " --warning=none --overwrite --directory restore_path") @@ -100,7 +100,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase): self.builder.set_encryption("encrypt_pass_file", "openssl") self.assertEquals( self.builder.build(), - 'openssl enc -aes-256-cfb -pass file:encrypt_pass_file ' + 'openssl enc -d -aes-256-cfb -pass file:encrypt_pass_file ' '| gnutar -x -z --incremental --unlink-first --ignore-zeros') def test_get_tar_flag_from_algo(self):