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

salt.nacl.dec: expected str, bytearray, or unicode #51818

Closed
syphernl opened this issue Feb 26, 2019 · 1 comment

Comments

@syphernl
Copy link
Contributor

commented Feb 26, 2019

Description of Issue/Question

After updating to 2019.2.0 running this in a pillar

token: {{ salt.nacl.dec('XXXXXXXXXXXXX')|json }}

results in:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 392, in render_jinja_tmpl
[...]
---
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/jinja.py", line 70, in render
    **kws)
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 169, in render_tmpl
    output = render_str(tmplstr, context, tmplpath)
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 441, in render_jinja_tmpl
    trace=tracestr)
SaltRenderError: Jinja error: expected str, bytearray, or unicode
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 392, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 5, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/modules/nacl.py", line 228, in dec
    return salt.utils.nacl.dec(data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/utils/nacl.py", line 272, in dec
    return sealedbox_decrypt(data, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/utils/nacl.py", line 347, in sealedbox_decrypt
    sk = _get_sk(**kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/utils/nacl.py", line 72, in _get_sk
    key = salt.utils.stringutils.to_str(config['sk'])
  File "/usr/lib/python2.7/dist-packages/salt/utils/stringutils.py", line 118, in to_str
    raise TypeError('expected str, bytearray, or unicode')
TypeError: expected str, bytearray, or unicode

; line 5

Versions Report

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: 1.6.1
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.3.7
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.12 (default, Nov 12 2018, 14:36:49)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-1074-aws
         system: Linux
        version: Ubuntu 16.04 xenial

NACL config:

nacl.config:
  box_type: sealedbox
  sk_file: /etc/salt/pki/master/nacl
  pk_file: /etc/salt/pki/master/nacl.pub

The keyfile specs:

/etc/salt/pki/master/nacl: sticky , ASCII text, with no line terminators
/etc/salt/pki/master/nacl.pub: ASCII text, with no line terminators
@Ch3LL

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2019

looks like i'm able to replicate this and on the head of 2019.2. we'll need to get this fixed thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Salt Core Workspace
Pending Verification
Salt Open Workspace
  
Pending Verification
4 participants
You can’t perform that action at this time.