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

decode('base64') add a carriage return #5262

Closed
rgarrigue opened this issue Dec 12, 2013 · 5 comments
Closed

decode('base64') add a carriage return #5262

rgarrigue opened this issue Dec 12, 2013 · 5 comments
Labels
bug This issue/PR relates to a bug.

Comments

@rgarrigue
Copy link

Hi guys

I spent half of the morning trying to get a slurp / authorized_key to work. I'm now 99% sure it's about a carriage return added by decode('base64')

This works for me
key="{{sillage_key.content.decode('base64').rstrip('\r\n')}}"

This doesn't
key="{{sillage_key.content.decode('base64')}}"

Here is the -vvvv output

<192.168.111.222> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 192.168.111.222
<192.168.111.222> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1386845066.63-60882265649411 && echo $HOME/.ansible/tmp/ansible-1386845066.63-60882265649411'
<192.168.111.222> REMOTE_MODULE authorized_key user=genois key="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA05QAur3vsVo0Ta9Vy6eebuoxPsCAiRh/6C6jmRHIhFgCcoBqS8Dwxm243HY0Sy0kiiLHxamUaK3HHYlFO4+3aHDOXHAhuhT/ELM6+atFIk+3GtZjaxgEjEldBsfcPJIlMWvw+ktJanWEac+tKnNSjj3+Fj6sm0TaLA5x6HObRMroYl+rg9U5aIIyKJyz1PzVKbVKX4n/wCIP1KE2sCWwA4oLgm1VU2nHlcBk937EYt9MU/BxkuxbPbTAaQgxPWW4QNFIYwnSPQy3V4pHTUUz+zvjPJelTp6BDzpNy/dU9wB4hP2PqdbqrYdx3nNiZBfpU+hNJe3IER6URG/bMR9ivw== sillage@localhost
" manage_dir=no
<192.168.111.222> PUT /tmp/tmplKh4XM TO /root/.ansible/tmp/ansible-1386845066.63-60882265649411/authorized_key
<192.168.111.222> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-1386845066.63-60882265649411/authorized_key; rm -rf /root/.ansible/tmp/ansible-1386845066.63-60882265649411/ >/dev/null 2>&1'
failed: [lyr] => (item=genois) => {"failed": true, "item": "genois"}
msg: invalid key specified:

Note the new line between lines 3 and 4 that shouldn't be.

I got the issue with both devel and 1.4.1. Found the rstrip fix on 1.4.1, didn' t tried it on devel.

@rgarrigue
Copy link
Author

And Zart on irc gave me {{ sillage_key.content|b64decode|trim }} which is working too.

@jctanner
Copy link
Contributor

@rgarrigue how is sillage_key.content populated in your case?

@rgarrigue
Copy link
Author

@jctanner : with the key's hash, without ssh-rsa header and comment.

You've the debug on this gist, comment 3: https://gist.github.com/rgarrigue/7925446. Don't pay attention on hash difference between comments, I was testing on 2 differents VMs.

@mpdehaan mpdehaan added the P3 label Mar 19, 2014
@mpdehaan mpdehaan added P4 and removed P3 labels Apr 17, 2014
@jimi-c jimi-c removed the P4 label Dec 7, 2015
@azaghal
Copy link
Contributor

azaghal commented Dec 20, 2015

Well, figured I could start looking through the issue history to see if I can fix something, sorry if I am reviving an old issue or similar. From what I can tell, this issue is not reproducible since v1.5.0.

I also think that the decode call was not actually appending anything. This was tested via copy module combined with content parameter. The behaviour of authorized_key module probably got a bit smarter afterwards, so now it trims the key itself (only based on experimentation, not from reading the code).

Perhaps the issue should be closed?

@bcoca
Copy link
Member

bcoca commented Dec 22, 2015

closing as per above

@bcoca bcoca closed this as completed Dec 22, 2015
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

7 participants