-
Notifications
You must be signed in to change notification settings - Fork 199
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
ansible_mitogen: Handle unsafe paths in _remote_chmod #1087
Conversation
Thank you, would you be able to rebase this, include a changelog entry, and an automated test case? If not don't worry, I can have a go. |
I've rebased this, but I'm missing a GH issue to reference in the changelog, and I also failed at the first step of trying to look at adding tests as the instructions here https://github.com/mitogen-hq/mitogen/blob/master/tests/README.md#steps-to-prepare-development-environment reference some scripts that don't seem to exist any more. |
The PR number is good enough for the changelog. I'll try to look at the devenv instructions. |
This is missing from mitogen-hq@b822f20
Holy smoke this bug is specific, even
- hosts: u2004.mynet
gather_facts: false
vars:
foo: Foo
bar: Bar
tasks:
- name: Using with_items
template:
src: foo.bar.j2
dest: "{{ item }}"
mode: u=rw,go=r
with_items:
- /tmp/foo
- /tmp/foo.txt
- name: Cleanup 1
file:
path: "{{ item }}"
state: absent
with_items:
- /tmp/foo
- /tmp/foo.txt
- name: Using loop
template:
src: foo.bar.j2
dest: "{{ item }}"
mode: u=rw,go=r
loop:
- /tmp/foo
- /tmp/foo.txt
- name: Cleanup 2
file:
path: "{{ item }}"
state: absent
with_items:
- /tmp/foo
- /tmp/foo.txt |
…mod() Adapted from Jonathon's reproducer in mitogen-hq#1087.
@jrosser please could you tick "Allow edits and access to secrets by maintainers" on this PR and #1110? This should allow me to push to the branches in question. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork I think I have the finished tests for this PR in master...moreati:mitogen:unsafe-chmod. I may needfurther tweaks once CI has run with it. |
On second thoughts that probably won't work. github.com/bbc is an organisation account not a personal account, so the tickbox isn't applicable. |
@moreati I have updated my branch with your changes. |
Some ansible_mitogen connection plugins look more like become plugins (e.g. mitogen_sudo) & use become plugin options. For now there's special handling in PlayContextSpec._become_option(). Further design/discussion can go in mitogen-hq#1173. Refs mitogen-hq#1087.
This is missing from b822f20
Seems to be only triggered when using
with_items
and the destination filenames have an extension.The rather surprising behaviour of only failing when there is a filename extension is due to https://github.com/ansible/ansible/blob/906c969b551b346ef54a2c0b41e04f632b7b73c2/lib/ansible/plugins/action/copy.py#L294-L300
The temporary file name created by the copy module gets the source path extension appended if the source file has an extension (i.e. contains a dot). Something in Ansible wraps the filename in an unsafe and because the filename is unsafe, so is the extension pulled from it and therefore so is the temporary file name once the extension gets appended.