From bd2b18250158ba90768c304d2c7cb4d7e81d8dcd Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 1 Sep 2020 15:33:18 +0200 Subject: auth:creds: Add cli_credentials_get_password_and_obtained() Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- auth/credentials/credentials.c | 20 ++++++++++++++++++++ auth/credentials/credentials.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'auth') diff --git a/auth/credentials/credentials.c b/auth/credentials/credentials.c index ac2b42a669b..5c39569e34a 100644 --- a/auth/credentials/credentials.c +++ b/auth/credentials/credentials.c @@ -446,6 +446,26 @@ _PUBLIC_ const char *cli_credentials_get_password(struct cli_credentials *cred) return cred->password; } +/** + * @brief Obtain the password for this credentials context. + * + * @param[in] cred The credential context. + * + * @param[in] obtained A pointer to store the obtained information. + * + * return The user name or NULL if an error occured. + */ +_PUBLIC_ const char * +cli_credentials_get_password_and_obtained(struct cli_credentials *cred, + enum credentials_obtained *obtained) +{ + if (obtained != NULL) { + *obtained = cred->password_obtained; + } + + return cli_credentials_get_password(cred); +} + /* Set a password on the credentials context, including an indication * of 'how' the password was obtained */ diff --git a/auth/credentials/credentials.h b/auth/credentials/credentials.h index bea734f06dc..04cf5138aec 100644 --- a/auth/credentials/credentials.h +++ b/auth/credentials/credentials.h @@ -91,6 +91,8 @@ 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); +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, const char **username, const char **domain); -- cgit v1.2.1