r15414: Support retrying different username/password combinations
authorJelmer Vernooij <jelmer@samba.org>
Wed, 3 May 2006 14:15:31 +0000 (14:15 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:05:34 +0000 (14:05 -0500)
(This used to be commit 5de894fb8bac8efa5bff004dbfc2e8b386d4003b)

source4/auth/credentials/credentials.c
source4/auth/credentials/credentials.h

index ee90c8228ab62f078aee8a6abed4365d51f84879..66b6c120cf3a7b182440ce1d6065ea11aa127336 100644 (file)
@@ -639,3 +639,24 @@ BOOL cli_credentials_is_anonymous(struct cli_credentials *cred)
 
        return False;
 }
+
+/**
+ * Mark the current password for a credentials struct as wrong. This will 
+ * cause the password to be prompted again (if a callback is set).
+ *
+ * This will decremebt the number of times the password can be tried.
+ *
+ * @retval whether the credentials struct is finished
+ */
+BOOL cli_credentials_wrong_password(struct cli_credentials *cred)
+{
+       if (cred->password_obtained != CRED_CALLBACK_RESULT) {
+               return False;
+       }
+       
+       cred->password_obtained = CRED_CALLBACK;
+
+       cred->tries--;
+
+       return (cred->tries > 0);
+}
index 2e9d77ccae52948144ba16f0d1961fce802f9738..c0fec45b6fdd4d11bf29f47a24fb2dc7248c9736 100644 (file)
@@ -3,7 +3,7 @@
 
    Client credentials structure
 
-   Copyright (C) Jelmer Vernooij 2004-2005
+   Copyright (C) Jelmer Vernooij 2004-2006
    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
 
    This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,7 @@ enum credentials_obtained {
        CRED_GUESS_ENV,          /* Current value should be used, which was guessed */
        CRED_CALLBACK,           /* Callback should be used to obtain value */
        CRED_GUESS_FILE,         /* A guess from a file (or file pointed at in env variable) */
+       CRED_CALLBACK_RESULT,    /* Value was obtained from a callback */
        CRED_SPECIFIED           /* Was explicitly specified on the command-line */
 };
 
@@ -104,6 +105,9 @@ struct cli_credentials {
 
        /* Should we be trying to use kerberos? */
        enum credentials_use_kerberos use_kerberos;
+
+       /* Number of retries left before bailing out */
+       int tries;
 };
 
 #include "auth/credentials/credentials_proto.h"