userman: handle weak passwords

busybox prompts for a password three times if its weak.

Resolves openbmc/openbmc#543.

Change-Id: I7a5ccd10e082844f6b7df065a30ad59974f1d532
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/userman.py b/userman.py
index f0042bd..d99846c 100644
--- a/userman.py
+++ b/userman.py
@@ -161,14 +161,18 @@
         else:
             cmd = "adduser "  + opts + " " + username
 
+        prompts = ['New password: ', 'Retype password: ', 'Re-enter new password: ']
         proc = pexpect.spawn (cmd)
-        proc.expect (['New password: ', 'Retype password: '])
+        proc.expect (prompts)
         proc.sendline (passwd)
-        proc.expect (['New password: ', 'Retype password: '])
+        proc.expect (prompts)
         proc.sendline (passwd)
 
+        if proc.expect(prompts + [pexpect.EOF]) != len(prompts):
+            proc.sendline (passwd)
+
         r = proc.wait()
-        return r
+        return r if r else 0
 
     @dbus.service.method(INTF_NAME, "", "as")
     def UserList (self):