mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-22 02:17:26 +00:00
Mask password input on stdin
This commit is contained in:
parent
242cadebc8
commit
5774205bc2
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import sys, urllib.request, urllib.error
|
import sys, getpass, urllib.request, urllib.error
|
||||||
|
|
||||||
def mgmt(cmd, data=None):
|
def mgmt(cmd, data=None):
|
||||||
req = urllib.request.Request('http://localhost:10222' + cmd, urllib.parse.urlencode(data).encode("utf8") if data else 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)
|
sys.exit(1)
|
||||||
return response.read().decode('utf8')
|
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:
|
if len(sys.argv) < 2:
|
||||||
print("Usage: ")
|
print("Usage: ")
|
||||||
print(" tools/mail.py user (lists users)")
|
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: ")
|
email = input("email: ")
|
||||||
else:
|
else:
|
||||||
email = sys.argv[3]
|
email = sys.argv[3]
|
||||||
pw = input("password: ")
|
pw = read_password()
|
||||||
else:
|
else:
|
||||||
email, pw = sys.argv[3:5]
|
email, pw = sys.argv[3:5]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user