summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-07-31 14:32:36 +0200
committerAndrew Bartlett <abartlet@samba.org>2013-08-05 09:36:05 +0200
commitb699d404bb5d4385a757b5aa5d0e792cf9d5de59 (patch)
tree1fb975a7678cb8f4ef64605d5f4d98843525ea10
parent8ea36a8e58d499aa7bf342b365ca00cb39f295b6 (diff)
downloadsamba-b699d404bb5d4385a757b5aa5d0e792cf9d5de59.tar.gz
samba-b699d404bb5d4385a757b5aa5d0e792cf9d5de59.tar.bz2
samba-b699d404bb5d4385a757b5aa5d0e792cf9d5de59.zip
auth/credentials: use CRED_CALLBACK_RESULT after a callback
We only do this if it's still CRED_CALLBACK after the callback, this allowes the callback to overwrite it. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Aug 5 09:36:05 CEST 2013 on sn-devel-104
-rw-r--r--auth/credentials/credentials.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c
index 4ac5356441..be497bc974 100644
--- a/auth/credentials/credentials.c
+++ b/auth/credentials/credentials.c
@@ -206,8 +206,10 @@ _PUBLIC_ const char *cli_credentials_get_username(struct cli_credentials *cred)
cred->callback_running = true;
cred->username = cred->username_cb(cred);
cred->callback_running = false;
- cred->username_obtained = CRED_SPECIFIED;
- cli_credentials_invalidate_ccache(cred, cred->username_obtained);
+ if (cred->username_obtained == CRED_CALLBACK) {
+ cred->username_obtained = CRED_CALLBACK_RESULT;
+ cli_credentials_invalidate_ccache(cred, cred->username_obtained);
+ }
}
return cred->username;
@@ -275,8 +277,10 @@ _PUBLIC_ const char *cli_credentials_get_principal_and_obtained(struct cli_crede
cred->callback_running = true;
cred->principal = cred->principal_cb(cred);
cred->callback_running = false;
- cred->principal_obtained = CRED_SPECIFIED;
- cli_credentials_invalidate_ccache(cred, cred->principal_obtained);
+ if (cred->principal_obtained == CRED_CALLBACK) {
+ cred->principal_obtained = CRED_CALLBACK_RESULT;
+ cli_credentials_invalidate_ccache(cred, cred->principal_obtained);
+ }
}
if (cred->principal_obtained < cred->username_obtained
@@ -382,8 +386,10 @@ _PUBLIC_ const char *cli_credentials_get_password(struct cli_credentials *cred)
cred->callback_running = true;
cred->password = cred->password_cb(cred);
cred->callback_running = false;
- cred->password_obtained = CRED_CALLBACK_RESULT;
- cli_credentials_invalidate_ccache(cred, cred->password_obtained);
+ if (cred->password_obtained == CRED_CALLBACK) {
+ cred->password_obtained = CRED_CALLBACK_RESULT;
+ cli_credentials_invalidate_ccache(cred, cred->password_obtained);
+ }
}
return cred->password;
@@ -502,8 +508,10 @@ _PUBLIC_ const char *cli_credentials_get_domain(struct cli_credentials *cred)
cred->callback_running = true;
cred->domain = cred->domain_cb(cred);
cred->callback_running = false;
- cred->domain_obtained = CRED_SPECIFIED;
- cli_credentials_invalidate_ccache(cred, cred->domain_obtained);
+ if (cred->domain_obtained == CRED_CALLBACK) {
+ cred->domain_obtained = CRED_CALLBACK_RESULT;
+ cli_credentials_invalidate_ccache(cred, cred->domain_obtained);
+ }
}
return cred->domain;
@@ -561,8 +569,10 @@ _PUBLIC_ const char *cli_credentials_get_realm(struct cli_credentials *cred)
cred->callback_running = true;
cred->realm = cred->realm_cb(cred);
cred->callback_running = false;
- cred->realm_obtained = CRED_SPECIFIED;
- cli_credentials_invalidate_ccache(cred, cred->realm_obtained);
+ if (cred->realm_obtained == CRED_CALLBACK) {
+ cred->realm_obtained = CRED_CALLBACK_RESULT;
+ cli_credentials_invalidate_ccache(cred, cred->realm_obtained);
+ }
}
return cred->realm;
@@ -612,7 +622,9 @@ _PUBLIC_ const char *cli_credentials_get_workstation(struct cli_credentials *cre
cred->callback_running = true;
cred->workstation = cred->workstation_cb(cred);
cred->callback_running = false;
- cred->workstation_obtained = CRED_SPECIFIED;
+ if (cred->workstation_obtained == CRED_CALLBACK) {
+ cred->workstation_obtained = CRED_CALLBACK_RESULT;
+ }
}
return cred->workstation;