Fix openssl decryption command

Change-Id: I24182482306aa02878b0951b1458561de3867f0c
Closes-bug: #1555625
This commit is contained in:
eldar nugaev 2016-03-10 14:50:37 +00:00
parent 671d57cfd9
commit e4c1f0e026
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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):