Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to encrypt compressed tar archive as pillar #53899

Closed
ksoviero-medici opened this issue Jul 18, 2019 · 1 comment
Closed

Unable to encrypt compressed tar archive as pillar #53899

ksoviero-medici opened this issue Jul 18, 2019 · 1 comment
Labels
Bug broken, incorrect, or confusing behavior Duplicate Duplicate of another issue or PR - will be closed

Comments

@ksoviero-medici
Copy link

Description of Issue

I need to encrypt an entire directory, and the only way I know of to do that is to tar up the file and encrypt it using Salt's GPG key. Then add it to pillars.

The problem comes when I try to create the file on the receiving end and I get this error:

'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/pillar/__init__.py", line 736, in render_pstate
    **defaults)
  File "/usr/lib/python2.7/dist-packages/salt/template.py", line 101, in compile_template
    ret = render(input_data, saltenv, sls, **render_kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/renderers/gpg.py", line 350, in render
    return _decrypt_object(gpg_data, translate_newlines=translate_newlines)
  File "/usr/lib/python2.7/dist-packages/salt/renderers/gpg.py", line 329, in _decrypt_object
    translate_newlines=translate_newlines)
  File "/usr/lib/python2.7/dist-packages/salt/renderers/gpg.py", line 329, in _decrypt_object
    translate_newlines=translate_newlines)
  File "/usr/lib/python2.7/dist-packages/salt/renderers/gpg.py", line 325, in _decrypt_object
    return _decrypt_ciphertexts(obj, translate_newlines=translate_newlines)
  File "/usr/lib/python2.7/dist-packages/salt/renderers/gpg.py", line 307, in _decrypt_ciphertexts
    ret, num = GPG_CIPHERTEXT.subn(lambda m: _decrypt_ciphertext(m.group()), cipher)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)

This issues was supposed to be fixed way back in 2018.X, but it appears to still be an issue, or at least my use case is an edge case that still causes it.

Setup

  1. tar -czf ../archive.tar.gz ./
  2. cat ../archive.tar.gz | gpg --encrypt --armor --trust-model always -r [email protected]
  3. Add it to a pillar.
  4. Reference the pillar like this:
/path/to/archive.tar.gz:
  file.managed:
    - contents_pillar: path:to:pillar

Obviously most of those values are sanitized.

Steps to Reproduce Issue

See above.

Versions Report

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: 2.0.3
      gitpython: 2.1.8
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
   python-gnupg: 0.4.1
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: 2.0.3
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.2.5
 
System Versions:
           dist: Ubuntu 18.04 bionic
         locale: UTF-8
        machine: x86_64
        release: 4.15.0-1037-aws
         system: Linux
        version: Ubuntu 18.04 bionic
@waynew
Copy link
Contributor

waynew commented Jul 18, 2019

I'm pretty sure this is a duplicate of #51879 - if that's not the case, please let me know and we'll re-open!

@waynew waynew closed this as completed Jul 18, 2019
@waynew waynew added Bug broken, incorrect, or confusing behavior Duplicate Duplicate of another issue or PR - will be closed labels Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Duplicate Duplicate of another issue or PR - will be closed
Projects
None yet
Development

No branches or pull requests

2 participants