Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

hash_password does not work without a tty #4277

Closed
user318 opened this issue Dec 9, 2018 · 1 comment
Closed

hash_password does not work without a tty #4277

user318 opened this issue Dec 9, 2018 · 1 comment
Labels
z-bug (Deprecated Label) z-p3 (Deprecated Label)

Comments

@user318
Copy link

user318 commented Dec 9, 2018

hash_password tool does not work without a tty, i.e. when stdin is not bound to a tty. Looks like it is some python input locale stuff - I do not know much about it. In the example below you can see that locale variable is set, but when it is run with input from /dev/null, it fails until I set PYTHONIOENCODING variable.

matrix@server ~ $ cd synapse
matrix@server ~/synapse $ . bin/activate
(synapse)matrix@server ~/synapse $ env | grep LANG
LANG=en_US.utf8
(synapse)matrix@server ~/synapse $ hash_password -c homeserver.yaml -p test
$2b$12$nM4g1fpajQfDHLE1xfWSGeXloe6BfJgFg7fcyVjOnv/Temq.hQ1xK
(synapse)matrix@server ~/synapse $ hash_password -c homeserver.yaml -p test </dev/null 
Traceback (most recent call last):
  File "/home/matrix/synapse/bin/hash_password", line 65, in <module>
    password = password.decode(sys.stdin.encoding)
TypeError: decode() argument 1 must be string, not None
(synapse)matrix@server ~/synapse $ PYTHONIOENCODING=UTF-8 hash_password -c homeserver.yaml -p test </dev/null 
$2b$12$tYUTBs3gf3Tj6mQR.RFigerXqyyBYeHRehefsFPaSILbPXmOE5Esu
@neilisfragile neilisfragile added z-p3 (Deprecated Label) z-bug (Deprecated Label) labels Dec 17, 2018
@richvdh
Copy link
Member

richvdh commented Apr 8, 2020

this was only an issue on python 2.

@richvdh richvdh closed this as completed Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p3 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

3 participants