Advertisement
Guest User

Untitled

a guest
Oct 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import sqlite3
  2. import subprocess
  3.  
  4. conn = sqlite3.connect('/var/lib/matrix-synapse/homeserver.db')
  5. c = conn.cursor()
  6.  
  7. print('Select users:\n')
  8. for row in c.execute('select * from users;'):
  9. print(row[0])
  10.  
  11.  
  12. selected_user = str(input())
  13. print('\n')
  14. print('Print password:\n')
  15. password = str(input())
  16.  
  17. hash_password = subprocess.check_output(['/usr/bin/hash_password', '-p ' + password]).strip()
  18. print(hash_password.decode("utf-8"))
  19. print("UPDATE users SET password_hash='{}' where name ='{}'".format(hash_password.decode("utf-8"), selected_user))
  20. subprocess.call(['service', 'matrix-synapse', 'stop'])
  21. c.execute("UPDATE users SET password_hash='{}' where name ='{}';".format(hash_password.decode("utf-8"), selected_user))
  22. print('Password set!')
  23. conn.commit()
  24. subprocess.call(['service', 'matrix-synapse', 'start'])
  25. print('matrix reload')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement