mirror of
https://github.com/willshersystems/ansible-sshd
synced 2024-11-08 12:53:29 +01:00
3331fa7b35
Setting TMPDIR globally causes problems on some platforms. Instead, set it at the `block` level and put the role invocation inside the block. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
---
|
|
- name: Test quote with unsafe input
|
|
hosts: all
|
|
vars:
|
|
__sshd_test_backup_files:
|
|
- /etc/ssh/sshd_config
|
|
- /etc/ssh/sshd_config.d/00-ansible_system_role.conf
|
|
__badflag_file: /tmp/BADFLAG
|
|
# Avoid / in TMPDIR file name
|
|
__badflag: >-
|
|
$(touch -- "$(echo {{ __badflag_file | b64encode }} | base64 -d)")
|
|
# Iterate w/o quote, w/ ' and w/ "
|
|
__tmpdir: >-
|
|
/tmp/a {{ __badflag }} ' {{ __badflag }} '" {{ __badflag }} "b
|
|
|
|
tasks:
|
|
- name: Ensure BADFLAG does not exist
|
|
ansible.builtin.file:
|
|
path: /tmp/BADFLAG
|
|
state: absent
|
|
|
|
- name: "Backup configuration files"
|
|
ansible.builtin.include_tasks: tasks/backup.yml
|
|
|
|
- name: Create BAD TMPDIR
|
|
ansible.builtin.file:
|
|
state: directory
|
|
path: "{{ __tmpdir }}"
|
|
mode: '0755'
|
|
|
|
- name: Wrap this in a block to set environment
|
|
environment:
|
|
TMPDIR: "{{ __tmpdir }}"
|
|
block:
|
|
- name: Configure sshd with BAD config
|
|
ansible.builtin.include_role:
|
|
name: ansible-sshd
|
|
vars:
|
|
sshd_skip_defaults: true
|
|
sshd_verify_hostkeys: []
|
|
when:
|
|
- ansible_facts['os_family'] != 'RedHat' or ansible_facts['distribution_major_version'] | int != 8
|
|
|
|
- name: Verify the options are correctly set
|
|
tags: tests::verify
|
|
block:
|
|
- name: Flush handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
- name: Get status BADFLAG
|
|
ansible.builtin.stat:
|
|
path: "{{ __badflag_file }}"
|
|
register: badflag
|
|
|
|
- name: Ensure BADFLAG does not exist
|
|
ansible.builtin.assert:
|
|
that:
|
|
- not badflag.stat.exists
|
|
|
|
- name: Remove BAD TMPDIR
|
|
ansible.builtin.file:
|
|
state: absent
|
|
path: "{{ __tmpdir }}"
|
|
|
|
- name: "Restore configuration files"
|
|
ansible.builtin.include_tasks: tasks/restore.yml
|