Fix openssl decryption command
Change-Id: I24182482306aa02878b0951b1458561de3867f0c Closes-bug: #1555625
This commit is contained in:
parent
671d57cfd9
commit
e4c1f0e026
@ -109,6 +109,7 @@ class TarCommandRestoreBuilder:
|
|||||||
'--ignore-zeros --warning=none'
|
'--ignore-zeros --warning=none'
|
||||||
UNIX_TEMPLATE = '{0} {1} --incremental --extract --unlink-first ' \
|
UNIX_TEMPLATE = '{0} {1} --incremental --extract --unlink-first ' \
|
||||||
'--ignore-zeros --warning=none --overwrite --directory {2}'
|
'--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,
|
def __init__(self, restore_path, compression_algo, is_windows,
|
||||||
tar_path=None):
|
tar_path=None):
|
||||||
@ -143,9 +144,9 @@ class TarCommandRestoreBuilder:
|
|||||||
# Check if encryption file is provided and set the openssl decrypt
|
# Check if encryption file is provided and set the openssl decrypt
|
||||||
# command accordingly
|
# command accordingly
|
||||||
if self.encrypt_pass_file:
|
if self.encrypt_pass_file:
|
||||||
openssl_cmd = "{openssl_path} enc -aes-256-cfb -pass file:{file}"\
|
openssl_cmd = self.OPENSSL_DEC.format(
|
||||||
.format(openssl_path=self.openssl_path,
|
openssl_path=self.openssl_path,
|
||||||
file=self.encrypt_pass_file)
|
file=self.encrypt_pass_file)
|
||||||
tar_command = '{0} | {1}'.format(openssl_cmd, tar_command)
|
tar_command = '{0} | {1}'.format(openssl_cmd, tar_command)
|
||||||
return tar_command
|
return tar_command
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase):
|
|||||||
self.builder.set_encryption("encrypt_pass_file", "openssl")
|
self.builder.set_encryption("encrypt_pass_file", "openssl")
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.builder.build(),
|
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"
|
"-z --incremental --extract --unlink-first --ignore-zeros"
|
||||||
" --warning=none --overwrite --directory restore_path")
|
" --warning=none --overwrite --directory restore_path")
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase):
|
|||||||
self.builder.set_encryption("encrypt_pass_file", "openssl")
|
self.builder.set_encryption("encrypt_pass_file", "openssl")
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.builder.build(),
|
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')
|
'| gnutar -x -z --incremental --unlink-first --ignore-zeros')
|
||||||
|
|
||||||
def test_get_tar_flag_from_algo(self):
|
def test_get_tar_flag_from_algo(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user