auth/credentials: add cli_credentials_get_password_obtained()
authorStefan Metzmacher <metze@samba.org>
Thu, 14 Apr 2022 11:46:18 +0000 (13:46 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 7 May 2024 11:30:33 +0000 (11:30 +0000)
It's often useful to know if a password was already explicitly
specified without triggering the password callback function.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
auth/credentials/credentials.c
auth/credentials/credentials.h

index 7564ede5a427e6dbd307e9ebd4203a4532c39196..c0a17e24276a8056f8a2c75dbca212a762162fb9 100644 (file)
@@ -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.
  *
index 3f8474eec2632a2d60b598696996e294c0bc3e04..279b51e1daa24c481fccdb97e05ad4566aadfa53 100644 (file)
@@ -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,