s3/smbpasswd: Check if Unix account exists before asking for the password.
authorKarolin Seeger <kseeger@samba.org>
Fri, 9 Jan 2009 14:54:16 +0000 (15:54 +0100)
committerKarolin Seeger <kseeger@samba.org>
Fri, 9 Jan 2009 15:11:58 +0000 (16:11 +0100)
Admins shouldn't have to type in the password twice when the passdb account
cannot be created because the Unix account is missing.

Karolin

source3/utils/smbpasswd.c

index d2652ad95a55fbf45a3cf7297f52846f51155501..93e2f81585a0e2f6ac15b34e2d610c2b6dc1c779 100644 (file)
@@ -430,6 +430,15 @@ static int process_root(int local_flags)
                }
 
                if((local_flags & LOCAL_SET_PASSWORD) && (new_passwd == NULL)) {
+                       struct passwd *passwd;
+
+                       passwd = getpwnam_alloc(NULL, user_name);
+                       if (!passwd) {
+                               DEBUG(0, ("Cannot locate Unix account for "
+                                         "'%s'!\n", user_name));
+                               exit(1);;
+                       }
+
                        new_passwd = prompt_for_new_password(stdin_passwd_get);
 
                        if(!new_passwd) {