mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-26 02:57:04 +00:00
Merge pull request #65 from mkropat/mkropat/password-mask
Mask password input on stdin in tools/mail.py
This commit is contained in:
commit
add1545deb
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys, urllib.request, urllib.error
|
||||
import sys, getpass, urllib.request, urllib.error
|
||||
|
||||
def mgmt(cmd, data=None):
|
||||
req = urllib.request.Request('http://localhost:10222' + cmd, urllib.parse.urlencode(data).encode("utf8") if data else None)
|
||||
@ -11,6 +11,15 @@ def mgmt(cmd, data=None):
|
||||
sys.exit(1)
|
||||
return response.read().decode('utf8')
|
||||
|
||||
def read_password():
|
||||
first = getpass.getpass('password: ')
|
||||
second = getpass.getpass(' (again): ')
|
||||
while first != second:
|
||||
print('Passwords not the same. Try again.')
|
||||
first = getpass.getpass('password: ')
|
||||
second = getpass.getpass(' (again): ')
|
||||
return first
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: ")
|
||||
print(" tools/mail.py user (lists users)")
|
||||
@ -33,7 +42,7 @@ elif sys.argv[1] == "user" and sys.argv[2] in ("add", "password"):
|
||||
email = input("email: ")
|
||||
else:
|
||||
email = sys.argv[3]
|
||||
pw = input("password: ")
|
||||
pw = read_password()
|
||||
else:
|
||||
email, pw = sys.argv[3:5]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user