Use the '-p' non-interactive option to generate password hash instead of 'expect'

This commit is contained in:
Lyubomir Popov 2019-05-03 11:02:17 +03:00
parent 134faa3139
commit a206b65ed7
4 changed files with 1 additions and 40 deletions

View file

@ -25,7 +25,6 @@
- docker-python - docker-python
- ntp - ntp
- fuse - fuse
- expect
state: latest state: latest
update_cache: yes update_cache: yes
when: ansible_distribution == 'CentOS' when: ansible_distribution == 'CentOS'
@ -63,7 +62,6 @@
- python-docker - python-docker
- ntp - ntp
- fuse - fuse
- expect
state: latest state: latest
update_cache: yes update_cache: yes
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'

View file

@ -79,9 +79,3 @@
dest: "/usr/local/bin/matrix-synapse-register-user" dest: "/usr/local/bin/matrix-synapse-register-user"
mode: 0750 mode: 0750
- name: Ensure matrix-synapse-generate-password-hash script created
template:
src: "{{ role_path }}/templates/synapse/usr-local-bin/matrix-synapse-generate-password-hash.j2"
dest: "/usr/local/bin/matrix-synapse-generate-password-hash"
mode: 0750

View file

@ -41,7 +41,7 @@
when: postgres_start_result.changed when: postgres_start_result.changed
- name: Generate password hash - name: Generate password hash
shell: "/usr/local/bin/matrix-synapse-generate-password-hash {{ password }}" shell: "/usr/bin/docker exec matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml -p {{ password }}"
register: password_hash register: password_hash
- name: Update user password hash - name: Update user password hash

View file

@ -1,31 +0,0 @@
#!/usr/bin/env expect
# Read the password string
set pass [lindex $argv 0]
# Check if password was provided
if { $pass == "" } {
puts "Usage: $argv0 <password>"
exit 1
}
# Disable output
log_user 0
# Execute password hashing script
spawn docker exec -it matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml
expect "Password: "
send "$pass\r"
expect "Confirm password: "
send "$pass\r"
expect "%"
# Save the hash output to a variable
set output $expect_out(buffer)
# Trim the whitespace
regexp {\S+} $output passwordHash
# Output the password hash
puts -nonewline stdout $passwordHash
close stdout