From: Stefan Metzmacher Date: Thu, 14 Apr 2022 11:46:18 +0000 (+0200) Subject: auth/credentials: add cli_credentials_get_password_obtained() X-Git-Tag: tdb-1.4.11~855 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c14366cce45a437584d9050067a34fffb847e134;p=thirdparty%2Fsamba.git auth/credentials: add cli_credentials_get_password_obtained() It's often useful to know if a password was already explicitly specified without triggering the password callback function. Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c index 7564ede5a42..c0a17e24276 100644 --- a/auth/credentials/credentials.c +++ b/auth/credentials/credentials.c @@ -511,6 +511,19 @@ _PUBLIC_ const char *cli_credentials_get_password(struct cli_credentials *cred) return cred->password; } +/** + * @brief Find out how the password was obtained. + * + * @param cred A credentials context. + * + * @return The obtained information for the password. + */ +_PUBLIC_ enum credentials_obtained +cli_credentials_get_password_obtained(struct cli_credentials *cred) +{ + return cred->password_obtained; +} + /** * @brief Obtain the password for this credentials context. * diff --git a/auth/credentials/credentials.h b/auth/credentials/credentials.h index 3f8474eec26..279b51e1daa 100644 --- a/auth/credentials/credentials.h +++ b/auth/credentials/credentials.h @@ -91,6 +91,7 @@ struct cli_credentials *cli_credentials_init_server(TALLOC_CTX *mem_ctx, void cli_credentials_set_anonymous(struct cli_credentials *cred); bool cli_credentials_wrong_password(struct cli_credentials *cred); const char *cli_credentials_get_password(struct cli_credentials *cred); +enum credentials_obtained cli_credentials_get_password_obtained(struct cli_credentials *cred); const char *cli_credentials_get_password_and_obtained(struct cli_credentials *cred, enum credentials_obtained *obtained); void cli_credentials_get_ntlm_username_domain(struct cli_credentials *cred, TALLOC_CTX *mem_ctx,