From 6989df0af3d4d8a08137471bbb2bf403c43d71e3 Mon Sep 17 00:00:00 2001 From: Sascha Reynolds Date: Mon, 30 Mar 2015 19:59:07 +0200 Subject: [PATCH] fix(read_password): regex check for spaces, quotes * Passwords must be at least four characters. So we need to check them here to ensure that first user creation works during initial setup * Change quotes to match rest of code --- tools/mail.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/mail.py b/tools/mail.py index b87b0f3f..e02177b1 100755 --- a/tools/mail.py +++ b/tools/mail.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import sys, getpass, urllib.request, urllib.error, json +import sys, getpass, urllib.request, urllib.error, json, re def mgmt(cmd, data=None, is_json=False): # The base URL for the management daemon. (Listens on IPv4 only.) @@ -31,11 +31,14 @@ def read_password(): while True: first = getpass.getpass('password: ') if len(first) < 4: - print('Passwords must be at least four characters.') + print("Passwords must be at least four characters.") + continue + if re.search(r'[\s]', first): + print("Passwords cannot contain spaces.") continue second = getpass.getpass(' (again): ') if first != second: - print('Passwords not the same. Try again.') + print("Passwords not the same. Try again.") continue break return first